Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finish merging and removing obsolete stuff from helm-config.el

  • Loading branch information...
commit a1b8c7b09bf74323e69132bc532eadf123fe8d14 1 parent 915e971
Thierry Volpiatto thierryvolpiatto authored
416 helm-config.el
View
@@ -17,6 +17,7 @@
;;; Code:
+
;;; Require
;;
;;
@@ -50,6 +51,7 @@
(require 'helm-sys)
(require 'helm-misc)
(require 'helm-help)
+(require 'helm-match-plugin)
(require 'helm-elscreen nil t)
(require 'helm-w3m nil t)
(require 'helm-firefox nil t)
@@ -62,19 +64,6 @@
(require 'helm-call-tree nil t)
(require 'helm-descbinds nil t)
(require 'helm-slime nil t)
-(eval-when-compile (require 'semantic nil t))
-(require 'helm-match-plugin)
-
-
-
-;;; Declare external functions
-;;
-;;
-(declare-function semantic-format-tag-summarize "ext:format.el" (tag &optional parent color) t)
-(declare-function semantic-tag-components "ext:tag.el" (tag) t)
-(declare-function semantic-go-to-tag "ext:tag-file.el" (tag) t)
-(declare-function semantic-tag-type "ext:tag-file.el" (tag) t)
-(declare-function semantic-tag-class "ext:tag-file.el" (tag) t)
;;; Helm-command-map
@@ -180,6 +169,7 @@
"----"
["Prefered Options" helm-configuration t]))
+
;;; Helm map add ons
;;
;;
@@ -188,346 +178,6 @@
(define-key helm-map (kbd "C-w") 'helm-yank-text-at-point)
-;;;; <File>
-;;
-;;
-;;; ffap
-(eval-when-compile (require 'ffap))
-(defvar helm-c-source-ffap-guesser
- `((name . "File at point")
- (init . (lambda () (require 'ffap)))
- (candidates . (lambda ()
- (helm-aif
- (with-helm-current-buffer
- (ffap-guesser))
- (list it))))
- (keymap . ,helm-generic-files-map)
- (help-message . helm-generic-file-help-message)
- (mode-line . helm-generic-file-mode-line-string)
- (type . file)))
-
-;;; ffap with line number
-(defun helm-c-ffap-file-line-at-point ()
- "Get (FILENAME . LINENO) at point."
- (helm-aif (let (ffap-alist) (ffap-file-at-point))
- (save-excursion
- (beginning-of-line)
- (when (and (search-forward it nil t)
- (looking-at ":\\([0-9]+\\)"))
- (cons it (string-to-number (match-string 1)))))))
-
-(defun helm-c-ffap-line-candidates ()
- (with-helm-current-buffer
- (helm-attrset 'ffap-line-location (helm-c-ffap-file-line-at-point)))
- (helm-aif (helm-attr 'ffap-line-location)
- (destructuring-bind (file . line) it
- (list (cons (format "%s (line %d)" file line) file)))))
-
-;;; Goto line after opening file by `helm-c-source-ffap-line'.
-(defun helm-c-ffap-line-goto-line ()
- (when (car (helm-attr 'ffap-line-location))
- (unwind-protect
- (ignore-errors
- (with-selected-window
- (get-buffer-window
- (get-file-buffer (car (helm-attr 'ffap-line-location))))
- (helm-goto-line (cdr (helm-attr 'ffap-line-location)))))
- (helm-attrset 'ffap-line-location nil))))
-(add-hook 'helm-after-action-hook 'helm-c-ffap-line-goto-line)
-(add-hook 'helm-after-persistent-action-hook 'helm-c-ffap-line-goto-line)
-
-(defvar helm-c-source-ffap-line
- `((name . "File/Lineno at point")
- (init . (lambda () (require 'ffap)))
- (candidates . helm-c-ffap-line-candidates)
- (keymap . ,helm-map)
- (type . file)))
-
-
-
-;;; Visible Bookmarks
-;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el")
-
-
-;; http://d.hatena.ne.jp/grandVin/20080911/1221114327
-(defvar helm-c-source-bm
- '((name . "Visible Bookmarks")
- (init . helm-c-bm-init)
- (candidates-in-buffer)
- (type . line))
- "Needs bm.el.
-
-http://www.nongnu.org/bm/")
-
-(defun helm-c-bm-init ()
- "Init function for `helm-c-source-bm'."
- (when (require 'bm nil t)
- (with-no-warnings
- (let ((bookmarks (bm-lists))
- (buf (helm-candidate-buffer 'global)))
- (dolist (bm (sort* (append (car bookmarks) (cdr bookmarks))
- '< :key 'overlay-start))
- (let ((start (overlay-start bm))
- (end (overlay-end bm))
- (annotation (or (overlay-get bm 'annotation) "")))
- (unless (< (- end start) 1) ; org => (if (< (- end start) 2)
- (let ((str (format "%5d: [%s]: %s\n"
- (line-number-at-pos start)
- annotation
- (buffer-substring start (1- end)))))
- (with-current-buffer buf (insert str))))))))))
-
-
-;;; Semantic
-;;
-;;
-(defvar helm-semantic-candidates nil)
-
-(defun helm-semantic-construct-candidates (tags depth)
- (when (require 'semantic nil t)
- (apply
- 'append
- (mapcar
- (lambda (tag)
- (if (listp tag)
- (let ((type (semantic-tag-type tag))
- (class (semantic-tag-class tag)))
- (if (or (and (stringp type)
- (or (string= type "class")
- (string= type "namespace")))
- (eq class 'function)
- (eq class 'variable))
- (cons (cons (concat (make-string (* depth 2) ?\s)
- (semantic-format-tag-summarize tag nil t))
- tag)
- (helm-semantic-construct-candidates
- (semantic-tag-components tag) (1+ depth)))))))
- tags))))
-
-(defun helm-semantic-default-action (candidate)
- (let ((tag (cdr (assoc candidate helm-semantic-candidates))))
- (semantic-go-to-tag tag)))
-
-(defvar helm-c-source-semantic
- '((name . "Semantic Tags")
- (init . (lambda ()
- (setq helm-semantic-candidates
- (ignore-errors (helm-semantic-construct-candidates
- (semantic-fetch-tags) 0)))))
- (candidates . (lambda ()
- (if helm-semantic-candidates
- (mapcar 'car helm-semantic-candidates))))
- (persistent-action . (lambda (elm)
- (helm-semantic-default-action elm)
- (helm-match-line-color-current-line)))
- (persistent-help . "Show this entry")
- (action . helm-semantic-default-action)
- "Needs semantic in CEDET.
-
-http://cedet.sourceforge.net/semantic.shtml
-http://cedet.sourceforge.net/"))
-
-
-;;; Call source.
-(defvar helm-source-select-buffer "*helm source select*")
-(defvar helm-c-source-call-source
- `((name . "Call helm source")
- (candidate-number-limit)
- (candidates
- . (lambda ()
- (loop for vname in (all-completions "helm-c-source-" obarray)
- for var = (intern vname)
- for name = (ignore-errors (assoc-default 'name (symbol-value var)))
- if name collect
- (cons (format "%s `%s'"
- name (propertize vname 'face 'font-lock-variable-name-face))
- var))))
- (action
- . (("Invoke helm with selected source"
- .
- (lambda (candidate)
- (setq helm-candidate-number-limit 9999)
- (helm candidate nil nil nil nil
- helm-source-select-buffer)))
- ("Describe variable" . describe-variable)
- ("Find variable" . find-variable)))
- (persistent-action . describe-variable)
- (persistent-help . "Show description of this source")))
-
-(defun helm-call-source-from-helm ()
- "Call helm source within `helm' session."
- (interactive)
- (setq helm-input-idle-delay 0)
- (helm-set-sources '(helm-c-source-call-source)))
-
-
-;; Do many actions for input
-(defvar helm-c-source-create
- '((name . "Create")
- (dummy)
- (action)
- (action-transformer . helm-create--actions))
- "Do many create actions from `helm-pattern'.
-See also `helm-create--actions'.")
-
-(defun helm-create-from-helm ()
- "Run `helm-create' from `helm' as a fallback."
- (interactive)
- (helm-run-after-quit 'helm-create nil helm-pattern))
-
-(defun helm-create--actions (&rest ignored)
- "Default actions for `helm-create' / `helm-c-source-create'."
- (remove-if-not
- (lambda (pair) (and (consp pair) (functionp (cdr pair))))
- (append helm-create--actions-private
- '(("find-file" . find-file)
- ("find-file other window" . find-file-other-window)
- ("New buffer" . helm-c-switch-to-buffer)
- ("New buffer other window" . switch-to-buffer-other-window)
- ("Bookmark Set" . bookmark-set)
- ("Set Register" .
- (lambda (x) (set-register (read-char "Register: ") x)))
- ("Insert Linkd star" . linkd-insert-star)
- ("Insert Linkd Tag" . linkd-insert-tag)
- ("Insert Linkd Link" . linkd-insert-link)
- ("Insert Linkd Lisp" . linkd-insert-lisp)
- ("Insert Linkd Wiki" . linkd-insert-wiki)
- ("Google Search" . google)))))
-
-
-;; Minibuffer History
-;;
-;;
-(defvar helm-c-source-minibuffer-history
- '((name . "Minibuffer History")
- (header-name . (lambda (name)
- (format "%s (%s)" name minibuffer-history-variable)))
- (candidates
- . (lambda ()
- (let ((history (loop for i in
- (symbol-value minibuffer-history-variable)
- unless (string= "" i) collect i)))
- (if (consp (car history))
- (mapcar 'prin1-to-string history)
- history))))
- (migemo)
- (action . (lambda (candidate)
- (delete-minibuffer-contents)
- (insert candidate)))))
-
-
-;;; Generic action functions
-;;
-;;
-(helm-document-attribute 'default-directory "type . file-line"
- "`default-directory' to interpret file.")
-(helm-document-attribute 'before-jump-hook "type . file-line / line"
- "Function to call before jumping to the target location.")
-(helm-document-attribute 'after-jump-hook "type . file-line / line"
- "Function to call after jumping to the target location.")
-(helm-document-attribute 'adjust "type . file-line"
- "Search around line matching line contents.")
-(helm-document-attribute 'recenter "type . file-line / line"
- "`recenter' after jumping.")
-(helm-document-attribute 'target-file "type . line"
- "Goto line of target-file.")
-
-(defun helm-c-call-interactively (cmd-or-name)
- "Execute CMD-OR-NAME as Emacs command.
-It is added to `extended-command-history'.
-`helm-current-prefix-arg' is used as the command's prefix argument."
- (setq extended-command-history
- (cons (helm-c-stringify cmd-or-name)
- (delete (helm-c-stringify cmd-or-name) extended-command-history)))
- (let ((current-prefix-arg helm-current-prefix-arg)
- (cmd (helm-c-symbolify cmd-or-name)))
- (if (stringp (symbol-function cmd))
- (execute-kbd-macro (symbol-function cmd))
- (setq this-command cmd)
- (call-interactively cmd))))
-
-;;;###autoload
-(defun helm-c-set-variable (var)
- "Set value to VAR interactively."
- (interactive)
- (let ((sym (helm-c-symbolify var)))
- (set sym (eval-minibuffer (format "Set %s: " var)
- (prin1-to-string (symbol-value sym))))))
-;; (setq hh 12)
-;; (helm-c-set-variable 'hh)
-
-
-;;; Actions Transformers
-;;; Function
-(defun helm-c-transform-function-call-interactively (actions candidate)
- "Add an action to call the function CANDIDATE interactively if
-it is a command. Else return ACTIONS unmodified."
- (if (commandp (intern-soft candidate))
- (append actions '(("Call Interactively"
- .
- helm-c-call-interactively)))
- actions))
-
-;;;; S-Expressions
-(defun helm-c-transform-sexp-eval-command-sexp (actions candidate)
- "If CANDIDATE's `car' is a command, then add an action to
-evaluate it and put it onto the `command-history'."
- (if (commandp (car (read candidate)))
- ;; Make it first entry
- (cons '("Eval and put onto command-history" .
- (lambda (sexp)
- (let ((sym (read sexp)))
- (eval sym)
- (setq command-history
- (cons sym command-history)))))
- actions)
- actions))
-
-
-;;; Functions
-(defun helm-c-mark-interactive-functions (functions)
- "Mark interactive functions (commands) with (i) after the function name."
- (let (list)
- (loop for function in functions
- do (push (cons (concat function
- (when (commandp (intern-soft function)) " (i)"))
- function)
- list)
- finally (return (nreverse list)))))
-
-
-;;; Outliner
-;;
-;;
-(defvar helm-outline-goto-near-line-flag t)
-(defvar helm-outline-using nil)
-(defun helm-after-update-hook--outline ()
- (if (and (eq helm-outline-using t)
- (eq helm-outline-goto-near-line-flag t))
- (helm-outline-goto-near-line)))
-(add-hook 'helm-after-update-hook 'helm-after-update-hook--outline)
-
-(defun helm-outline-goto-near-line ()
- (with-helm-window
- ;; TODO need consideration whether to update position by every input.
- (when t ; (equal helm-pattern "")
- (helm-goto-line 2)
- (let ((lineno (with-helm-current-buffer
- (line-number-at-pos (car helm-current-position)))))
- (block exit
- (while (<= (progn (skip-chars-forward " ")
- (or (number-at-point) lineno))
- lineno)
- (forward-line 1)
- (when (eobp)
- (forward-line -1)
- (return-from exit))))
- (forward-line -1)
- (and (bobp) (forward-line 1))
- (and (helm-pos-header-line-p) (forward-line -2))
- (helm-mark-current-line)))))
-
-
;;; Type Attributes
;;
;;
@@ -614,12 +264,6 @@ evaluate it and put it onto the `command-history'."
(coerce . helm-c-symbolify))
"Variable.")
-(define-helm-type-attribute 'sexp
- '((action ("Eval s-expression" . (lambda (c) (eval (read c))))
- ("Add s-expression to kill ring" . kill-new))
- (action-transformer helm-c-transform-sexp-eval-command-sexp))
- "String representing S-Expressions.")
-
(define-helm-type-attribute 'bookmark
`((coerce . helm-bookmark-get-bookmark-from-name)
(action
@@ -685,60 +329,6 @@ the center of window, otherwise at the top of window.")
(persistent-help . "Describe Function"))
"Timer.")
-
-;;; Preconfigured Helm
-;;
-;;
-;;;###autoload
-(defun helm-mini ()
- "Preconfigured `helm' lightweight version \(buffer -> recentf\)."
- (interactive)
- (helm-other-buffer '(helm-c-source-buffers-list
- helm-c-source-recentf
- helm-c-source-buffer-not-found)
- "*helm mini*"))
-
-;;;###autoload
-(defun helm-minibuffer-history ()
- "Preconfigured `helm' for `minibuffer-history'."
- (interactive)
- (let ((enable-recursive-minibuffers t))
- (helm-other-buffer 'helm-c-source-minibuffer-history
- "*helm minibuffer-history*")))
-
-;;;###autoload
-(defun helm-bm-list ()
- "Preconfigured `helm' for visible bookmarks.
-
-Needs bm.el
-
-http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el"
- (interactive)
- (let ((helm-outline-using t))
- (helm-other-buffer 'helm-c-source-bm "*helm bm list*")))
-
-;;;###autoload
-(defun helm-call-source ()
- "Preconfigured `helm' to call helm source."
- (interactive)
- (helm :sources 'helm-c-source-call-source
- :buffer helm-source-select-buffer))
-
-;;;###autoload
-(defun helm-create (&optional string initial-input)
- "Preconfigured `helm' to do many create actions from STRING.
-See also `helm-create--actions'."
- (interactive)
- (setq string (or string (read-string "Create Helm: " initial-input)))
- (helm :sources '(((name . "Helm Create")
- (header-name . (lambda (_) (format "Action for \"%s\"" string)))
- (candidates . helm-create--actions)
- (candidate-number-limit)
- (action . (lambda (func) (funcall func string)))))))
-
-
-
-;;; Unit tests are now in ../developer-tools/unit-test-helm-config.el.
(provide 'helm-config)
7 helm-elisp.el
View
@@ -400,6 +400,13 @@ STRING is string to match."
(add-to-list 'names name)))))
names))
+(defun helm-c-set-variable (var)
+ "Set value to VAR interactively."
+ (interactive)
+ (let ((sym (helm-c-symbolify var)))
+ (set sym (eval-minibuffer (format "Set %s: " var)
+ (prin1-to-string (symbol-value sym))))))
+
;;; Elisp Timers.
;;
;;
87 helm-files.el
View
@@ -2316,6 +2316,93 @@ Else return ACTIONS unmodified."
(candidates . helm-c-file-cache-files)
(match helm-c-match-on-basename)
(type . file)))
+
+;;; ffap
+;;
+;;
+(eval-when-compile (require 'ffap))
+(defvar helm-c-source-ffap-guesser
+ `((name . "File at point")
+ (init . (lambda () (require 'ffap)))
+ (candidates . (lambda ()
+ (helm-aif
+ (with-helm-current-buffer
+ (ffap-guesser))
+ (list it))))
+ (keymap . ,helm-generic-files-map)
+ (help-message . helm-generic-file-help-message)
+ (mode-line . helm-generic-file-mode-line-string)
+ (type . file)))
+
+;;; ffap with line number
+(defun helm-c-ffap-file-line-at-point ()
+ "Get (FILENAME . LINENO) at point."
+ (helm-aif (let (ffap-alist) (ffap-file-at-point))
+ (save-excursion
+ (beginning-of-line)
+ (when (and (search-forward it nil t)
+ (looking-at ":\\([0-9]+\\)"))
+ (cons it (string-to-number (match-string 1)))))))
+
+(defun helm-c-ffap-line-candidates ()
+ (with-helm-current-buffer
+ (helm-attrset 'ffap-line-location (helm-c-ffap-file-line-at-point)))
+ (helm-aif (helm-attr 'ffap-line-location)
+ (destructuring-bind (file . line) it
+ (list (cons (format "%s (line %d)" file line) file)))))
+
+;;; Goto line after opening file by `helm-c-source-ffap-line'.
+(defun helm-c-ffap-line-goto-line ()
+ (when (car (helm-attr 'ffap-line-location))
+ (unwind-protect
+ (ignore-errors
+ (with-selected-window
+ (get-buffer-window
+ (get-file-buffer (car (helm-attr 'ffap-line-location))))
+ (helm-goto-line (cdr (helm-attr 'ffap-line-location)))))
+ (helm-attrset 'ffap-line-location nil))))
+(add-hook 'helm-after-action-hook 'helm-c-ffap-line-goto-line)
+(add-hook 'helm-after-persistent-action-hook 'helm-c-ffap-line-goto-line)
+
+(defvar helm-c-source-ffap-line
+ `((name . "File/Lineno at point")
+ (init . (lambda () (require 'ffap)))
+ (candidates . helm-c-ffap-line-candidates)
+ (keymap . ,helm-map)
+ (type . file)))
+
+
+
+;;; Outliner
+;;
+;;
+(defvar helm-outline-goto-near-line-flag t)
+(defvar helm-outline-using nil)
+(defun helm-after-update-hook--outline ()
+ (if (and (eq helm-outline-using t)
+ (eq helm-outline-goto-near-line-flag t))
+ (helm-outline-goto-near-line)))
+(add-hook 'helm-after-update-hook 'helm-after-update-hook--outline)
+
+(defun helm-outline-goto-near-line ()
+ (with-helm-window
+ ;; TODO need consideration whether to update position by every input.
+ (when t ; (equal helm-pattern "")
+ (helm-goto-line 2)
+ (let ((lineno (with-helm-current-buffer
+ (line-number-at-pos (car helm-current-position)))))
+ (block exit
+ (while (<= (progn (skip-chars-forward " ")
+ (or (number-at-point) lineno))
+ lineno)
+ (forward-line 1)
+ (when (eobp)
+ (forward-line -1)
+ (return-from exit))))
+ (forward-line -1)
+ (and (bobp) (forward-line 1))
+ (and (helm-pos-header-line-p) (forward-line -2))
+ (helm-mark-current-line)))))
;;; File name history
;;
51 helm-misc.el
View
@@ -192,6 +192,41 @@ http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el")
http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
+(defun helm-c-call-interactively (cmd-or-name)
+ "Execute CMD-OR-NAME as Emacs command.
+It is added to `extended-command-history'.
+`helm-current-prefix-arg' is used as the command's prefix argument."
+ (setq extended-command-history
+ (cons (helm-c-stringify cmd-or-name)
+ (delete (helm-c-stringify cmd-or-name) extended-command-history)))
+ (let ((current-prefix-arg helm-current-prefix-arg)
+ (cmd (helm-c-symbolify cmd-or-name)))
+ (if (stringp (symbol-function cmd))
+ (execute-kbd-macro (symbol-function cmd))
+ (setq this-command cmd)
+ (call-interactively cmd))))
+
+;; Minibuffer History
+;;
+;;
+(defvar helm-c-source-minibuffer-history
+ '((name . "Minibuffer History")
+ (header-name . (lambda (name)
+ (format "%s (%s)" name minibuffer-history-variable)))
+ (candidates
+ . (lambda ()
+ (let ((history (loop for i in
+ (symbol-value minibuffer-history-variable)
+ unless (string= "" i) collect i)))
+ (if (consp (car history))
+ (mapcar 'prin1-to-string history)
+ history))))
+ (migemo)
+ (action . (lambda (candidate)
+ (delete-minibuffer-contents)
+ (insert candidate)))))
+
+
;;; Helm ratpoison UI
;;
@@ -251,6 +286,22 @@ http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
(helm-other-buffer 'helm-c-source-ratpoison-commands
"*helm ratpoison commands*"))
+;;;###autoload
+(defun helm-mini ()
+ "Preconfigured `helm' lightweight version \(buffer -> recentf\)."
+ (interactive)
+ (helm-other-buffer '(helm-c-source-buffers-list
+ helm-c-source-recentf
+ helm-c-source-buffer-not-found)
+ "*helm mini*"))
+
+;;;###autoload
+(defun helm-minibuffer-history ()
+ "Preconfigured `helm' for `minibuffer-history'."
+ (interactive)
+ (let ((enable-recursive-minibuffers t))
+ (helm-other-buffer 'helm-c-source-minibuffer-history
+ "*helm minibuffer-history*")))
(provide 'helm-misc)
13 helm-plugin.el
View
@@ -285,8 +285,21 @@ with original attribute value.
source))
(add-to-list 'helm-compile-source-functions
'helm-compile-source--default-action t)
+
(helm-document-attribute 'default-action "default-action plug-in"
"Default action.")
+(helm-document-attribute 'default-directory "type . file-line"
+ "`default-directory' to interpret file.")
+(helm-document-attribute 'before-jump-hook "type . file-line / line"
+ "Function to call before jumping to the target location.")
+(helm-document-attribute 'after-jump-hook "type . file-line / line"
+ "Function to call after jumping to the target location.")
+(helm-document-attribute 'adjust "type . file-line"
+ "Search around line matching line contents.")
+(helm-document-attribute 'recenter "type . file-line / line"
+ "`recenter' after jumping.")
+(helm-document-attribute 'target-file "type . line"
+ "Goto line of target-file.")
(provide 'helm-plugin)
Please sign in to comment.
Something went wrong with that request. Please try again.