Skip to content
Browse files

* helm.el (helm-read-pattern-maybe): Allow using history attr in sour…

…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...
1 parent 2d09d7b commit 6ff63d49822d75541b127cf6983ccdf814a2950c @thierryvolpiatto thierryvolpiatto committed Apr 19, 2012
Showing with 23 additions and 13 deletions.
  1. +2 −5 helm-files.el
  2. +3 −0 helm-grep.el
  3. +5 −0 helm-help.el
  4. +1 −0 helm-locate.el
  5. +1 −1 helm-mode.el
  6. +11 −7 helm.el
View
7 helm-files.el
@@ -483,14 +483,11 @@ ACTION must be an action supported by `helm-dired-action'."
(defun helm-find-files-grep (candidate)
"Default action to grep files from `helm-find-files'."
- (helm-do-grep-1 (helm-marked-candidates)
- helm-current-prefix-arg))
+ (helm-do-grep-1 (helm-marked-candidates) helm-current-prefix-arg))
(defun helm-ff-zgrep (candidate)
"Default action to zgrep files from `helm-find-files'."
- (let ((prefarg helm-current-prefix-arg)
- (ls (helm-marked-candidates)))
- (helm-ff-zgrep-1 ls prefarg)))
+ (helm-ff-zgrep-1 (helm-marked-candidates) helm-current-prefix-arg))
(defun helm-ff-pdfgrep (candidate)
"Default action to pdfgrep files from `helm-find-files'."
View
3 helm-grep.el
@@ -474,6 +474,7 @@ If it's empty --exclude `grep-find-ignored-files' is used instead."
(nohighlight)
(mode-line . helm-grep-mode-line-string)
(keymap . ,helm-c-grep-map)
+ (history . ,'helm-c-grep-history)
(action . ,(delq
nil
`(("Find File" . helm-c-grep-action)
@@ -488,6 +489,7 @@ If it's empty --exclude `grep-find-ignored-files' is used instead."
(requires-pattern . 3)
(delayed)))
:buffer "*helm grep*"
+ :keymap helm-c-grep-map
:history 'helm-c-grep-history)))
(defun helm-ff-zgrep-1 (flist recursive)
@@ -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)
(candidate-number-limit . 9999)
(nohighlight)
+ (history . ,'helm-c-grep-history)
(keymap . ,helm-c-pdfgrep-map)
(mode-line . helm-pdfgrep-mode-line-string)
(action . helm-c-pdfgrep-action)
View
5 helm-help.el
@@ -905,6 +905,11 @@ NOTE: This have effect only on sources using `candidates-in-buffer'.")
(helm-document-attribute 'nohighlight "optional"
" 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)
;; Local Variables:
View
1 helm-locate.el
@@ -186,6 +186,7 @@ See also `helm-locate'."
(candidates . helm-c-locate-init)
(type . file)
(requires-pattern . 3)
+ (history . ,'helm-file-name-history)
(keymap . ,helm-generic-files-map)
(help-message . helm-generic-file-help-message)
(candidate-number-limit . 9999)
View
2 helm-mode.el
@@ -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."
(declare (special helm-mode))
(let* ((current-command this-command)
- (str-command (if (consp current-command)
+ (str-command (if (consp current-command) ; Maybe a lambda.
"Anonymous"
(symbol-name current-command)))
(buf-name (format "*helm-mode-%s*" str-command))
View
18 helm.el
@@ -696,12 +696,12 @@ of \(action-display . function\)."
(helm-attr 'action))))
(defun helm-get-current-source ()
- "Return the source for the current selection.
-Use it in init, candidates, action, candidate-transformer,
-filtered-candidate-transformer functions."
+ "Return the source for the current selection."
(declare (special source))
- ;; The name `helm-get-current-source' should be used in init function etc.
- (if (and (boundp 'helm-source-name) (stringp helm-source-name))
+ ;; `helm-source-name' let-bounded in some function with value of source.
+ ;; Return source from this function. (e.g `helm-funcall-with-source').
+ (if (and (boundp 'helm-source-name)
+ (stringp helm-source-name))
source
(with-current-buffer (helm-buffer-get)
(or
@@ -1316,7 +1316,11 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `helm'."
(helm-mark-current-line t)
(helm-update any-preselect))
(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
;; or helm arg, otherwise use global value of `helm-map'.
;; This map will be used as a `minibuffer-local-map'.
@@ -1342,7 +1346,7 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `helm'."
(thing-at-point 'symbol)))))
(read-from-minibuffer (or any-prompt "pattern: ")
any-input helm-map
- nil any-history tap)))))))
+ nil hist tap)))))))
(defun helm-maybe-update-keymap ()
"Handle differents keymaps in multiples sources.

0 comments on commit 6ff63d4

Please sign in to comment.
Something went wrong with that request. Please try again.