Skip to content

Commit

Permalink
* helm.el (helm-read-pattern-maybe): Allow using history attr in sour…
Browse files Browse the repository at this point in the history
…ces.

* helm-grep.el (helm-do-grep-1): Use it.
* helm-locate.el (helm-c-source-locate): Same.
* helm-files.el (helm-ff-zgrep): simplify.
  • Loading branch information
thierryvolpiatto committed Apr 19, 2012
1 parent 2d09d7b commit 6ff63d4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
7 changes: 2 additions & 5 deletions helm-files.el
Expand Up @@ -483,14 +483,11 @@ ACTION must be an action supported by `helm-dired-action'."


(defun helm-find-files-grep (candidate) (defun helm-find-files-grep (candidate)
"Default action to grep files from `helm-find-files'." "Default action to grep files from `helm-find-files'."
(helm-do-grep-1 (helm-marked-candidates) (helm-do-grep-1 (helm-marked-candidates) helm-current-prefix-arg))
helm-current-prefix-arg))


(defun helm-ff-zgrep (candidate) (defun helm-ff-zgrep (candidate)
"Default action to zgrep files from `helm-find-files'." "Default action to zgrep files from `helm-find-files'."
(let ((prefarg helm-current-prefix-arg) (helm-ff-zgrep-1 (helm-marked-candidates) helm-current-prefix-arg))
(ls (helm-marked-candidates)))
(helm-ff-zgrep-1 ls prefarg)))


(defun helm-ff-pdfgrep (candidate) (defun helm-ff-pdfgrep (candidate)
"Default action to pdfgrep files from `helm-find-files'." "Default action to pdfgrep files from `helm-find-files'."
Expand Down
3 changes: 3 additions & 0 deletions helm-grep.el
Expand Up @@ -474,6 +474,7 @@ If it's empty --exclude `grep-find-ignored-files' is used instead."
(nohighlight) (nohighlight)
(mode-line . helm-grep-mode-line-string) (mode-line . helm-grep-mode-line-string)
(keymap . ,helm-c-grep-map) (keymap . ,helm-c-grep-map)
(history . ,'helm-c-grep-history)
(action . ,(delq (action . ,(delq
nil nil
`(("Find File" . helm-c-grep-action) `(("Find File" . helm-c-grep-action)
Expand All @@ -488,6 +489,7 @@ If it's empty --exclude `grep-find-ignored-files' is used instead."
(requires-pattern . 3) (requires-pattern . 3)
(delayed))) (delayed)))
:buffer "*helm grep*" :buffer "*helm grep*"
:keymap helm-c-grep-map
:history 'helm-c-grep-history))) :history 'helm-c-grep-history)))


(defun helm-ff-zgrep-1 (flist recursive) (defun helm-ff-zgrep-1 (flist recursive)
Expand Down Expand Up @@ -741,6 +743,7 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers."
(filtered-candidate-transformer helm-c-grep-cand-transformer) (filtered-candidate-transformer helm-c-grep-cand-transformer)
(candidate-number-limit . 9999) (candidate-number-limit . 9999)
(nohighlight) (nohighlight)
(history . ,'helm-c-grep-history)
(keymap . ,helm-c-pdfgrep-map) (keymap . ,helm-c-pdfgrep-map)
(mode-line . helm-pdfgrep-mode-line-string) (mode-line . helm-pdfgrep-mode-line-string)
(action . helm-c-pdfgrep-action) (action . helm-c-pdfgrep-action)
Expand Down
5 changes: 5 additions & 0 deletions helm-help.el
Expand Up @@ -905,6 +905,11 @@ NOTE: This have effect only on sources using `candidates-in-buffer'.")
(helm-document-attribute 'nohighlight "optional" (helm-document-attribute 'nohighlight "optional"
" Disable highlight match in this source.") " Disable highlight match in this source.")


(helm-document-attribute 'history "optional"
" Allow passing history variable to helm from source.
It should be a quoted symbol evaluated from source.
i.e (history . ,'history-var).")

(provide 'helm-help) (provide 'helm-help)


;; Local Variables: ;; Local Variables:
Expand Down
1 change: 1 addition & 0 deletions helm-locate.el
Expand Up @@ -186,6 +186,7 @@ See also `helm-locate'."
(candidates . helm-c-locate-init) (candidates . helm-c-locate-init)
(type . file) (type . file)
(requires-pattern . 3) (requires-pattern . 3)
(history . ,'helm-file-name-history)
(keymap . ,helm-generic-files-map) (keymap . ,helm-generic-files-map)
(help-message . helm-generic-file-help-message) (help-message . helm-generic-file-help-message)
(candidate-number-limit . 9999) (candidate-number-limit . 9999)
Expand Down
2 changes: 1 addition & 1 deletion helm-mode.el
Expand Up @@ -461,7 +461,7 @@ Don't use it directly, use instead `helm-comp-read' in your programs.
See documentation of `completing-read' and `all-completions' for details." See documentation of `completing-read' and `all-completions' for details."
(declare (special helm-mode)) (declare (special helm-mode))
(let* ((current-command this-command) (let* ((current-command this-command)
(str-command (if (consp current-command) (str-command (if (consp current-command) ; Maybe a lambda.
"Anonymous" "Anonymous"
(symbol-name current-command))) (symbol-name current-command)))
(buf-name (format "*helm-mode-%s*" str-command)) (buf-name (format "*helm-mode-%s*" str-command))
Expand Down
18 changes: 11 additions & 7 deletions helm.el
Expand Up @@ -696,12 +696,12 @@ of \(action-display . function\)."
(helm-attr 'action)))) (helm-attr 'action))))


(defun helm-get-current-source () (defun helm-get-current-source ()
"Return the source for the current selection. "Return the source for the current selection."
Use it in init, candidates, action, candidate-transformer,
filtered-candidate-transformer functions."
(declare (special source)) (declare (special source))
;; The name `helm-get-current-source' should be used in init function etc. ;; `helm-source-name' let-bounded in some function with value of source.
(if (and (boundp 'helm-source-name) (stringp helm-source-name)) ;; Return source from this function. (e.g `helm-funcall-with-source').
(if (and (boundp 'helm-source-name)
(stringp helm-source-name))
source source
(with-current-buffer (helm-buffer-get) (with-current-buffer (helm-buffer-get)
(or (or
Expand Down Expand Up @@ -1316,7 +1316,11 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `helm'."
(helm-mark-current-line t) (helm-mark-current-line t)
(helm-update any-preselect)) (helm-update any-preselect))
(with-current-buffer (helm-buffer-get) (with-current-buffer (helm-buffer-get)
(let ((src-keymap (assoc-default 'keymap (helm-get-current-source)))) (let* ((src (helm-get-current-source))
(src-keymap (assoc-default 'keymap src))
(hist (or any-history
;; Needed for resuming.
(assoc-default 'history src))))
;; Startup with the first keymap found either in current source ;; Startup with the first keymap found either in current source
;; or helm arg, otherwise use global value of `helm-map'. ;; or helm arg, otherwise use global value of `helm-map'.
;; This map will be used as a `minibuffer-local-map'. ;; This map will be used as a `minibuffer-local-map'.
Expand All @@ -1342,7 +1346,7 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `helm'."
(thing-at-point 'symbol))))) (thing-at-point 'symbol)))))
(read-from-minibuffer (or any-prompt "pattern: ") (read-from-minibuffer (or any-prompt "pattern: ")
any-input helm-map any-input helm-map
nil any-history tap))))))) nil hist tap)))))))


(defun helm-maybe-update-keymap () (defun helm-maybe-update-keymap ()
"Handle differents keymaps in multiples sources. "Handle differents keymaps in multiples sources.
Expand Down

0 comments on commit 6ff63d4

Please sign in to comment.