From 22d6e073451a8604821541565b0f0a5e424f838a Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Fri, 16 Mar 2012 12:46:01 +0200 Subject: [PATCH] replaced anything with helm --- modules/prelude-global-keybindings.el | 2 +- .../anything-config/anything-match-plugin.el | 677 -- vendor/anything-config/anything.el | 4427 -------- .../helm-config.el} | 9305 ++++++++--------- vendor/helm/helm-match-plugin.el | 550 + vendor/helm/helm.el | 4427 ++++++++ 6 files changed, 9586 insertions(+), 9802 deletions(-) delete mode 100644 vendor/anything-config/anything-match-plugin.el delete mode 100644 vendor/anything-config/anything.el rename vendor/{anything-config/anything-config.el => helm/helm-config.el} (54%) create mode 100644 vendor/helm/helm-match-plugin.el create mode 100644 vendor/helm/helm.el diff --git a/modules/prelude-global-keybindings.el b/modules/prelude-global-keybindings.el index 75b1e70..cf28533 100644 --- a/modules/prelude-global-keybindings.el +++ b/modules/prelude-global-keybindings.el @@ -108,7 +108,7 @@ (global-set-key (kbd "C-c w") (make-repeatable-command 'er/expand-region)) (require 'anything-config) -(global-set-key (kbd "C-x j") 'anything) +(global-set-key (kbd "C-x j") 'helm) (provide 'prelude-global-keybindings) diff --git a/vendor/anything-config/anything-match-plugin.el b/vendor/anything-config/anything-match-plugin.el deleted file mode 100644 index 26d22b5..0000000 --- a/vendor/anything-config/anything-match-plugin.el +++ /dev/null @@ -1,677 +0,0 @@ -;;; anything-match-plugin.el --- Multiple regexp matching methods for anything - -;; Author: rubikitch - -;; Maintainers: rubikitch -;; Thierry Volpiatto - -;; Copyright (C) 2008~2012, rubikitch, all rights reserved. -;; Copyright (C) 2011~2012, Thierry Volpiatto, all rights reserved. - -;; Keywords: anything, matching -;; X-URL: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Auto documentation -;; ------------------ -;; -;; * User variables -;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "anything-mp" :var-value t) -;; `anything-mp-matching-method' -;; Default Value: multi3 -;; `anything-mp-highlight-delay' -;; Default Value: 0.7 -;; `anything-mp-highlight-threshold' -;; Default Value: 2 -;; -;; * Internal variables -;; [EVAL] (autodoc-document-lisp-buffer :type 'internal-variable :prefix "anything-mp" :var-value t) -;; `anything-mp-default-match-functions' -;; Default Value: (anything-mp-exact-match anything-mp-3-match) -;; `anything-mp-default-search-functions' -;; Default Value: (anything-mp-exact-search anything-mp-3-search) -;; `anything-mp-default-search-backward-functions' -;; Default Value: (anything-mp-exact-search-backward anything-mp-3-search-backward) -;; `anything-mp-space-regexp' -;; Default Value: "[\\ ] " -;; `anything-mp-exact-pattern-str' -;; Default Value: "autod" -;; `anything-mp-exact-pattern-real' -;; Default Value: "\nautod\n" -;; `anything-mp-prefix-pattern-str' -;; Default Value: nil -;; `anything-mp-prefix-pattern-real' -;; Default Value: nil -;; `anything-mp-1-pattern-str' -;; Default Value: nil -;; `anything-mp-1-pattern-real' -;; Default Value: nil -;; `anything-mp-2-pattern-str' -;; Default Value: nil -;; `anything-mp-2-pattern-real' -;; Default Value: nil -;; `anything-mp-3-pattern-str' -;; Default Value: "autod" -;; `anything-mp-3-pattern-list' -;; Default Value: ((identity . "autod")) -;; `anything-mp-initial-highlight-delay' -;; Default Value: nil -;; -;; * Anything match plugin Functions -;; [EVAL] (autodoc-document-lisp-buffer :type 'function :prefix "anything-mp") -;; `anything-mp-set-matching-method' -;; `anything-mp-make-regexps' -;; `anything-mp-1-make-regexp' -;; `anything-mp-exact-get-pattern' -;; `anything-mp-exact-match' -;; `anything-mp-exact-search' -;; `anything-mp-exact-search-backward' -;; `anything-mp-prefix-get-pattern' -;; `anything-mp-prefix-match' -;; `anything-mp-prefix-search' -;; `anything-mp-prefix-search-backward' -;; `anything-mp-1-get-pattern' -;; `anything-mp-1-match' -;; `anything-mp-1-search' -;; `anything-mp-1-search-backward' -;; `anything-mp-2-get-pattern' -;; `anything-mp-2-match' -;; `anything-mp-2-search' -;; `anything-mp-2-search-backward' -;; `anything-mp-3-get-patterns' -;; `anything-mp-3-get-patterns-internal' -;; `anything-mp-3-match' -;; `anything-mp-3-search-base' -;; `anything-mp-3-search' -;; `anything-mp-3-search-backward' -;; `anything-mp-3p-match' -;; `anything-mp-3p-search' -;; `anything-mp-3p-search-backward' -;; `anything-mp-highlight-match' -;; `anything-mp-highlight-region' -;; `anything-mp-highlight-match-internal' - -;; *** END auto-documentation - -;;; Commentary: - -;; Change anything.el matching algorithm humanely. -;; It gives anything.el search refinement functionality. -;; exact match -> prefix match -> multiple regexp match - -;;; Commands: -;; -;; Below are complete command list: -;; -;; -;;; Customizable Options: -;; -;; Below are customizable option list: -;; -;; `anything-grep-candidates-fast-directory-regexp' -;; *Directory regexp where a RAM disk (or tmpfs) is mounted. -;; default = nil - -;; A query of multiple regexp match is space-delimited string. -;; Anything displays candidates which matches all the regexps. -;; A regexp with "!" prefix means not matching the regexp. -;; To include spaces to a regexp, prefix "\" before space, -;; it is controlled by `anything-mp-space-regexp' variable. - -;; If multiple regexps are specified, first one also tries to match the source name. -;; If you want to disable this feature, evaluate -;; (setq anything-mp-match-source-name nil) . -;; NOTE: This is obsolete and disabled in anything versions >= 1.3.7 - -;; This file highlights patterns like `occur'. Note that patterns -;; longer than `anything-mp-highlight-threshold' are highlighted. And -;; region out of screen is highlighted after -;; `anything-mp-highlight-delay' seconds. -;; -;; Highlight in Emacs is time-consuming process for slow computers. To -;; disable it is to set nil to `anything-mp-highlight-delay'. - -;; anything-match-plugin is enable by default in anything. -;; To disable/enable it use M-x anything-c-toggle-match-plugin. - -;;; Code: - -(require 'anything) -(require 'cl) - - -;;;; Match-plugin - -;; Internal -(defvar anything-mp-default-match-functions nil) -(defvar anything-mp-default-search-functions nil) -(defvar anything-mp-default-search-backward-functions nil) - -(defun anything-mp-set-matching-method (var key) - "Default function to set matching methods in anything match plugin." - (set-default var key) - (case (symbol-value var) - (multi1 (setq anything-mp-default-match-functions - '(anything-mp-exact-match anything-mp-1-match) - anything-mp-default-search-functions - '(anything-mp-exact-search anything-mp-1-search) - anything-mp-default-search-backward-functions - '(anything-mp-exact-search-backward - anything-mp-1-search-backward))) - (multi2 (setq anything-mp-default-match-functions - '(anything-mp-exact-match anything-mp-2-match) - anything-mp-default-search-functions - '(anything-mp-exact-search anything-mp-2-search) - anything-mp-default-search-backward-functions - '(anything-mp-exact-search-backward - anything-mp-2-search-backward))) - (multi3 (setq anything-mp-default-match-functions - '(anything-mp-exact-match anything-mp-3-match) - anything-mp-default-search-functions - '(anything-mp-exact-search anything-mp-3-search) - anything-mp-default-search-backward-functions - '(anything-mp-exact-search-backward - anything-mp-3-search-backward))) - (multi3p (setq anything-mp-default-match-functions - '(anything-mp-exact-match anything-mp-3p-match) - anything-mp-default-search-functions - '(anything-mp-exact-search anything-mp-3p-search) - anything-mp-default-search-backward-functions - '(anything-mp-exact-search-backward - anything-mp-3p-search-backward))) - (t (error "Unknow value: %s" anything-mp-matching-method)))) - -(defgroup anything-match-plugin nil - "Anything match plugin." - :group 'anything) - -(defcustom anything-mp-matching-method 'multi3 - "Matching method for anything match plugin. -You can set here different methods to match candidates in anything. -Here are the possible value of this symbol and their meaning: -- multi1: Respect order, prefix of pattern must match. -- multi2: Same but with partial match. -- multi3: The best, multiple regexp match, allow negation. -- multi3p: Same but prefix must match. -Default is multi3." - :type '(radio :tag "Matching methods for anything" - (const :tag "Multiple regexp 1 ordered with prefix match" multi1) - (const :tag "Multiple regexp 2 ordered with partial match" multi2) - (const :tag "Multiple regexp 3 matching no order, partial, best." multi3) - (const :tag "Multiple regexp 3p matching with prefix match" multi3p)) - :set 'anything-mp-set-matching-method - :group 'anything-match-plugin) - -(defface anything-match - '((t (:inherit match))) - "Face used to highlight matches." - :group 'anything-match-plugin) - -(defcustom anything-mp-highlight-delay 0.7 - "Highlight matches with `anything-match' face after this many seconds. - If nil, no highlight. " - :type 'integer - :group 'anything-match-plugin) - -(defcustom anything-mp-highlight-threshold 2 - "Minimum length of pattern to highlight. -The smaller this value is, the slower highlight is." - :type 'integer - :group 'anything-match-plugin) - - - -;;; Build regexps -;; -;; -(defvar anything-mp-space-regexp "[\\ ] " - "Regexp to represent space itself in multiple regexp match.") - -(defun anything-mp-make-regexps (pattern) - "Split PATTERN if it contain spaces and return resulting list. -If spaces in PATTERN are escaped, don't split at this place. -i.e \"foo bar\"=> (\"foo\" \"bar\") -but \"foo\ bar\"=> (\"foobar\")." - (if (string= pattern "") - '("") - (loop for s in (split-string - (replace-regexp-in-string anything-mp-space-regexp - "\000\000" pattern) - " " t) - collect (replace-regexp-in-string "\000\000" " " s)))) - -(defun anything-mp-1-make-regexp (pattern) - "Replace spaces in PATTERN with \"\.*\"." - (mapconcat 'identity (anything-mp-make-regexps pattern) ".*")) - - -;;; Exact match. -;; -;; -;; Internal. -(defvar anything-mp-exact-pattern-str nil) -(defvar anything-mp-exact-pattern-real nil) - -(defun anything-mp-exact-get-pattern (pattern) - (unless (equal pattern anything-mp-exact-pattern-str) - (setq anything-mp-exact-pattern-str pattern - anything-mp-exact-pattern-real (concat "\n" pattern "\n"))) - anything-mp-exact-pattern-real) - - -(defun anything-mp-exact-match (str &optional pattern) - (string= str (or pattern anything-pattern))) - -(defun anything-mp-exact-search (pattern &rest ignore) - (and (search-forward (anything-mp-exact-get-pattern pattern) nil t) - (forward-line -1))) - -(defun anything-mp-exact-search-backward (pattern &rest ignore) - (and (search-backward (anything-mp-exact-get-pattern pattern) nil t) - (forward-line 1))) - - -;;; Prefix match -;; -;; -;; Internal -(defvar anything-mp-prefix-pattern-str nil) -(defvar anything-mp-prefix-pattern-real nil) - -(defun anything-mp-prefix-get-pattern (pattern) - (unless (equal pattern anything-mp-prefix-pattern-str) - (setq anything-mp-prefix-pattern-str pattern - anything-mp-prefix-pattern-real (concat "\n" pattern))) - anything-mp-prefix-pattern-real) - -(defun anything-mp-prefix-match (str &optional pattern) - (setq pattern (or pattern anything-pattern)) - (let ((len (length pattern))) - (and (<= len (length str)) - (string= (substring str 0 len) pattern )))) - -(defun anything-mp-prefix-search (pattern &rest ignore) - (search-forward (anything-mp-prefix-get-pattern pattern) nil t)) - -(defun anything-mp-prefix-search-backward (pattern &rest ignore) - (and (search-backward (anything-mp-prefix-get-pattern pattern) nil t) - (forward-line 1))) - - -;;; Multiple regexp patterns 1 (order is preserved / prefix). -;; -;; -;; Internal -(defvar anything-mp-1-pattern-str nil) -(defvar anything-mp-1-pattern-real nil) - -(defun anything-mp-1-get-pattern (pattern) - (unless (equal pattern anything-mp-1-pattern-str) - (setq anything-mp-1-pattern-str pattern - anything-mp-1-pattern-real - (concat "^" (anything-mp-1-make-regexp pattern)))) - anything-mp-1-pattern-real) - -(defun* anything-mp-1-match (str &optional (pattern anything-pattern)) - (string-match (anything-mp-1-get-pattern pattern) str)) - -(defun anything-mp-1-search (pattern &rest ignore) - (re-search-forward (anything-mp-1-get-pattern pattern) nil t)) - -(defun anything-mp-1-search-backward (pattern &rest ignore) - (re-search-backward (anything-mp-1-get-pattern pattern) nil t)) - - -;;; Multiple regexp patterns 2 (order is preserved / partial). -;; -;; -;; Internal -(defvar anything-mp-2-pattern-str nil) -(defvar anything-mp-2-pattern-real nil) - -(defun anything-mp-2-get-pattern (pattern) - (unless (equal pattern anything-mp-2-pattern-str) - (setq anything-mp-2-pattern-str pattern - anything-mp-2-pattern-real - (concat "^.*" (anything-mp-1-make-regexp pattern)))) - anything-mp-2-pattern-real) - -(defun* anything-mp-2-match (str &optional (pattern anything-pattern)) - (string-match (anything-mp-2-get-pattern pattern) str)) - -(defun anything-mp-2-search (pattern &rest ignore) - (re-search-forward (anything-mp-2-get-pattern pattern) nil t)) - -(defun anything-mp-2-search-backward (pattern &rest ignore) - (re-search-backward (anything-mp-2-get-pattern pattern) nil t)) - - -;;; Multiple regexp patterns 3 (permutation). -;; -;; -;; Internal -(defvar anything-mp-3-pattern-str nil) -(defvar anything-mp-3-pattern-list nil) - -(defun anything-mp-3-get-patterns (pattern) - "Return `anything-mp-3-pattern-list', a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\")). -This is done only if `anything-mp-3-pattern-str' is same as PATTERN." - (unless (equal pattern anything-mp-3-pattern-str) - (setq anything-mp-3-pattern-str pattern - anything-mp-3-pattern-list - (anything-mp-3-get-patterns-internal pattern))) - anything-mp-3-pattern-list) - -(defun anything-mp-3-get-patterns-internal (pattern) - "Return a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\"))." - (unless (string= pattern "") - (loop for pat in (anything-mp-make-regexps pattern) - collect (if (string= "!" (substring pat 0 1)) - (cons 'not (substring pat 1)) - (cons 'identity pat))))) - -(defun anything-mp-3-match (str &optional pattern) - "Check if PATTERN match STR. -When PATTERN contain a space, it is splitted and matching is done -with the several resulting regexps against STR. -e.g \"bar foo\" will match \"foobar\" and \"barfoo\". -Argument PATTERN, a string, is transformed in a list of -cons cell with `anything-mp-3-get-patterns' if it contain a space. -e.g \"foo bar\"=>((identity . \"foo\") (identity . \"bar\")). -Then each predicate of cons cell(s) is called with regexp of same -cons cell against STR (a candidate). -i.e (identity (string-match \"foo\" \"foo bar\")) => t." - (let ((pat (anything-mp-3-get-patterns (or pattern anything-pattern)))) - (loop for (predicate . regexp) in pat - always (funcall predicate (string-match regexp str))))) - -(defun anything-mp-3-search-base (pattern searchfn1 searchfn2) - (loop with pat = (if (stringp pattern) - (anything-mp-3-get-patterns pattern) - pattern) - while (funcall searchfn1 (or (cdar pat) "") nil t) - for bol = (point-at-bol) - for eol = (point-at-eol) - if (loop for (pred . str) in (cdr pat) always - (progn (goto-char bol) - (funcall pred (funcall searchfn2 str eol t)))) - do (goto-char eol) and return t - else do (goto-char eol) - finally return nil)) - -(defun anything-mp-3-search (pattern &rest ignore) - (when (stringp pattern) - (setq pattern (anything-mp-3-get-patterns pattern))) - (anything-mp-3-search-base - pattern 're-search-forward 're-search-forward)) - -(defun anything-mp-3-search-backward (pattern &rest ignore) - (when (stringp pattern) - (setq pattern (anything-mp-3-get-patterns pattern))) - (anything-mp-3-search-base - pattern 're-search-backward 're-search-backward)) - - -;;; mp-3p- (multiple regexp pattern 3 with prefix search) -;; -;; -(defun anything-mp-3p-match (str &optional pattern) - "Check if PATTERN match STR. -Same as `anything-mp-3-match' but more strict, matching against prefix also. -e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to -`anything-mp-3-match'." - (let* ((pat (anything-mp-3-get-patterns (or pattern anything-pattern))) - (first (car pat))) - (and (funcall (car first) (anything-mp-prefix-match str (cdr first))) - (loop for (predicate . regexp) in (cdr pat) - always (funcall predicate (string-match regexp str)))))) - -(defun anything-mp-3p-search (pattern &rest ignore) - (when (stringp pattern) - (setq pattern (anything-mp-3-get-patterns pattern))) - (anything-mp-3-search-base - pattern 'anything-mp-prefix-search 're-search-forward)) - -(defun anything-mp-3p-search-backward (pattern &rest ignore) - (when (stringp pattern) - (setq pattern (anything-mp-3-get-patterns pattern))) - (anything-mp-3-search-base - pattern 'anything-mp-prefix-search-backward 're-search-backward)) - - -;;; source compiler -;; -;; -(defun anything-compile-source--match-plugin (source) - (let ((searchers (if (assoc 'search-from-end source) - anything-mp-default-search-backward-functions - anything-mp-default-search-functions))) - `(,(if (or (assoc 'candidates-in-buffer source) - (equal '(identity) (assoc-default 'match source))) - '(match identity) - `(match ,@anything-mp-default-match-functions - ,@(assoc-default 'match source))) - (search ,@searchers - ,@(assoc-default 'search source)) - ,@source))) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--match-plugin t) - - -;;; Highlight matches. -;; -;; -(defun anything-mp-highlight-match () - "Highlight matches after `anything-mp-highlight-delay' seconds." - (when (and anything-mp-highlight-delay - (not (string= anything-pattern ""))) - (anything-mp-highlight-match-internal (window-end (anything-window))) - (run-with-idle-timer anything-mp-highlight-delay nil - 'anything-mp-highlight-match-internal - (with-current-buffer anything-buffer (point-max))))) -(add-hook 'anything-update-hook 'anything-mp-highlight-match) - -(defun anything-mp-highlight-region (start end regexp face) - (save-excursion - (goto-char start) - (let (me) - (while (and (setq me (re-search-forward regexp nil t)) - (< (point) end) - (< 0 (- (match-end 0) (match-beginning 0)))) - (unless (anything-pos-header-line-p) - (put-text-property (match-beginning 0) me 'face face)))))) - -(defun anything-mp-highlight-match-internal (end) - (when (anything-window) - (set-buffer anything-buffer) - (let ((requote (loop for (pred . re) in - (anything-mp-3-get-patterns anything-pattern) - when (and (eq pred 'identity) - (>= (length re) - anything-mp-highlight-threshold)) - collect re into re-list - finally return - (if (and re-list (>= (length re-list) 1)) - (mapconcat 'identity re-list "\\|") - (regexp-quote anything-pattern))))) - (when (>= (length requote) anything-mp-highlight-threshold) - (anything-mp-highlight-region - (point-min) end requote 'anything-match))))) - - -;;; Toggle anything-match-plugin -;; -;; -(defvar anything-mp-initial-highlight-delay nil) - -;;;###autoload -(defun anything-mp-toggle-match-plugin () - "Turn on/off multiple regexp matching in anything. -i.e anything-match-plugin." - (interactive) - (let ((anything-match-plugin-enabled - (member 'anything-compile-source--match-plugin - anything-compile-source-functions))) - (flet ((disable-match-plugin () - (setq anything-compile-source-functions - (delq 'anything-compile-source--match-plugin - anything-compile-source-functions)) - (setq anything-mp-initial-highlight-delay - anything-mp-highlight-delay) - (setq anything-mp-highlight-delay nil)) - (enable-match-plugin () - (unless anything-mp-initial-highlight-delay - (setq anything-mp-initial-highlight-delay - anything-mp-highlight-delay)) - (setq anything-compile-source-functions - (cons 'anything-compile-source--match-plugin - anything-compile-source-functions)) - (unless anything-mp-highlight-delay - (setq anything-mp-highlight-delay - anything-mp-initial-highlight-delay)))) - (if anything-match-plugin-enabled - (when (y-or-n-p "Really disable match-plugin? ") - (disable-match-plugin) - (message "Anything-match-plugin disabled")) - (when (y-or-n-p "Really enable match-plugin? ") - (enable-match-plugin) - (message "Anything-match-plugin enabled")))))) - - -;;;; Grep-candidates plug-in - -(defcustom anything-grep-candidates-fast-directory-regexp nil - "*Directory regexp where a RAM disk (or tmpfs) is mounted. - -If non-nil, grep-candidates plugin gets faster because it uses -grep as synchronous process. - -ex. (setq anything-grep-candidates-fast-directory-regexp \"^/tmp/\")" - :type 'string - :group 'anything) - -(defun agp-candidates (&optional filter) - "Normal version of grep-candidates candidates function. -Grep is run by asynchronous process." - (start-process-shell-command - "anything-grep-candidates" nil - (agp-command-line-2 filter (anything-attr-defined 'search-from-end)))) - -(defun agp-candidates-synchronous-grep (&optional filter) - "Faster version of grep-candidates candidates function. -Grep is run by synchronous process. -It is faster when candidate files are in ramdisk." - (split-string - (shell-command-to-string - (agp-command-line-2 filter (anything-attr-defined 'search-from-end))) - "\n")) - -(defun agp-candidates-synchronous-grep--direct-insert-match (&optional filter) - "[EXPERIMENTAL]Fastest version of grep-candidates candidates function at the cost of absense of transformers. -Grep is run by synchronous process. -It is faster when candidate files are in ramdisk. - -If (direct-insert-match) is in the source, this function is used." - (with-current-buffer (anything-candidate-buffer 'global) - (call-process-shell-command - (agp-command-line-2 filter (anything-attr-defined 'search-from-end)) - nil t))) - -(defun agp-command-line (query files &optional limit filter search-from-end) - "Build command line used by grep-candidates from QUERY, FILES, LIMIT, and FILTER." - (let ((allfiles (mapconcat (lambda (f) (shell-quote-argument (expand-file-name f))) - files " "))) - (with-temp-buffer - (when search-from-end - (insert "tac " allfiles)) - (if (string= query "") - (unless search-from-end - (insert "cat " allfiles)) - (when search-from-end (insert " | ")) - (loop for (flag . re) in (anything-mp-3-get-patterns-internal query) - for i from 0 - do - (setq re (replace-regexp-in-string "^-" "\\-" re)) - (unless (zerop i) (insert " | ")) - (insert "grep -ih " - (if (eq flag 'identity) "" "-v ") - (shell-quote-argument re)) - (when (and (not search-from-end) (zerop i)) - (insert " " allfiles)))) - - (when limit (insert (format " | head -n %d" limit))) - (when filter (insert " | " filter)) - (buffer-string)))) - -(defun agp-command-line-2 (filter &optional search-from-end) - "Build command line used by grep-candidates from FILTER and current source." - (agp-command-line - anything-pattern - (anything-mklist (anything-interpret-value (anything-attr 'grep-candidates))) - (anything-candidate-number-limit (anything-get-current-source)) - filter search-from-end)) - -(defun anything-compile-source--grep-candidates (source) - (anything-aif (assoc-default 'grep-candidates source) - (append - source - (let ((use-fast-directory - (and anything-grep-candidates-fast-directory-regexp - (string-match - anything-grep-candidates-fast-directory-regexp - (or (car (anything-mklist (anything-interpret-value it))) ""))))) - (cond ((not (anything-interpret-value it)) nil) - ((and use-fast-directory (assq 'direct-insert-match source)) - (anything-log "fastest version (use-fast-directory and direct-insert-match)") - `((candidates . agp-candidates-synchronous-grep--direct-insert-match) - (match identity) - (volatile))) - (use-fast-directory - (anything-log "faster version (use-fast-directory)") - `((candidates . agp-candidates-synchronous-grep) - (match identity) - (volatile))) - (t - (anything-log "normal version") - '((candidates . agp-candidates) - (delayed)))))) - source)) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--grep-candidates) - -(anything-document-attribute 'grep-candidates "grep-candidates plug-in" - "grep-candidates plug-in provides anything-match-plugin.el feature with grep and head program. -It is MUCH FASTER than normal match-plugin to search from vary large (> 1MB) candidates. -Make sure to install these programs. - -It expands `candidates' and `delayed' attributes. - -`grep-candidates' attribute accepts a filename or list of filename. -It also accepts 0-argument function name or variable name.") - -;; (anything '(((name . "grep-test") (grep-candidates . "~/.emacs.el") (action . message)))) -;; (let ((a "~/.emacs.el")) (anything '(((name . "grep-test") (grep-candidates . a) (action . message) (delayed))))) -;; (let ((a "~/.emacs.el")) (anything '(((name . "grep-test") (grep-candidates . (lambda () a)) (action . message) (delayed))))) -;; (anything '(((name . "grep-test") (grep-candidates . "~/.emacs.el") (action . message) (delayed) (candidate-number-limit . 2)))) -;; (let ((anything-candidate-number-limit 2)) (anything '(((name . "grep-test") (grep-candidates . "~/.emacs.el") (action . message) (delayed))))) - -;;;; unit test -;; unit test for match plugin are now in developper-tools/unit-test-match-plugin.el - -(provide 'anything-match-plugin) - -;;; anything-match-plugin.el ends here diff --git a/vendor/anything-config/anything.el b/vendor/anything-config/anything.el deleted file mode 100644 index 66c0b40..0000000 --- a/vendor/anything-config/anything.el +++ /dev/null @@ -1,4427 +0,0 @@ -;;; anything.el --- open anything / QuickSilver-like candidate-selection framework - -;; Copyright (C) 2007 Tamas Patrovics -;; 2008 ~ 2012 rubikitch -;; 2011 ~ 2012 Thierry Volpiatto - -;; Author: Tamas Patrovics - -;; Maintainers: rubikitch -;; Thierry Volpiatto - -;; Keywords: files, frames, help, matching, outlines, -;; processes, tools, convenience, anything - -;; X-URL: - -;; Site: - -;; MailingList: - - -;;; This file is NOT part of GNU Emacs - -;;; License -;; -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Autodoc documentation: -;; --------------------- - -;; * Commands defined here are: -;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "anything" :docstring t) -;; `anything-open-last-log' -;; Open anything log file of last anything session. -;; `anything' -;; Main function to execute anything sources. -;; `anything-resume' -;; Resurrect previously invoked `anything'. -;; `anything-resume-window-only' -;; -;; `anything-at-point' -;; Call anything with symbol at point as initial input. -;; `anything-force-update' -;; Force recalculation and update of candidates. -;; `anything-select-action' -;; Select an action for the currently selected candidate. -;; `anything-previous-line' -;; Move selection to the previous line. -;; `anything-next-line' -;; Move selection to the next line. -;; `anything-previous-page' -;; Move selection back with a pageful. -;; `anything-next-page' -;; Move selection forward with a pageful. -;; `anything-beginning-of-buffer' -;; Move selection at the top. -;; `anything-end-of-buffer' -;; Move selection at the bottom. -;; `anything-previous-source' -;; Move selection to the previous source. -;; `anything-next-source' -;; Move selection to the next source. -;; `anything-select-with-prefix-shortcut' -;; Invoke default action with prefix shortcut. -;; `anything-select-with-digit-shortcut' -;; Invoke default action with digit/alphabet shortcut. -;; `anything-confirm-and-exit-minibuffer' -;; Maybe ask for confirmation when exiting anything. -;; `anything-exit-minibuffer' -;; Select the current candidate by exiting the minibuffer. -;; `anything-keyboard-quit' -;; Quit minibuffer in anything. -;; `anything-help' -;; Help of `anything'. -;; `anything-debug-output' -;; Show all anything-related variables at this time. -;; `anything-delete-current-selection' -;; Delete the currently selected item. -;; `anything-delete-minibuffer-contents' -;; Same as `delete-minibuffer-contents' but this is a command. -;; `anything-toggle-resplit-window' -;; Toggle resplit anything window, vertically or horizontally. -;; `anything-narrow-window' -;; Narrow anything window. -;; `anything-enlarge-window' -;; Enlarge anything window. -;; `anything-select-2nd-action' -;; Select the 2nd action for the currently selected candidate. -;; `anything-select-3rd-action' -;; Select the 3rd action for the currently selected candidate. -;; `anything-select-4th-action' -;; Select the 4th action for the currently selected candidate. -;; `anything-select-2nd-action-or-end-of-line' -;; Select the 2nd action for the currently selected candidate. -;; `anything-execute-persistent-action' -;; Perform the associated action ATTR without quitting anything. -;; `anything-scroll-other-window' -;; Scroll other window (not *Anything* window) upward. -;; `anything-scroll-other-window-down' -;; Scroll other window (not *Anything* window) downward. -;; `anything-toggle-visible-mark' -;; Toggle anything visible mark at point. -;; `anything-display-all-visible-marks' -;; Show all `anything' visible marks strings. -;; `anything-next-visible-mark' -;; Move next anything visible mark. -;; `anything-prev-visible-mark' -;; Move previous anything visible mark. -;; `anything-yank-selection' -;; Set minibuffer contents to current selection. -;; `anything-kill-selection-and-quit' -;; Store current selection to kill ring. -;; `anything-follow-mode' -;; If this mode is on, persistent action is executed everytime the cursor is moved. -;; `anything-migrate-sources' -;; Help to migrate to new `anything' way. -;; `anything-describe-anything-attribute' -;; Display the full documentation of ANYTHING-ATTRIBUTE. -;; `anything-send-bug-report' -;; Send a bug report of anything.el. -;; `anything-send-bug-report-from-anything' -;; Send a bug report of anything.el in anything session. - -;; * Variables defined here are: -;; [EVAL] (autodoc-document-lisp-buffer :type 'internal-variable :prefix "anything-" :docstring t) -;; `anything-version' -;; Not documented. -;; `anything-sources' -;; A list of sources to use with `anything'. -;; `anything-type-attributes' -;; It's a list of (TYPE ATTRIBUTES ...). -;; `anything-enable-shortcuts' -;; *Whether to use digit/alphabet shortcut to select the first nine matches. -;; `anything-shortcut-keys-alist' -;; Not documented. -;; `anything-display-source-at-screen-top' -;; *Display candidates at the top of screen. -;; `anything-candidate-number-limit' -;; Apply candidate-number-limit attribute value. -;; `anything-idle-delay' -;; *Be idle for this many seconds, before updating in delayed sources. -;; `anything-input-idle-delay' -;; Be idle for this many seconds, before updating. -;; `anything-samewindow' -;; Use current window to show the candidates. -;; `anything-source-filter' -;; A list of source names to be displayed. -;; `anything-map' -;; Keymap for anything. -;; `anything-header-face' -;; *Face for header lines in the anything buffer. -;; `anything-selection-face' -;; *Face for currently selected item. -;; `anything-buffer' -;; Buffer showing completions. -;; `anything-action-buffer' -;; Buffer showing actions. -;; `anything-selection-overlay' -;; Overlay used to highlight the currently selected item. -;; `anything-digit-overlays' -;; Overlays for digit shortcuts. See `anything-enable-shortcuts'. -;; `anything-candidate-cache' -;; Holds the available candidate withing a single anything invocation. -;; `anything-pattern' -;; Not documented. -;; `anything-input' -;; Not documented. -;; `anything-async-processes' -;; List of information about asynchronous processes managed by anything. -;; `anything-digit-shortcut-count' -;; Number of digit shortcuts shown in the anything buffer. -;; `anything-before-initialize-hook' -;; Run before anything initialization. -;; `anything-after-initialize-hook' -;; Run after anything initialization. -;; `anything-update-hook' -;; Run after the anything buffer was updated according the new input pattern. -;; `anything-after-update-hook' -;; Run after the anything buffer was updated according the new input pattern. -;; `anything-cleanup-hook' -;; Run after anything minibuffer is closed. -;; `anything-select-action-hook' -;; Run when opening the action buffer. -;; `anything-before-action-hook' -;; Run before executing action. -;; `anything-after-action-hook' -;; Run after executing action. -;; `anything-after-persistent-action-hook' -;; Run after executing persistent action. -;; `anything-move-selection-before-hook' -;; Run before moving selection in `anything-buffer'. -;; `anything-move-selection-after-hook' -;; Run after moving selection in `anything-buffer'. -;; `anything-restored-variables' -;; Variables which are restored after `anything' invocation. -;; `anything-saved-selection' -;; Value of the currently selected object when the action list is shown. -;; `anything-current-prefix-arg' -;; Record `current-prefix-arg' when exiting minibuffer. -;; `anything-candidate-separator' -;; Candidates separator of `multiline' source. -;; `anything-current-buffer' -;; Current buffer when `anything' is invoked. -;; `anything-buffer-file-name' -;; Variable `buffer-file-name' when `anything' is invoked. -;; `anything-saved-action' -;; Saved value of the currently selected action by key. -;; `anything-last-sources' -;; OBSOLETE!! Sources of previously invoked `anything'. -;; `anything-saved-current-source' -;; Value of the current source when the action list is shown. -;; `anything-compiled-sources' -;; Compiled version of `anything-sources'. -;; `anything-in-persistent-action' -;; Flag whether in persistent-action or not. -;; `anything-quick-update' -;; If non-nil, suppress displaying sources which are out of screen at first. -;; `anything-last-sources-local' -;; Buffer local value of `anything-sources'. -;; `anything-last-buffer' -;; `anything-buffer' of previously `anything' session. -;; `anything-save-configuration-functions' -;; The functions used to restore/save window or frame configurations. -;; `anything-persistent-action-use-special-display' -;; If non-nil, use `special-display-function' in persistent action. -;; `anything-execute-action-at-once-if-one' -;; Execute default action and exit when only one candidate is remaining. -;; `anything-quit-if-no-candidate' -;; Quit when there is no candidates when non--nil. -;; `anything-scroll-amount' -;; Scroll amount when scrolling other window in an anything session. -;; `anything-display-function' -;; Function to display *anything* buffer. -;; `anything-delayed-init-executed' -;; Not documented. -;; `anything-mode-line-string' -;; Help string displayed in mode-line in `anything'. -;; `anything-help-message' -;; Detailed help message string for `anything'. -;; `anything-source-in-each-line-flag' -;; Non-nil means add anything-source text-property in each candidate. -;; `anything-debug-forms' -;; Forms to show in `anything-debug-output'. -;; `anything-debug' -;; If non-nil, write log message into *Anything Log* buffer. -;; `anything-test-candidate-list' -;; Not documented. -;; `anything-test-mode' -;; Not documented. -;; `anything-source-name' -;; Not documented. -;; `anything-candidate-buffer-alist' -;; Not documented. -;; `anything-check-minibuffer-input-timer' -;; Not documented. -;; `anything-match-hash' -;; Not documented. -;; `anything-cib-hash' -;; Not documented. -;; `anything-tick-hash' -;; Not documented. -;; `anything-issued-errors' -;; Not documented. -;; `anything-shortcut-keys' -;; Not documented. -;; `anything-once-called-functions' -;; Not documented. -;; `anything-follow-mode' -;; If this mode is on, persistent action is executed everytime the cursor is moved. -;; `anything-let-variables' -;; Not documented. -;; `anything-split-window-state' -;; Not documented. -;; `anything-selection-point' -;; Not documented. -;; `anything-last-log-file' -;; Not documented. -;; `anything-compile-source-functions' -;; Functions to compile elements of `anything-sources' (plug-in). -;; `anything-quit' -;; Not documented. -;; `anything-additional-attributes' -;; List of all `anything' attributes. -;; `anything-buffers' -;; All of `anything-buffer' in most recently used order. -;; `anything-current-position' -;; Restore or save current position in `anything-current-buffer'. -;; `anything-last-frame-or-window-configuration' -;; Used to store window or frame configuration when anything start. -;; `anything-reading-pattern' -;; Whether in `read-string' in anything or not. -;; `anything-compile-source-functions-default' -;; Plug-ins this file provides. -;; `anything-input-local' -;; Not documented. -;; `anything-process-delayed-sources-timer' -;; Not documented. -;; `anything-mode-line-string-real' -;; Not documented. -;; `anything-exit-status' -;; Flag to inform whether anything have exited or quitted. -;; `anything-minibuffer-confirm-state' -;; Not documented. -;; `anything-types' -;; Not documented. -;; `anything-orig-enable-shortcuts' -;; Not documented. -;; `anything-persistent-action-display-window' -;; Return the window that will be used for presistent action. -;; `anything-visible-mark-face' -;; Not documented. -;; `anything-visible-mark-overlays' -;; Not documented. -;; `anything-marked-candidates' -;; Return marked candidates of current source if any. -;; `anything-maintainer-mail-address' -;; Not documented. -;; `anything-bug-report-salutation' -;; Not documented. -;; `anything-no-dump-variables' -;; Variables not to dump in bug report. - -;; *** END auto-documentation - -;; [EVAL] (autodoc-update-all) - - -;;; Commentary: - -;; -;; Start with M-x anything, narrow the list by typing some pattern, -;; select with up/down/pgup/pgdown/C-p/C-n/C-v/M-v, choose with enter, -;; left/right moves between sources. With TAB actions can be selected -;; if the selected candidate has more than one possible action. -;; -;; Note that anything.el provides only the framework and some example -;; configurations for demonstration purposes. See anything-config.el -;; for practical, polished, easy to use configurations which can be -;; used to assemble a custom personalized configuration. -;; -;; NOTE: What you find on Emacswiki is mostly deprecated and not maintained, -;; don't complain if you use such code or configuration and something -;; doesn't work. -;; -;; Here is Japanese translation of `anything-sources' attributes. Thanks. -;; http://d.hatena.ne.jp/sirocco634/20091012/1255336649 - - -;;; Bug Report: -;; -;; If you have problems, send a bug report via C-c C-x C-b in anything session (best) -;; or M-x anything-send-bug-report outside anything session. -;; I implemented bug report feature because I want to know your current state. -;; It helps me to solve problems easily. -;; The step is: -;; 0) Setup mail in Emacs, the easiest way is: -;; (setq user-mail-address "your@mail.address") -;; (setq user-full-name "Your Full Name") -;; (setq smtpmail-smtp-server "your.smtp.server.jp") -;; (setq mail-user-agent 'message-user-agent) -;; (setq message-send-mail-function 'message-smtpmail-send-it) -;; 1) Be sure to use the LATEST version of anything.el. -;; 2) Enable debugger. M-x toggle-debug-on-error or (setq debug-on-error t) -;; 3) Use Lisp version instead of compiled one: (load "anything.el") -;; 4) Do it! -;; 5) If you got an error, please do not close *Backtrace* buffer. -;; 6) Type C-c C-x C-b (anything session, best!) -;; or M-x anything-send-bug-report (outside) -;; then M-x insert-buffer *Backtrace* (if you got error) -;; 7) Describe the bug using a precise recipe. -;; 8) Type C-c C-c to send. -;; -;; You can also just report bug to: -;; https://groups.google.com/group/emacs-anything?hl=en - - -;; You can extend `anything' by writing plug-ins. As soon as -;; `anything' is invoked, `anything-sources' is compiled into basic -;; attributes, then compiled one is used during invocation. -;; -;; The oldest built-in plug-in is `type' attribute: appends -;; appropriate element of `anything-type-attributes'. Second built-in -;; plug-in is `candidates-in-buffer': selecting a line from candidates -;; buffer. -;; -;; To write a plug-in: -;; 1. Define a compiler: anything-compile-source--* -;; 2. Add compier function to `anything-compile-source-functions'. -;; 3. (optional) Write helper functions. -; -;; Tested on Emacs 22/23/24. -;; -;; -;; Thanks to Vagn Johansen for ideas. -;; Thanks to Stefan Kamphausen for fixes and XEmacs support. -;; Thanks to Tassilo Horn for fixes. -;; Thanks to Drew Adams for various fixes -;; Thanks to IMAKADO for candidates-in-buffer idea. -;; Thanks to Tomohiro MATSUYAMA for multiline patch. -;; - -;;; (@* "Index") - -;; If you have library `linkd.el', load -;; `linkd.el' and turn on `linkd-mode' now. It lets you easily -;; navigate around the sections Linkd mode will -;; highlight this Index. You can get `linkd.el' here: -;; http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el -;; - - -;;; (@* "Tips") - -;; -;; `anything' accepts keyword arguments. See docstring. -;; [EVAL IT] (describe-function 'anything) - -;; -;; `anything-enable-shortcuts' enables us to select candidate easily. -;; If 'prefix then they can be selected using . -;; The prefix key is `anything-select-with-prefix-shortcut'. -;; If the is a letter, pressing twice inputs the letter itself. -;; e.g. -;; (setq anything-enable-shortcuts 'prefix) -;; (define-key anything-map \"@\" 'anything-select-with-prefix-shortcut) - -;; -;; You can edit current selection using `anything-edit-current-selection'. -;; It is useful after persistent-action. - -;; -;; For `anything' users, setting `anything-sources' directly and -;; invoke M-x anything is obsolete way for now. Try M-x -;; `anything-migrate-sources'! - -;; -;; If you want to create anything sources, yasnippet would help you. -;; http://yasnippet.googlecode.com/ -;; -;; Then get the snippet from -;; http://www.emacswiki.org/cgi-bin/wiki/download/anything-source.yasnippet -;; -;; Put it in ~/.emacs.d/plugins/yasnippet/snippets/text-mode/emacs-lisp-mode/ - - -;; -;; `anything-interpret-value' is useful function to interpret value -;; like `candidates' attribute. -;; -;; (anything-interpret-value "literal") ; => "literal" -;; (anything-interpret-value (lambda () "lambda")) ; => "lambda" -;; (let ((source '((name . "lambda with source name")))) -;; (anything-interpret-value -;; (lambda () anything-source-name) -;; source)) ; => "lambda with source name" -;; (flet ((f () "function symbol")) -;; (anything-interpret-value 'f)) ; => "function symbol" -;; (let ((v "variable symbol")) -;; (anything-interpret-value 'v)) ; => "variable symbol" -;; (anything-interpret-value 'unbounded-1) ; error - -;; -;; Now symbols are acceptable as candidates. So you do not have to use -;; `symbol-name' function. The source is much simpler. For example, -;; `apropos-internal' returns a list of symbols. -;; -;; (anything -;; '(((name . "Commands") -;; (candidates . (lambda () (apropos-internal anything-pattern 'commandp))) -;; (volatile) -;; (action . describe-function)))) - -;; -;; To mark a candidate, press C-SPC as normal Emacs marking. To go to -;; marked candidate, press M-[ or M-]. - -;; -;; `anything-map' is now Emacs-standard key bindings by default. -;; -;; There are many `anything' applications, using `anything' for -;; selecting candidate. In this case, if there is one candidate or no -;; candidate, popping up *anything* buffer is irritating. If one -;; candidate, you want to select it at once. If no candidate, you want -;; to quit `anything'. Set `anything-execute-action-at-once-if-one' -;; and `anything-quit-if-no-candidate' to non-nil to remedy it. Note -;; that setting these variables GLOBALLY is bad idea because of -;; delayed sources. These are meant to be let-binded. -;; -;; ex. -;; (let ((anything-execute-action-at-once-if-one t) -;; (anything-quit-if-no-candidate (lambda () (message "No candidate")))) -;; (anything temporary-sources input)) - -;; -;; `set-frame-configuration' arises flickering. If you hate -;; flickering, eval: -;; (setq anything-save-configuration-functions -;; '(set-window-configuration . current-window-configuration)) -;; at the cost of restoring frame configuration (only window configuration). - -;; -;; `anything-delete-current-selection' deletes the current line. -;; It is useful when deleting a candidate in persistent action. -;; eg. `kill-buffer'. -;; -;; [EVAL IT] (describe-function 'anything-delete-current-selection) - -;; -;; `anything-attr' gets the attribute. `anything-attrset' sets the -;; attribute. `anything-attr-defined' tests whether the attribute is -;; defined. They handles source-local variables. -;; -;; [EVAL IT] (describe-function 'anything-attr) -;; [EVAL IT] (describe-function 'anything-attrset) -;; [EVAL IT] (describe-function 'anything-attr-defined) - -;; -;; `anything-sources' accepts many attributes to make your life easier. -;; Now `anything-sources' accepts a list of symbols. -;; -;; [EVAL IT] (describe-variable 'anything-sources) - -;; -;; `anything' has optional arguments. Now you do not have to let-bind -;; `anything-sources'. -;; -;; [EVAL IT] (describe-function 'anything) - -;; -;; `anything-resume' resumes last `anything' session. Now you do not -;; have to retype pattern. -;; -;; [EVAL IT] (describe-function 'anything-resume) - -;; -;; `anything-execute-persistent-action' executes action without -;; quitting `anything'. When popping up a buffer in other window by -;; persistent action, you can scroll with `anything-scroll-other-window' and -;; `anything-scroll-other-window-down'. See also `anything-sources' docstring. -;; -;; [EVAL IT] (describe-function 'anything-execute-persistent-action) -;; [EVAL IT] (describe-variable 'anything-sources) - -;; -;; `anything-select-2nd-action', `anything-select-3rd-action' and -;; `anything-select-4th-action' select other than default action -;; without pressing Tab. - -;; -;; Using `anything-candidate-buffer' and the candidates-in-buffer -;; attribute is much faster than traditional "candidates and match" -;; way. And `anything-current-buffer-is-modified' avoids to -;; recalculate candidates for unmodified buffer. See docstring of -;; them. -;; -;; [EVAL IT] (describe-function 'anything-candidate-buffer) -;; [EVAL IT] (describe-function 'anything-candidates-in-buffer) -;; [EVAL IT] (describe-function 'anything-current-buffer-is-modified) - -;; -;; `anything-current-buffer' and `anything-buffer-file-name' stores -;; `(current-buffer)' and `buffer-file-name' in the buffer `anything' -;; is invoked. Use them freely. -;; -;; [EVAL IT] (describe-variable 'anything-current-buffer) -;; [EVAL IT] (describe-variable 'anything-buffer-file-name) - -;; -;; `anything-completing-read' and `anything-read-file-name' are -;; experimental implementation. If you are curious, type M-x -;; anything-read-string-mode. It is a minor mode and toggles on/off. - -;; -;; Use `anything-test-candidates' to test your handmade anything -;; sources. It simulates contents of *anything* buffer with pseudo -;; `anything-sources' and `anything-pattern', without side-effect. So -;; you can unit-test your anything sources! Let's TDD! -;; -;; [EVAL IT] (describe-function 'anything-test-candidates) -;; -;; For anything developpers: -;; -;; There are many unit-testing framework in Emacs Lisp. See the EmacsWiki. -;; http://www.emacswiki.org/cgi-bin/emacs/UnitTesting -;; There is an unit-test by Emacs Lisp Expectations in developper-tools directory. -;; http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el -;; http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el - -;; -;; If you want to create anything sources, see anything-config.el. -;; It is huge collection of sources. You can learn from examples. - - -;; (@* "TODO") -;; -;; - process status indication -;; -;; - async sources doesn't honor digit-shortcut-count -;; -;; - anything-candidate-number-limit can't be nil everywhere - -;; (@* "HISTORY") -;; -;; Change log of this file is found at -;; http://repo.or.cz/w/anything-config.git/history/master:/anything.el -;; -;; Change log of this project is found at -;; http://repo.or.cz/w/anything-config.git?a=shortlog -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -;;; Code: - -(require 'cl) - -(defvar anything-version "1.3.9") - -;; (@* "User Configuration") - - -;;; Variables -;; -;; -;; [DEPRECATED] -;; A default value is provided in anything-config.el -(defvar anything-sources nil - "A list of sources to use with `anything'. -It is deprecated, you should not use this. -Use instead individual sources or list of sources of your choice.") - -;; Default values are provided in anything-config.el. -(defvar anything-type-attributes nil - "It's a list of \(TYPE ATTRIBUTES ...\). -ATTRIBUTES are the same as attributes for `anything-sources'. -TYPE connects the value to the appropriate sources. -Don't set this directly, use instead `define-anything-type-attribute'. - -This allows specifying common attributes for several sources. -For example, sources which provide files can specify -common attributes with a `file' type.") - -(defvaralias 'anything-enable-digit-shortcuts 'anything-enable-shortcuts - "Same as `anything-enable-shortcuts'. -Alphabet shortcuts are available now in `anything-enable-shortcuts'. -`anything-enable-digit-shortcuts' is retained for compatibility.") - -(defvar anything-enable-shortcuts nil - "*Whether to use digit/alphabet shortcut to select the first nine matches. -If t then they can be selected using Ctrl+. - -If 'prefix then they can be selected using . -The prefix key is `anything-select-with-prefix-shortcut'. -If the is a letter, pressing twice inputs the letter itself. -e.g. - (setq anything-enable-shortcuts 'prefix) - (define-key anything-map \"@\" 'anything-select-with-prefix-shortcut) - -If 'alphabet then they can be selected using Shift+ (deprecated). -It is not recommended because you cannot input capital letters in pattern. - -Keys (digit/alphabet) are listed in `anything-shortcut-keys-alist'.") - -(defvar anything-shortcut-keys-alist - '((alphabet . "asdfghjklzxcvbnmqwertyuiop") - (prefix . "asdfghjklzxcvbnmqwertyuiop1234567890") - (t . "123456789"))) - -(defvar anything-display-source-at-screen-top t - "*Display candidates at the top of screen. -This happen when using `anything-next-source' and `anything-previous-source'.") - -(defvar anything-candidate-number-limit 50 - "*Limit candidate number globally. -Do not show more candidates than this limit from individual sources. -It is usually pointless to show hundreds of matches -when the pattern is empty, because it is much simpler to type a -few characters to narrow down the list of potential candidates. - -Set it to nil if you don't want this limit.") - -(defvar anything-idle-delay 0.3 - "*Be idle for this many seconds, before updating in delayed sources. -This is useful for sources involving heavy operations -\(like launching external programs\), so that candidates -from the source are not retrieved unnecessarily if the user keeps typing. - -It also can be used to declutter the results anything displays, -so that results from certain sources are not shown with every -character typed, only if the user hesitates a bit.") - -(defvar anything-input-idle-delay 0.3 - "Be idle for this many seconds, before updating. - -Unlike `anything-idle-delay', it is also effective for non-delayed sources. -If nil, candidates are collected immediately. - -Note: If this value is too low compared to `anything-idle-delay', -you may have duplicated sources when using multiples sources. -Safe value is always >= `anything-idle-delay'. -Default settings are equal value for both.") - -(defvar anything-samewindow nil - "Use current window to show the candidates. -If t then Anything doesn't pop up a new window.") - -(defvar anything-source-filter nil - "A list of source names to be displayed. -Other sources won't appear in the search results. -If nil then there is no filtering. -See also `anything-set-source-filter'.") - - -(defvar anything-map - (let ((map (copy-keymap minibuffer-local-map))) - (define-key map (kbd "") 'anything-next-line) - (define-key map (kbd "") 'anything-previous-line) - (define-key map (kbd "C-n") 'anything-next-line) - (define-key map (kbd "C-p") 'anything-previous-line) - (define-key map (kbd "") 'anything-previous-page) - (define-key map (kbd "") 'anything-next-page) - (define-key map (kbd "M-v") 'anything-previous-page) - (define-key map (kbd "C-v") 'anything-next-page) - (define-key map (kbd "M-<") 'anything-beginning-of-buffer) - (define-key map (kbd "M->") 'anything-end-of-buffer) - (define-key map (kbd "C-g") 'anything-keyboard-quit) - (define-key map (kbd "") 'anything-next-source) - (define-key map (kbd "") 'anything-previous-source) - (define-key map (kbd "") 'anything-exit-minibuffer) - (define-key map (kbd "C-1") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-2") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-3") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-4") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-5") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-6") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-7") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-8") 'anything-select-with-digit-shortcut) - (define-key map (kbd "C-9") 'anything-select-with-digit-shortcut) - (loop for c from ?A to ?Z do - (define-key map (make-string 1 c) 'anything-select-with-digit-shortcut)) - (define-key map (kbd "C-i") 'anything-select-action) - (define-key map (kbd "C-z") 'anything-execute-persistent-action) - (define-key map (kbd "C-e") 'anything-select-2nd-action-or-end-of-line) - (define-key map (kbd "C-j") 'anything-select-3rd-action) - (define-key map (kbd "C-o") 'anything-next-source) - (define-key map (kbd "C-M-v") 'anything-scroll-other-window) - (define-key map (kbd "M-") 'anything-scroll-other-window) - (define-key map (kbd "C-M-y") 'anything-scroll-other-window-down) - (define-key map (kbd "C-M-S-v") 'anything-scroll-other-window-down) - (define-key map (kbd "M-") 'anything-scroll-other-window-down) - (define-key map (kbd "") 'anything-scroll-other-window) - (define-key map (kbd "") 'anything-scroll-other-window-down) - (define-key map (kbd "C-SPC") 'anything-toggle-visible-mark) - (define-key map (kbd "M-SPC") 'anything-toggle-visible-mark) - (define-key map (kbd "M-[") 'anything-prev-visible-mark) - (define-key map (kbd "M-]") 'anything-next-visible-mark) - (define-key map (kbd "C-k") 'anything-delete-minibuffer-contents) - - (define-key map (kbd "C-r") 'undefined) - (define-key map (kbd "C-t") 'anything-toggle-resplit-window) - (define-key map (kbd "C-}") 'anything-narrow-window) - (define-key map (kbd "C-{") 'anything-enlarge-window) - - (define-key map (kbd "C-c C-d") 'anything-delete-current-selection) - (define-key map (kbd "C-c C-y") 'anything-yank-selection) - (define-key map (kbd "C-c C-k") 'anything-kill-selection-and-quit) - (define-key map (kbd "C-c C-f") 'anything-follow-mode) - (define-key map (kbd "C-c C-u") 'anything-force-update) - (define-key map (kbd "M-p") 'previous-history-element) - (define-key map (kbd "M-n") 'next-history-element) - ;; Debugging command - (define-key map "\C-c\C-x\C-d" 'anything-debug-output) - (define-key map "\C-c\C-x\C-m" 'anything-display-all-visible-marks) - (define-key map "\C-c\C-x\C-b" 'anything-send-bug-report-from-anything) - ;; Use `describe-mode' key in `global-map'. - (define-key map [f1] nil) ; Allow to eval keymap whithout errors. - (dolist (k (where-is-internal 'describe-mode global-map)) - (define-key map k 'anything-help)) - map) - "Keymap for anything.") - - -(defgroup anything nil - "Open anything." - :prefix "anything-" :group 'convenience) - -(defface anything-header - '((t (:inherit header-line))) - "Face for header lines in the anything buffer." - :group 'anything) - -(defvar anything-header-face 'anything-header - "*Face for header lines in the anything buffer.") - -(defface anything-candidate-number - '((t (:background "Yellow" :foreground "black"))) - "Face for candidate number in mode-line." :group 'anything) - -(defvar anything-selection-face 'highlight - "*Face for currently selected item.") - -(defvar anything-buffer "*anything*" - "Buffer showing completions.") - -(defvar anything-action-buffer "*anything action*" - "Buffer showing actions.") - -(defvar anything-selection-overlay nil - "Overlay used to highlight the currently selected item.") - -(defvar anything-digit-overlays nil - "Overlays for digit shortcuts. See `anything-enable-shortcuts'.") - -(defvar anything-candidate-cache nil - "Holds the available candidate withing a single anything invocation.") - -(defvar anything-pattern - "The input pattern used to update the anything buffer.") - -(defvar anything-input - "The input typed in the candidates panel.") - -(defvar anything-async-processes nil - "List of information about asynchronous processes managed by anything.") - -(defvar anything-digit-shortcut-count 0 - "Number of digit shortcuts shown in the anything buffer.") - -(defvar anything-before-initialize-hook nil - "Run before anything initialization. -This hook is run before init functions in `anything-sources'.") - -(defvar anything-after-initialize-hook nil - "Run after anything initialization. -Global variables are initialized and the anything buffer is created. -But the anything buffer has no contents.") - -(defvar anything-update-hook nil - "Run after the anything buffer was updated according the new input pattern. -This hook is run at the beginning of buffer. -The first candidate is selected after running this hook. -See also `anything-after-update-hook'.") - -(defvar anything-after-update-hook nil - "Run after the anything buffer was updated according the new input pattern. -This is very similar to `anything-update-hook' but selection is not moved. -It is useful to select a particular object instead of the first one.") - -(defvar anything-cleanup-hook nil - "Run after anything minibuffer is closed. -IOW this hook is executed BEFORE performing action.") - -(defvar anything-select-action-hook nil - "Run when opening the action buffer.") - -(defvar anything-before-action-hook nil - "Run before executing action. -Contrarily to `anything-cleanup-hook', -this hook run before anything minibuffer is closed -and before performing action.") - -(defvar anything-after-action-hook nil - "Run after executing action.") - -(defvar anything-after-persistent-action-hook nil - "Run after executing persistent action.") - -(defvar anything-move-selection-before-hook nil - "Run before moving selection in `anything-buffer'.") - -(defvar anything-move-selection-after-hook nil - "Run after moving selection in `anything-buffer'.") - -(defvar anything-restored-variables - '(anything-candidate-number-limit - anything-source-filter - anything-source-in-each-line-flag - anything-map - anything-sources) - "Variables which are restored after `anything' invocation.") - -(defvar anything-saved-selection nil - "Value of the currently selected object when the action list is shown.") - -(defvar anything-current-prefix-arg nil - "Record `current-prefix-arg' when exiting minibuffer.") - -(defvar anything-candidate-separator - "--------------------" - "Candidates separator of `multiline' source.") - -(defvar anything-current-buffer nil - "Current buffer when `anything' is invoked.") - -(defvar anything-buffer-file-name nil - "Variable `buffer-file-name' when `anything' is invoked.") - -(defvar anything-saved-action nil - "Saved value of the currently selected action by key.") - -(defvar anything-last-sources nil - "OBSOLETE!! Sources of previously invoked `anything'.") - -(defvar anything-saved-current-source nil - "Value of the current source when the action list is shown.") - -(defvar anything-compiled-sources nil - "Compiled version of `anything-sources'.") - -(defvar anything-in-persistent-action nil - "Flag whether in persistent-action or not.") - -(defvar anything-quick-update nil - "If non-nil, suppress displaying sources which are out of screen at first. -They are treated as delayed sources at this input. -This flag makes `anything' a bit faster with many sources.") - -(defvar anything-last-sources-local nil - "Buffer local value of `anything-sources'.") - -(defvar anything-last-buffer nil - "`anything-buffer' of previously `anything' session.") - -(defvar anything-save-configuration-functions - '(set-window-configuration . current-window-configuration) - "The functions used to restore/save window or frame configurations. -It is a pair where the car is the function to restore window or frame config, -and the cdr is the function to save the window or frame config. - -If you want to save and restore frame configuration, set this variable to - '\(set-frame-configuration . current-frame-configuration\) - -Older version saves/restores frame configuration, but the default is changed now -because flickering can occur in some environment. ") - -(defvar anything-persistent-action-use-special-display nil - "If non-nil, use `special-display-function' in persistent action.") - -(defvar anything-execute-action-at-once-if-one nil - "Execute default action and exit when only one candidate is remaining. -It is useful for `anything' applications.") - -(defvar anything-quit-if-no-candidate nil - "Quit when there is no candidates when non--nil. -This variable accepts a function, which is executed if no candidate. - -It is useful for `anything' applications.") - -(defvar anything-scroll-amount nil - "Scroll amount when scrolling other window in an anything session. -It is used by `anything-scroll-other-window' -and `anything-scroll-other-window-down'. - -If you prefer scrolling line by line, set this value to 1.") - -(defvar anything-display-function 'anything-default-display-buffer - "Function to display *anything* buffer. -It is `anything-default-display-buffer' by default, -which affects `anything-samewindow'.") - -(defvar anything-delayed-init-executed nil) - -(defvar anything-mode-line-string "\\\\[anything-help]:help \ -\\[anything-select-action]:Acts \ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct \ -\\[anything-send-bug-report-from-anything]:BugReport" - "Help string displayed in mode-line in `anything'. -It can be a string or a list of two args, in this case, -first arg is a string that will be used as name for candidates number, -second arg any string to display in mode line. -If nil, use default `mode-line-format'.") - -(defvar anything-help-message - "\\The keys that are defined for `anything' are: - \\{anything-map}" - "Detailed help message string for `anything'. -It also accepts function or variable symbol.") - -(defvar anything-source-in-each-line-flag nil - "Non-nil means add anything-source text-property in each candidate. -experimental feature.") - -(defvaralias 'anything-debug-variables 'anything-debug-forms) - -(defvar anything-debug-forms nil - "Forms to show in `anything-debug-output'. -Otherwise all variables started with `anything-' are shown. -It is useful for debug.") - -(defvar anything-debug nil - "If non-nil, write log message into *Anything Log* buffer. -If `debug-on-error' is non-nil, write log message regardless of this variable. -It is disabled by default because *Anything Log* grows quickly.") - -(defcustom anything-local-map-override-anything-map t - "Override `anything-map' keys with the corresponding ones in source local map. -When non--nil keys in source local map will override same keys in `anything-map' -otherwise same keys in `anything-map' will take precedence." - :group 'anything - :type 'boolean) - - -;; (@* "Internal Variables") -(defvar anything-test-candidate-list nil) -(defvar anything-test-mode nil) -(defvar anything-source-name nil) -(defvar anything-candidate-buffer-alist nil) -(defvar anything-check-minibuffer-input-timer nil) -(defvar anything-match-hash (make-hash-table :test 'equal)) -(defvar anything-cib-hash (make-hash-table :test 'equal)) -(defvar anything-tick-hash (make-hash-table :test 'equal)) -(defvar anything-issued-errors nil) -(defvar anything-shortcut-keys nil) -(defvar anything-once-called-functions nil) -(defvar anything-follow-mode nil) -(defvar anything-let-variables nil) -(defvar anything-split-window-state nil) -(defvar anything-selection-point nil) -(defvar anything-alive-p nil) - - -;; (@* "Utility: logging") -(defun anything-log (format-string &rest args) - "Log message if `debug-on-error' or `anything-debug' is non-nil. -Messages are written to the *Anything Log* buffer. - -Argument FORMAT-STRING is a string to use with `format'. -Use optional arguments ARGS like in `format'." - (when (or debug-on-error anything-debug) - (with-current-buffer (get-buffer-create "*Anything Log*") - (buffer-disable-undo) - (set (make-local-variable 'inhibit-read-only) t) - (goto-char (point-max)) - (insert (let ((tm (current-time))) - (format "%s.%06d (%s) %s\n" - (format-time-string "%H:%M:%S" tm) - (nth 2 tm) - (anything-log-get-current-function) - (apply #'format (cons format-string args)))))))) - -(defmacro anything-log-eval (&rest exprs) - "Write each EXPRS evaluation result to the *Anything Log* buffer." - `(anything-log-eval-internal ',exprs)) - -(defun anything-log-run-hook (hook) - "Run HOOK like `run-hooks' but write these actions to anything log buffer." - (anything-log "executing %s" hook) - (when (boundp hook) - (anything-log-eval (symbol-value hook)) - (anything-log-eval (default-value hook))) - (run-hooks hook) - (anything-log "executed %s" hook)) - -(defun anything-log-eval-internal (exprs) - "Eval EXPRS and write results to anything log buffer." - (dolist (expr exprs) - (condition-case err - (anything-log "%S = %S" expr (eval expr)) - (error (anything-log "%S = ERROR!" expr))))) - -(defun anything-log-get-current-function () - "Get function name calling `anything-log'. -The original idea is from `tramp-debug-message'." - (loop with exclude-func-re = "^anything-\\(?:interpret\\|log\\|.*funcall\\)" - for btn from 1 to 40 ;avoid inf-loop - for btf = (second (backtrace-frame btn)) - for fn = (if (symbolp btf) (symbol-name btf) "") - if (and (string-match "^anything" fn) - (not (string-match exclude-func-re fn))) - return fn)) - -(defun anything-log-error (&rest args) - "Accumulate error messages into `anything-issued-errors'. -ARGS are args given to `format'." - (apply 'anything-log (concat "ERROR: " (car args)) (cdr args)) - (let ((msg (apply 'format args))) - (unless (member msg anything-issued-errors) - (add-to-list 'anything-issued-errors msg)))) - -(defvar anything-last-log-file nil) -(defun anything-log-save-maybe () - "May be save log buffer to `anything-last-log-file'." - (when (stringp anything-debug) - (let ((logdir (expand-file-name (format-time-string "%Y%m%d") - anything-debug))) - (make-directory logdir t) - (with-current-buffer (get-buffer-create "*Anything Log*") - (write-region (point-min) (point-max) - (setq anything-last-log-file - (expand-file-name (format-time-string "%Y%m%d-%H%M%S") - logdir)) - nil 'silent) - (erase-buffer))))) - -(defun anything-open-last-log () - "Open anything log file of last anything session." - (interactive) - (if anything-last-log-file - (view-file anything-last-log-file) - (switch-to-buffer "*Anything Log*"))) - -(defun anything-print-error-messages () - "Print error messages in `anything-issued-errors'." - (message "%s" (mapconcat 'identity (reverse anything-issued-errors) "\n"))) - -;; (anything-log "test") -;; (switch-to-buffer-other-window "*Anything Log*") - - -;; (@* "Programming Tools") -(defmacro anything-aif (test-form then-form &rest else-forms) - "Like `if' but set the result of TEST-FORM in a temprary variable called `it'. -THEN-FORM and ELSE-FORMS are then excuted just like in `if'." - (declare (indent 2) (debug t)) - `(let ((it ,test-form)) - (if it ,then-form ,@else-forms))) - -(defun anything-mklist (obj) - "If OBJ is a list \(but not lambda\), return itself. -Otherwise make a list with one element." - (if (and (listp obj) (not (functionp obj))) - obj - (list obj))) - - -;; (@* "Anything API") - -(defun anything-buffer-get () - "Return `anything-action-buffer' if shown otherwise `anything-buffer'." - (if (anything-action-window) - anything-action-buffer - anything-buffer)) - -(defun anything-window () - "Window of `anything-buffer'." - (get-buffer-window (anything-buffer-get) 'visible)) - -(defun anything-action-window () - "Window of `anything-action-buffer'." - (get-buffer-window anything-action-buffer 'visible)) - -(defmacro with-anything-window (&rest body) - "Be sure BODY is excuted in the anything window." - (declare (indent 0) (debug t)) - `(if anything-test-mode - (with-current-buffer (anything-buffer-get) - ,@body) - (with-selected-window (anything-window) - ,@body))) - -(defmacro with-anything-current-buffer (&rest body) - "Eval BODY inside `anything-current-buffer'." - (declare (indent 0) (debug t)) - `(with-current-buffer anything-current-buffer - ,@body)) - -(defmacro with-anything-restore-variables(&rest body) - "Restore `anything-restored-variables' after executing BODY. -`post-command-hook' is handled specially." - (declare (indent 0) (debug t)) - `(let ((--orig-vars (mapcar (lambda (v) - (cons v (symbol-value v))) - anything-restored-variables)) - (--post-command-hook-pair (cons post-command-hook - (default-value 'post-command-hook)))) - (setq post-command-hook '(t)) - (setq-default post-command-hook nil) - (unwind-protect (progn ,@body) - (loop for (var . value) in --orig-vars - do (set var value)) - (setq post-command-hook (car --post-command-hook-pair)) - (setq-default post-command-hook (cdr --post-command-hook-pair)) - (anything-log "restore variables")))) - -(defun* anything-attr (attribute-name &optional - (src (anything-get-current-source))) - "Get the value of ATTRIBUTE-NAME of SRC. -if SRC is omitted, use current source. -It is useful to write your sources." - (anything-aif (assq attribute-name src) - (cdr it))) - -(defun* anything-attr* (attribute-name - &optional (src (anything-get-current-source))) - "Pass the value of ATTRIBUTE-NAME of SRC to `anything-interpret-value'. -if SRC is omitted, use current source. -It is useful to write your sources." - (anything-interpret-value (anything-attr attribute-name src))) - -(defun* anything-attr-defined (attribute-name - &optional (src (anything-get-current-source))) - "Return non-nil if ATTRIBUTE-NAME of SRC is defined. -if SRC is omitted, use current source. -It is useful to write your sources." - (and (assq attribute-name src) t)) - -(defun* anything-attrset (attribute-name value - &optional - (src (anything-get-current-source))) - "Set the value of ATTRIBUTE-NAME of SRC to VALUE. -if SRC is omitted, use current source. -It is useful to write your sources." - (anything-aif (assq attribute-name src) - (setcdr it value) - (setcdr src (cons (cons attribute-name value) (cdr src)))) - value) - -(defun anything-set-source-filter (sources) - "Set the value of `anything-source-filter' to SOURCES and update. - -This function sets a filter for anything sources and it may be -called while anything is running. It can be used to toggle -displaying of sources dinamically. For example, additional keys -can be bound into `anything-map' to display only the file-related -results if there are too many matches from other sources and -you're after files only: - -Shift+F shows only file results from some sources: - -\(define-key anything-map \"F\" 'anything-my-show-files-only) - -\(defun anything-my-show-files-only () - (interactive) - (anything-set-source-filter '(\"File Name History\" - \"Files from Current Directory\"))) - -Shift+A shows all results: - -\(define-key anything-map \"A\" 'anything-my-show-all) - -\(defun anything-my-show-all () - (interactive) - (anything-set-source-filter nil)) - -Note that you have to prefix the functions with anything- prefix, -otherwise they won't be bound when Anything is used under -Iswitchb. The -my- part is added to avoid collisions with -existing Anything function names." - (unless (and (listp sources) - (loop for name in sources always (stringp name))) - (error "Invalid data in `anything-set-source-filter': %S" sources)) - (setq anything-source-filter sources) - (anything-log-eval anything-source-filter) - (anything-update)) - -(defun anything-set-sources (sources &optional no-init no-update) - "Set SOURCES during `anything' invocation. -If NO-INIT is non-nil, skip executing init functions of SOURCES. -If NO-UPDATE is non-nil, skip executing `anything-update'." - (with-current-buffer anything-buffer - (setq anything-compiled-sources nil - anything-sources sources - anything-last-sources-local sources) - (anything-log-eval anything-compiled-sources anything-sources)) - (unless no-init (anything-funcall-foreach 'init)) - (unless no-update (anything-update))) - -(defvar anything-compile-source-functions - '(anything-compile-source--type - anything-compile-source--dummy - anything-compile-source--disable-shortcuts - anything-compile-source--candidates-in-buffer) - "Functions to compile elements of `anything-sources' (plug-in).") - -(defun anything-get-sources () - "Return compiled `anything-sources', which is memoized. - -Attributes: - -- type - `anything-type-attributes' are merged in. -- candidates-buffer - candidates, volatile and match attribute are created." - (cond - ;; action - ((anything-action-window) - anything-sources) - ;; memoized - (anything-compiled-sources) - ;; first time - (t - (prog1 - (setq anything-compiled-sources - (anything-compile-sources - anything-sources anything-compile-source-functions)) - (anything-log-eval anything-compiled-sources))))) - -(defun* anything-get-selection (&optional (buffer nil buffer-s) (force-display-part)) - "Return the currently selected item or nil. -if BUFFER is nil or unspecified, use anything-buffer as default value. -If FORCE-DISPLAY-PART is non-nil, return the display string." - (setq buffer (if (and buffer buffer-s) buffer anything-buffer)) - (unless (anything-empty-buffer-p buffer) - (with-current-buffer buffer - (let ((selection - (or (and (not force-display-part) - (get-text-property (overlay-start - anything-selection-overlay) - 'anything-realvalue)) - (let ((disp (buffer-substring-no-properties - (overlay-start anything-selection-overlay) - (1- (overlay-end anything-selection-overlay)))) - (source (anything-get-current-source))) - (anything-aif (and (not force-display-part) - (assoc-default 'display-to-real source)) - (anything-funcall-with-source source it disp) - disp))))) - (unless (equal selection "") - (anything-log-eval selection) - selection))))) - -(defun anything-get-action () - "Return the associated action for the selected candidate. -It is a function symbol \(sole action\) or list -of \(action-display . function\)." - (unless (anything-empty-buffer-p (anything-buffer-get)) - (anything-aif (anything-attr 'action-transformer) - (anything-composed-funcall-with-source - (anything-get-current-source) it - (anything-attr 'action) (anything-get-selection)) - (anything-attr 'action)))) - -(defun anything-get-current-source () - "Return the source for the current selection. -Use it in init, candidates, action, candidate-transformer, -filtered-candidate-transformer functions." - (declare (special source)) - ;; The name `anything-get-current-source' should be used in init function etc. - (if (and (boundp 'anything-source-name) (stringp anything-source-name)) - source - (with-current-buffer (anything-buffer-get) - (or - ;; This happen only when `anything-source-in-each-line-flag' - ;; is non--nil and there is candidates in buffer. - (get-text-property (point) 'anything-source) - ;; Return nil when no--candidates. - (block exit - ;; This goto-char shouldn't be necessary, but point is moved to - ;; point-min somewhere else which shouldn't happen. - (goto-char (overlay-start anything-selection-overlay)) - (let* ((header-pos (or (anything-get-previous-header-pos) - (anything-get-next-header-pos))) - (source-name - (save-excursion - (unless header-pos - (return-from exit nil)) - (goto-char header-pos) - (anything-current-line-contents)))) - (loop for source in (anything-get-sources) thereis - (and (equal (assoc-default 'name source) source-name) - source)))))))) - -(defun anything-buffer-is-modified (buffer) - "Return non-nil when BUFFER is modified since `anything' was invoked." - (let* ((b (get-buffer buffer)) - (key (concat (buffer-name b) "/" (anything-attr 'name))) - (source-tick (or (gethash key anything-tick-hash) 0)) - (buffer-tick (buffer-chars-modified-tick b)) - (modifiedp (/= source-tick buffer-tick))) - (puthash key buffer-tick anything-tick-hash) - (anything-log-eval buffer modifiedp) - modifiedp)) - -(defun anything-current-buffer-is-modified () - "Check if `anything-current-buffer' is modified since `anything' was invoked." - (anything-buffer-is-modified anything-current-buffer)) - -(defvar anything-quit nil) -(defun anything-run-after-quit (function &rest args) - "Perform an action after quitting `anything'. -The action is to call FUNCTION with arguments ARGS." - (setq anything-quit t) - (anything-kill-async-processes) - (anything-log-eval function args) - (apply 'run-with-idle-timer 0 nil function args) - (anything-exit-minibuffer)) - - -(defun define-anything-type-attribute (type definition &optional doc) - "Register type attribute of TYPE as DEFINITION with DOC. -DOC is displayed in `anything-type-attributes' docstring. - -Use this function is better than setting `anything-type-attributes' directly." - (loop for i in definition do - ;; without `ignore-errors', error at emacs22 - (ignore-errors (setf i (delete nil i)))) - (anything-add-type-attribute type definition) - (and doc (anything-document-type-attribute type doc)) - nil) - -(defvaralias 'anything-attributes 'anything-additional-attributes) -(defvar anything-additional-attributes nil - "List of all `anything' attributes.") - -(defun anything-document-attribute (attribute short-doc &optional long-doc) - "Register ATTRIBUTE documentation introduced by plug-in. -SHORT-DOC is displayed beside attribute name. -LONG-DOC is displayed below attribute name and short documentation." - (if long-doc - (setq short-doc (concat "(" short-doc ")")) - (setq long-doc short-doc - short-doc "")) - (add-to-list 'anything-additional-attributes attribute t) - (put attribute 'anything-attrdoc - (concat "- " (symbol-name attribute) - " " short-doc "\n\n" long-doc "\n"))) - -(put 'anything-document-attribute 'lisp-indent-function 2) - -(defun anything-interpret-value (value &optional source) - "Interpret VALUE as variable, function or literal. -If VALUE is a function, call it with no arguments and return the value. -If SOURCE is `anything' source, `anything-source-name' is source name. - -If VALUE is a variable, return the value. - -If VALUE is a symbol, but it is not a function or a variable, cause an error. - -Otherwise, return VALUE itself." - (cond ((and source (functionp value)) - (anything-funcall-with-source source value)) - ((functionp value) - (funcall value)) - ((and (symbolp value) (boundp value)) - (symbol-value value)) - ((symbolp value) - (error "anything-interpret-value: Symbol must be a function or a variable")) - (t - value))) - -(defun anything-once (function &rest args) - "Ensure FUNCTION with ARGS to be called once in `anything' session." - (let ((spec (cons function args))) - (unless (member spec anything-once-called-functions) - (apply function args) - (push spec anything-once-called-functions)))) - - -;; (@* "Core: API helper") -(defun* anything-empty-buffer-p (&optional (buffer anything-buffer)) - "Check if BUFFER have candidates. -Default value for BUFFER is `anything-buffer'." - (zerop (buffer-size (and buffer (get-buffer buffer))))) - -(defun anything-let-eval-varlist (varlist) - "Return the list of pairs VARLIST with each cdr of pair evaluated. -If VARLIST contain single elements, those are returned -as a list of one element." - (mapcar (lambda (pair) - (if (listp pair) - (cons (car pair) (eval (cadr pair))) - (cons pair nil))) - varlist)) - -;; [NOT USED] -;; (defun anything-let*-eval-varlist (varlist) -;; (let ((vars (mapcar (lambda (pair) -;; (or (car-safe pair) pair)) -;; varlist))) -;; (eval `(let ,vars -;; ,@(mapcar (lambda (pair) -;; (if (listp pair) -;; `(setq ,(car pair) ,(cadr pair)) -;; `(setq ,pair nil))) -;; varlist) -;; (mapcar (lambda (v) -;; (cons v (symbol-value v))) -;; ',vars))))) - -(defun anything-let-internal (binding bodyfunc) - "Set BINDING to anything buffer-local variables and Evaluate BODYFUNC. -BINDING is a list of \(VARNAME . VALUE\) pair." - (setq anything-let-variables binding) - (unwind-protect - (funcall bodyfunc) - (setq anything-let-variables nil))) - - -;; (@* "Core: tools") -(defun anything-current-line-contents () - "Current line string without properties." - (buffer-substring-no-properties (point-at-bol) (point-at-eol))) - -(defun anything-funcall-with-source (source func &rest args) - "Call from SOURCE FUNC list or single function FUNC with ARGS. -FUNC can be a symbol or a list of functions. -Return the result of last function call." - (let ((anything-source-name (assoc-default 'name source)) - result) - (anything-log-eval anything-source-name func args) - (dolist (func (if (functionp func) (list func) func) result) - (setq result (apply func args))))) - -(defun anything-funcall-foreach (sym) - "Call the function SYM for each source if any." - (dolist (source (anything-get-sources)) - (anything-aif (assoc-default sym source) - (anything-funcall-with-source source it)))) - -(defun anything-normalize-sources (sources) - "If SOURCES is only one source, make a list of one element." - (cond ((or (and sources - (symbolp sources)) - (and (listp sources) (assq 'name sources))) - (list sources)) - (sources) - (t anything-sources))) - -(defun anything-approximate-candidate-number (&optional in-current-source) - "Return approximate number of candidates in `anything-buffer'. -If IN-CURRENT-SOURCE is provided return number of candidates -in the source where point is. -It is used to check if candidate number is 0, 1, or 2+." - (with-current-buffer anything-buffer - (save-excursion - (if in-current-source - (goto-char (anything-get-previous-header-pos)) - (goto-char (point-min))) - (forward-line 1) - (let ((count-multi 1)) - (if (anything-pos-multiline-p) - (save-excursion - (loop while (and (not (if in-current-source - (save-excursion - (forward-line 2) - (or (anything-pos-header-line-p) (eobp))) - (eobp))) - (search-forward anything-candidate-separator nil t)) - do (incf count-multi) - finally return count-multi)) - (save-excursion - (loop with ln = 0 - while (not (if in-current-source - (or (anything-pos-header-line-p) (eobp)) - (eobp))) - unless (anything-pos-header-line-p) - do (incf ln) - do (forward-line 1) finally return ln))))))) - -(defmacro with-anything-quittable (&rest body) - "If an error occur in execution of BODY, quit anything safely." - (declare (indent 0) (debug t)) - `(let (inhibit-quit) - (condition-case v - (progn ,@body) - (quit (setq anything-quit t) - (exit-minibuffer) - (keyboard-quit))))) - -(defun anything-compose (arg-lst func-lst) - "Apply arguments specified in ARG-LST with each function of FUNC-LST. -The result of each function will be the new `car' of ARG-LST. - -This function allows easy sequencing of transformer functions." - (dolist (func func-lst) - (setcar arg-lst (apply func arg-lst))) - (car arg-lst)) - -(defun anything-composed-funcall-with-source (source funcs &rest args) - "With SOURCE apply `anything-funcall-with-source' with each FUNCS and ARGS. -This is used in transformers to modify candidates list." - (if (functionp funcs) - (apply 'anything-funcall-with-source source funcs args) - (apply 'anything-funcall-with-source source - (lambda (&rest args) - (anything-compose args funcs)) - args))) - -(defun anything-new-timer (variable timer) - "Give VARIABLE value to TIMER and cancel old timer." - (anything-aif (symbol-value variable) - (cancel-timer it)) - (set variable timer)) - - -;; (@* "Core: entry point") -(defconst anything-argument-keys - '(:sources :input :prompt :resume :preselect :buffer :keymap :default :history)) - -;;;###autoload -(defun anything (&rest plist) - "Main function to execute anything sources. - -Keywords supported: -:sources :input :prompt :resume :preselect :buffer :keymap :default :history -Extra keywords are supported and can be added, see below. - -When call interactively with no arguments deprecated `anything-sources' -will be used if non--nil. - -PLIST is a list like \(:key1 val1 :key2 val2 ...\) or -\(&optional sources input prompt resume preselect buffer keymap default history\). - -Basic keywords are the following: - -\:sources - -Temporary value of `anything-sources'. It also accepts a -symbol, interpreted as a variable of an anything source. It -also accepts an alist representing an anything source, which is -detected by \(assq 'name ANY-SOURCES\) - -\:input - -Temporary value of `anything-pattern', ie. initial input of minibuffer. - -\:prompt - -Prompt other than \"pattern: \". - -\:resume - -If t, Resurrect previously instance of `anything'. Skip the initialization. -If 'noresume, this instance of `anything' cannot be resumed. - -\:preselect - -Initially selected candidate. Specified by exact candidate or a regexp. - -\:buffer - -`anything-buffer' instead of *anything*. - -\:keymap - -`anything-map' for current `anything' session. - -\:default - -A default argument that will be inserted in minibuffer \ -with \\\\[next-history-element]. -When nil of not present `thing-at-point' will be used instead. - -\:history - -By default all minibuffer input is pushed to `minibuffer-history', -if an argument HISTORY is provided, input will be pushed to HISTORY. -History element should be a symbol. - -Of course, conventional arguments are supported, the two are same. - -\(anything :sources sources :input input :prompt prompt :resume resume - :preselect preselect :buffer buffer :keymap keymap :default default - :history history\) -\(anything sources input prompt resume preselect buffer keymap default history\) - -Other keywords are interpreted as local variables of this anything session. -The `anything-' prefix can be omitted. For example, - -\(anything :sources 'anything-c-source-buffers - :buffer \"*buffers*\" :candidate-number-limit 10\) - -means starting anything session with `anything-c-source-buffers' -source in *buffers* buffer and set variable `anything-candidate-number-limit' -to 10 as session local variable." - (interactive) - (if (keywordp (car plist)) - (anything-let-internal - (anything-parse-keys plist) - (lambda () - (apply 'anything - (mapcar (lambda (key) (plist-get plist key)) - anything-argument-keys)))) - (apply 'anything-internal plist))) - -(defun anything-parse-keys (keys) - "Parse the KEYS arguments of `anything'. -Return only the keys that are not in `anything-argument-keys'. -It is used to set local variables via `anything-let-internal'. -This allow to add arguments that are not part of `anything-argument-keys', -but are valid anything attributes. -i.e :candidate-number-limit will be bound to `anything-candidate-number-limit' -in source." - ;; (anything-parse-keys '(:sources ((name . "test") - ;; (candidates . (a b c))) - ;; :buffer "toto" - ;; :candidate-number-limit 4)) - ;; ==> ((anything-candidate-number-limit . 4)) - (loop for (key value) on keys by #'cddr - for symname = (substring (symbol-name key) 1) - for sym = (intern (if (string-match "^anything-" symname) - symname - (concat "anything-" symname))) - unless (memq key anything-argument-keys) - collect (cons sym value))) - -;;; (@* "Core: entry point helper") -(defun anything-internal (&optional - any-sources any-input - any-prompt any-resume - any-preselect any-buffer - any-keymap any-default any-history) - "The internal anything function called by `anything'. -For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and -ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `anything'." - (anything-log (concat "[Start session] " (make-string 41 ?+))) - (anything-log-eval any-prompt any-preselect - any-buffer any-keymap any-default) - (let ((old-overridding-local-map overriding-local-map)) - (unwind-protect - (condition-case v - (let ( ;; It is needed because `anything-source-name' is non-nil - ;; when `anything' is invoked by action. Awful global scope. - anything-source-name - anything-in-persistent-action - anything-quit - (case-fold-search t) - (anything-buffer (or any-buffer anything-buffer)) - ;; cua-mode ; avoid error when region is selected - ) - (with-anything-restore-variables - (anything-initialize any-resume any-input any-sources) - (anything-display-buffer anything-buffer) - (anything-log "show prompt") - (unwind-protect - (anything-read-pattern-maybe - any-prompt any-input any-preselect - any-resume any-keymap any-default - (when (and any-history (symbolp any-history)) any-history)) - (anything-cleanup))) - (prog1 (unless anything-quit - (anything-execute-selection-action-1)) - (anything-log (concat "[End session] " (make-string 41 ?-))))) - (quit - (anything-restore-position-on-quit) - (anything-log (concat "[End session (quit)] " (make-string 34 ?-))) - nil)) - (setq overriding-local-map old-overridding-local-map) - (anything-log-save-maybe)))) - - -;;; Anything resume -;; -;; -(defun* anything-resume (&optional - (any-buffer anything-last-buffer) - buffer-pattern (any-resume t)) - "Resurrect previously invoked `anything'. -Called with a prefix arg, allow choosing among all existing -anything buffers. i.e choose among various anything sessions." - (interactive) - (when (or current-prefix-arg buffer-pattern) - (setq any-buffer (anything-resume-select-buffer buffer-pattern))) - (setq anything-compiled-sources nil) - (anything - :sources (or (buffer-local-value 'anything-last-sources-local (get-buffer any-buffer)) - anything-last-sources anything-sources) - :input (buffer-local-value 'anything-input-local (get-buffer any-buffer)) - :resume any-resume - :buffer any-buffer)) - -;;; rubikitch: experimental -;;; I use this and check it whether I am convenient. -;;; I may introduce an option to control the behavior. -(defun* anything-resume-window-only (&optional - (any-buffer anything-last-buffer) - buffer-pattern) - (interactive) - (anything-resume any-buffer buffer-pattern 'window-only)) - -(defun anything-resume-p (any-resume) - "Whether current anything session is resumed or not. -Just check if ANY-RESUME value is t or window-only." - (memq any-resume '(t window-only))) - -(defun anything-resume-select-buffer (input) - "Resume precedent anything session with initial input INPUT." - (or (anything :sources '(((name . "Resume anything buffer") - (candidates . anything-buffers) - (action . identity))) - :input input - :resume 'noresume - :buffer "*anything resume*") - (keyboard-quit))) - - -;;;###autoload -(defun anything-at-point (&optional - any-sources any-input - any-prompt any-resume - any-preselect any-buffer) - "Call anything with symbol at point as initial input. -ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT and ANY-BUFFER -are same args as in `anything'." - (interactive) - (anything :sources any-sources - :input (if current-prefix-arg - (concat "\\b" (thing-at-point 'symbol) "\\b" - (if (featurep 'anything-match-plugin) " " "")) - any-input) - :prompt any-prompt - :resume any-resume - :preselect any-preselect - :buffer any-buffer)) - -;;;###autoload -(defun anything-other-buffer (any-sources any-buffer) - "Simplified interface of `anything' with other `anything-buffer'. -Call `anything' with only ANY-SOURCES and ANY-BUFFER as args." - (anything :sources any-sources :buffer any-buffer)) - -(defun anything-nest (&rest same-as-anything) - "Allow calling `anything' whithin a running anything session." - (with-anything-window - (let (anything-current-position - anything-current-buffer - (orig-anything-current-buffer anything-current-buffer) - (orig-anything-buffer anything-buffer) - (orig-anything-last-frame-or-window-configuration - anything-last-frame-or-window-configuration) - anything-pattern - (anything-buffer (or (getf same-as-anything :buffer) - (nth 5 same-as-anything) - "*Anything*")) - anything-sources - anything-compiled-sources - (anything-samewindow t) - (enable-recursive-minibuffers t)) - (unwind-protect - (apply #'anything same-as-anything) - (with-current-buffer orig-anything-buffer - (anything-initialize-overlays orig-anything-buffer) - (setq anything-buffer (current-buffer)) - (anything-mark-current-line) - (setq anything-last-frame-or-window-configuration - orig-anything-last-frame-or-window-configuration) - (setq cursor-type t) - (setq anything-current-buffer orig-anything-current-buffer)))))) - - -;;; Initialize -;; -;; -(defvar anything-buffers nil - "All of `anything-buffer' in most recently used order.") -(defun anything-initialize (any-resume any-input any-sources) - "Start initialization of `anything' session. -For ANY-RESUME ANY-INPUT and ANY-SOURCES See `anything'." - (anything-log "start initialization: any-resume=%S any-input=%S" any-resume any-input) - (anything-frame-or-window-configuration 'save) - (setq anything-sources (anything-normalize-sources any-sources)) - (anything-log "sources = %S" anything-sources) - (anything-hooks 'setup) - (anything-current-position 'save) - (if (anything-resume-p any-resume) - (anything-initialize-overlays (anything-buffer-get)) - (anything-initial-setup)) - (unless (eq any-resume 'noresume) - (anything-recent-push anything-buffer 'anything-buffers) - (setq anything-last-buffer anything-buffer)) - (when any-input (setq anything-input any-input anything-pattern any-input)) - (and (anything-resume-p any-resume) (anything-funcall-foreach 'resume)) - (anything-log "end initialization")) - -(defun anything-execute-selection-action-1 () - "Execute current action." - (anything-log-run-hook 'anything-before-action-hook) - (unwind-protect - (anything-execute-selection-action) - (anything-aif (get-buffer anything-action-buffer) - (kill-buffer it)) - (anything-log-run-hook 'anything-after-action-hook))) - -(defun anything-restore-position-on-quit () - "Restore position in `anything-current-buffer' when quitting." - (anything-current-position 'restore)) - -(defun anything-recent-push (elt list-var) - "Add ELT to the value of LIST-VAR as most recently used value." - (let ((m (member elt (symbol-value list-var)))) - (and m (set list-var (delq (car m) (symbol-value list-var)))) - (push elt (symbol-value list-var)))) - - -;;; (@* "Core: Accessors") -;;; rubikitch: I love to create functions to control variables. -(defvar anything-current-position nil - "Cons of \(point . window-start\) when `anything' is invoked. -It is needed to restore position in `anything-current-buffer' -when `anything' is keyboard-quitted.") -(defun anything-current-position (save-or-restore) - "Restore or save current position in `anything-current-buffer'. -Argument SAVE-OR-RESTORE is one of save or restore." - (case save-or-restore - (save - (anything-log "Save position at %S" (cons (point) (window-start))) - (setq anything-current-position (cons (point) (window-start)))) - (restore - (anything-log "Restore position at %S in buffer %s" - anything-current-position - (buffer-name (current-buffer))) - (goto-char (car anything-current-position)) - ;; Fix this position with the NOFORCE arg of `set-window-start' - ;; otherwise, if there is some other buffer than `anything-current-buffer' - ;; one, position will be lost. - (set-window-start (selected-window) (cdr anything-current-position) t)))) - - -;; Internal. -(defvar anything-last-frame-or-window-configuration nil - "Used to store window or frame configuration when anything start.") -(defun anything-frame-or-window-configuration (save-or-restore) - "Save or restore last frame or window configuration. -Possible value of SAVE-OR-RESTORE are 'save and 'restore. -window or frame configuration is saved/restored according to values of -`anything-save-configuration-functions'." - (anything-log-eval anything-save-configuration-functions) - (case save-or-restore - (save (setq anything-last-frame-or-window-configuration - (funcall (cdr anything-save-configuration-functions)))) - (restore (funcall (car anything-save-configuration-functions) - anything-last-frame-or-window-configuration) - ;; Restore frame focus. - (let ((frame (and (listp anything-last-frame-or-window-configuration) - (caadr anything-last-frame-or-window-configuration)))) - ;; If `anything-save-configuration-functions' are window functions - ;; frame should be nil, use current frame. - (unless (framep frame) - (setq frame (selected-frame))) - (select-frame-set-input-focus frame))))) - - -;; (@* "Core: Display *anything* buffer") -(defun anything-display-buffer (buf) - "Display *anything* buffer BUF." - (let (pop-up-frames) - (funcall (with-current-buffer buf anything-display-function) buf))) - -(defun anything-default-display-buffer (buf) - "Default function to display BUF. -Where BUF is generally `anything-buffer'. -It use `switch-to-buffer' or `pop-to-buffer' depending of value of -`anything-samewindow'." - (funcall (if anything-samewindow 'switch-to-buffer 'pop-to-buffer) buf)) - - -;; (@* "Core: initialize") -(defun anything-initial-setup () - "Initialize anything settings and set up the anything buffer." - (anything-log-run-hook 'anything-before-initialize-hook) - (setq anything-current-prefix-arg nil) - (setq anything-once-called-functions nil) - (setq anything-delayed-init-executed nil) - (setq anything-alive-p t) - (setq anything-current-buffer - (if (minibuffer-window-active-p (minibuffer-window)) - ;; If minibuffer is active be sure to use it's buffer - ;; as `anything-current-buffer'. - (window-buffer (active-minibuffer-window)) - (current-buffer))) - (setq anything-buffer-file-name buffer-file-name) - (setq anything-issued-errors nil) - (setq anything-compiled-sources nil) - (setq anything-saved-current-source nil) - (if (or (not split-width-threshold) - (and (integerp split-width-threshold) - (>= split-width-threshold (+ (frame-width) 4)))) - (setq anything-split-window-state 'vertical) - (setq anything-split-window-state 'horizontal)) - ;; Call the init function for sources where appropriate - (anything-funcall-foreach 'init) - (setq anything-pattern "") - (setq anything-input "") - (setq anything-candidate-cache nil) - (setq anything-last-sources anything-sources) - (anything-create-anything-buffer) - (anything-log-run-hook 'anything-after-initialize-hook)) - -(defvar anything-reading-pattern nil - "Whether in `read-string' in anything or not.") - -(defun anything-read-pattern-maybe (any-prompt any-input - any-preselect any-resume any-keymap - any-default any-history) - "Read pattern with prompt ANY-PROMPT and initial input ANY-INPUT. -For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `anything'." - (if (anything-resume-p any-resume) - (anything-mark-current-line t) - (anything-update any-preselect)) - (with-current-buffer (anything-buffer-get) - (let ((src-keymap (assoc-default 'keymap (anything-get-current-source)))) - ;; Startup with the first keymap found either in current source - ;; or anything arg, otherwise use global value of `anything-map'. - ;; This map will be used as a `minibuffer-local-map'. - ;; Maybe it will be overriden when changing source - ;; by `anything-maybe-update-keymap'. - (unless anything-local-map-override-anything-map - (anything-aif (or src-keymap any-keymap) - (ignore-errors - (set-keymap-parent it anything-map)))) - (set (make-local-variable 'anything-map) - (or src-keymap any-keymap anything-map)) - (anything-log-eval (anything-approximate-candidate-number) - anything-execute-action-at-once-if-one - anything-quit-if-no-candidate) - (cond ((and anything-execute-action-at-once-if-one - (= (anything-approximate-candidate-number) 1)) - (ignore)) - ((and anything-quit-if-no-candidate - (= (anything-approximate-candidate-number) 0)) - (setq anything-quit t) - (and (functionp anything-quit-if-no-candidate) - (funcall anything-quit-if-no-candidate))) - (t - (let ((anything-reading-pattern t) - (tap (or any-default - (with-anything-current-buffer - (thing-at-point 'symbol))))) - (read-from-minibuffer (or any-prompt "pattern: ") - any-input anything-map - nil any-history tap))))))) - -(defun anything-maybe-update-keymap () - "Handle differents keymaps in multiples sources. -This function is meant to be run in `anything-move-selection-after-hook'. -It will override `anything-map' with the keymap attribute of current source -if some when multiples sources are present." - (with-anything-window - (let ((kmap (assoc-default 'keymap (anything-get-current-source)))) - (when kmap - (and (not anything-local-map-override-anything-map) - (ignore-errors (set-keymap-parent kmap (default-value 'anything-map)))) - (setq overriding-local-map kmap))))) -(add-hook 'anything-move-selection-after-hook 'anything-maybe-update-keymap) - -(defun anything-create-anything-buffer (&optional test-mode) - "Create newly created `anything-buffer'. -If TEST-MODE is non-nil, clear `anything-candidate-cache'." - (when test-mode - (setq anything-candidate-cache nil)) - (with-current-buffer (get-buffer-create anything-buffer) - (anything-log "kill local variables: %S" (buffer-local-variables)) - (kill-all-local-variables) - (set (make-local-variable 'inhibit-read-only) t) - (buffer-disable-undo) - (erase-buffer) - (set (make-local-variable 'inhibit-read-only) t) - (set (make-local-variable 'anything-last-sources-local) anything-sources) - (set (make-local-variable 'anything-follow-mode) nil) - (set (make-local-variable 'anything-display-function) anything-display-function) - (set (make-local-variable 'anything-selection-point) nil) - (anything-initialize-persistent-action) - (anything-log-eval anything-display-function anything-let-variables) - (loop for (var . val) in anything-let-variables - do (set (make-local-variable var) val)) - (setq cursor-type nil) - (setq mode-name "Anything")) - (anything-initialize-overlays anything-buffer) - (get-buffer anything-buffer)) - -(defun anything-initialize-overlays (buffer) - "Initialize anything overlays in BUFFER." - (anything-log "overlay setup") - (if anything-selection-overlay - ;; make sure the overlay belongs to the anything buffer if - ;; it's newly created - (move-overlay anything-selection-overlay (point-min) (point-min) - (get-buffer buffer)) - - (setq anything-selection-overlay - (make-overlay (point-min) (point-min) (get-buffer buffer))) - (overlay-put anything-selection-overlay 'face anything-selection-face)) - - (cond (anything-enable-shortcuts - (setq anything-shortcut-keys - (assoc-default anything-enable-shortcuts anything-shortcut-keys-alist)) - (unless anything-digit-overlays - (setq anything-digit-overlays - (loop for key across anything-shortcut-keys - for overlay = (make-overlay (point-min) (point-min) - (get-buffer buffer)) - do (overlay-put overlay 'before-string - (format "%s - " (upcase (make-string 1 key)))) - collect overlay)))) - (anything-digit-overlays - (mapc 'delete-overlay anything-digit-overlays) - (setq anything-digit-overlays nil)))) - -(defun anything-hooks (setup-or-cleanup) - "Add or remove hooks according to SETUP-OR-CLEANUP value. -if SETUP-OR-CLEANUP value is setup add hooks, any other value -will remove hooks. -hooks concerned are `post-command-hook' and `minibuffer-setup-hook'." - (let ((hooks '((post-command-hook anything-check-minibuffer-input) - (minibuffer-setup-hook anything-print-error-messages)))) - (if (eq setup-or-cleanup 'setup) - (dolist (args hooks) (apply 'add-hook args)) - (dolist (args (reverse hooks)) (apply 'remove-hook args))))) - - -;; (@* "Core: clean up") -;;; TODO move -(defun anything-cleanup () - "Clean up the mess when anything exit or quit." - (anything-log "start cleanup") - (with-current-buffer anything-buffer - ;; rubikitch: I think it is not needed. - ;; thierry: If you end up for any reasons (error etc...) - ;; with an anything-buffer staying around (visible), - ;; You will have no cursor in this buffer when switching to it, - ;; so I think this is needed. - (setq cursor-type t) - ;; Call burry-buffer whithout arg - ;; to be sure anything-buffer is removed from window. - (bury-buffer) - ;; Be sure we call this from anything-buffer. - (anything-funcall-foreach 'cleanup)) - (anything-new-timer 'anything-check-minibuffer-input-timer nil) - (anything-kill-async-processes) - (anything-log-run-hook 'anything-cleanup-hook) - (anything-hooks 'cleanup) - (anything-frame-or-window-configuration 'restore) - (setq anything-alive-p nil) - ;; This is needed in some cases where last input - ;; is yielded infinitely in minibuffer after anything session. - (anything-clean-up-minibuffer)) - -(defun anything-clean-up-minibuffer () - "Remove contents of minibuffer." - (let ((miniwin (minibuffer-window))) - ;; Clean only current minibuffer used by anything. - ;; i.e The precedent one is active. - (unless (minibuffer-window-active-p miniwin) - (with-current-buffer (window-buffer miniwin) - (delete-minibuffer-contents))))) - - -;; (@* "Core: input handling") -(defun anything-check-minibuffer-input () - "Extract input string from the minibuffer and check if it needs to be handled." - (let ((delay (with-current-buffer anything-buffer - (and anything-input-idle-delay - (max anything-input-idle-delay 0.1))))) - (if (or (not delay) (anything-action-window)) - (anything-check-minibuffer-input-1) - (anything-new-timer - 'anything-check-minibuffer-input-timer - (run-with-idle-timer delay nil 'anything-check-minibuffer-input-1))))) - -(defun anything-check-minibuffer-input-1 () - "Check minibuffer content." - (with-anything-quittable - (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) - (anything-check-new-input (minibuffer-contents))))) - -(defun anything-check-new-input (input) - "Check INPUT string and update the anything buffer if necessary." - (unless (equal input anything-pattern) - (setq anything-pattern input) - (unless (anything-action-window) - (setq anything-input anything-pattern)) - (anything-log-eval anything-pattern anything-input) - (anything-update))) - - -;; (@* "Core: source compiler") -(defvar anything-compile-source-functions-default anything-compile-source-functions - "Plug-ins this file provides.") -(defun anything-compile-sources (sources funcs) - "Compile SOURCES with FUNCS. -See `anything-compile-source-functions'. -Anything plug-ins are realized by this function." - (mapcar - (lambda (source) - (loop with source = (if (listp source) source (symbol-value source)) - for f in funcs - do (setq source (funcall f source)) - finally (return source))) - sources)) - - -;; (@* "Core: plug-in attribute documentation hack") - -;; `anything-document-attribute' is public API. -(defadvice documentation-property (after anything-document-attribute activate) - "Display plug-in attributes' documentation as `anything-sources' docstring." - (when (eq (ad-get-arg 0) 'anything-sources) - (setq ad-return-value - (concat ad-return-value "\n" - (mapconcat (lambda (sym) (get sym 'anything-attrdoc)) - anything-additional-attributes - "\n"))))) -;; (describe-variable 'anything-sources) -;; (documentation-property 'anything-sources 'variable-documentation) -;; (progn (ad-disable-advice 'documentation-property 'after 'anything-document-attribute) (ad-update 'documentation-property)) - - -;; (@* "Core: all candidates") -(defun anything-process-delayed-init (source) - "Initialize delayed SOURCE." - (let ((name (assoc-default 'name source))) - (unless (member name anything-delayed-init-executed) - (anything-aif (assoc-default 'delayed-init source) - (with-current-buffer anything-current-buffer - (anything-funcall-with-source source it) - (dolist (f (if (functionp it) (list it) it)) - (add-to-list 'anything-delayed-init-executed name))))))) - -(defun anything-get-candidates (source) - "Retrieve and return the list of candidates from SOURCE." - (anything-process-delayed-init source) - (let* ((candidate-source (assoc-default 'candidates source)) - (type-error (lambda () - (error (concat "Candidates must either be a function, " - " a variable or a list: %s") - candidate-source))) - (candidates (condition-case err - (anything-interpret-value candidate-source source) - (error (funcall type-error))))) - (cond ((processp candidates) candidates) - ((listp candidates) (anything-transform-candidates candidates source)) - (t (funcall type-error))))) - - -(defun anything-get-cached-candidates (source) - "Return the cached value of candidates for SOURCE. -Cache the candidates if there is not yet a cached value." - (let* ((name (assoc-default 'name source)) - (candidate-cache (assoc name anything-candidate-cache))) - (cond (candidate-cache - (anything-log "use cached candidates") - (cdr candidate-cache)) - (t - (anything-log "calculate candidates") - (let ((candidates (anything-get-candidates source))) - (cond ((processp candidates) - (push (cons candidates - (append source - (list (cons 'item-count 0) - (cons 'incomplete-line "")))) - anything-async-processes) - (set-process-filter candidates 'anything-output-filter) - (setq candidates nil)) - ((not (assoc 'volatile source)) - (setq candidate-cache (cons name candidates)) - (push candidate-cache anything-candidate-cache))) - candidates))))) - - -;;; (@* "Core: candidate transformers") -(defun anything-transform-mapcar (function args) - "`mapcar' for candidate-transformer. - -ARGS is (cand1 cand2 ...) or ((disp1 . real1) (disp2 . real2) ...) - -\(anything-transform-mapcar 'upcase '(\"foo\" \"bar\")) -=> (\"FOO\" \"BAR\") -\(anything-transform-mapcar 'upcase '((\"1st\" . \"foo\") (\"2nd\" . \"bar\"))) -=> ((\"1st\" . \"FOO\") (\"2nd\" . \"BAR\")) -" - (loop for arg in args - if (consp arg) - collect (cons (car arg) (funcall function (cdr arg))) - else - collect (funcall function arg))) - -(defun anything-process-candidate-transformer (candidates source) - "Execute candidate-transformer function on all CANDIDATES of SOURCE." - (anything-aif (assoc-default 'candidate-transformer source) - (anything-composed-funcall-with-source source it candidates) - candidates)) - -(defun anything-process-filtered-candidate-transformer (candidates source) - "Execute filtered-candidate-transformer function on all CANDIDATES of SOURCE." - (anything-aif (assoc-default 'filtered-candidate-transformer source) - (anything-composed-funcall-with-source source it candidates source) - candidates)) - -(defun anything-process-filtered-candidate-transformer-maybe (candidates source process-p) - "Execute filtered-candidate-transformer function on all CANDIDATES of SOURCE. -This happen if PROCESS-P is non-nil." - (if process-p - (anything-process-filtered-candidate-transformer candidates source) - candidates)) - -(defun anything-process-real-to-display (candidates source) - "Execute real-to-display function on all CANDIDATES of SOURCE." - (anything-aif (assoc-default 'real-to-display source) - (setq candidates (anything-funcall-with-source - source 'mapcar - (lambda (cand_) - (if (consp cand_) - ;; override DISPLAY from candidate-transformer - (cons (funcall it (cdr cand_)) (cdr cand_)) - (cons (funcall it cand_) cand_))) - candidates)) - candidates)) - -(defun anything-transform-candidates (candidates source &optional process-p) - "Transform CANDIDATES of SOURCE according to candidate transformers. -This happen if PROCESS-P is non-nil." - (anything-process-real-to-display - (anything-process-filtered-candidate-transformer-maybe - (anything-process-candidate-transformer candidates source) source process-p) - source)) - - -;; (@* "Core: narrowing candidates") -(defun anything-candidate-number-limit (source) - "Apply candidate-number-limit attribute value. -This overhide variable `anything-candidate-number-limit'. - -e.g: -If \(candidate-number-limit\) is in SOURCE, show all candidates in SOURCE. -If \(candidate-number-limit . 123\) is in SOURCE limit candidate to 123." - (anything-aif (assq 'candidate-number-limit source) - (or (cdr it) 99999999) - (or anything-candidate-number-limit 99999999))) - -;; FIXME: Why a defconst here -(defconst anything-default-match-functions - (list (lambda (candidate) - (string-match anything-pattern candidate))) - "Default functions to match candidates according to `anything-pattern'.") - -(defun anything-compute-matches (source) - "Compute matched results from SOURCE according to its settings." - (if debug-on-error - (anything-compute-matches-internal source) - (condition-case v - (anything-compute-matches-internal source) - (error (anything-log-error - "anything-compute-matches: error when processing source: %s" - (assoc-default 'name source)) - nil)))) - -(defun anything-candidate-get-display (candidate) - "Get searched display part from CANDIDATE. -CANDIDATE is a string, a symbol, or \(DISPLAY . REAL\) cons cell." - (format "%s" (or (car-safe candidate) candidate))) - -(defun anything-process-pattern-transformer (pattern source) - "Execute pattern-transformer attribute PATTERN function in SOURCE." - (anything-aif (assoc-default 'pattern-transformer source) - (anything-composed-funcall-with-source source it pattern) - pattern)) - -(defun anything-match-functions (source) - (or (assoc-default 'match source) - anything-default-match-functions)) - -(defmacro anything-accumulate-candidates-internal (cand newmatches - hash item-count limit) - "Internal, add CAND into NEWMATCHES. -Use HASH to uniq NEWMATCHES. -Argument ITEM-COUNT count the matches. -if ITEM-COUNT reaches LIMIT, exit from inner loop." - `(unless (gethash ,cand ,hash) - (puthash ,cand t ,hash) - (push ,cand ,newmatches) - (incf ,item-count) - (when (= ,item-count ,limit) - (setq exit t) - (return)))) - -(defun anything-take-first-elements (seq n) - (if (> (length seq) n) - (setq seq (subseq seq 0 n)) - seq)) - -(defun anything-match-from-candidates (cands matchfns limit) - (let (matches) - (condition-case nil - (let ((item-count 0) exit) - (clrhash anything-match-hash) - (dolist (match matchfns) - (let (newmatches) - (dolist (candidate cands) - (when (funcall match (anything-candidate-get-display candidate)) - (anything-accumulate-candidates-internal - candidate newmatches anything-match-hash item-count limit))) - (setq matches (append matches (reverse newmatches))) - (if exit (return))))) - (invalid-regexp (setq matches nil))) - matches)) - -(defun anything-compute-matches-internal (source) - (save-current-buffer - (let ((matchfns (anything-match-functions source)) - (anything-source-name (assoc-default 'name source)) - (limit (anything-candidate-number-limit source)) - (anything-pattern (anything-process-pattern-transformer - anything-pattern source))) - (anything-process-filtered-candidate-transformer - (if (or (equal anything-pattern "") (equal matchfns '(identity))) - (anything-take-first-elements - (anything-get-cached-candidates source) limit) - (anything-match-from-candidates - (anything-get-cached-candidates source) matchfns limit)) - source)))) - -;; (anything '(((name . "error")(candidates . (lambda () (hage))) (action . identity)))) - -(defun anything-process-source (source) - "Display matched results from SOURCE according to its settings." - (anything-log-eval (assoc-default 'name source)) - (if (assq 'direct-insert-match source) ;experimental - (anything-process-source--direct-insert-match source) - (let ((matches (anything-compute-matches source))) - (when matches - (when anything-test-mode - (setq anything-test-candidate-list - `(,@anything-test-candidate-list - (,(assoc-default 'name source) - ,matches)))) - (anything-insert-header-from-source source) - (if (not (assq 'multiline source)) - (mapc 'anything-insert-match-with-digit-overlay matches) - (let ((start (point)) separate) - (dolist (match matches) - (if separate - (anything-insert-candidate-separator) - (setq separate t)) - (anything-insert-match-with-digit-overlay match)) - (put-text-property start (point) 'anything-multiline t))))))) - -(defun anything-insert-match-with-digit-overlay (match) - (declare (special source)) - (anything-put-digit-overlay-maybe) - (anything-insert-match match 'insert source)) - -(defun anything-put-digit-overlay-maybe () - (when (and anything-enable-shortcuts - (not (eq anything-digit-shortcut-count - (length anything-digit-overlays)))) - (move-overlay (nth anything-digit-shortcut-count - anything-digit-overlays) - (point-at-bol) - (point-at-bol)) - (incf anything-digit-shortcut-count))) - -(defun anything-process-source--direct-insert-match (source) - "[EXPERIMENTAL] Insert candidates from `anything-candidate-buffer' in SOURCE." - (anything-log-eval (assoc-default 'name source)) - (let ((anything-source-name (assoc-default 'name source)) - content-buf) - (funcall (assoc-default 'candidates source)) - (setq content-buf (anything-candidate-buffer)) - (unless (anything-empty-buffer-p content-buf) - (anything-insert-header-from-source source) - (insert-buffer-substring content-buf) - ;; TODO call anything-put-digit-overlay-maybe with loop - ))) - -(defun anything-process-delayed-sources (delayed-sources &optional preselect) - "Process anything DELAYED-SOURCES. -Move selection to string or regexp PRESELECT if non--nil. -This function is called in `anything-process-delayed-sources-timer' -when emacs is idle for `anything-idle-delay'." - (with-anything-quittable - (anything-log-eval (mapcar (lambda (s) (assoc-default 'name s)) delayed-sources)) - (with-current-buffer anything-buffer - (save-excursion - (goto-char (point-max)) - (mapc 'anything-process-source delayed-sources) - (when (and (not (anything-empty-buffer-p)) - ;; No selection yet. - (= (overlay-start anything-selection-overlay) - (overlay-end anything-selection-overlay))) - (anything-update-move-first-line 'without-hook))) - (when preselect (anything-preselect preselect)) - (save-excursion - (goto-char (point-min)) - (anything-log-run-hook 'anything-update-hook)) - (anything-log-run-hook 'anything-after-update-hook)))) - - -;; (@* "Core: *anything* buffer contents") -(defvar anything-input-local nil) -(defvar anything-process-delayed-sources-timer nil) -(defun anything-update (&optional preselect) - "Update candidates list in `anything-buffer' according to `anything-pattern'. -Argument PRESELECT is a string or regexp used to move selection to a particular -place once updating is done. It should be used on single source because search -is done on whole `anything-buffer' and not on current source." - (anything-log "start update") - (setq anything-digit-shortcut-count 0) - (anything-kill-async-processes) - (with-current-buffer (anything-buffer-get) - (set (make-local-variable 'anything-input-local) anything-pattern) - (erase-buffer) - (when anything-enable-shortcuts - (mapc 'delete-overlay anything-digit-overlays)) - (let (delayed-sources - normal-sources) - (unwind-protect ; Process normal sources and store delayed one's. - (setq delayed-sources - (loop for source in (remove-if-not 'anything-update-source-p - (anything-get-sources)) - if (anything-delayed-source-p source) - collect source - else do (progn (push source normal-sources) - (anything-process-source source)))) - (anything-log-eval - (mapcar (lambda (s) (assoc-default 'name s)) delayed-sources)) - (if anything-test-mode ; Need only to process sources. - (mapc 'anything-process-source delayed-sources) - (cond ((and preselect delayed-sources normal-sources) - ;; Preselection run here when there is - ;; normal AND delayed sources. - (anything-log "Update preselect candidate %s" preselect) - (anything-preselect preselect)) - (delayed-sources ; Preselection and hooks will run later. - (anything-update-move-first-line 'without-hook)) - (t ; No delayed sources, run the hooks now. - (anything-update-move-first-line) - (anything-log-run-hook 'anything-after-update-hook) - (when preselect - (anything-log "Update preselect candidate %s" preselect) - (anything-preselect preselect)))) - (when delayed-sources - (anything-new-timer - 'anything-process-delayed-sources-timer - (run-with-idle-timer - ;; Be sure anything-idle-delay is > - ;; to anything-input-idle-delay - ;; otherwise use value of anything-input-idle-delay - ;; or 0.1 if == to 0. - (max anything-idle-delay anything-input-idle-delay 0.1) nil - 'anything-process-delayed-sources delayed-sources preselect)))) - (anything-log "end update"))))) - -(defun anything-update-source-p (source) - "Wheter SOURCE need updating or not." - (and (or (not anything-source-filter) - (member (assoc-default 'name source) anything-source-filter)) - (>= (length anything-pattern) - (anything-aif (assoc 'requires-pattern source) - (or (cdr it) 1) - 0)))) - -(defun anything-delayed-source-p (source) - "Wheter SOURCE is a delayed source or not." - (or (assoc 'delayed source) - (and anything-quick-update - (< (window-height (get-buffer-window (current-buffer))) - (line-number-at-pos (point-max)))))) - -(defun anything-update-move-first-line (&optional without-hook) - "Goto first line of `anything-buffer'." - (goto-char (point-min)) - (unless without-hook - (save-excursion (anything-log-run-hook 'anything-update-hook))) - (anything-next-line)) - -(defun anything-force-update (&optional preselect) - "Force recalculation and update of candidates. -If current source has `update' attribute, a function without argument, -call it before update." - (interactive) - (let ((source (anything-get-current-source)) - (selection (anything-get-selection nil t))) - (when source - (mapc 'anything-force-update--reinit - (anything-get-sources))) - (anything-update preselect) - ;; If preselect arg exists, `anything-update' should - ;; have moved to selection, otherwise do it now. - (unless preselect - (anything-keep-selection (assoc-default 'name source) selection)) - (with-anything-window (recenter)))) - -(defun anything-force-update--reinit (source) - "Reinit SOURCE by calling his update and/or init functions." - (anything-aif (anything-funcall-with-source - source 'anything-candidate-buffer) - (kill-buffer it)) - (dolist (attr '(update init)) - (anything-aif (assoc-default attr source) - (anything-funcall-with-source source it))) - (anything-remove-candidate-cache source)) - -(defun anything-keep-selection (source selection) - "Switch to SOURCE and goto SELECTION." - (when (and source selection) - (with-anything-window - (anything-goto-source source) - (forward-char -1) - (if (search-forward selection nil t) - (forward-line 0) - (goto-char (point-min)) - (forward-line 1)) - (anything-mark-current-line)))) - -(defun anything-remove-candidate-cache (source) - "Remove SOURCE from `anything-candidate-cache'." - (setq anything-candidate-cache - (delete (assoc (assoc-default 'name source) - anything-candidate-cache) - anything-candidate-cache))) - -(defun anything-insert-match (match insert-function source) - "Insert MATCH into `anything-buffer' with INSERT-FUNCTION for SOURCE. -If MATCH is a list then insert the string intended to appear on the display -and store the real value in a text property." - (let ((start (point-at-bol (point))) - (dispvalue (or (car-safe match) match)) - (realvalue (cdr-safe match))) - (setq dispvalue - (cond ((symbolp dispvalue) (symbol-name dispvalue)) - ((numberp dispvalue) (number-to-string dispvalue)) - (t dispvalue))) - (when (stringp dispvalue) - (funcall insert-function dispvalue) - ;; Some sources with candidates-in-buffer have already added - ;; 'anything-realvalue property when creating candidate buffer. - (unless (get-text-property start 'anything-realvalue) - (and realvalue - (put-text-property start (point-at-eol) - 'anything-realvalue realvalue))) - (when anything-source-in-each-line-flag - (put-text-property start (point-at-eol) 'anything-source source)) - (funcall insert-function "\n")))) - -(defun anything-insert-header-from-source (source) - "Insert SOURCE name in `anything-buffer' header. -Maybe insert by overlay additional info after source name if SOURCE have -header-name attribute." - (let ((name (assoc-default 'name source))) - (anything-insert-header - name - (anything-aif (assoc-default 'header-name source) - (anything-funcall-with-source source it name))))) - -(defun anything-insert-header (name &optional display-string) - "Insert header of source NAME into the anything buffer. -If DISPLAY-STRING is non--nil and a string, display this additional info -after the source name by overlay." - (unless (bobp) - (let ((start (point))) - (insert "\n") - (put-text-property start (point) 'anything-header-separator t))) - (let ((start (point))) - (insert name) - (put-text-property (point-at-bol) - (point-at-eol) 'anything-header t) - (when display-string - (overlay-put (make-overlay (point-at-bol) (point-at-eol)) - 'display display-string)) - (insert "\n") - (put-text-property start (point) 'face anything-header-face))) - -(defun anything-insert-candidate-separator () - "Insert separator of candidates into the anything buffer." - (insert anything-candidate-separator) - (put-text-property (point-at-bol) - (point-at-eol) 'anything-candidate-separator t) - (insert "\n")) - - -;; (@* "Core: async process") -(defun anything-output-filter (process string) - "From PROCESS process output STRING." - (anything-output-filter-1 (assoc process anything-async-processes) string)) - -(defun anything-output-filter-1 (process-assoc string) - (anything-log-eval string) - (with-current-buffer anything-buffer - (let ((source (cdr process-assoc))) - (save-excursion - (anything-aif (assoc-default 'insertion-marker source) - (goto-char it) - (goto-char (point-max)) - (anything-insert-header-from-source source) - (setcdr process-assoc - (append source `((insertion-marker . ,(point-marker)))))) - (anything-output-filter--process-source - (car process-assoc) string source - (anything-candidate-number-limit source)))) - (anything-output-filter--post-process))) - -(defun anything-output-filter--process-source (process string source limit) - (dolist (candidate (anything-transform-candidates - (anything-output-filter--collect-candidates - (split-string string "\n") - (assoc 'incomplete-line source)) - source t)) - (if (not (assq 'multiline source)) - (anything-insert-match candidate 'insert-before-markers source) - (let ((start (point))) - (anything-insert-candidate-separator) - (anything-insert-match candidate 'insert-before-markers source) - (put-text-property start (point) 'anything-multiline t))) - (incf (cdr (assoc 'item-count source))) - (when (>= (assoc-default 'item-count source) limit) - (anything-kill-async-process process) - (return)))) - -(defun anything-output-filter--collect-candidates (lines incomplete-line-info) - (anything-log-eval (cdr incomplete-line-info)) - (butlast - (loop for line in lines collect - (if (cdr incomplete-line-info) - (prog1 - (concat (cdr incomplete-line-info) line) - (setcdr incomplete-line-info nil)) - line) - finally (setcdr incomplete-line-info line)))) - -(defun anything-output-filter--post-process () - (anything-log-run-hook 'anything-update-hook) - (anything-aif (get-buffer-window anything-buffer 'visible) - (save-selected-window - (select-window it) - (anything-skip-noncandidate-line 'next) - (anything-mark-current-line)))) - -(defun anything-kill-async-processes () - "Kill all known asynchronous processes of `anything-async-processes'." - (mapc 'anything-kill-async-process (mapcar 'car anything-async-processes)) - (setq anything-async-processes nil)) - -(defun anything-kill-async-process (process) - "Kill PROCESS and detach the associated functions." - (set-process-filter process nil) - (delete-process process)) - - -;; (@* "Core: action") -(defun anything-execute-selection-action (&optional - selection action - preserve-saved-action) - "If a candidate SELECTION is present then perform the associated ACTION on it. -If PRESERVE-SAVED-ACTION is non-nil don't save action." - (anything-log "executing action") - (setq action (anything-get-default-action - (or action - anything-saved-action - (if (get-buffer anything-action-buffer) - (anything-get-selection anything-action-buffer) - (anything-get-action))))) - (let ((source (or anything-saved-current-source - (anything-get-current-source)))) - (setq selection (or selection - (anything-get-selection) - (and (assoc 'accept-empty source) ""))) - (unless preserve-saved-action (setq anything-saved-action nil)) - (if (and selection action) - (anything-funcall-with-source - source action - (anything-coerce-selection selection source))))) - -(defun anything-coerce-selection (selection source) - "Apply coerce attribute function to SELECTION in SOURCE. -Coerce source with coerce function." - (anything-aif (assoc-default 'coerce source) - (anything-funcall-with-source source it selection) - selection)) - -(defun anything-get-default-action (action) - "Get the first ACTION value of action list in source." - (if (and (listp action) (not (functionp action))) - (cdar action) - action)) - -(defun anything-select-action () - "Select an action for the currently selected candidate. -If action buffer is selected, back to the anything buffer." - (interactive) - (anything-log-run-hook 'anything-select-action-hook) - (cond ((get-buffer-window anything-action-buffer 'visible) - (set-window-buffer (get-buffer-window anything-action-buffer) - anything-buffer) - (kill-buffer anything-action-buffer) - (anything-set-pattern anything-input 'noupdate)) - (t - (setq anything-saved-selection (anything-get-selection)) - (unless anything-saved-selection - (error "Nothing is selected")) - (setq anything-saved-current-source (anything-get-current-source)) - (let ((actions (anything-get-action))) - (if (functionp actions) - (message "Sole action: %s" actions) - (anything-show-action-buffer actions) - (anything-delete-minibuffer-contents) - (setq anything-pattern 'dummy) ; so that it differs from the previous one - (anything-check-minibuffer-input)))))) - -(defun anything-show-action-buffer (actions) - (with-current-buffer (get-buffer-create anything-action-buffer) - (erase-buffer) - (buffer-disable-undo) - (set-window-buffer (get-buffer-window anything-buffer) anything-action-buffer) - (set (make-local-variable 'anything-sources) - `(((name . "Actions") - (volatile) - (candidates . ,actions) - (candidate-number-limit)))) - (set (make-local-variable 'anything-source-filter) nil) - (set (make-local-variable 'anything-selection-overlay) nil) - (set (make-local-variable 'anything-digit-overlays) nil) - (anything-initialize-overlays anything-action-buffer))) - - -;; (@* "Core: selection") -(defun anything-move-selection-common (move-func unit direction) - "Move the selection marker to a new position wit function MOVE-FUNC. -It is determined by UNIT and DIRECTION." - (unless (or (anything-empty-buffer-p (anything-buffer-get)) - (not (anything-window))) - (with-anything-window - (anything-log-run-hook 'anything-move-selection-before-hook) - (funcall move-func) - (anything-skip-noncandidate-line direction) - (anything-display-source-at-screen-top-maybe unit) - (when (anything-get-previous-header-pos) - (anything-mark-current-line)) - (anything-display-mode-line (anything-get-current-source)) - (anything-log-run-hook 'anything-move-selection-after-hook)))) - -(defun anything-display-source-at-screen-top-maybe (unit) - (when (and anything-display-source-at-screen-top (eq unit 'source)) - (set-window-start (selected-window) - (save-excursion (forward-line -1) (point))))) - -(defun anything-skip-noncandidate-line (direction) - (anything-skip-header-and-separator-line direction) - (and (bobp) (forward-line 1)) ;skip first header - (and (eobp) (forward-line -1))) ;avoid last empty line - - -(defun anything-skip-header-and-separator-line (direction) - (while (and (not (bobp)) - (or (anything-pos-header-line-p) - (anything-pos-candidate-separator-p))) - (forward-line (if (and (eq direction 'previous) - (not (eq (point-at-bol) (point-min)))) - -1 1)))) - -(defvar anything-mode-line-string-real nil) -(defun anything-display-mode-line (source) - (set (make-local-variable 'anything-mode-line-string) - (anything-interpret-value (or (assoc-default 'mode-line source) - (default-value 'anything-mode-line-string)) - source)) - (if anything-mode-line-string - (setq mode-line-format - '(" " mode-line-buffer-identification " " - (line-number-mode "L%l") " " (anything-follow-mode "(F) ") - (:eval (anything-show-candidate-number - (when (listp anything-mode-line-string) - (car anything-mode-line-string)))) - " " anything-mode-line-string-real "-%-") - anything-mode-line-string-real - (substitute-command-keys (if (listp anything-mode-line-string) - (cadr anything-mode-line-string) - anything-mode-line-string))) - (setq mode-line-format - (default-value 'mode-line-format))) - (setq header-line-format - (anything-interpret-value (assoc-default 'header-line source) source))) - -(defun anything-show-candidate-number (&optional name) - "Used to display candidate number in mode-line. -You can specify NAME of candidates e.g \"Buffers\" otherwise -it is \"Candidate\(s\)\" by default." - (propertize - (format "[%s %s]" - (anything-approximate-candidate-number 'in-current-source) - (or name "Candidate(s)")) - 'face 'anything-candidate-number)) - -(defun anything-previous-line () - "Move selection to the previous line." - (interactive) - (anything-move-selection-common - (lambda () - (if (not (anything-pos-multiline-p)) - (forward-line -1) ;double forward-line is meaningful - (forward-line -1) ;because evaluation order is important - (anything-skip-header-and-separator-line 'previous) - (let ((header-pos (anything-get-previous-header-pos)) - (separator-pos (anything-get-previous-candidate-separator-pos))) - (when header-pos - (goto-char (if (or (null separator-pos) (< separator-pos header-pos)) - header-pos ; first candidate - separator-pos)) - (forward-line 1))))) - 'line 'previous)) - -(defun anything-next-line () - "Move selection to the next line." - (interactive) - (anything-move-selection-common - (lambda () - (if (not (anything-pos-multiline-p)) - (forward-line 1) - (let ((header-pos (anything-get-next-header-pos)) - (separator-pos (anything-get-next-candidate-separator-pos))) - (cond ((and separator-pos - (or (null header-pos) (< separator-pos header-pos))) - (goto-char separator-pos)) - (header-pos - (goto-char header-pos)))))) - 'line 'next)) - -(defun anything-previous-page () - "Move selection back with a pageful." - (interactive) - (anything-move-selection-common - (lambda () - (condition-case nil - (scroll-down) - (beginning-of-buffer (goto-char (point-min))))) - 'page 'previous)) - -(defun anything-next-page () - "Move selection forward with a pageful." - (interactive) - (anything-move-selection-common - (lambda () - (condition-case nil - (scroll-up) - (end-of-buffer (goto-char (point-max))))) - 'page 'next)) - -(defun anything-beginning-of-buffer () - "Move selection at the top." - (interactive) - (anything-move-selection-common - (lambda () (goto-char (point-min))) - 'edge 'previous)) - -(defun anything-end-of-buffer () - "Move selection at the bottom." - (interactive) - (anything-move-selection-common - (lambda () (goto-char (point-max))) - 'edge 'next)) - -(defun anything-previous-source () - "Move selection to the previous source." - (interactive) - (anything-move-selection-common - (lambda () - (forward-line -1) - (if (bobp) - (goto-char (point-max)) - (anything-skip-header-and-separator-line 'previous)) - (goto-char (anything-get-previous-header-pos)) - (forward-line 1)) - 'source 'previous)) - -(defun anything-next-source () - "Move selection to the next source." - (interactive) - (anything-move-selection-common - (lambda () - (goto-char (or (anything-get-next-header-pos) (point-min)))) - 'source 'next)) - -(defun anything-goto-source (source-or-name) - "Move the selection to the source SOURCE-OR-NAME." - (anything-move-selection-common - (lambda () - (goto-char (point-min)) - (let ((name (if (stringp source-or-name) source-or-name - (assoc-default 'name source-or-name)))) - (condition-case err - (while (not (string= name (anything-current-line-contents))) - (goto-char (anything-get-next-header-pos))) - (error (message ""))))) - 'source 'next)) - -(defun anything-mark-current-line (&optional resumep) - "Move `anything-selection-overlay' to current line. -Note that this is not related with visibles marks, which are used -to mark candidates." - (with-anything-window - (when resumep - (goto-char anything-selection-point)) - (move-overlay - anything-selection-overlay (point-at-bol) - (if (anything-pos-multiline-p) - (let ((header-pos (anything-get-next-header-pos)) - (separator-pos (anything-get-next-candidate-separator-pos))) - (or (and (null header-pos) separator-pos) - (and header-pos separator-pos (< separator-pos header-pos) - separator-pos) - header-pos - (point-max))) - (1+ (point-at-eol)))) - (setq anything-selection-point (overlay-start anything-selection-overlay))) - (anything-follow-execute-persistent-action-maybe)) - -(defun anything-this-command-key () - (event-basic-type (elt (this-command-keys-vector) 0))) -;; (progn (read-key-sequence "Key: ") (p (anything-this-command-key))) - -(defun anything-select-with-shortcut-internal (types get-key-func) - (if (memq anything-enable-shortcuts types) - (save-selected-window - (select-window (anything-window)) - (let* ((key (funcall get-key-func)) - (overlay (ignore-errors (nth (position key anything-shortcut-keys) - anything-digit-overlays)))) - (if (not (and overlay (overlay-buffer overlay))) - (when (numberp key) - (select-window (minibuffer-window)) - (self-insert-command 1)) - (goto-char (overlay-start overlay)) - (anything-mark-current-line) - (anything-exit-minibuffer)))) - (self-insert-command 1))) - -(defun anything-select-with-prefix-shortcut () - "Invoke default action with prefix shortcut." - (interactive) - (anything-select-with-shortcut-internal - '(prefix) - (lambda () (read-event "Select shortcut key: ")))) - -(defun anything-select-with-digit-shortcut () - "Invoke default action with digit/alphabet shortcut." - (interactive) - (anything-select-with-shortcut-internal - '(alphabet t) 'anything-this-command-key)) - -;; (setq anything-enable-shortcuts 'prefix) -;; (define-key anything-map "@" 'anything-select-with-prefix-shortcut) -;; (define-key anything-map (kbd "") 'anything-select-with-prefix-shortcut) - -(defvar anything-exit-status 0 - "Flag to inform whether anything have exited or quitted. -Exit with 0 mean anything have exited executing an action. -Exit with 1 mean anything have quitted with \\[keyboard-quit] -It is useful for example to restore a window config if anything abort -in special cases. -See `anything-exit-minibuffer' and `anything-keyboard-quit'.") - -(defvar anything-minibuffer-confirm-state nil) -(defun anything-confirm-and-exit-minibuffer () - "Maybe ask for confirmation when exiting anything. -It is similar to `minibuffer-complete-and-exit' adapted to anything. -If `minibuffer-completion-confirm' value is 'confirm, -send in minibuffer confirm message and exit on next hit. -If `minibuffer-completion-confirm' value is t, -don't exit and send message 'no match'." - (interactive) - (let ((empty-buffer-p (with-current-buffer anything-buffer - (eq (point-min) (point-max))))) - (cond ((and empty-buffer-p - (eq minibuffer-completion-confirm 'confirm)) - (setq anything-minibuffer-confirm-state - 'confirm) - (setq minibuffer-completion-confirm nil) - (minibuffer-message " [confirm]")) - ((and empty-buffer-p - (eq minibuffer-completion-confirm t)) - (minibuffer-message " [No match]")) - (t - (setq anything-minibuffer-confirm-state nil) - (anything-exit-minibuffer))))) -(add-hook 'anything-after-update-hook 'anything-confirm-and-exit-hook) - -(defun anything-confirm-and-exit-hook () - "Restore `minibuffer-completion-confirm' when anything update." - (unless (or (eq minibuffer-completion-confirm t) - (not anything-minibuffer-confirm-state)) - (setq minibuffer-completion-confirm - anything-minibuffer-confirm-state))) - -(defun anything-exit-minibuffer () - "Select the current candidate by exiting the minibuffer." - (interactive) - (unless anything-current-prefix-arg - (setq anything-current-prefix-arg current-prefix-arg)) - (setq anything-exit-status 0) - (exit-minibuffer)) - -(defun anything-keyboard-quit () - "Quit minibuffer in anything. -If action buffer is displayed, kill it." - (interactive) - (when (get-buffer-window anything-action-buffer 'visible) - (kill-buffer anything-action-buffer)) - (setq anything-exit-status 1) - (abort-recursive-edit)) - -(defun anything-get-next-header-pos () - "Return the position of the next header from point." - (next-single-property-change (point) 'anything-header)) - -(defun anything-get-previous-header-pos () - "Return the position of the previous header from point." - (previous-single-property-change (point) 'anything-header)) - -(defun anything-pos-multiline-p () - "Return non-nil if the current position is in the multiline source region." - (get-text-property (point) 'anything-multiline)) - -(defun anything-get-next-candidate-separator-pos () - "Return the position of the next candidate separator from point." - (next-single-property-change (point) 'anything-candidate-separator)) - -(defun anything-get-previous-candidate-separator-pos () - "Return the position of the previous candidate separator from point." - (previous-single-property-change (point) 'anything-candidate-separator)) - -(defun anything-pos-header-line-p () - "Return t if the current line is a header line." - (or (get-text-property (point-at-bol) 'anything-header) - (get-text-property (point-at-bol) 'anything-header-separator))) - -(defun anything-pos-candidate-separator-p () - "Return t if the current line is a candidate separator." - (get-text-property (point-at-bol) 'anything-candidate-separator)) - - -;; (@* "Core: help") -(defun anything-help-internal (bufname insert-content-fn) - "Show long message during `anything' session in BUFNAME. -INSERT-CONTENT-FN is the text to be displayed in BUFNAME." - (save-window-excursion - (select-window (anything-window)) - (delete-other-windows) - (switch-to-buffer (get-buffer-create bufname)) - (erase-buffer) - (funcall insert-content-fn) - (setq mode-line-format "%b (SPC,C-v:NextPage b,M-v:PrevPage other:Exit)") - (setq cursor-type nil) - (goto-char 1) - (anything-help-event-loop))) - -(defun anything-help-event-loop () - (ignore-errors - (loop for event = (read-event) do - (case event - ((?\C-v ? ) (scroll-up)) - ((?\M-v ?b) (scroll-down)) - (t (return)))))) - -(defun anything-help () - "Help of `anything'." - (interactive) - (anything-help-internal - " *Anything Help*" - (lambda () - (insert (substitute-command-keys - (anything-interpret-value (or (assoc-default - 'help-message - (anything-get-current-source)) - anything-help-message)))) - (org-mode)))) - -(defun anything-debug-output () - "Show all anything-related variables at this time." - (interactive) - (anything-help-internal " *Anything Debug*" 'anything-debug-output-function)) - -(defun anything-debug-output-function (&optional vars) - (message "Calculating all anything-related values...") - (insert "If you debug some variables or forms, set `anything-debug-forms' -to a list of forms.\n\n") - (dolist (v (or vars - anything-debug-forms - (apropos-internal "^anything-" 'boundp))) - (insert "** " - (pp-to-string v) "\n" - (pp-to-string (with-current-buffer anything-buffer (eval v))) "\n")) - (message "Calculating all anything-related values...Done")) - - -;; (@* "Core: misc") -(defun anything-kill-buffer-hook () - "Remove tick entry from `anything-tick-hash' when killing a buffer." - (loop for key being the hash-keys in anything-tick-hash - if (string-match (format "^%s/" (regexp-quote (buffer-name))) key) - do (remhash key anything-tick-hash))) -(add-hook 'kill-buffer-hook 'anything-kill-buffer-hook) - -(defun anything-preselect (candidate-or-regexp) - "Move `anything-selection-overlay' to CANDIDATE-OR-REGEXP on startup." - (with-anything-window - (when candidate-or-regexp - (goto-char (point-min)) - ;; go to first candidate of first source - (forward-line 1) - (let ((start (point))) - (or (re-search-forward - (concat "^" (regexp-quote candidate-or-regexp) "$") nil t) - (re-search-forward candidate-or-regexp nil t) - (search-forward candidate-or-regexp nil t) - (goto-char start)))) - (anything-mark-current-line))) - -(defun anything-delete-current-selection () - "Delete the currently selected item." - (interactive) - (with-anything-window - (cond ((anything-pos-multiline-p) - (anything-aif (anything-get-next-candidate-separator-pos) - (delete-region (point-at-bol) - (1+ (progn (goto-char it) (point-at-eol)))) - ;; last candidate - (goto-char (anything-get-previous-candidate-separator-pos)) - (delete-region (point-at-bol) (point-max))) - (when (anything-end-of-source-p) - (goto-char (or (anything-get-previous-candidate-separator-pos) - (point-min))) - (forward-line 1))) - (t - (delete-region (point-at-bol) (1+ (point-at-eol))) - (when (anything-end-of-source-p) (forward-line -1)))) - (anything-mark-current-line))) - -(defun anything-end-of-source-p () - "Return non--nil if we are at eob or end of source." - (save-excursion - (forward-line 1) - (or (eq (point-at-bol) (point-at-eol)) - (anything-pos-header-line-p) - (eobp)))) - -(defun anything-edit-current-selection-internal (func) - (with-anything-window - (beginning-of-line) - (let ((realvalue (get-text-property (point) 'anything-realvalue))) - (funcall func) - (beginning-of-line) - (and realvalue - (put-text-property (point) (point-at-eol) - 'anything-realvalue realvalue)) - (anything-mark-current-line)))) - -(defmacro anything-edit-current-selection (&rest forms) - "Evaluate FORMS at current selection in the anything buffer. -You can edit the line." - (declare (indent 0) (debug t)) - `(anything-edit-current-selection-internal - (lambda () ,@forms))) - -(defun anything-set-pattern (pattern &optional noupdate) - "Set minibuffer contents to PATTERN. -if optional NOUPDATE is non-nil, anything buffer is not changed." - (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) - (delete-minibuffer-contents) - (insert pattern)) - (when noupdate - (setq anything-pattern pattern) - (anything-hooks 'cleanup) - (run-with-idle-timer 0 nil 'anything-hooks 'setup))) - -(defun anything-delete-minibuffer-contents () - "Same as `delete-minibuffer-contents' but this is a command." - (interactive) - (anything-set-pattern "")) -(defalias 'anything-delete-minibuffer-content 'anything-delete-minibuffer-contents) - - -;;; Plugins -;; -;; (@* "Built-in plug-in: type") -(defun anything-compile-source--type (source) - (anything-aif (assoc-default 'type source) - (append source (assoc-default it anything-type-attributes) nil) - source)) - -;; `define-anything-type-attribute' is public API. - -(defun anything-add-type-attribute (type definition) - (anything-aif (assq type anything-type-attributes) - (setq anything-type-attributes (delete it anything-type-attributes))) - (push (cons type definition) anything-type-attributes)) - -(defvar anything-types nil) -(defun anything-document-type-attribute (type doc) - (add-to-list 'anything-types type t) - (put type 'anything-typeattrdoc - (concat "- " (symbol-name type) "\n\n" doc "\n"))) - -(defadvice documentation-property (after anything-document-type-attribute activate) - "Display type attributes' documentation as `anything-type-attributes' docstring." - (when (eq (ad-get-arg 0) 'anything-type-attributes) - (setq ad-return-value - (concat ad-return-value "\n\n++++ Types currently defined ++++\n" - (mapconcat (lambda (sym) (get sym 'anything-typeattrdoc)) - anything-types "\n"))))) - -;; (@* "Built-in plug-in: dummy") -(defun anything-dummy-candidate (candidate source) - "Use `anything-pattern' as CANDIDATE in SOURCE." - ;; `source' is defined in filtered-candidate-transformer - (list anything-pattern)) - -(defun anything-compile-source--dummy (source) - (if (assoc 'dummy source) - (append source - '((candidates "dummy") - (accept-empty) - (match identity) - (filtered-candidate-transformer . anything-dummy-candidate) - (disable-shortcuts) - (volatile))) - source)) - -;; (@* "Built-in plug-in: disable-shortcuts") -(defvar anything-orig-enable-shortcuts nil) -(defun anything-save-enable-shortcuts () - (anything-once - (lambda () - (setq anything-orig-enable-shortcuts anything-enable-shortcuts - anything-enable-shortcuts nil)))) - -(defun anything-compile-source--disable-shortcuts (source) - (if (assoc 'disable-shortcuts source) - (append `((init ,@(anything-mklist (assoc-default 'init source)) - anything-save-enable-shortcuts) - (resume ,@(anything-mklist (assoc-default 'resume source)) - anything-save-enable-shortcuts) - (cleanup ,@(anything-mklist (assoc-default 'cleanup source)) - (lambda () (setq anything-enable-shortcuts - anything-orig-enable-shortcuts)))) - source) - source)) - -;; (@* "Built-in plug-in: candidates-in-buffer") -(defun anything-candidates-in-buffer () - "Get candidates from the candidates buffer according to `anything-pattern'. - -BUFFER is `anything-candidate-buffer' by default. Each -candidate must be placed in one line. This function is meant to -be used in candidates-in-buffer or candidates attribute of an -anything source. Especially fast for many (1000+) candidates. - -eg. - '((name . \"many files\") - (init . (lambda () (with-current-buffer (anything-candidate-buffer 'local) - (insert-many-filenames)))) - (search re-search-forward) ; optional - (candidates-in-buffer) - (type . file)) - -+===============================================================+ -| The new way of making and narrowing candidates: Using buffers | -+===============================================================+ - -By default, `anything' makes candidates by evaluating the -candidates function, then narrows them by `string-match' for each -candidate. - -But this way is very slow for many candidates. The new way is -storing all candidates in a buffer and narrowing them by -`re-search-forward'. Search function is customizable by search -attribute. The important point is that buffer processing is MUCH -FASTER than string list processing and is the Emacs way. - -The init function writes all candidates to a newly-created -candidate buffer. The candidates buffer is created or specified -by `anything-candidate-buffer'. Candidates are stored in a line. - -The candidates function narrows all candidates, IOW creates a -subset of candidates dynamically. It is the task of -`anything-candidates-in-buffer'. As long as -`anything-candidate-buffer' is used,`(candidates-in-buffer)' is -sufficient in most cases. - -Note that `(candidates-in-buffer)' is shortcut of three attributes: - (candidates . anything-candidates-in-buffer) - (volatile) - (match identity) -And `(candidates-in-buffer . func)' is shortcut of three attributes: - (candidates . func) - (volatile) - (match identity) -The expansion is performed in `anything-get-sources'. - -The candidates-in-buffer attribute implies the volatile attribute. -The volatile attribute is needed because `anything-candidates-in-buffer' -creates candidates dynamically and need to be called everytime -`anything-pattern' changes. - -Because `anything-candidates-in-buffer' plays the role of `match' attribute -function, specifying `(match identity)' makes the source slightly faster. - -To customize `anything-candidates-in-buffer' behavior, use search, -get-line and search-from-end attributes. See also `anything-sources' docstring." - (declare (special source)) - (anything-candidates-in-buffer-1 - (anything-candidate-buffer) - anything-pattern - (or (assoc-default 'get-line source) - #'buffer-substring-no-properties) - ;; use external variable `source'. - (or (assoc-default 'search source) - (if (assoc 'search-from-end source) - '(anything-candidates-in-buffer-search-from-end) - '(anything-candidates-in-buffer-search-from-start))) - (anything-candidate-number-limit source) - (assoc 'search-from-end source))) - -(defun anything-candidates-in-buffer-search-from-start (pattern) - "Search PATTERN with `re-search-forward' with bound and noerror args." - (re-search-forward pattern nil t)) - -(defun anything-candidates-in-buffer-search-from-end (pattern) - "Search PATTERN with `re-search-backward' with bound and noerror args." - (re-search-backward pattern nil t)) - -(defun anything-candidates-in-buffer-1 (buffer pattern get-line-fn - search-fns limit search-from-end) - ;; buffer == nil when candidates buffer does not exist. - (when buffer - (with-current-buffer buffer - (let ((start-point (if search-from-end (point-max) (point-min))) - (endp (if search-from-end #'bobp #'eobp))) - (goto-char (1- start-point)) - (if (string= pattern "") - (anything-initial-candidates-from-candidate-buffer - endp get-line-fn limit search-from-end) - (anything-search-from-candidate-buffer - pattern get-line-fn search-fns limit search-from-end - start-point endp)))))) - -(defun anything-point-is-moved (proc) - "If point is moved after executing PROC, return t, otherwise nil." - (/= (point) (progn (funcall proc) (point)))) - -(defun anything-search-from-candidate-buffer (pattern get-line-fn search-fns - limit search-from-end - start-point endp) - (let (buffer-read-only - matches exit newmatches) - (anything-search-from-candidate-buffer-internal - (lambda () - (clrhash anything-cib-hash) - (dolist (searcher search-fns) - (goto-char start-point) - (setq newmatches nil) - (loop with item-count = 0 - while (funcall searcher pattern) - for cand = (funcall get-line-fn (point-at-bol) (point-at-eol)) - do (anything-accumulate-candidates-internal - cand newmatches anything-cib-hash item-count limit) - unless (anything-point-is-moved - (lambda () - (if search-from-end - (goto-char (1- (point-at-bol))) - (forward-line 1)))) - return nil) - (setq matches (append matches (nreverse newmatches))) - (if exit (return))) - (delq nil matches))))) - -(defun anything-initial-candidates-from-candidate-buffer (endp get-line-fn limit search-from-end) - (delq nil (loop with next-line-fn = - (if search-from-end - (lambda (x) (goto-char (max (1- (point-at-bol)) 1))) - #'forward-line) - until (funcall endp) - for i from 1 to limit - collect (funcall get-line-fn (point-at-bol) (point-at-eol)) - do (funcall next-line-fn 1)))) - -(defun anything-search-from-candidate-buffer-internal (search-fn) - (goto-char (point-min)) - (insert "\n") - (goto-char (point-max)) - (insert "\n") - (unwind-protect - (funcall search-fn) - (goto-char (point-min)) - (delete-char 1) - (goto-char (1- (point-max))) - (delete-char 1) - - (set-buffer-modified-p nil))) - -(defun anything-candidate-buffer (&optional create-or-buffer) - "Register and return a buffer containing candidates of current source. -`anything-candidate-buffer' searches buffer-local candidates buffer first, -then global candidates buffer. - -Acceptable values of CREATE-OR-BUFFER: - -- nil (omit) - Only return the candidates buffer. -- a buffer - Register a buffer as a candidates buffer. -- 'global - Create a new global candidates buffer, - named \" *anything candidates:SOURCE*\". -- other non-nil value - Create a new local candidates buffer, - named \" *anything candidates:SOURCE*ANYTHING-CURRENT-BUFFER\"." - (let* ((global-bname (format " *anything candidates:%s*" - anything-source-name)) - (local-bname (format " *anything candidates:%s*%s" - anything-source-name - (buffer-name anything-current-buffer)))) - (flet ((register-func () - (setq anything-candidate-buffer-alist - (cons (cons anything-source-name create-or-buffer) - (delete (assoc anything-source-name - anything-candidate-buffer-alist) - anything-candidate-buffer-alist)))) - (kill-buffers-func () - (loop for b in (buffer-list) - if (string-match (format "^%s" (regexp-quote global-bname)) - (buffer-name b)) - do (kill-buffer b))) - (create-func () - (with-current-buffer - (get-buffer-create (if (eq create-or-buffer 'global) - global-bname - local-bname)) - (buffer-disable-undo) - (erase-buffer) - (font-lock-mode -1))) - (return-func () - (or (get-buffer local-bname) - (get-buffer global-bname) - (anything-aif (assoc-default anything-source-name - anything-candidate-buffer-alist) - (and (buffer-live-p it) it))))) - (when create-or-buffer - (register-func) - (unless (bufferp create-or-buffer) - (and (eq create-or-buffer 'global) (kill-buffers-func)) - (create-func))) - (return-func)))) - -(defun anything-compile-source--candidates-in-buffer (source) - (anything-aif (assoc 'candidates-in-buffer source) - (append source - `((candidates . ,(or (cdr it) 'anything-candidates-in-buffer)) - (volatile) (match identity))) - source)) - - -;; (@* "Utility: resplit anything window") -(defun anything-toggle-resplit-window () - "Toggle resplit anything window, vertically or horizontally." - (interactive) - (with-anything-window - (let ((before-height (window-height))) - (delete-window) - (set-window-buffer - (select-window (if (= (window-height) before-height) - (prog1 - (split-window-vertically) - (setq anything-split-window-state 'vertical)) - (setq anything-split-window-state 'horizontal) - (split-window-horizontally))) - anything-buffer)))) - -;; (@* "Utility: Resize anything window.") -(defun anything-enlarge-window-1 (n) - "Enlarge or narrow anything window. -If N is positive enlarge, if negative narrow." - (unless anything-samewindow - (let ((horizontal-p (eq anything-split-window-state 'horizontal))) - (with-anything-window - (enlarge-window n horizontal-p))))) - -(defun anything-narrow-window () - "Narrow anything window." - (interactive) - (anything-enlarge-window-1 -1)) - -(defun anything-enlarge-window () - "Enlarge anything window." - (interactive) - (anything-enlarge-window-1 1)) - -;; (@* "Utility: select another action by key") -(defun anything-select-nth-action (n) - "Select the N nth action for the currently selected candidate." - (setq anything-saved-selection (anything-get-selection)) - (unless anything-saved-selection - (error "Nothing is selected")) - (setq anything-saved-action (anything-get-nth-action n (anything-get-action))) - (anything-exit-minibuffer)) - -(defun anything-get-nth-action (n action) - (cond ((and (zerop n) (functionp action)) - action) - ((listp action) - (or (cdr (elt action n)) - (error "No such action"))) - ((and (functionp action) (< 0 n)) - (error "Sole action")) - (t - (error "Error in `anything-select-nth-action'")))) - -(defun anything-select-2nd-action () - "Select the 2nd action for the currently selected candidate." - (interactive) - (anything-select-nth-action 1)) - -(defun anything-select-3rd-action () - "Select the 3rd action for the currently selected candidate." - (interactive) - (anything-select-nth-action 2)) - -(defun anything-select-4th-action () - "Select the 4th action for the currently selected candidate." - (interactive) - (anything-select-nth-action 3)) - -(defun anything-select-2nd-action-or-end-of-line () - "Select the 2nd action for the currently selected candidate. -This happen when point is at the end of minibuffer. -Otherwise goto the end of minibuffer." - (interactive) - (if (eolp) - (anything-select-nth-action 1) - (end-of-line))) - -;; (@* "Utility: Persistent Action") -(defmacro with-anything-display-same-window (&rest body) - "Execute BODY in the window used for persistent action. -Make `pop-to-buffer' and `display-buffer' display in the same window." - (declare (indent 0) (debug t)) - `(let ((display-buffer-function 'anything-persistent-action-display-buffer)) - ,@body)) - -(defvar anything-persistent-action-display-window nil) -(defun anything-initialize-persistent-action () - (set (make-local-variable 'anything-persistent-action-display-window) nil)) - -(defun* anything-execute-persistent-action (&optional (attr 'persistent-action) onewindow) - "Perform the associated action ATTR without quitting anything. -ATTR default is 'persistent-action', but it can be anything else. -In this case you have to add this new attribute to your source. -When `anything-samewindow' and ONEWINDOW are non--nil, -the anything window is never split in persistent action." - (interactive) - (anything-log "executing persistent-action") - (with-anything-window - (save-selected-window - (anything-select-persistent-action-window onewindow) - (anything-log-eval (current-buffer)) - (let ((anything-in-persistent-action t)) - (with-anything-display-same-window - (anything-execute-selection-action - nil - (or (assoc-default attr (anything-get-current-source)) - (anything-get-action)) - t) - (anything-log-run-hook 'anything-after-persistent-action-hook)))))) - - -(defun anything-persistent-action-display-window (&optional onewindow) - "Return the window that will be used for presistent action. -If ONEWINDOW is non--nil window will not be splitted in persistent action -if `anything-samewindow' is non--nil also." - (with-anything-window - (setq anything-persistent-action-display-window - (cond ((window-live-p anything-persistent-action-display-window) - anything-persistent-action-display-window) - ((and anything-samewindow (one-window-p t) (not onewindow)) - (split-window)) - ((get-buffer-window anything-current-buffer)) - (t - (next-window (selected-window) 1)))))) - -(defun anything-select-persistent-action-window (&optional onewindow) - "Select the window that will be used for persistent action. -See `anything-persistent-action-display-window' for how to use ONEWINDOW." - (select-window (get-buffer-window (anything-buffer-get))) - (select-window - (setq minibuffer-scroll-window - (anything-persistent-action-display-window onewindow)))) - -(defun anything-persistent-action-display-buffer (buf &optional not-this-window) - "Make `pop-to-buffer' and `display-buffer' display in the same window. -If `anything-persistent-action-use-special-display' is non-nil and -BUF is to be displayed by `special-display-function', use it. -Otherwise ignores `special-display-buffer-names' and `special-display-regexps'. -Argument NOT-THIS-WINDOW if present will be used as -second argument of `display-buffer'." - (let* ((name (buffer-name buf)) - display-buffer-function pop-up-windows pop-up-frames - (same-window-regexps - (unless (and anything-persistent-action-use-special-display - (or (member name - (mapcar (lambda (x) (or (car-safe x) x)) - special-display-buffer-names)) - (remove-if-not - (lambda (x) (string-match (or (car-safe x) x) name)) - special-display-regexps))) - '(".")))) - (display-buffer buf not-this-window))) - -;; scroll-other-window(-down)? for persistent-action -(defun anything-scroll-other-window-base (command) - (with-selected-window (anything-persistent-action-display-window) - (funcall command anything-scroll-amount))) - -(defun anything-scroll-other-window () - "Scroll other window (not *Anything* window) upward." - (interactive) - (anything-scroll-other-window-base 'scroll-up)) - -(defun anything-scroll-other-window-down () - "Scroll other window (not *Anything* window) downward." - (interactive) - (anything-scroll-other-window-base 'scroll-down)) - - -;; (@* "Utility: Visible Mark") -(defface anything-visible-mark - '((((min-colors 88) (background dark)) - (:background "green1" :foreground "black")) - (((background dark)) (:background "green" :foreground "black")) - (((min-colors 88)) (:background "green1")) - (t (:background "green"))) - "Face for visible mark." - :group 'anything) - -(defvar anything-visible-mark-face 'anything-visible-mark) -(defvar anything-visible-mark-overlays nil) - -(defun anything-clear-visible-mark () - (with-current-buffer (anything-buffer-get) - (mapc 'delete-overlay anything-visible-mark-overlays) - (set (make-local-variable 'anything-visible-mark-overlays) nil))) -(add-hook 'anything-after-initialize-hook 'anything-clear-visible-mark) - -(defvar anything-marked-candidates nil - "Marked candadates. List of \(source . real\) pair.") - -(defun anything-this-visible-mark () - (loop for o in anything-visible-mark-overlays - when (equal (point-at-bol) (overlay-start o)) - return o)) - -(defun anything-delete-visible-mark (overlay) - (setq anything-marked-candidates - (remove - (cons (anything-get-current-source) (anything-get-selection)) - anything-marked-candidates)) - (delete-overlay overlay) - (setq anything-visible-mark-overlays - (delq overlay anything-visible-mark-overlays))) - -(defun anything-make-visible-mark () - (let ((o (make-overlay (point-at-bol) (1+ (point-at-eol))))) - (overlay-put o 'face anything-visible-mark-face) - (overlay-put o 'source (assoc-default 'name (anything-get-current-source))) - (overlay-put o 'string (buffer-substring (overlay-start o) (overlay-end o))) - (overlay-put o 'real (anything-get-selection)) - (add-to-list 'anything-visible-mark-overlays o)) - (push (cons (anything-get-current-source) (anything-get-selection)) - anything-marked-candidates)) - -(defun anything-toggle-visible-mark () - "Toggle anything visible mark at point." - (interactive) - (with-anything-window - (anything-aif (anything-this-visible-mark) - (anything-delete-visible-mark it) - (anything-make-visible-mark)) - (anything-next-line))) - -(defun anything-display-all-visible-marks () - "Show all `anything' visible marks strings." - (interactive) - (with-anything-window - (lexical-let ((overlays (reverse anything-visible-mark-overlays))) - (anything-run-after-quit - (lambda () - (with-output-to-temp-buffer "*anything visible marks*" - (dolist (o overlays) (princ (overlay-get o 'string))))))))) - -(defun anything-marked-candidates () - "Return marked candidates of current source if any. -Otherwise one element list of current selection. - -It is analogous to `dired-get-marked-files'." - (with-current-buffer (anything-buffer-get) - (let ((cands - (if anything-marked-candidates - (loop with current-src = (anything-get-current-source) - for (source . real) in (reverse anything-marked-candidates) - when (equal current-src source) - collect (anything-coerce-selection real source)) - (list (anything-get-selection))))) - (anything-log-eval cands) - cands))) - -(defun anything-reset-marked-candidates () - (with-current-buffer (anything-buffer-get) - (set (make-local-variable 'anything-marked-candidates) nil))) - -(add-hook 'anything-after-initialize-hook 'anything-reset-marked-candidates) -;; (add-hook 'anything-after-action-hook 'anything-reset-marked-candidates) - -(defun anything-current-source-name= (name) - (save-excursion - (goto-char (anything-get-previous-header-pos)) - (equal name (anything-current-line-contents)))) - -(defun anything-revive-visible-mark () - "Restore marked candidates when anything update display." - (with-current-buffer anything-buffer - (dolist (o anything-visible-mark-overlays) - (goto-char (point-min)) - (while (and (search-forward (overlay-get o 'string) nil t) - (anything-current-source-name= (overlay-get o 'source))) - ;; Calculate real value of candidate. - ;; It can be nil if candidate have only a display value. - (let ((real (get-text-property (point-at-bol 0) 'anything-realvalue))) - (if real - ;; Check if real value of current candidate is the same - ;; that the one stored in overlay. - (and (string= (overlay-get o 'real) real) - (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0)))) - (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0))))))))) -(add-hook 'anything-update-hook 'anything-revive-visible-mark) - -(defun anything-next-point-in-list (curpos points &optional prev) - (cond - ;; rule out special cases - ((null points) curpos) - ((and prev (< curpos (car points))) curpos) - ((< (car (last points)) curpos) - (if prev (car (last points)) curpos)) - (t - (nth (if prev - (loop for pt in points - for i from 0 - if (<= curpos pt) - return (1- i)) - (loop for pt in points - for i from 0 - if (< curpos pt) - return i)) - points)))) - -(defun anything-next-visible-mark (&optional prev) - "Move next anything visible mark. -If PREV is non-nil move to precedent." - (interactive) - (with-anything-window - (ignore-errors - (goto-char (anything-next-point-in-list - (point) - (sort (mapcar 'overlay-start anything-visible-mark-overlays) '<) - prev))) - (anything-mark-current-line))) - -(defun anything-prev-visible-mark () - "Move previous anything visible mark." - (interactive) - (anything-next-visible-mark t)) - -;; (@* "Utility: Selection Paste") -(defun anything-yank-selection () - "Set minibuffer contents to current selection." - (interactive) - (anything-set-pattern (anything-get-selection nil t))) - -(defun anything-kill-selection-and-quit () - "Store current selection to kill ring. -You can paste it by typing \\[yank]." - (interactive) - (anything-run-after-quit - (lambda (sel) - (kill-new sel) - (message "Killed: %s" sel)) - (anything-get-selection nil t))) - - -;; (@* "Utility: Automatical execution of persistent-action") -(add-to-list 'minor-mode-alist '(anything-follow-mode " AFollow")) -(defun anything-follow-mode () - "If this mode is on, persistent action is executed everytime the cursor is moved." - (interactive) - (with-current-buffer anything-buffer - (setq anything-follow-mode (not anything-follow-mode)) - (message "anything-follow-mode is %s" - (if anything-follow-mode "enabled" "disabled")))) - -(defun anything-follow-execute-persistent-action-maybe () - "Execute persistent action in mode `anything-follow-mode'. -This happen after `anything-input-idle-delay' secs." - (and (not (get-buffer-window anything-action-buffer 'visible)) - (buffer-local-value 'anything-follow-mode - (get-buffer-create anything-buffer)) - (sit-for (and anything-input-idle-delay - (max anything-input-idle-delay 0.1))) - (anything-window) - (anything-get-selection) - (save-excursion - (anything-execute-persistent-action)))) - - -;; (@* "Utility: Migrate `anything-sources' to my-anything command") -(defun anything-migrate-sources () - "Help to migrate to new `anything' way." - (interactive) - (with-current-buffer (get-buffer-create "*anything migrate*") - (erase-buffer) - (insert (format "\ -Setting `anything-sources' directly is not good because -`anything' is not for one command. For now, interactive use of -`anything' (M-x anything) is only for demonstration purpose. -So you should define commands calling `anything'. -I help you to migrate to the new way. - -The code below is automatically generated from current -`anything-sources' value. You can use the `my-anything' command -now! - -Copy and paste it to your .emacs. Then substitute `my-anything' -for `anything' bindings in all `define-key', `local-set-key' and -`global-set-key' calls. - -\(defun my-anything () - \"Anything command for you. - -It is automatically generated by `anything-migrate-sources'.\" - (interactive) - (anything-other-buffer - '%S - \"*my-anything*\")) -" anything-sources)) - (eval-last-sexp nil) - (substitute-key-definition 'anything 'my-anything global-map) - (pop-to-buffer (current-buffer)))) - - -;; (@* "Compatibility") - -;; Copied assoc-default from XEmacs version 21.5.12 -(unless (fboundp 'assoc-default) - (defun assoc-default (key alist &optional test default) - "Find object KEY in a pseudo-alist ALIST. -ALIST is a list of conses or objects. Each element (or the element's car, -if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). -If that is non-nil, the element matches; -then `assoc-default' returns the element's cdr, if it is a cons, -or DEFAULT if the element is not a cons. - -If no element matches, the value is nil. -If TEST is omitted or nil, `equal' is used." - (let (found (tail alist) value) - (while (and tail (not found)) - (let ((elt (car tail))) - (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) - (setq found t value (if (consp elt) (cdr elt) default)))) - (setq tail (cdr tail))) - value))) - -;; Function not available in XEmacs, -(unless (fboundp 'minibuffer-contents) - (defun minibuffer-contents () - "Return the user input in a minbuffer as a string. -The current buffer must be a minibuffer." - (field-string (point-max))) - - (defun delete-minibuffer-contents () - "Delete all user input in a minibuffer. -The current buffer must be a minibuffer." - (delete-field (point-max)))) - -;; Function not available in older Emacs (<= 22.1). -(unless (fboundp 'buffer-chars-modified-tick) - (defun buffer-chars-modified-tick (&optional buffer) - "Return BUFFER's character-change tick counter. -Each buffer has a character-change tick counter, which is set to the -value of the buffer's tick counter (see `buffer-modified-tick'), each -time text in that buffer is inserted or deleted. By comparing the -values returned by two individual calls of `buffer-chars-modified-tick', -you can tell whether a character change occurred in that buffer in -between these calls. No argument or nil as argument means use current -buffer as BUFFER." - (with-current-buffer (or buffer (current-buffer)) - (if (listp buffer-undo-list) - (length buffer-undo-list) - (buffer-modified-tick))))) - - -;; (@* "CUA workaround") -(defadvice cua-delete-region (around anything-avoid-cua activate) - (ignore-errors ad-do-it)) - -(defadvice copy-region-as-kill (around anything-avoid-cua activate) - (if cua-mode - (ignore-errors ad-do-it) - ad-do-it)) - -;;(@* "Attribute Documentation") -(defun anything-describe-anything-attribute (anything-attribute) - "Display the full documentation of ANYTHING-ATTRIBUTE. -ANYTHING-ATTRIBUTE should be a symbol." - (interactive (list (intern - (completing-read - "Describe anything attribute: " - (mapcar 'symbol-name anything-additional-attributes) - nil t)))) - (with-output-to-temp-buffer "*Help*" - (princ (get anything-attribute 'anything-attrdoc)))) - -(anything-document-attribute 'name "mandatory" - " The name of the source. It is also the heading which appears - above the list of matches from the source. Must be unique.") - -(anything-document-attribute 'header-name "optional" - " A function returning the display string of the header. Its - argument is the name of the source. This attribute is useful to - add an additional information with the source name.") - -(anything-document-attribute 'candidates "mandatory if candidates-in-buffer attribute is not provided" - " Specifies how to retrieve candidates from the source. It can - either be a variable name, a function called with no parameters - or the actual list of candidates. - - The list must be a list whose members are strings, symbols - or (DISPLAY . REAL) pairs. - - In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown - in the Anything buffer, but the REAL one is used as action - argument when the candidate is selected. This allows a more - readable presentation for candidates which would otherwise be, - for example, too long or have a common part shared with other - candidates which can be safely replaced with an abbreviated - string for display purposes. - - Note that if the (DISPLAY . REAL) form is used then pattern - matching is done on the displayed string, not on the real - value. - - If the candidates have to be retrieved asynchronously (for - example, by an external command which takes a while to run) - then the function should start the external command - asynchronously and return the associated process object. - Anything will take care of managing the process (receiving the - output from it, killing it if necessary, etc.). The process - should return candidates matching the current pattern (see - variable `anything-pattern'.) - - Note that currently results from asynchronous sources appear - last in the anything buffer regardless of their position in - `anything-sources'.") - -(anything-document-attribute 'action "mandatory if type attribute is not provided" - " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. - FUNCTION is called with one parameter: the selected candidate. - - An action other than the default can be chosen from this list - of actions for the currently selected candidate (by default - with TAB). The DISPLAY string is shown in the completions - buffer and the FUNCTION is invoked when an action is - selected. The first action of the list is the default.") - -(anything-document-attribute 'coerce "optional" - " It's a function called with one argument: the selected candidate. - - This function is intended for type convertion. - In normal case, the selected candidate (string) is passed to action function. - If coerce function is specified, it is called just before action function. - - Example: converting string to symbol - (coerce . intern)") - -(anything-document-attribute 'type "optional if action attribute is provided" - " Indicates the type of the items the source returns. - - Merge attributes not specified in the source itself from - `anything-type-attributes'. - - This attribute is implemented by plug-in.") - -(anything-document-attribute 'init "optional" - " Function called with no parameters when anything is started. It - is useful for collecting current state information which can be - used to create the list of candidates later. - - For example, if a source needs to work with the current - directory then it can store its value here, because later - anything does its job in the minibuffer and in the - `anything-buffer' and the current directory can be different - there.") - -(anything-document-attribute 'delayed-init "optional" - " Function called with no parameters before candidate function is - called. It is similar with `init' attribute, but its - evaluation is deferred. It is useful to combine with ") - -(anything-document-attribute 'match "optional" - " List of functions called with one parameter: a candidate. The - function should return non-nil if the candidate matches the - current pattern (see variable `anything-pattern'). - - This attribute allows the source to override the default - pattern matching based on `string-match'. It can be used, for - example, to implement a source for file names and do the - pattern matching on the basename of files, since it's more - likely one is typing part of the basename when searching for a - file, instead of some string anywhere else in its path. - - If the list contains more than one function then the list of - matching candidates from the source is constructed by appending - the results after invoking the first function on all the - potential candidates, then the next function, and so on. The - matching candidates supplied by the first function appear first - in the list of results and then results from the other - functions, respectively. - - This attribute has no effect for asynchronous sources (see - attribute `candidates'), since they perform pattern matching - themselves.") - -(anything-document-attribute 'candidate-transformer "optional" - " It's a function or a list of functions called with one argument - when the completion list from the source is built. The argument - is the list of candidates retrieved from the source. The - function should return a transformed list of candidates which - will be used for the actual completion. If it is a list of - functions, it calls each function sequentially. - - This can be used to transform or remove items from the list of - candidates. - - Note that `candidates' is run already, so the given transformer - function should also be able to handle candidates with (DISPLAY - . REAL) format.") - -(anything-document-attribute 'filtered-candidate-transformer "optional" - " It has the same format as `candidate-transformer', except the - function is called with two parameters: the candidate list and - the source. - - This transformer is run on the candidate list which is already - filtered by the current pattern. While `candidate-transformer' - is run only once, it is run every time the input pattern is - changed. - - It can be used to transform the candidate list dynamically, for - example, based on the current pattern. - - In some cases it may also be more efficent to perform candidate - transformation here, instead of with `candidate-transformer' - even if this transformation is done every time the pattern is - changed. For example, if a candidate set is very large then - `candidate-transformer' transforms every candidate while only - some of them will actually be dislpayed due to the limit - imposed by `anything-candidate-number-limit'. - - Note that `candidates' and `candidate-transformer' is run - already, so the given transformer function should also be able - to handle candidates with (DISPLAY . REAL) format. - - This option has no effect for asynchronous sources. (Not yet, - at least.") - -(anything-document-attribute 'action-transformer "optional" - " It's a function or a list of functions called with two - arguments when the action list from the source is - assembled. The first argument is the list of actions, the - second is the current selection. If it is a list of functions, - it calls each function sequentially. - - The function should return a transformed action list. - - This can be used to customize the list of actions based on the - currently selected candidate.") - -(anything-document-attribute 'pattern-transformer "optional" - " It's a function or a list of functions called with one argument - before computing matches. Its argument is `anything-pattern'. - Functions should return transformed `anything-pattern'. - - It is useful to change interpretation of `anything-pattern'.") - -(anything-document-attribute 'delayed "optional" - " Candidates from the source are shown only if the user stops - typing and is idle for `anything-idle-delay' seconds.") - -(anything-document-attribute 'volatile "optional" - " Indicates the source assembles the candidate list dynamically, - so it shouldn't be cached within a single Anything - invocation. It is only applicable to synchronous sources, - because asynchronous sources are not cached.") - -(anything-document-attribute 'requires-pattern "optional" - " If present matches from the source are shown only if the - pattern is not empty. Optionally, it can have an integer - parameter specifying the required length of input which is - useful in case of sources with lots of candidates.") - -(anything-document-attribute 'persistent-action "optional" - " Function called with one parameter; the selected candidate. - - An action performed by `anything-execute-persistent-action'. - If none, use the default action.") - -(anything-document-attribute 'candidates-in-buffer "optional" - " Shortcut attribute for making and narrowing candidates using - buffers. This newly-introduced attribute prevents us from - forgetting to add volatile and match attributes. - - See docstring of `anything-candidates-in-buffer'. - - (candidates-in-buffer) is equivalent of three attributes: - (candidates . anything-candidates-in-buffer) - (volatile) - (match identity) - - (candidates-in-buffer . candidates-function) is equivalent of: - (candidates . candidates-function) - (volatile) - (match identity) - - This attribute is implemented by plug-in.") - -(anything-document-attribute 'search "optional" - " List of functions like `re-search-forward' or `search-forward'. - Buffer search function used by `anything-candidates-in-buffer'. - By default, `anything-candidates-in-buffer' uses `re-search-forward'. - This attribute is meant to be used with - (candidates . anything-candidates-in-buffer) or - (candidates-in-buffer) in short.") - -(anything-document-attribute 'search-from-end "optional" - " Make `anything-candidates-in-buffer' search from the end of buffer. - If this attribute is specified, `anything-candidates-in-buffer' uses - `re-search-backward' instead.") - -(anything-document-attribute 'get-line "optional" - " A function like `buffer-substring-no-properties' or `buffer-substring'. - This function converts point of line-beginning and point of line-end, - which represents a candidate computed by `anything-candidates-in-buffer'. - By default, `anything-candidates-in-buffer' uses - `buffer-substring-no-properties'.") - -(anything-document-attribute 'display-to-real "optional" - " Function called with one parameter; the selected candidate. - - The function transforms the selected candidate, and the result - is passed to the action function. The display-to-real - attribute provides another way to pass other string than one - shown in Anything buffer. - - Traditionally, it is possible to make candidates, - candidate-transformer or filtered-candidate-transformer - function return a list with (DISPLAY . REAL) pairs. But if REAL - can be generated from DISPLAY, display-to-real is more - convenient and faster.") - -(anything-document-attribute 'real-to-display "optional" - " Function called with one parameter; the selected candidate. - - The inverse of display-to-real attribute. - - The function transforms the selected candidate, which is passed - to the action function, for display. The real-to-display - attribute provides the other way to pass other string than one - shown in Anything buffer. - - Traditionally, it is possible to make candidates, - candidate-transformer or filtered-candidate-transformer - function return a list with (DISPLAY . REAL) pairs. But if - DISPLAY can be generated from REAL, real-to-display is more - convenient. - - Note that DISPLAY parts returned from candidates / - candidate-transformer are IGNORED as the name `display-to-real' - says.") - -(anything-document-attribute 'cleanup "optional" - " Function called with no parameters when *anything* buffer is closed. It - is useful for killing unneeded candidates buffer. - - Note that the function is executed BEFORE performing action.") - -(anything-document-attribute 'candidate-number-limit "optional" - " Override `anything-candidate-number-limit' only for this source.") - -(anything-document-attribute 'accept-empty "optional" - " Pass empty string \"\" to action function.") - -(anything-document-attribute 'disable-shortcuts "optional" - " Disable `anything-enable-shortcuts' in current `anything' session. - - This attribute is implemented by plug-in.") - -(anything-document-attribute 'dummy "optional" - " Set `anything-pattern' to candidate. If this attribute is - specified, The candidates attribute is ignored. - - This attribute is implemented by plug-in. - This plug-in implies disable-shortcuts plug-in.") - -(anything-document-attribute 'multiline "optional" - " Enable to selection multiline candidates.") - -(anything-document-attribute 'update "optional" - (substitute-command-keys - " Function called with no parameters when \ -\\\\[anything-force-update] is pressed.")) - -(anything-document-attribute 'mode-line "optional" - " source local `anything-mode-line-string'. (included in `mode-line-format') - It accepts also variable/function name.") - -(anything-document-attribute 'header-line "optional" - " source local `header-line-format'. - It accepts also variable/function name. ") - -(anything-document-attribute - 'resume "optional" - " Function called with no parameters when `anything-resume' is started.") - -(anything-document-attribute 'keymap "optional" - " Specific keymap for this source. - It is useful to have a keymap per source when using more than one source. - Otherwise, a keymap can be set per command with `anything' argument KEYMAP. - NOTE: when a source have `anything-map' as keymap attr, - the global value of `anything-map' will override the actual local one.") - -(anything-document-attribute 'help-message "optional" - " Help message for this source. - If not present, `anything-help-message' value will be used.") - - -;; (@* "Bug Report") -(defvar anything-maintainer-mail-address "emacs-anything@googlegroups.com") - -(defvar anything-bug-report-salutation - "Describe bug below, using a precise recipe. - -When I executed M-x ... - -How to send a bug report: - 1) Be sure to use the LATEST version of anything.el. - 2) Enable debugger. M-x toggle-debug-on-error or (setq debug-on-error t) - 3) Use Lisp version instead of compiled one: (load \"anything.el\") - 4) If you got an error, please paste *Backtrace* buffer. - 5) Type C-c C-c to send.") - -(defvar anything-no-dump-variables - '(anything-candidate-buffer-alist - anything-digit-overlays - anything-help-message - anything-candidate-cache - ) - "Variables not to dump in bug report.") - -(defun anything-dumped-variables-in-bug-report () - (let ((hash (make-hash-table))) - (loop for var in (apropos-internal "anything-" 'boundp) - for vname = (symbol-name var) - unless (or (string-match "-map$" vname) - (string-match "^anything-c-source-" vname) - (string-match "-hash$" vname) - (string-match "-face$" vname) - (memq var anything-no-dump-variables)) - collect var))) - -(defun anything-send-bug-report () - "Send a bug report of anything.el." - (interactive) - (with-current-buffer (or anything-last-buffer - (current-buffer)) - (reporter-submit-bug-report - anything-maintainer-mail-address - "anything.el" - (anything-dumped-variables-in-bug-report) - nil nil - anything-bug-report-salutation))) - -(defun anything-send-bug-report-from-anything () - "Send a bug report of anything.el in anything session." - (interactive) - (anything-run-after-quit 'anything-send-bug-report)) - -;; Debugging function. -(defun* anything-test-candidates - (sources &optional (input "") - (compile-source-functions - anything-compile-source-functions-default)) - "Test helper function for anything. -Given pseudo `anything-sources' and `anything-pattern', returns list like - ((\"source name1\" (\"candidate1\" \"candidate2\")) - (\"source name2\" (\"candidate3\" \"candidate4\")))" - (let ((anything-test-mode t) - anything-enable-shortcuts - anything-candidate-cache - (anything-compile-source-functions compile-source-functions) - anything-before-initialize-hook - anything-after-initialize-hook - anything-update-hook - anything-test-candidate-list) - (get-buffer-create anything-buffer) - (anything-initialize nil input sources) - (anything-update) - ;; test-mode spec: select 1st candidate! - (with-current-buffer anything-buffer - (forward-line 1) - (anything-mark-current-line)) - (prog1 - anything-test-candidate-list - (anything-cleanup)))) - - -;; (@* "Unit Tests") -;; See developer-tools/unit-test-anything.el - -(provide 'anything) - -;; Local Variables: -;; coding: utf-8 -;; End: - -;;; anything.el ends here diff --git a/vendor/anything-config/anything-config.el b/vendor/helm/helm-config.el similarity index 54% rename from vendor/anything-config/anything-config.el rename to vendor/helm/helm-config.el index a218380..4f42d43 100644 --- a/vendor/anything-config/anything-config.el +++ b/vendor/helm/helm-config.el @@ -1,30 +1,33 @@ -;;; anything-config.el --- Applications libary for `anything.el' +;;; helm-config.el --- Applications libary for `helm.el' -;; Filename: anything-config.el +;; Filename: helm-config.el -;; Description: Applications libary for `anything.el' +;; Description: Applications libary for `helm.el' -;; Author: Tassilo Horn +;; Original Author: Tassilo Horn + +;; This is a fork of original `anything-config.el' created by +;; Tassilo Horn . + +;; Maintainers: Thierry Volpiatto +;; Le Wang -;; Maintainer: Tassilo Horn -;; rubikitch -;; Thierry Volpiatto ;; Copyright (C) 2007 ~ 2011, Tassilo Horn, all rights reserved. ;; Copyright (C) 2009, Andy Stewart, all rights reserved. ;; Copyright (C) 2009 ~ 2012, rubikitch, all rights reserved. ;; Copyright (C) 2009 ~ 2012, Thierry Volpiatto, all rights reserved. -;; Created: 2009-02-16 21:38:23 +;; Created: 2012-03-15 12:29:23 -;; X-URL: +;; X-URL: -;; MailingList: +;; MailingList: -;; Keywords: anything, anything-config +;; Keywords: helm, helm-config ;; Compatibility: GNU Emacs 22 ~ 24 -;; Dependencies: `anything.el', `anything-match-plugin.el'. +;; Dependencies: `helm.el', `helm-match-plugin.el'. ;;; This file is NOT part of GNU Emacs @@ -47,31 +50,31 @@ ;;; Commentary: ;; -;; Predefined configurations for `anything.el' +;; Predefined configurations for `helm.el' ;; -;; For quick start, try `anything-for-files' to open files. +;; For quick start, try `helm-for-files' to open files. ;; -;; To configure anything you should define anything command +;; To configure helm you should define helm command ;; with your favorite sources, like below: ;; -;; (defun my-anything () +;; (defun my-helm () ;; (interactive) -;; (anything-other-buffer -;; '(anything-c-source-buffers -;; anything-c-source-file-name-history -;; anything-c-source-info-pages -;; anything-c-source-info-elisp -;; anything-c-source-man-pages -;; anything-c-source-locate -;; anything-c-source-emacs-commands) -;; " *my-anything*")) +;; (helm-other-buffer +;; '(helm-c-source-buffers +;; helm-c-source-file-name-history +;; helm-c-source-info-pages +;; helm-c-source-info-elisp +;; helm-c-source-man-pages +;; helm-c-source-locate +;; helm-c-source-emacs-commands) +;; " *my-helm*")) ;; -;; Then type M-x my-anything to use sources. +;; Then type M-x my-helm to use sources. ;; -;; Defining own command is better than setup `anything-sources' -;; directly, because you can define multiple anything commands with -;; different sources. Each anything command should have own anything -;; buffer, because M-x anything-resume revives anything command. +;; Defining own command is better than setup `helm-sources' +;; directly, because you can define multiple helm commands with +;; different sources. Each helm command should have own helm +;; buffer, because M-x helm-resume revives helm command. ;; NOTE: What you find on Emacswiki is mostly deprecated and not maintained, ;; don't complain if you use such code or configuration and something @@ -82,555 +85,555 @@ ;; --------------------- ;; * Commands defined here are: -;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "anything-" :docstring t) -;; `anything-configuration' -;; Customize `anything'. -;; `anything-c-buffer-help' -;; Help command for anything buffers. -;; `anything-ff-help' -;; Help command for `anything-find-files'. -;; `anything-read-file-name-help' +;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "helm-" :docstring t) +;; `helm-configuration' +;; Customize `helm'. +;; `helm-c-buffer-help' +;; Help command for helm buffers. +;; `helm-ff-help' +;; Help command for `helm-find-files'. +;; `helm-read-file-name-help' ;; Not documented. -;; `anything-generic-file-help' +;; `helm-generic-file-help' ;; Not documented. -;; `anything-grep-help' +;; `helm-grep-help' ;; Not documented. -;; `anything-pdfgrep-help' +;; `helm-pdfgrep-help' ;; Not documented. -;; `anything-etags-help' +;; `helm-etags-help' ;; The help function for etags. -;; `anything-c-ucs-help' -;; Help command for `anything-ucs'. -;; `anything-c-bookmark-help' +;; `helm-c-ucs-help' +;; Help command for `helm-ucs'. +;; `helm-c-bookmark-help' ;; Help command for bookmarks. -;; `anything-show-this-source-only' +;; `helm-show-this-source-only' ;; Show all candidates of this source. -;; `anything-test-sources' -;; List all anything sources for test. -;; `anything-select-source' +;; `helm-test-sources' +;; List all helm sources for test. +;; `helm-select-source' ;; [OBSOLETE] Select source. -;; `anything-insert-buffer-name' +;; `helm-insert-buffer-name' ;; Insert buffer name. -;; `anything-quit-and-find-file' -;; Drop into `anything-find-files' from `anything'. -;; `anything-mark-all' +;; `helm-quit-and-find-file' +;; Drop into `helm-find-files' from `helm'. +;; `helm-mark-all' ;; Mark all visible unmarked candidates in current source. -;; `anything-unmark-all' -;; Unmark all candidates in all sources of current anything session. -;; `anything-toggle-all-marks' +;; `helm-unmark-all' +;; Unmark all candidates in all sources of current helm session. +;; `helm-toggle-all-marks' ;; Toggle all marks. -;; `anything-buffer-diff-persistent' -;; Toggle diff buffer without quitting anything. -;; `anything-buffer-revert-persistent' -;; Revert buffer without quitting anything. -;; `anything-buffer-save-persistent' -;; Save buffer without quitting anything. -;; `anything-buffer-run-kill-buffers' -;; Run kill buffer action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-grep' -;; Run Grep action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-zgrep' -;; Run Grep action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-query-replace-regexp' -;; Run Query replace regexp action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-query-replace' -;; Run Query replace action from `anything-c-source-buffers-list'. -;; `anything-buffer-switch-other-window' -;; Run switch to other window action from `anything-c-source-buffers-list'. -;; `anything-buffer-switch-other-frame' -;; Run switch to other frame action from `anything-c-source-buffers-list'. -;; `anything-buffer-switch-to-elscreen' -;; Run switch to elscreen action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-ediff' -;; Run ediff action from `anything-c-source-buffers-list'. -;; `anything-buffer-run-ediff-merge' -;; Run ediff action from `anything-c-source-buffers-list'. -;; `anything-ff-run-toggle-auto-update' +;; `helm-buffer-diff-persistent' +;; Toggle diff buffer without quitting helm. +;; `helm-buffer-revert-persistent' +;; Revert buffer without quitting helm. +;; `helm-buffer-save-persistent' +;; Save buffer without quitting helm. +;; `helm-buffer-run-kill-buffers' +;; Run kill buffer action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-grep' +;; Run Grep action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-zgrep' +;; Run Grep action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-query-replace-regexp' +;; Run Query replace regexp action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-query-replace' +;; Run Query replace action from `helm-c-source-buffers-list'. +;; `helm-buffer-switch-other-window' +;; Run switch to other window action from `helm-c-source-buffers-list'. +;; `helm-buffer-switch-other-frame' +;; Run switch to other frame action from `helm-c-source-buffers-list'. +;; `helm-buffer-switch-to-elscreen' +;; Run switch to elscreen action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-ediff' +;; Run ediff action from `helm-c-source-buffers-list'. +;; `helm-buffer-run-ediff-merge' +;; Run ediff action from `helm-c-source-buffers-list'. +;; `helm-ff-run-toggle-auto-update' ;; Not documented. -;; `anything-ff-run-switch-to-history' -;; Run Switch to history action from `anything-c-source-find-files'. -;; `anything-ff-run-grep' -;; Run Grep action from `anything-c-source-find-files'. -;; `anything-ff-run-pdfgrep' -;; Run Pdfgrep action from `anything-c-source-find-files'. -;; `anything-ff-run-zgrep' -;; Run Grep action from `anything-c-source-find-files'. -;; `anything-ff-run-copy-file' -;; Run Copy file action from `anything-c-source-find-files'. -;; `anything-ff-run-rename-file' -;; Run Rename file action from `anything-c-source-find-files'. -;; `anything-ff-run-byte-compile-file' -;; Run Byte compile file action from `anything-c-source-find-files'. -;; `anything-ff-run-load-file' -;; Run Load file action from `anything-c-source-find-files'. -;; `anything-ff-run-eshell-command-on-file' -;; Run eshell command on file action from `anything-c-source-find-files'. -;; `anything-ff-run-ediff-file' -;; Run Ediff file action from `anything-c-source-find-files'. -;; `anything-ff-run-ediff-merge-file' -;; Run Ediff merge file action from `anything-c-source-find-files'. -;; `anything-ff-run-symlink-file' -;; Run Symlink file action from `anything-c-source-find-files'. -;; `anything-ff-run-hardlink-file' -;; Run Hardlink file action from `anything-c-source-find-files'. -;; `anything-ff-run-delete-file' -;; Run Delete file action from `anything-c-source-find-files'. -;; `anything-ff-run-complete-fn-at-point' -;; Run complete file name action from `anything-c-source-find-files'. -;; `anything-ff-run-switch-to-eshell' -;; Run switch to eshell action from `anything-c-source-find-files'. -;; `anything-ff-run-switch-other-window' -;; Run switch to other window action from `anything-c-source-find-files'. -;; `anything-ff-run-switch-other-frame' -;; Run switch to other frame action from `anything-c-source-find-files'. -;; `anything-ff-run-open-file-externally' -;; Run open file externally command action from `anything-c-source-find-files'. -;; `anything-ff-run-locate' -;; Run locate action from `anything-c-source-find-files'. -;; `anything-ff-run-gnus-attach-files' -;; Run gnus attach files command action from `anything-c-source-find-files'. -;; `anything-ff-run-etags' -;; Run Etags command action from `anything-c-source-find-files'. -;; `anything-ff-run-print-file' -;; Run Print file action from `anything-c-source-find-files'. -;; `anything-ff-run-toggle-basename' +;; `helm-ff-run-switch-to-history' +;; Run Switch to history action from `helm-c-source-find-files'. +;; `helm-ff-run-grep' +;; Run Grep action from `helm-c-source-find-files'. +;; `helm-ff-run-pdfgrep' +;; Run Pdfgrep action from `helm-c-source-find-files'. +;; `helm-ff-run-zgrep' +;; Run Grep action from `helm-c-source-find-files'. +;; `helm-ff-run-copy-file' +;; Run Copy file action from `helm-c-source-find-files'. +;; `helm-ff-run-rename-file' +;; Run Rename file action from `helm-c-source-find-files'. +;; `helm-ff-run-byte-compile-file' +;; Run Byte compile file action from `helm-c-source-find-files'. +;; `helm-ff-run-load-file' +;; Run Load file action from `helm-c-source-find-files'. +;; `helm-ff-run-eshell-command-on-file' +;; Run eshell command on file action from `helm-c-source-find-files'. +;; `helm-ff-run-ediff-file' +;; Run Ediff file action from `helm-c-source-find-files'. +;; `helm-ff-run-ediff-merge-file' +;; Run Ediff merge file action from `helm-c-source-find-files'. +;; `helm-ff-run-symlink-file' +;; Run Symlink file action from `helm-c-source-find-files'. +;; `helm-ff-run-hardlink-file' +;; Run Hardlink file action from `helm-c-source-find-files'. +;; `helm-ff-run-delete-file' +;; Run Delete file action from `helm-c-source-find-files'. +;; `helm-ff-run-complete-fn-at-point' +;; Run complete file name action from `helm-c-source-find-files'. +;; `helm-ff-run-switch-to-eshell' +;; Run switch to eshell action from `helm-c-source-find-files'. +;; `helm-ff-run-switch-other-window' +;; Run switch to other window action from `helm-c-source-find-files'. +;; `helm-ff-run-switch-other-frame' +;; Run switch to other frame action from `helm-c-source-find-files'. +;; `helm-ff-run-open-file-externally' +;; Run open file externally command action from `helm-c-source-find-files'. +;; `helm-ff-run-locate' +;; Run locate action from `helm-c-source-find-files'. +;; `helm-ff-run-gnus-attach-files' +;; Run gnus attach files command action from `helm-c-source-find-files'. +;; `helm-ff-run-etags' +;; Run Etags command action from `helm-c-source-find-files'. +;; `helm-ff-run-print-file' +;; Run Print file action from `helm-c-source-find-files'. +;; `helm-ff-run-toggle-basename' ;; Not documented. -;; `anything-find-files-down-one-level' +;; `helm-find-files-down-one-level' ;; Go down one level like unix command `cd ..'. -;; `anything-ff-properties-persistent' -;; Show properties without quitting anything. -;; `anything-ff-persistent-delete' +;; `helm-ff-properties-persistent' +;; Show properties without quitting helm. +;; `helm-ff-persistent-delete' ;; Delete current candidate without quitting. -;; `anything-ff-run-kill-buffer-persistent' -;; Execute `anything-ff-kill-buffer-fname' whitout quitting. -;; `anything-ff-rotate-left-persistent' -;; Rotate image left without quitting anything. -;; `anything-ff-rotate-right-persistent' -;; Rotate image right without quitting anything. -;; `anything-c-goto-precedent-file' -;; Go to precedent file in anything grep/etags buffers. -;; `anything-c-goto-next-file' -;; Go to precedent file in anything grep/etags buffers. -;; `anything-c-grep-run-persistent-action' -;; Run grep persistent action from `anything-do-grep-1'. -;; `anything-c-grep-run-default-action' -;; Run grep default action from `anything-do-grep-1'. -;; `anything-c-grep-run-other-window-action' -;; Run grep goto other window action from `anything-do-grep-1'. -;; `anything-c-grep-run-save-buffer' -;; Run grep save results action from `anything-do-grep-1'. -;; `anything-yank-text-at-point' +;; `helm-ff-run-kill-buffer-persistent' +;; Execute `helm-ff-kill-buffer-fname' whitout quitting. +;; `helm-ff-rotate-left-persistent' +;; Rotate image left without quitting helm. +;; `helm-ff-rotate-right-persistent' +;; Rotate image right without quitting helm. +;; `helm-c-goto-precedent-file' +;; Go to precedent file in helm grep/etags buffers. +;; `helm-c-goto-next-file' +;; Go to precedent file in helm grep/etags buffers. +;; `helm-c-grep-run-persistent-action' +;; Run grep persistent action from `helm-do-grep-1'. +;; `helm-c-grep-run-default-action' +;; Run grep default action from `helm-do-grep-1'. +;; `helm-c-grep-run-other-window-action' +;; Run grep goto other window action from `helm-do-grep-1'. +;; `helm-c-grep-run-save-buffer' +;; Run grep save results action from `helm-do-grep-1'. +;; `helm-yank-text-at-point' ;; Yank text at point in minibuffer. -;; `anything-c-bookmark-run-jump-other-window' +;; `helm-c-bookmark-run-jump-other-window' ;; Jump to bookmark from keyboard. -;; `anything-c-bookmark-run-delete' +;; `helm-c-bookmark-run-delete' ;; Delete bookmark from keyboard. -;; `anything-c-bmkext-run-edit' +;; `helm-c-bmkext-run-edit' ;; Run `bmkext-edit-bookmark' from keyboard. -;; `anything-yaoddmuse-cache-pages' +;; `helm-yaoddmuse-cache-pages' ;; Fetch the list of files on emacswiki and create cache file. -;; `anything-eval-new-line-and-indent' +;; `helm-eval-new-line-and-indent' ;; Not documented. -;; `anything-call-source-from-anything' -;; Call anything source within `anything' session. -;; `anything-create-from-anything' -;; Run `anything-create' from `anything' as a fallback. -;; `anything-c-ucs-persistent-insert' +;; `helm-call-source-from-helm' +;; Call helm source within `helm' session. +;; `helm-create-from-helm' +;; Run `helm-create' from `helm' as a fallback. +;; `helm-c-ucs-persistent-insert' ;; Not documented. -;; `anything-c-ucs-persistent-forward' +;; `helm-c-ucs-persistent-forward' ;; Not documented. -;; `anything-c-ucs-persistent-backward' +;; `helm-c-ucs-persistent-backward' ;; Not documented. -;; `anything-c-ucs-persistent-delete' +;; `helm-c-ucs-persistent-delete' ;; Not documented. -;; `anything-lisp-completion-at-point' -;; Anything lisp symbol completion at point. -;; `anything-c-complete-file-name-at-point' +;; `helm-lisp-completion-at-point' +;; Helm lisp symbol completion at point. +;; `helm-c-complete-file-name-at-point' ;; Complete file name at point. -;; `anything-lisp-completion-at-point-or-indent' +;; `helm-lisp-completion-at-point-or-indent' ;; First call indent and second call complete lisp symbol. -;; `anything-lisp-completion-or-file-name-at-point' +;; `helm-lisp-completion-or-file-name-at-point' ;; Complete lisp symbol or filename at point. -;; `anything-w32-shell-execute-open-file' +;; `helm-w32-shell-execute-open-file' ;; Not documented. -;; `anything-c-set-variable' +;; `helm-c-set-variable' ;; Set value to VAR interactively. -;; `anything-c-adaptive-save-history' -;; Save history information to file given by `anything-c-adaptive-history-file'. -;; `anything-c-reset-adaptative-history' -;; Delete all `anything-c-adaptive-history' and his file. -;; `anything-mini' -;; Preconfigured `anything' lightweight version (buffer -> recentf). -;; `anything-for-files' -;; Preconfigured `anything' for opening files. -;; `anything-recentf' -;; Preconfigured `anything' for `recentf'. -;; `anything-info-at-point' -;; Preconfigured `anything' for searching info at point. -;; `anything-show-kill-ring' -;; Preconfigured `anything' for `kill-ring'. -;; `anything-minibuffer-history' -;; Preconfigured `anything' for `minibuffer-history'. -;; `anything-gentoo' -;; Preconfigured `anything' for gentoo linux. -;; `anything-imenu' -;; Preconfigured `anything' for `imenu'. -;; `anything-google-suggest' -;; Preconfigured `anything' for google search with google suggest. -;; `anything-yahoo-suggest' -;; Preconfigured `anything' for Yahoo searching with Yahoo suggest. -;; `anything-for-buffers' -;; Preconfigured `anything' for buffers. -;; `anything-buffers-list' -;; Preconfigured `anything' to list buffers. -;; `anything-bbdb' -;; Preconfigured `anything' for BBDB. -;; `anything-locate' -;; Preconfigured `anything' for Locate. -;; `anything-w3m-bookmarks' -;; Preconfigured `anything' for w3m bookmark. -;; `anything-firefox-bookmarks' -;; Preconfigured `anything' for firefox bookmark. -;; `anything-colors' -;; Preconfigured `anything' for color. -;; `anything-bookmarks' -;; Preconfigured `anything' for bookmarks. -;; `anything-c-pp-bookmarks' -;; Preconfigured `anything' for bookmarks (pretty-printed). -;; `anything-c-insert-latex-math' -;; Preconfigured anything for latex math symbols completion. -;; `anything-register' -;; Preconfigured `anything' for Emacs registers. -;; `anything-man-woman' -;; Preconfigured `anything' for Man and Woman pages. -;; `anything-org-keywords' -;; Preconfigured `anything' for org keywords. -;; `anything-emms' -;; Preconfigured `anything' for emms sources. -;; `anything-eev-anchors' -;; Preconfigured `anything' for eev anchors. -;; `anything-bm-list' -;; Preconfigured `anything' for visible bookmarks. -;; `anything-timers' -;; Preconfigured `anything' for timers. -;; `anything-list-emacs-process' -;; Preconfigured `anything' for emacs process. -;; `anything-occur' -;; Preconfigured Anything for Occur source. -;; `anything-browse-code' -;; Preconfigured anything to browse code. -;; `anything-org-headlines' -;; Preconfigured anything to show org headlines. -;; `anything-regexp' -;; Preconfigured anything to build regexps. -;; `anything-c-copy-files-async' -;; Preconfigured anything to copy file list FLIST to DEST asynchronously. -;; `anything-find-files' -;; Preconfigured `anything' for anything implementation of `find-file'. -;; `anything-write-file' -;; Preconfigured `anything' providing completion for `write-file'. -;; `anything-insert-file' -;; Preconfigured `anything' providing completion for `insert-file'. -;; `anything-dired-rename-file' -;; Preconfigured `anything' to rename files from dired. -;; `anything-dired-copy-file' -;; Preconfigured `anything' to copy files from dired. -;; `anything-dired-symlink-file' -;; Preconfigured `anything' to symlink files from dired. -;; `anything-dired-hardlink-file' -;; Preconfigured `anything' to hardlink files from dired. -;; `anything-do-grep' -;; Preconfigured anything for grep. -;; `anything-do-pdfgrep' -;; Preconfigured anything for pdfgrep. -;; `anything-c-etags-select' -;; Preconfigured anything for etags. -;; `anything-filelist' -;; Preconfigured `anything' to open files instantly. -;; `anything-filelist+' -;; Preconfigured `anything' to open files/buffers/bookmarks instantly. -;; `anything-M-x' -;; Preconfigured `anything' for Emacs commands. -;; `anything-manage-advice' -;; Preconfigured `anything' to disable/enable function advices. -;; `anything-bookmark-ext' -;; Preconfigured `anything' for bookmark-extensions sources. -;; `anything-simple-call-tree' -;; Preconfigured `anything' for simple-call-tree. List function relationships. -;; `anything-mark-ring' -;; Preconfigured `anything' for `anything-c-source-mark-ring'. -;; `anything-global-mark-ring' -;; Preconfigured `anything' for `anything-c-source-global-mark-ring'. -;; `anything-all-mark-rings' -;; Preconfigured `anything' for `anything-c-source-global-mark-ring' and `anything-c-source-mark-ring'. -;; `anything-yaoddmuse-emacswiki-edit-or-view' -;; Preconfigured `anything' to edit or view EmacsWiki page. -;; `anything-yaoddmuse-emacswiki-post-library' -;; Preconfigured `anything' to post library to EmacsWiki. -;; `anything-eval-expression' -;; Preconfigured anything for `anything-c-source-evaluation-result'. -;; `anything-eval-expression-with-eldoc' -;; Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. -;; `anything-calcul-expression' -;; Preconfigured anything for `anything-c-source-calculation-result'. -;; `anything-surfraw' -;; Preconfigured `anything' to search PATTERN with search ENGINE. -;; `anything-call-source' -;; Preconfigured `anything' to call anything source. -;; `anything-execute-anything-command' -;; Preconfigured `anything' to execute preconfigured `anything'. -;; `anything-create' -;; Preconfigured `anything' to do many create actions from STRING. -;; `anything-top' -;; Preconfigured `anything' for top command. -;; `anything-select-xfont' -;; Preconfigured `anything' to select Xfont. -;; `anything-world-time' -;; Preconfigured `anything' to show world time. -;; `anything-apt' -;; Preconfigured `anything' : frontend of APT package manager. -;; `anything-esh-pcomplete' -;; Preconfigured anything to provide anything completion in eshell. -;; `anything-eshell-history' -;; Preconfigured anything for eshell history. -;; `anything-c-run-external-command' -;; Preconfigured `anything' to run External PROGRAM asyncronously from Emacs. -;; `anything-ratpoison-commands' -;; Preconfigured `anything' to execute ratpoison commands. -;; `anything-ucs' -;; Preconfigured anything for `ucs-names' math symbols. -;; `anything-c-apropos' -;; Preconfigured anything to describe commands, functions, variables and faces. -;; `anything-xrandr-set' +;; `helm-c-adaptive-save-history' +;; Save history information to file given by `helm-c-adaptive-history-file'. +;; `helm-c-reset-adaptative-history' +;; Delete all `helm-c-adaptive-history' and his file. +;; `helm-mini' +;; Preconfigured `helm' lightweight version (buffer -> recentf). +;; `helm-for-files' +;; Preconfigured `helm' for opening files. +;; `helm-recentf' +;; Preconfigured `helm' for `recentf'. +;; `helm-info-at-point' +;; Preconfigured `helm' for searching info at point. +;; `helm-show-kill-ring' +;; Preconfigured `helm' for `kill-ring'. +;; `helm-minibuffer-history' +;; Preconfigured `helm' for `minibuffer-history'. +;; `helm-gentoo' +;; Preconfigured `helm' for gentoo linux. +;; `helm-imenu' +;; Preconfigured `helm' for `imenu'. +;; `helm-google-suggest' +;; Preconfigured `helm' for google search with google suggest. +;; `helm-yahoo-suggest' +;; Preconfigured `helm' for Yahoo searching with Yahoo suggest. +;; `helm-for-buffers' +;; Preconfigured `helm' for buffers. +;; `helm-buffers-list' +;; Preconfigured `helm' to list buffers. +;; `helm-bbdb' +;; Preconfigured `helm' for BBDB. +;; `helm-locate' +;; Preconfigured `helm' for Locate. +;; `helm-w3m-bookmarks' +;; Preconfigured `helm' for w3m bookmark. +;; `helm-firefox-bookmarks' +;; Preconfigured `helm' for firefox bookmark. +;; `helm-colors' +;; Preconfigured `helm' for color. +;; `helm-bookmarks' +;; Preconfigured `helm' for bookmarks. +;; `helm-c-pp-bookmarks' +;; Preconfigured `helm' for bookmarks (pretty-printed). +;; `helm-c-insert-latex-math' +;; Preconfigured helm for latex math symbols completion. +;; `helm-register' +;; Preconfigured `helm' for Emacs registers. +;; `helm-man-woman' +;; Preconfigured `helm' for Man and Woman pages. +;; `helm-org-keywords' +;; Preconfigured `helm' for org keywords. +;; `helm-emms' +;; Preconfigured `helm' for emms sources. +;; `helm-eev-anchors' +;; Preconfigured `helm' for eev anchors. +;; `helm-bm-list' +;; Preconfigured `helm' for visible bookmarks. +;; `helm-timers' +;; Preconfigured `helm' for timers. +;; `helm-list-emacs-process' +;; Preconfigured `helm' for emacs process. +;; `helm-occur' +;; Preconfigured Helm for Occur source. +;; `helm-browse-code' +;; Preconfigured helm to browse code. +;; `helm-org-headlines' +;; Preconfigured helm to show org headlines. +;; `helm-regexp' +;; Preconfigured helm to build regexps. +;; `helm-c-copy-files-async' +;; Preconfigured helm to copy file list FLIST to DEST asynchronously. +;; `helm-find-files' +;; Preconfigured `helm' for helm implementation of `find-file'. +;; `helm-write-file' +;; Preconfigured `helm' providing completion for `write-file'. +;; `helm-insert-file' +;; Preconfigured `helm' providing completion for `insert-file'. +;; `helm-dired-rename-file' +;; Preconfigured `helm' to rename files from dired. +;; `helm-dired-copy-file' +;; Preconfigured `helm' to copy files from dired. +;; `helm-dired-symlink-file' +;; Preconfigured `helm' to symlink files from dired. +;; `helm-dired-hardlink-file' +;; Preconfigured `helm' to hardlink files from dired. +;; `helm-do-grep' +;; Preconfigured helm for grep. +;; `helm-do-pdfgrep' +;; Preconfigured helm for pdfgrep. +;; `helm-c-etags-select' +;; Preconfigured helm for etags. +;; `helm-filelist' +;; Preconfigured `helm' to open files instantly. +;; `helm-filelist+' +;; Preconfigured `helm' to open files/buffers/bookmarks instantly. +;; `helm-M-x' +;; Preconfigured `helm' for Emacs commands. +;; `helm-manage-advice' +;; Preconfigured `helm' to disable/enable function advices. +;; `helm-bookmark-ext' +;; Preconfigured `helm' for bookmark-extensions sources. +;; `helm-simple-call-tree' +;; Preconfigured `helm' for simple-call-tree. List function relationships. +;; `helm-mark-ring' +;; Preconfigured `helm' for `helm-c-source-mark-ring'. +;; `helm-global-mark-ring' +;; Preconfigured `helm' for `helm-c-source-global-mark-ring'. +;; `helm-all-mark-rings' +;; Preconfigured `helm' for `helm-c-source-global-mark-ring' and `helm-c-source-mark-ring'. +;; `helm-yaoddmuse-emacswiki-edit-or-view' +;; Preconfigured `helm' to edit or view EmacsWiki page. +;; `helm-yaoddmuse-emacswiki-post-library' +;; Preconfigured `helm' to post library to EmacsWiki. +;; `helm-eval-expression' +;; Preconfigured helm for `helm-c-source-evaluation-result'. +;; `helm-eval-expression-with-eldoc' +;; Preconfigured helm for `helm-c-source-evaluation-result' with `eldoc' support. +;; `helm-calcul-expression' +;; Preconfigured helm for `helm-c-source-calculation-result'. +;; `helm-surfraw' +;; Preconfigured `helm' to search PATTERN with search ENGINE. +;; `helm-call-source' +;; Preconfigured `helm' to call helm source. +;; `helm-execute-helm-command' +;; Preconfigured `helm' to execute preconfigured `helm'. +;; `helm-create' +;; Preconfigured `helm' to do many create actions from STRING. +;; `helm-top' +;; Preconfigured `helm' for top command. +;; `helm-select-xfont' +;; Preconfigured `helm' to select Xfont. +;; `helm-world-time' +;; Preconfigured `helm' to show world time. +;; `helm-apt' +;; Preconfigured `helm' : frontend of APT package manager. +;; `helm-esh-pcomplete' +;; Preconfigured helm to provide helm completion in eshell. +;; `helm-eshell-history' +;; Preconfigured helm for eshell history. +;; `helm-c-run-external-command' +;; Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. +;; `helm-ratpoison-commands' +;; Preconfigured `helm' to execute ratpoison commands. +;; `helm-ucs' +;; Preconfigured helm for `ucs-names' math symbols. +;; `helm-c-apropos' +;; Preconfigured helm to describe commands, functions, variables and faces. +;; `helm-xrandr-set' ;; Not documented. ;; * User variables defined here: -;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "anything-" :var-value t) -;; `anything-c-adaptive-history-file' -;; Default Value: "~/.emacs.d/anything-c-adaptive-history" -;; `anything-c-adaptive-history-length' +;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "helm-" :var-value t) +;; `helm-c-adaptive-history-file' +;; Default Value: "~/.emacs.d/helm-c-adaptive-history" +;; `helm-c-adaptive-history-length' ;; Default Value: 50 -;; `anything-c-google-suggest-url' +;; `helm-c-google-suggest-url' ;; Default Value: "http://google.com/complete/search?output=toolbar&q=" -;; `anything-c-google-suggest-search-url' +;; `helm-c-google-suggest-search-url' ;; Default Value: "http://www.google.com/search?ie=utf-8&oe=utf-8&q=" -;; `anything-google-suggest-use-curl-p' +;; `helm-google-suggest-use-curl-p' ;; Default Value: nil -;; `anything-c-yahoo-suggest-url' +;; `helm-c-yahoo-suggest-url' ;; Default Value: "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=G [...] -;; `anything-c-yahoo-suggest-search-url' +;; `helm-c-yahoo-suggest-search-url' ;; Default Value: "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p=" -;; `anything-c-boring-buffer-regexp' -;; Default Value: "\\ (\\` \\)\\|\\*anything\\|\\*ac-mode\\| \\*Echo Area\\| \\*Minibuf" -;; `anything-c-boring-file-regexp' +;; `helm-c-boring-buffer-regexp' +;; Default Value: "\\ (\\` \\)\\|\\*helm\\|\\*helm-mode\\| \\*Echo Area\\| \\*Minibuf" +;; `helm-c-boring-file-regexp' ;; Default Value: "/\\ (?:\\(?:\\.\\(?:git\\|hg\\|svn\\)\\|CVS\\|_darcs\\)\\)\\(?:/\\|$\\)\\| [...] -;; `anything-kill-ring-threshold' +;; `helm-kill-ring-threshold' ;; Default Value: 10 -;; `anything-c-kill-ring-max-lines-number' +;; `helm-c-kill-ring-max-lines-number' ;; Default Value: nil -;; `anything-su-or-sudo' +;; `helm-su-or-sudo' ;; Default Value: "su" -;; `anything-for-files-prefered-list' -;; Default Value: (anything-c-source-ffap-line anything-c-source-ffap-guesser anything-c-sou [...] -;; `anything-create--actions-private' +;; `helm-for-files-prefered-list' +;; Default Value: (helm-c-source-ffap-line helm-c-source-ffap-guesser helm-c-sou [...] +;; `helm-create--actions-private' ;; Default Value: nil -;; `anything-allow-skipping-current-buffer' +;; `helm-allow-skipping-current-buffer' ;; Default Value: nil -;; `anything-c-enable-eval-defun-hack' +;; `helm-c-enable-eval-defun-hack' ;; Default Value: t -;; `anything-tramp-verbose' +;; `helm-tramp-verbose' ;; Default Value: 0 -;; `anything-raise-command' +;; `helm-raise-command' ;; Default Value: nil -;; `anything-command-map-prefix-key' +;; `helm-command-map-prefix-key' ;; Default Value: " a" -;; `anything-c-browse-code-regexp-lisp' +;; `helm-c-browse-code-regexp-lisp' ;; Default Value: "^ * (def\\(un\\|subst\\|macro\\|face\\|alias\\|advice\\|struct\\|type\\|th [...] -;; `anything-c-browse-code-regexp-python' +;; `helm-c-browse-code-regexp-python' ;; Default Value: "\\\\|\\" -;; `anything-c-browse-code-regexp-alist' +;; `helm-c-browse-code-regexp-alist' ;; Default Value: ((lisp-interaction-mode . "^ *(def\\(un\\|subst\\|macro\\|face\\|alias\\|a [...] -;; `anything-c-external-programs-associations' +;; `helm-c-external-programs-associations' ;; Default Value: nil -;; `anything-ff-auto-update-initial-value' +;; `helm-ff-auto-update-initial-value' ;; Default Value: t -;; `anything-c-copy-async-prefered-emacs' +;; `helm-c-copy-async-prefered-emacs' ;; Default Value: "emacs" -;; `anything-ff-lynx-style-map' +;; `helm-ff-lynx-style-map' ;; Default Value: t -;; `anything-ff-history-max-length' +;; `helm-ff-history-max-length' ;; Default Value: 100 -;; `anything-ff-smart-completion' +;; `helm-ff-smart-completion' ;; Default Value: t -;; `anything-ff-default-kbsize' +;; `helm-ff-default-kbsize' ;; Default Value: 1024.0 -;; `anything-ff-tramp-not-fancy' +;; `helm-ff-tramp-not-fancy' ;; Default Value: t -;; `anything-ff-exif-data-program' +;; `helm-ff-exif-data-program' ;; Default Value: "exiftran" -;; `anything-ff-exif-data-program-args' +;; `helm-ff-exif-data-program-args' ;; Default Value: "-d" -;; `anything-c-grep-use-ioccur-style-keys' +;; `helm-c-grep-use-ioccur-style-keys' ;; Default Value: t -;; `anything-c-pdfgrep-default-read-command' +;; `helm-c-pdfgrep-default-read-command' ;; Default Value: "xpdf '%f' %p" -;; `anything-c-etags-tag-file-name' +;; `helm-c-etags-tag-file-name' ;; Default Value: "TAGS" -;; `anything-c-etags-tag-file-search-limit' +;; `helm-c-etags-tag-file-search-limit' ;; Default Value: 10 -;; `anything-c-etags-use-regexp-search' +;; `helm-c-etags-use-regexp-search' ;; Default Value: nil -;; `anything-c-etags-search-regexp' +;; `helm-c-etags-search-regexp' ;; Default Value: "^.+: .+ \\<%s" -;; `anything-c-filelist-file-name' +;; `helm-c-filelist-file-name' ;; Default Value: nil -;; `anything-c-eldoc-in-minibuffer-show-fn' -;; Default Value: anything-c-show-info-in-mode-line -;; `anything-c-turn-on-show-completion' +;; `helm-c-eldoc-in-minibuffer-show-fn' +;; Default Value: helm-c-show-info-in-mode-line +;; `helm-c-turn-on-show-completion' ;; Default Value: t -;; `anything-c-show-completion-use-special-display' +;; `helm-c-show-completion-use-special-display' ;; Default Value: t -;; `anything-c-show-completion-min-window-height' +;; `helm-c-show-completion-min-window-height' ;; Default Value: 7 -;; `anything-lisp-completion-or-indent-delay' +;; `helm-lisp-completion-or-indent-delay' ;; Default Value: 0.6 -;; `anything-c-default-external-file-browser' +;; `helm-c-default-external-file-browser' ;; Default Value: "nautilus" -;; `anything-c-use-adaptative-sorting' +;; `helm-c-use-adaptative-sorting' ;; Default Value: nil -;; `anything-ff-newfile-prompt-p' +;; `helm-ff-newfile-prompt-p' ;; Default Value: t -;; `anything-ff-avfs-directory' +;; `helm-ff-avfs-directory' ;; Default Value: nil -;; `anything-ff-file-compressed-list' +;; `helm-ff-file-compressed-list' ;; Default Value: ("gz" "bz2" "zip" "7z") -;; `anything-locate-db-file-regexp' +;; `helm-locate-db-file-regexp' ;; Default Value: "m?locate.db$" -;; `anything-c-locate-command' +;; `helm-c-locate-command' ;; Default Value: nil -;; `anything-c-show-info-in-mode-line-delay' +;; `helm-c-show-info-in-mode-line-delay' ;; Default Value: 12 -;; `anything-c-copy-files-async-log-file' +;; `helm-c-copy-files-async-log-file' ;; Default Value: "/tmp/dired.log" -;; `anything-ff-printer-list' +;; `helm-ff-printer-list' ;; Default Value: nil -;; `anything-ff-transformer-show-only-basename' +;; `helm-ff-transformer-show-only-basename' ;; Default Value: nil -;; `anything-ff-quick-delete-dont-prompt-for-deletion' +;; `helm-ff-quick-delete-dont-prompt-for-deletion' ;; Default Value: nil -;; `anything-ff-signal-error-on-dot-files' +;; `helm-ff-signal-error-on-dot-files' ;; Default Value: t -;; `anything-completing-read-handlers-alist' -;; Default Value: ((describe-function . anything-completing-read-symbols) (describe-variabl [...] +;; `helm-completing-read-handlers-alist' +;; Default Value: ((describe-function . helm-completing-read-symbols) (describe-variabl [...] -;; * Anything sources defined here: -;; [EVAL] (autodoc-document-lisp-buffer :type 'anything-source :prefix "anything-" :any-sname t) -;; `anything-c-source-regexp' (Regexp Builder) -;; `anything-c-source-buffers' (Buffers) -;; `anything-c-source-buffer-not-found' (Create buffer) -;; `anything-c-source-buffers-list' (Buffers) -;; `anything-c-source-file-name-history' (File Name History) -;; `anything-c-source-files-in-current-dir' (Files from Current Directory) -;; `anything-c-source-files-in-current-dir+' (Files from Current Directory) -;; `anything-c-source-find-files' (Find Files) -;; `anything-c-source-write-file' (Write File) -;; `anything-c-source-insert-file' (Insert File) -;; `anything-c-source-copy-files' (Copy Files) -;; `anything-c-source-symlink-files' (Symlink Files) -;; `anything-c-source-hardlink-files' (Hardlink Files) -;; `anything-c-source-file-cache' (File Cache) -;; `anything-c-source-locate' (Locate) -;; `anything-c-source-recentf' (Recentf) -;; `anything-c-source-ffap-guesser' (File at point) -;; `anything-c-source-ffap-line' (File/Lineno at point) -;; `anything-c-source-files-in-all-dired' (Files in all dired buffer.) -;; `anything-c-source-filelist' (FileList) -;; `anything-c-source-info-pages' (Info Pages) -;; `anything-c-source-man-pages' (Manual Pages) -;; `anything-c-source-complex-command-history' (Complex Command History) -;; `anything-c-source-extended-command-history' (Emacs Commands History) -;; `anything-c-source-emacs-commands' (Emacs Commands) -;; `anything-c-source-emacs-functions' (Emacs Functions) -;; `anything-c-source-emacs-functions-with-abbrevs' (Emacs Functions) -;; `anything-c-source-advice' (Function Advice) -;; `anything-c-source-emacs-variables' (Emacs Variables) -;; `anything-c-source-lacarte' (Lacarte) -;; `anything-c-source-bookmarks' (Bookmarks) -;; `anything-c-source-bookmark-set' (Set Bookmark) -;; `anything-c-source-bm' (Visible Bookmarks) -;; `anything-c-source-bookmarks-ssh' (Bookmarks-ssh) -;; `anything-c-source-bookmarks-su' (Bookmarks-root) -;; `anything-c-source-bookmarks-local' (Bookmarks-Local) -;; `anything-c-source-bmkext-addressbook' (Bookmark Addressbook) -;; `anything-c-source-bookmark-w3m' (Bookmark W3m) -;; `anything-c-source-bookmark-images' (Bookmark Images) -;; `anything-c-source-bookmark-man' (Bookmark Woman&Man) -;; `anything-c-source-bookmark-gnus' (Bookmark Gnus) -;; `anything-c-source-bookmark-info' (Bookmark Info) -;; `anything-c-source-bookmark-files&dirs' (Bookmark Files&Directories) -;; `anything-c-source-bookmark-su-files&dirs' (Bookmark Root-Files&Directories) -;; `anything-c-source-bookmark-ssh-files&dirs' (Bookmark Ssh-Files&Directories) -;; `anything-c-source-firefox-bookmarks' (Firefox Bookmarks) -;; `anything-c-source-w3m-bookmarks' (W3m Bookmarks) -;; `anything-c-source-elisp-library-scan' (Elisp libraries (Scan)) -;; `anything-c-source-imenu' (Imenu) -;; `anything-c-source-ctags' (Exuberant ctags) -;; `anything-c-source-etags-select' (Etags) -;; `anything-c-source-semantic' (Semantic Tags) -;; `anything-c-source-simple-call-tree-functions-callers' (Function is called by) -;; `anything-c-source-simple-call-tree-callers-functions' (Function calls) -;; `anything-c-source-commands-and-options-in-file' (Commands/Options in file) -;; `anything-c-source-customize-face' (Customize Face) -;; `anything-c-source-colors' (Colors) -;; `anything-c-source-tracker-search' (Tracker Search) -;; `anything-c-source-mac-spotlight' (mdfind) -;; `anything-c-source-picklist' (Picklist) -;; `anything-c-source-kill-ring' (Kill Ring) -;; `anything-c-source-mark-ring' (mark-ring) -;; `anything-c-source-global-mark-ring' (global-mark-ring) -;; `anything-c-source-register' (Registers) -;; `anything-c-source-latex-math' (Latex Math Menu) -;; `anything-c-source-fixme' (TODO/FIXME/DRY comments) -;; `anything-c-source-rd-headline' (RD HeadLine) -;; `anything-c-source-oddmuse-headline' (Oddmuse HeadLine) -;; `anything-c-source-emacs-source-defun' (Emacs Source DEFUN) -;; `anything-c-source-emacs-lisp-expectations' (Emacs Lisp Expectations) -;; `anything-c-source-emacs-lisp-toplevels' (Emacs Lisp Toplevel / Level 4 Comment / Linkd Star) -;; `anything-c-source-yaoddmuse-emacswiki-edit-or-view' (Yaoddmuse Edit or View (EmacsWiki)) -;; `anything-c-source-yaoddmuse-emacswiki-post-library' (Yaoddmuse Post library (EmacsWiki)) -;; `anything-c-source-eev-anchor' (Anchors) -;; `anything-c-source-org-headline' (Org HeadLine) -;; `anything-c-source-org-keywords' (Org Keywords) -;; `anything-c-source-bbdb' (BBDB) -;; `anything-c-source-evaluation-result' (Evaluation Result) -;; `anything-c-source-calculation-result' (Calculation Result) -;; `anything-c-source-google-suggest' (Google Suggest) -;; `anything-c-source-yahoo-suggest' (Yahoo Suggest) -;; `anything-c-source-emms-streams' (Emms Streams) -;; `anything-c-source-emms-dired' (Music Directory) -;; `anything-c-source-emms-files' (Emms files) -;; `anything-c-source-jabber-contacts' (Jabber Contacts) -;; `anything-c-source-call-source' (Call anything source) -;; `anything-c-source-anything-commands' (Preconfigured Anything) -;; `anything-c-source-occur' (Occur) -;; `anything-c-source-browse-code' (Browse code) -;; `anything-c-source-create' (Create) -;; `anything-c-source-minibuffer-history' (Minibuffer History) -;; `anything-c-source-elscreen' (Elscreen) -;; `anything-c-source-top' (Top (Press C-c C-u to refresh)) -;; `anything-c-source-absolute-time-timers' (Absolute Time Timers) -;; `anything-c-source-idle-time-timers' (Idle Time Timers) -;; `anything-c-source-xrandr-change-resolution' (Change Resolution) -;; `anything-c-source-xfonts' (X Fonts) -;; `anything-c-source-ucs' (Ucs names) -;; `anything-c-source-emacs-process' (Emacs Process) -;; `anything-c-source-time-world' (Time World List) -;; `anything-c-source-apt' (APT) -;; `anything-c-source-gentoo' (Portage sources) -;; `anything-c-source-use-flags' (Use Flags) -;; `anything-c-source-ratpoison-commands' (Ratpoison Commands) -;; `anything-c-source-esh' (Eshell completions) -;; `anything-c-source-eshell-history' (Eshell history) +;; * Helm sources defined here: +;; [EVAL] (autodoc-document-lisp-buffer :type 'helm-source :prefix "helm-" :any-sname t) +;; `helm-c-source-regexp' (Regexp Builder) +;; `helm-c-source-buffers' (Buffers) +;; `helm-c-source-buffer-not-found' (Create buffer) +;; `helm-c-source-buffers-list' (Buffers) +;; `helm-c-source-file-name-history' (File Name History) +;; `helm-c-source-files-in-current-dir' (Files from Current Directory) +;; `helm-c-source-files-in-current-dir+' (Files from Current Directory) +;; `helm-c-source-find-files' (Find Files) +;; `helm-c-source-write-file' (Write File) +;; `helm-c-source-insert-file' (Insert File) +;; `helm-c-source-copy-files' (Copy Files) +;; `helm-c-source-symlink-files' (Symlink Files) +;; `helm-c-source-hardlink-files' (Hardlink Files) +;; `helm-c-source-file-cache' (File Cache) +;; `helm-c-source-locate' (Locate) +;; `helm-c-source-recentf' (Recentf) +;; `helm-c-source-ffap-guesser' (File at point) +;; `helm-c-source-ffap-line' (File/Lineno at point) +;; `helm-c-source-files-in-all-dired' (Files in all dired buffer.) +;; `helm-c-source-filelist' (FileList) +;; `helm-c-source-info-pages' (Info Pages) +;; `helm-c-source-man-pages' (Manual Pages) +;; `helm-c-source-complex-command-history' (Complex Command History) +;; `helm-c-source-extended-command-history' (Emacs Commands History) +;; `helm-c-source-emacs-commands' (Emacs Commands) +;; `helm-c-source-emacs-functions' (Emacs Functions) +;; `helm-c-source-emacs-functions-with-abbrevs' (Emacs Functions) +;; `helm-c-source-advice' (Function Advice) +;; `helm-c-source-emacs-variables' (Emacs Variables) +;; `helm-c-source-lacarte' (Lacarte) +;; `helm-c-source-bookmarks' (Bookmarks) +;; `helm-c-source-bookmark-set' (Set Bookmark) +;; `helm-c-source-bm' (Visible Bookmarks) +;; `helm-c-source-bookmarks-ssh' (Bookmarks-ssh) +;; `helm-c-source-bookmarks-su' (Bookmarks-root) +;; `helm-c-source-bookmarks-local' (Bookmarks-Local) +;; `helm-c-source-bmkext-addressbook' (Bookmark Addressbook) +;; `helm-c-source-bookmark-w3m' (Bookmark W3m) +;; `helm-c-source-bookmark-images' (Bookmark Images) +;; `helm-c-source-bookmark-man' (Bookmark Woman&Man) +;; `helm-c-source-bookmark-gnus' (Bookmark Gnus) +;; `helm-c-source-bookmark-info' (Bookmark Info) +;; `helm-c-source-bookmark-files&dirs' (Bookmark Files&Directories) +;; `helm-c-source-bookmark-su-files&dirs' (Bookmark Root-Files&Directories) +;; `helm-c-source-bookmark-ssh-files&dirs' (Bookmark Ssh-Files&Directories) +;; `helm-c-source-firefox-bookmarks' (Firefox Bookmarks) +;; `helm-c-source-w3m-bookmarks' (W3m Bookmarks) +;; `helm-c-source-elisp-library-scan' (Elisp libraries (Scan)) +;; `helm-c-source-imenu' (Imenu) +;; `helm-c-source-ctags' (Exuberant ctags) +;; `helm-c-source-etags-select' (Etags) +;; `helm-c-source-semantic' (Semantic Tags) +;; `helm-c-source-simple-call-tree-functions-callers' (Function is called by) +;; `helm-c-source-simple-call-tree-callers-functions' (Function calls) +;; `helm-c-source-commands-and-options-in-file' (Commands/Options in file) +;; `helm-c-source-customize-face' (Customize Face) +;; `helm-c-source-colors' (Colors) +;; `helm-c-source-tracker-search' (Tracker Search) +;; `helm-c-source-mac-spotlight' (mdfind) +;; `helm-c-source-picklist' (Picklist) +;; `helm-c-source-kill-ring' (Kill Ring) +;; `helm-c-source-mark-ring' (mark-ring) +;; `helm-c-source-global-mark-ring' (global-mark-ring) +;; `helm-c-source-register' (Registers) +;; `helm-c-source-latex-math' (Latex Math Menu) +;; `helm-c-source-fixme' (TODO/FIXME/DRY comments) +;; `helm-c-source-rd-headline' (RD HeadLine) +;; `helm-c-source-oddmuse-headline' (Oddmuse HeadLine) +;; `helm-c-source-emacs-source-defun' (Emacs Source DEFUN) +;; `helm-c-source-emacs-lisp-expectations' (Emacs Lisp Expectations) +;; `helm-c-source-emacs-lisp-toplevels' (Emacs Lisp Toplevel / Level 4 Comment / Linkd Star) +;; `helm-c-source-yaoddmuse-emacswiki-edit-or-view' (Yaoddmuse Edit or View (EmacsWiki)) +;; `helm-c-source-yaoddmuse-emacswiki-post-library' (Yaoddmuse Post library (EmacsWiki)) +;; `helm-c-source-eev-anchor' (Anchors) +;; `helm-c-source-org-headline' (Org HeadLine) +;; `helm-c-source-org-keywords' (Org Keywords) +;; `helm-c-source-bbdb' (BBDB) +;; `helm-c-source-evaluation-result' (Evaluation Result) +;; `helm-c-source-calculation-result' (Calculation Result) +;; `helm-c-source-google-suggest' (Google Suggest) +;; `helm-c-source-yahoo-suggest' (Yahoo Suggest) +;; `helm-c-source-emms-streams' (Emms Streams) +;; `helm-c-source-emms-dired' (Music Directory) +;; `helm-c-source-emms-files' (Emms files) +;; `helm-c-source-jabber-contacts' (Jabber Contacts) +;; `helm-c-source-call-source' (Call helm source) +;; `helm-c-source-helm-commands' (Preconfigured Helm) +;; `helm-c-source-occur' (Occur) +;; `helm-c-source-browse-code' (Browse code) +;; `helm-c-source-create' (Create) +;; `helm-c-source-minibuffer-history' (Minibuffer History) +;; `helm-c-source-elscreen' (Elscreen) +;; `helm-c-source-top' (Top (Press C-c C-u to refresh)) +;; `helm-c-source-absolute-time-timers' (Absolute Time Timers) +;; `helm-c-source-idle-time-timers' (Idle Time Timers) +;; `helm-c-source-xrandr-change-resolution' (Change Resolution) +;; `helm-c-source-xfonts' (X Fonts) +;; `helm-c-source-ucs' (Ucs names) +;; `helm-c-source-emacs-process' (Emacs Process) +;; `helm-c-source-time-world' (Time World List) +;; `helm-c-source-apt' (APT) +;; `helm-c-source-gentoo' (Portage sources) +;; `helm-c-source-use-flags' (Use Flags) +;; `helm-c-source-ratpoison-commands' (Ratpoison Commands) +;; `helm-c-source-esh' (Eshell completions) +;; `helm-c-source-eshell-history' (Eshell history) ;; *** END auto-documentation @@ -638,7 +641,7 @@ ;; ;; Install developer-tools/autodoc.el and ;; Evaluate (autodoc-update-all) before commit or run it interactively. -;; This function generates anything-c-source-* / functions / options list. +;; This function generates helm-c-source-* / functions / options list. ;; ;; [EVAL IT] (autodoc-update-all) ;; @@ -650,10 +653,10 @@ ;;; Change log: ;; ;; Change log of this file is found at -;; http://repo.or.cz/w/anything-config.git/history/master:/anything-config.el +;; http://repo.or.cz/w/helm-config.git/history/master:/helm-config.el ;; ;; Change log of this project is found at -;; http://repo.or.cz/w/anything-config.git?a=shortlog +;; http://repo.or.cz/w/helm-config.git?a=shortlog ;;; Contributors: ;; @@ -683,7 +686,7 @@ ;;; Require ;; ;; -(require 'anything) +(require 'helm) (require 'thingatpt) (require 'ffap) (require 'cl) @@ -696,7 +699,7 @@ (require 'xml) (eval-when-compile (require 'org)) ; Shut up byte compiler about org-directory. (eval-when-compile (require 'semantic nil t)) -(require 'anything-match-plugin) +(require 'helm-match-plugin) @@ -796,71 +799,71 @@ was called." ;;; Customize ;; ;; -(defgroup anything-config nil - "Predefined configurations for `anything.el'." - :group 'anything) +(defgroup helm-config nil + "Predefined configurations for `helm.el'." + :group 'helm) -(defcustom anything-c-adaptive-history-file - "~/.emacs.d/anything-c-adaptive-history" +(defcustom helm-c-adaptive-history-file + "~/.emacs.d/helm-c-adaptive-history" "Path of file where history information is stored." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-adaptive-history-length 50 +(defcustom helm-c-adaptive-history-length 50 "Maximum number of candidates stored for a source." :type 'number - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-google-suggest-url +(defcustom helm-c-google-suggest-url "http://google.com/complete/search?output=toolbar&q=" "URL used for looking up Google suggestions." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-google-suggest-search-url +(defcustom helm-c-google-suggest-search-url "http://www.google.com/search?ie=utf-8&oe=utf-8&q=" "URL used for Google searching." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-google-suggest-use-curl-p nil - "When non--nil use CURL to get info from `anything-c-google-suggest-url'. +(defcustom helm-google-suggest-use-curl-p nil + "When non--nil use CURL to get info from `helm-c-google-suggest-url'. Otherwise `url-retrieve-synchronously' is used." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-yahoo-suggest-url +(defcustom helm-c-yahoo-suggest-url "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=Generic&query=" "Url used for looking up Yahoo suggestions." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-yahoo-suggest-search-url +(defcustom helm-c-yahoo-suggest-search-url "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p=" "Url used for Yahoo searching." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-boring-buffer-regexp +(defcustom helm-c-boring-buffer-regexp (rx (or (group bos " ") - ;; anything-buffers - "*anything" "*ac-mode" + ;; helm-buffers + "*helm" "*helm-mode" ;; echo area " *Echo Area" " *Minibuf")) "The regexp that match boring buffers. Buffer candidates matching this regular expression will be filtered from the list of candidates if the -`anything-c-skip-boring-buffers' candidate transformer is used, or +`helm-c-skip-boring-buffers' candidate transformer is used, or they will be displayed with face `file-name-shadow' if -`anything-c-shadow-boring-buffers' is used." +`helm-c-shadow-boring-buffers' is used." :type 'string - :group 'anything-config) -;; (string-match anything-c-boring-buffer-regexp "buf") -;; (string-match anything-c-boring-buffer-regexp " hidden") -;; (string-match anything-c-boring-buffer-regexp " *Minibuf-1*") + :group 'helm-config) +;; (string-match helm-c-boring-buffer-regexp "buf") +;; (string-match helm-c-boring-buffer-regexp " hidden") +;; (string-match helm-c-boring-buffer-regexp " *Minibuf-1*") -(defcustom anything-c-boring-file-regexp +(defcustom helm-c-boring-file-regexp (rx (or ;; Boring directories (and "/" (or ".svn" "CVS" "_darcs" ".git" ".hg") (or "/" eol)) @@ -870,315 +873,297 @@ they will be displayed with face `file-name-shadow' if "The regexp that match boring files. File candidates matching this regular expression will be filtered from the list of candidates if the -`anything-c-skip-boring-files' candidate transformer is used, or +`helm-c-skip-boring-files' candidate transformer is used, or they will be displayed with face `file-name-shadow' if -`anything-c-shadow-boring-files' is used." +`helm-c-shadow-boring-files' is used." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-kill-ring-threshold 10 - "Minimum length to be listed by `anything-c-source-kill-ring'." +(defcustom helm-kill-ring-threshold 10 + "Minimum length to be listed by `helm-c-source-kill-ring'." :type 'integer - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-kill-ring-max-lines-number nil +(defcustom helm-c-kill-ring-max-lines-number nil "Max number of lines displayed per candidate in kill-ring browser. If nil or zero, don't truncate candidate, show all." :type 'integer - :group 'anything-config) + :group 'helm-config) -(defcustom anything-su-or-sudo "su" +(defcustom helm-su-or-sudo "su" "What command to use for root access." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-for-files-prefered-list - '(anything-c-source-ffap-line - anything-c-source-ffap-guesser - anything-c-source-buffers-list - anything-c-source-recentf - anything-c-source-bookmarks - anything-c-source-file-cache - anything-c-source-files-in-current-dir+ - anything-c-source-locate) +(defcustom helm-for-files-prefered-list + '(helm-c-source-ffap-line + helm-c-source-ffap-guesser + helm-c-source-buffers-list + helm-c-source-recentf + helm-c-source-bookmarks + helm-c-source-file-cache + helm-c-source-files-in-current-dir+ + helm-c-source-locate) "Your prefered sources to find files." :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-create--actions-private nil - "User defined actions for `anything-create' / `anything-c-source-create'. +(defcustom helm-create--actions-private nil + "User defined actions for `helm-create' / `helm-c-source-create'. It is a list of (DISPLAY . FUNCTION) pairs like `action' -attribute of `anything-sources'. +attribute of `helm-sources'. It is prepended to predefined pairs." :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-allow-skipping-current-buffer nil - "Show current buffer or not in anything buffer" +(defcustom helm-allow-skipping-current-buffer nil + "Show current buffer or not in helm buffer" :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-enable-eval-defun-hack t - "If non-nil, execute `anything' using the source at point when C-M-x is pressed. +(defcustom helm-c-enable-eval-defun-hack t + "If non-nil, execute `helm' using the source at point when C-M-x is pressed. This hack is invoked when pressing C-M-x in the form \ - (defvar anything-c-source-XXX ...) or (setq anything-c-source-XXX ...)." + (defvar helm-c-source-XXX ...) or (setq helm-c-source-XXX ...)." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-tramp-verbose 0 - "Just like `tramp-verbose' but specific to anything. -When set to 0 don't show tramp messages in anything. +(defcustom helm-tramp-verbose 0 + "Just like `tramp-verbose' but specific to helm. +When set to 0 don't show tramp messages in helm. If you want to have the default tramp messages set it to 3." :type 'integer - :group 'anything-config) + :group 'helm-config) -(defcustom anything-raise-command nil +(defcustom helm-raise-command nil "A shell command to jump to a window running specific program. Need external program wmctrl. This will be use with `format', so use something like \"wmctrl -xa %s\"." :type 'string - :group 'anything-config) + :group 'helm-config) -(defun anything-set-anything-command-map-prefix-key (var key) - "The customize set function for `anything-command-map-prefix-key'." +(defun helm-set-helm-command-map-prefix-key (var key) + "The customize set function for `helm-command-map-prefix-key'." (when (boundp var) (define-key global-map (read-kbd-macro (symbol-value var)) nil)) (set var key) (define-key global-map - (read-kbd-macro (symbol-value var)) 'anything-command-map)) + (read-kbd-macro (symbol-value var)) 'helm-command-map)) -(defcustom anything-command-map-prefix-key "C-x c" - "The prefix key for all `anything-command-map' commands." +(defcustom helm-command-map-prefix-key "C-x c" + "The prefix key for all `helm-command-map' commands." :type 'string - :set 'anything-set-anything-command-map-prefix-key - :group 'anything-config) + :set 'helm-set-helm-command-map-prefix-key + :group 'helm-config) -(defcustom anything-c-browse-code-regexp-lisp +(defcustom helm-c-browse-code-regexp-lisp "^ *\(def\\(un\\|subst\\|macro\\|face\\|alias\\|advice\\|struct\\|\ type\\|theme\\|var\\|group\\|custom\\|const\\|method\\|class\\)" "Regexp used to parse lisp buffer when browsing code." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-browse-code-regexp-python +(defcustom helm-c-browse-code-regexp-python "\\\\|\\" "Regexp used to parse python buffer when browsing code." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-browse-code-regexp-alist - `((lisp-interaction-mode . ,anything-c-browse-code-regexp-lisp) - (emacs-lisp-mode . ,anything-c-browse-code-regexp-lisp) - (lisp-mode . ,anything-c-browse-code-regexp-lisp) - (python-mode . ,anything-c-browse-code-regexp-python)) +(defcustom helm-c-browse-code-regexp-alist + `((lisp-interaction-mode . ,helm-c-browse-code-regexp-lisp) + (emacs-lisp-mode . ,helm-c-browse-code-regexp-lisp) + (lisp-mode . ,helm-c-browse-code-regexp-lisp) + (python-mode . ,helm-c-browse-code-regexp-python)) "Alist to store regexps for browsing code corresponding \ to a specific `major-mode'." :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-external-programs-associations nil +(defcustom helm-c-external-programs-associations nil "Alist to store externals programs associated with file extension. This variable overhide setting in .mailcap file. e.g : '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) " :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-auto-update-initial-value t +(defcustom helm-ff-auto-update-initial-value t "Auto update when only one candidate directory is matched. -This is the default value when starting `anything-find-files'." - :group 'anything-config +This is the default value when starting `helm-find-files'." + :group 'helm-config :type 'boolean) -(defcustom anything-c-copy-async-prefered-emacs "emacs" +(defcustom helm-c-copy-async-prefered-emacs "emacs" "Path to the emacs you want to use for copying async. Emacs versions < 24 fail to copy directory due to a bug not fixed in `copy-directory'." - :group 'anything-config + :group 'helm-config :type 'string) -(defcustom anything-ff-lynx-style-map t - "Use arrow keys to navigate with `anything-find-files'. -You will have to restart Emacs or reeval `anything-find-files-map' -and `anything-c-read-file-map' for this take effect." - :group 'anything-config +(defcustom helm-ff-lynx-style-map t + "Use arrow keys to navigate with `helm-find-files'. +You will have to restart Emacs or reeval `helm-find-files-map' +and `helm-c-read-file-map' for this take effect." + :group 'helm-config :type 'boolean) -(defcustom anything-ff-history-max-length 100 - "Number of elements shown in `anything-find-files' history." - :group 'anything-config +(defcustom helm-ff-history-max-length 100 + "Number of elements shown in `helm-find-files' history." + :group 'helm-config :type 'integer) -(defcustom anything-ff-smart-completion t +(defcustom helm-ff-smart-completion t "Try to complete filenames smarter when non--nil. -See `anything-ff-transform-fname-for-completion' for more info." - :group 'anything-config +See `helm-ff-transform-fname-for-completion' for more info." + :group 'helm-config :type 'boolean) -(defcustom anything-ff-default-kbsize 1024.0 +(defcustom helm-ff-default-kbsize 1024.0 "Default Kbsize to use for showing files size. It is a float, usually 1024.0 but could be 1000.0 on some systems." - :group 'anything-config + :group 'helm-config :type 'float) -(defcustom anything-ff-tramp-not-fancy t +(defcustom helm-ff-tramp-not-fancy t "No colors when listing remote files when set to non--nil. This make listing much faster, specially on slow machines." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-ff-exif-data-program "exiftran" +(defcustom helm-ff-exif-data-program "exiftran" "Program used to extract exif data of an image file." - :group 'anything-config + :group 'helm-config :type 'string) -(defcustom anything-ff-exif-data-program-args "-d" - "*Arguments used for `anything-ff-exif-data-program'." - :group 'anything-config +(defcustom helm-ff-exif-data-program-args "-d" + "*Arguments used for `helm-ff-exif-data-program'." + :group 'helm-config :type 'string) -(defcustom anything-c-grep-use-ioccur-style-keys t +(defcustom helm-c-grep-use-ioccur-style-keys t "Use Arrow keys to jump to occurences." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-c-pdfgrep-default-read-command "xpdf '%f' %p" +(defcustom helm-c-pdfgrep-default-read-command "xpdf '%f' %p" "Default command to read pdf files from pdfgrep. Where '%f' format spec is filename and '%p' is page number" - :group 'anything-config + :group 'helm-config :type 'string) -(defcustom anything-c-etags-tag-file-name "TAGS" +(defcustom helm-c-etags-tag-file-name "TAGS" "Etags tag file name." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-etags-tag-file-search-limit 10 +(defcustom helm-c-etags-tag-file-search-limit 10 "The limit level of directory to search tag file. Don't search tag file deeply if outside this value." :type 'number - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-etags-use-regexp-search nil +(defcustom helm-c-etags-use-regexp-search nil "When non--nil search etags candidates by regexp. -This disable anything-match-plugin when enabled. +This disable helm-match-plugin when enabled. When nil search is performed directly on patter and *match-plugin is used -if available. You can customize `anything-c-etags-search-regexp'." - :group 'anything-config +if available. You can customize `helm-c-etags-search-regexp'." + :group 'helm-config :type 'boolean) -(defcustom anything-c-etags-search-regexp "^.+: .+ \\<%s" - "Regexp that match tags in an anything etags buffer. +(defcustom helm-c-etags-search-regexp "^.+: .+ \\<%s" + "Regexp that match tags in an helm etags buffer. The format spec is replaced by pattern. -This regexp have no effect when `anything-c-etags-use-regexp-search' +This regexp have no effect when `helm-c-etags-use-regexp-search' is nil." - :group 'anything-config + :group 'helm-config :type 'regexp) -(defcustom anything-c-filelist-file-name nil - "Filename of file list. -Accept a list of string for multiple files. - -This file tend to be very large \(> 100MB\) and recommend to be in ramdisk for speed. -File list is created by make-filelist.rb script. - -Usage: - ruby make-filelist.rb > /tmp/all.filelist - -Then - ;; Assume that /tmp is ramdisk or tmpfs - \(setq anything-grep-candidates-fast-directory-regexp \"^/tmp/\"\) - \(setq anything-c-filelist-file-name \"/tmp/all.filelist\"\) -" - :type 'string - :group 'anything-config) - -(defcustom anything-c-eldoc-in-minibuffer-show-fn - 'anything-c-show-info-in-mode-line +(defcustom helm-c-eldoc-in-minibuffer-show-fn + 'helm-c-show-info-in-mode-line "A function to display eldoc info. Should take one arg: the string to display." - :group 'anything-config + :group 'helm-config :type 'symbol) -(defcustom anything-c-turn-on-show-completion t +(defcustom helm-c-turn-on-show-completion t "Display candidate in buffer while moving selection when non--nil." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-c-show-completion-use-special-display t +(defcustom helm-c-show-completion-use-special-display t "A special display will be used in lisp completion if non--nil. -All functions that are wrapped in macro `with-anything-show-completion' +All functions that are wrapped in macro `with-helm-show-completion' will be affected." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-c-show-completion-min-window-height 7 +(defcustom helm-c-show-completion-min-window-height 7 "Minimum completion window height used in show completion. -This is used in macro `with-anything-show-completion'." - :group 'anything-config +This is used in macro `with-helm-show-completion'." + :group 'helm-config :type 'integer) -(defcustom anything-lisp-completion-or-indent-delay 0.6 - "After this delay `anything-lisp-completion-counter' is reset to 0. +(defcustom helm-lisp-completion-or-indent-delay 0.6 + "After this delay `helm-lisp-completion-counter' is reset to 0. This allow to indent again without completing lisp symbol after this delay. Default is 0.6 seconds." - :group 'anything-config + :group 'helm-config :type 'number) -(defcustom anything-c-default-external-file-browser "nautilus" +(defcustom helm-c-default-external-file-browser "nautilus" "Default external file browser for your system. Directories will be opened externally with it when -opening file externally in `anything-find-files'. +opening file externally in `helm-find-files'. Set to nil if you do not have external file browser or do not want to use it. Windows users should set that to \"explorer.exe\"." - :group 'anything-config + :group 'helm-config :type 'string) -(defcustom anything-c-use-adaptative-sorting nil +(defcustom helm-c-use-adaptative-sorting nil "Wheter to use or not adaptative sorting. Even if a source use it, it will have no effect when set to nil." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-newfile-prompt-p t +(defcustom helm-ff-newfile-prompt-p t "Whether Prompt or not when creating new file. This set `ffap-newfile-prompt'." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-avfs-directory nil +(defcustom helm-ff-avfs-directory nil "The default avfs directory, usually '.avfs'. When this is set you will be able to expand archive filenames with `C-z' inside an avfs directory mounted with mountavfs. See ." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-file-compressed-list '("gz" "bz2" "zip" "7z") +(defcustom helm-ff-file-compressed-list '("gz" "bz2" "zip" "7z") "Minimal list of compressed files extension." :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-locate-db-file-regexp "m?locate\.db$" +(defcustom helm-locate-db-file-regexp "m?locate\.db$" "Default regexp to match locate database. If nil Search in all files." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-locate-db-filename "locate.db" +(defcustom helm-ff-locate-db-filename "locate.db" "The basename of the locatedb file you use locally in your directories. -When this is set and `anything' find such a file in the directory from +When this is set and `helm' find such a file in the directory from where you launch locate, it will use this file and will not prompt you for a db file. Note that this happen only when locate is launched with a prefix arg." - :group 'anything-config + :group 'helm-config :type 'string) -(defcustom anything-c-locate-command nil +(defcustom helm-c-locate-command nil "A list of arguments for locate program. -If nil it will be calculated when `anything-locate' startup +If nil it will be calculated when `helm-locate' startup with these default values for different systems: Gnu/linux: \"locate -i -r %s\" @@ -1189,71 +1174,71 @@ Others: \"locate %s\" This string will be passed to format so it should end with `%s'. The \"-r\" option must be the last option." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-show-info-in-mode-line-delay 12 +(defcustom helm-c-show-info-in-mode-line-delay 12 "Eldoc will show info in mode-line during this delay if user is idle." :type 'integer - :group 'anything-config) + :group 'helm-config) -(defcustom anything-c-copy-files-async-log-file "/tmp/dired.log" +(defcustom helm-c-copy-files-async-log-file "/tmp/dired.log" "The file used to communicate with two emacs when copying files async." :type 'string - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-printer-list nil +(defcustom helm-ff-printer-list nil "A list of available printers on your system. When non--nil let you choose a printer to print file. Otherwise when nil the variable `printer-name' will be used. On Unix based systems (lpstat command needed) you don't need to set this, -`anything-ff-find-printers' will find a list of available printers for you." +`helm-ff-find-printers' will find a list of available printers for you." :type 'list - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-transformer-show-only-basename nil - "Show only basename of candidates in `anything-find-files'. -This can be toggled at anytime from `anything-find-files' with \ -\\0\\[anything-ff-run-toggle-basename]." +(defcustom helm-ff-transformer-show-only-basename nil + "Show only basename of candidates in `helm-find-files'. +This can be toggled at anytime from `helm-find-files' with \ +\\0\\[helm-ff-run-toggle-basename]." :type 'boolean - :group 'anything-config) + :group 'helm-config) -(defcustom anything-ff-quick-delete-dont-prompt-for-deletion nil +(defcustom helm-ff-quick-delete-dont-prompt-for-deletion nil "Don't ask in persistent deletion of files when non--nil." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-ff-signal-error-on-dot-files t +(defcustom helm-ff-signal-error-on-dot-files t "Signal error when file is `.' or `..' on file deletion when non--nil. Default is non--nil. WARNING: Setting this to nil is unsafe and can cause deletion of a whole tree." - :group 'anything-config + :group 'helm-config :type 'boolean) -(defcustom anything-completing-read-handlers-alist - '((describe-function . anything-completing-read-symbols) - (describe-variable . anything-completing-read-symbols) - (debug-on-entry . anything-completing-read-symbols) - (find-function . anything-completing-read-symbols) - (trace-function . anything-completing-read-symbols) - (trace-function-background . anything-completing-read-symbols) - (find-tag . anything-completing-read-with-cands-in-buffer) +(defcustom helm-completing-read-handlers-alist + '((describe-function . helm-completing-read-symbols) + (describe-variable . helm-completing-read-symbols) + (debug-on-entry . helm-completing-read-symbols) + (find-function . helm-completing-read-symbols) + (trace-function . helm-completing-read-symbols) + (trace-function-background . helm-completing-read-symbols) + (find-tag . helm-completing-read-with-cands-in-buffer) (ffap-alternate-file . nil)) - "Alist of handlers to replace `completing-read', `read-file-name' in `ac-mode'. + "Alist of handlers to replace `completing-read', `read-file-name' in `helm-mode'. Each entry is a cons cell like \(emacs_command . completing-read_handler\) where key and value are symbols. Each key is an Emacs command that use originaly `completing-read'. -Each value maybe an anything function that take same arguments as +Each value maybe an helm function that take same arguments as `completing-read' plus NAME and BUFFER, where NAME is the name of the new -anything source and BUFFER the name of the buffer we will use. -This function prefix name must start by \"anything\". +helm source and BUFFER the name of the buffer we will use. +This function prefix name must start by \"helm\". -See `anything-completing-read-symbols' for example. +See `helm-completing-read-symbols' for example. If the value of an entry is nil completion will fall back to emacs vanilla behavior. -e.g If you want to disable anything completion for `describe-function': +e.g If you want to disable helm completion for `describe-function': \(describe-function . nil\). Ido is also supported, you can use `ido-completing-read' and @@ -1263,52 +1248,52 @@ e.g ido completion for `find-file': same as \(find-file . ido-read-file-name\) Note that you don't need to enable `ido-mode' for this to work." - :group 'anything-config + :group 'helm-config :type '(alist :key-type symbol :value-type symbol)) -(defcustom anything-M-x-requires-pattern 2 - "Value of requires-pattern for `anything-M-x'. -Set it to 0 to disable requires-pattern in `anything-M-x'." - :group 'anything-config +(defcustom helm-M-x-requires-pattern 2 + "Value of requires-pattern for `helm-M-x'. +Set it to 0 to disable requires-pattern in `helm-M-x'." + :group 'helm-config :type 'boolean) ;;; Build info-index sources with info-index plug-in. ;; ;; -(defun anything-c-build-info-index-command (name doc source buffer) - "Define an anything command NAME with documentation DOC. -Arg SOURCE will be an existing anything source named -`anything-c-source-info-' and BUFFER a string buffer name." +(defun helm-c-build-info-index-command (name doc source buffer) + "Define an helm command NAME with documentation DOC. +Arg SOURCE will be an existing helm source named +`helm-c-source-info-' and BUFFER a string buffer name." (eval (list 'defun name nil doc (list 'interactive) - (list 'anything + (list 'helm :sources source :buffer buffer :candidate-number-limit 1000)))) -(defun anything-c-define-info-index-sources (var-value &optional commands) - "Define anything sources named anything-c-source-info-. -Sources are generated for all entries of `anything-c-default-info-index-list'. -If COMMANDS arg is non--nil build also commands named `anything-info'. -Where NAME is one of `anything-c-default-info-index-list'." +(defun helm-c-define-info-index-sources (var-value &optional commands) + "Define helm sources named helm-c-source-info-. +Sources are generated for all entries of `helm-c-default-info-index-list'. +If COMMANDS arg is non--nil build also commands named `helm-info'. +Where NAME is one of `helm-c-default-info-index-list'." (loop with symbols = (loop for str in var-value collect - (intern (concat "anything-c-source-info-" str))) + (intern (concat "helm-c-source-info-" str))) for sym in symbols for str in var-value do (set sym (list (cons 'name (format "Info index: %s" str)) (cons 'info-index str))) when commands - do (let ((com (intern (concat "anything-info-" str)))) - (anything-c-build-info-index-command com - (format "Predefined anything for %s info." str) sym - (format "*anything info %s*" str))))) + do (let ((com (intern (concat "helm-info-" str)))) + (helm-c-build-info-index-command com + (format "Predefined helm for %s info." str) sym + (format "*helm info %s*" str))))) -(defun anything-info-index-set (var value) +(defun helm-info-index-set (var value) (set var value) - (anything-c-define-info-index-sources value t)) + (helm-c-define-info-index-sources value t)) -(defcustom anything-c-default-info-index-list +(defcustom helm-c-default-info-index-list '("elisp" "cl" "org" "gnus" "tramp" "ratpoison" "zsh" "bash" "coreutils" "fileutils" "find" "sh-utils" "textutils" "libc" @@ -1319,14 +1304,14 @@ Where NAME is one of `anything-c-default-info-index-list'." "ld" "diff" "flex" "grep" "gzip" "libtool" "texinfo" "info" "gdb" "stabs" "cvsbook" "cvs" "bison" "id-utils" "global") - "Info Manual entries to use for building anything info index commands." - :group 'anything-config + "Info Manual entries to use for building helm info index commands." + :group 'helm-config :type 'list - :set 'anything-info-index-set) + :set 'helm-info-index-set) -(defcustom anything-c-register-max-offset 160 +(defcustom helm-c-register-max-offset 160 "Max size of string register entries before truncating." - :group 'anything-config + :group 'helm-config :type 'integer) @@ -1334,209 +1319,209 @@ Where NAME is one of `anything-c-default-info-index-list'." ;; ;; Some internals variable that need to be loaded ;; here to avoid compiler warnings. -(defvar anything-c-external-commands-list nil +(defvar helm-c-external-commands-list nil "A list of all external commands the user can execute. If this variable is not set by the user, it will be calculated automatically.") -(defvar anything-c-show-completion-overlay nil) +(defvar helm-c-show-completion-overlay nil) ;;; Faces ;; ;; -(defface anything-buffer-saved-out +(defface helm-buffer-saved-out '((t (:foreground "red"))) "*Face used for buffer files modified outside of emacs." - :group 'anything-config) + :group 'helm-config) -(defface anything-buffer-not-saved +(defface helm-buffer-not-saved '((t (:foreground "Indianred2"))) "*Face used for buffer files not already saved on disk." - :group 'anything-config) + :group 'helm-config) -(defface anything-ff-prefix +(defface helm-ff-prefix '((t (:background "yellow" :foreground "black"))) - "*Face used to prefix new file or url paths in `anything-find-files'." - :group 'anything-config) + "*Face used to prefix new file or url paths in `helm-find-files'." + :group 'helm-config) -(defface anything-ff-executable +(defface helm-ff-executable '((t (:foreground "green"))) - "*Face used for executable files in `anything-find-files'." - :group 'anything-config) + "*Face used for executable files in `helm-find-files'." + :group 'helm-config) -(defface anything-ff-directory +(defface helm-ff-directory '((t (:foreground "DarkRed" :background "LightGray"))) - "*Face used for directories in `anything-find-files'." - :group 'anything-config) + "*Face used for directories in `helm-find-files'." + :group 'helm-config) -(defface anything-ff-symlink +(defface helm-ff-symlink '((t (:foreground "DarkOrange"))) - "*Face used for symlinks in `anything-find-files'." - :group 'anything-config) + "*Face used for symlinks in `helm-find-files'." + :group 'helm-config) -(defface anything-ff-invalid-symlink +(defface helm-ff-invalid-symlink '((t (:foreground "black" :background "red"))) - "*Face used for invalid symlinks in `anything-find-files'." - :group 'anything-config) + "*Face used for invalid symlinks in `helm-find-files'." + :group 'helm-config) -(defface anything-ff-file +(defface helm-ff-file '((t (:foreground "CadetBlue" :underline t))) - "*Face used for file names in `anything-find-files'." - :group 'anything-config) + "*Face used for file names in `helm-find-files'." + :group 'helm-config) -(defface anything-grep-match +(defface helm-grep-match '((t (:inherit match))) "Face used to highlight grep matches." - :group 'anything-config) + :group 'helm-config) -(defface anything-grep-file +(defface helm-grep-file '((t (:foreground "BlueViolet" :underline t))) "Face used to highlight grep results filenames." - :group 'anything-config) + :group 'helm-config) -(defface anything-grep-lineno +(defface helm-grep-lineno '((t (:foreground "Darkorange1"))) "Face used to highlight grep number lines." - :group 'anything-config) + :group 'helm-config) -(defface anything-grep-running +(defface helm-grep-running '((t (:foreground "Red"))) "Face used in mode line when grep is running." - :group 'anything-config) + :group 'helm-config) -(defface anything-grep-finish +(defface helm-grep-finish '((t (:foreground "Green"))) "Face used in mode line when grep is finish." - :group 'anything-config) + :group 'helm-config) -(defface anything-M-x-key-face '((t (:foreground "orange" :underline t))) - "*Face used in anything-M-x to show keybinding." - :group 'anything) +(defface helm-M-x-key-face '((t (:foreground "orange" :underline t))) + "*Face used in helm-M-x to show keybinding." + :group 'helm) -(defface anything-bmkext-info +(defface helm-bmkext-info '((t (:foreground "green"))) "*Face used for W3m Emacs bookmarks (not w3m bookmarks)." - :group 'anything) + :group 'helm) -(defface anything-bmkext-w3m +(defface helm-bmkext-w3m '((t (:foreground "yellow"))) "*Face used for W3m Emacs bookmarks (not w3m bookmarks)." - :group 'anything) + :group 'helm) -(defface anything-bmkext-gnus +(defface helm-bmkext-gnus '((t (:foreground "magenta"))) "*Face used for Gnus bookmarks." - :group 'anything) + :group 'helm) -(defface anything-bmkext-man +(defface helm-bmkext-man '((t (:foreground "Orange4"))) "*Face used for Woman/man bookmarks." - :group 'anything) + :group 'helm) -(defface anything-bmkext-no--file +(defface helm-bmkext-no--file '((t (:foreground "grey"))) "*Face used for non--file bookmarks." - :group 'anything) + :group 'helm) -(defface anything-bmkext-file +(defface helm-bmkext-file '((t (:foreground "Deepskyblue2"))) "*Face used for non--file bookmarks." - :group 'anything) + :group 'helm) -(defface anything-bookmarks-su-face '((t (:foreground "red"))) +(defface helm-bookmarks-su-face '((t (:foreground "red"))) "Face for su/sudo bookmarks." - :group 'anything) + :group 'helm) -(defface anything-w3m-bookmarks-face '((t (:foreground "cyan1" :underline t))) - "Face for w3m bookmarks" :group 'anything) +(defface helm-w3m-bookmarks-face '((t (:foreground "cyan1" :underline t))) + "Face for w3m bookmarks" :group 'helm) -(defface anything-emms-playlist +(defface helm-emms-playlist '((t (:foreground "Springgreen4" :underline t))) "*Face used for tracks in current emms playlist." - :group 'anything) + :group 'helm) -(defface anything-apt-installed +(defface helm-apt-installed '((t (:foreground "green"))) "*Face used for apt installed candidates." - :group 'anything) + :group 'helm) -(defface anything-apt-deinstalled +(defface helm-apt-deinstalled '((t (:foreground "DimGray"))) "*Face used for apt deinstalled candidates." - :group 'anything) + :group 'helm) -(defface anything-gentoo-match-face '((t (:foreground "red"))) - "Face for anything-gentoo installed packages." +(defface helm-gentoo-match-face '((t (:foreground "red"))) + "Face for helm-gentoo installed packages." :group 'traverse-faces) -(defface anything-lisp-show-completion +(defface helm-lisp-show-completion '((t (:background "DarkSlateGray"))) - "*Face used for showing candidates in `anything-lisp-completion'." - :group 'anything-config) + "*Face used for showing candidates in `helm-lisp-completion'." + :group 'helm-config) -(defface anything-lisp-completion-info +(defface helm-lisp-completion-info '((t (:foreground "red"))) - "*Face used for showing info in `anything-lisp-completion'." - :group 'anything-config) + "*Face used for showing info in `helm-lisp-completion'." + :group 'helm-config) -(defface anything-overlay-line-face '((t (:background "IndianRed4" :underline t))) - "Face for source header in the anything buffer." :group 'anything) +(defface helm-overlay-line-face '((t (:background "IndianRed4" :underline t))) + "Face for source header in the helm buffer." :group 'helm) ;;;###autoload -(defun anything-configuration () - "Customize `anything'." +(defun helm-configuration () + "Customize `helm'." (interactive) - (customize-group "anything-config")) + (customize-group "helm-config")) -;;; Anything-command-map +;;; Helm-command-map ;; ;; ;;;###autoload -(defvar anything-command-map) -(define-prefix-command 'anything-command-map) +(defvar helm-command-map) +(define-prefix-command 'helm-command-map) -(define-key anything-command-map (kbd "") 'anything-execute-anything-command) -(define-key anything-command-map (kbd "a") 'anything-c-apropos) -(define-key anything-command-map (kbd "e") 'anything-c-etags-select) -(define-key anything-command-map (kbd "l") 'anything-locate) -(define-key anything-command-map (kbd "s") 'anything-surfraw) -(define-key anything-command-map (kbd "r") 'anything-regexp) -(define-key anything-command-map (kbd "w") 'anything-w3m-bookmarks) -(define-key anything-command-map (kbd "x") 'anything-firefox-bookmarks) -(define-key anything-command-map (kbd "#") 'anything-emms) -(define-key anything-command-map (kbd "m") 'anything-man-woman) -(define-key anything-command-map (kbd "t") 'anything-top) -(define-key anything-command-map (kbd "i") 'anything-imenu) -(define-key anything-command-map (kbd "") 'anything-lisp-completion-at-point) -(define-key anything-command-map (kbd "p") 'anything-list-emacs-process) -(define-key anything-command-map (kbd "C-x r b") 'anything-c-pp-bookmarks) -(define-key anything-command-map (kbd "M-y") 'anything-show-kill-ring) -(define-key anything-command-map (kbd "C-c ") 'anything-all-mark-rings) -(define-key anything-command-map (kbd "C-x C-f") 'anything-find-files) -(define-key anything-command-map (kbd "f") 'anything-for-files) -(define-key anything-command-map (kbd "C-:") 'anything-eval-expression-with-eldoc) -(define-key anything-command-map (kbd "C-,") 'anything-calcul-expression) -(define-key anything-command-map (kbd "M-x") 'anything-M-x) -(define-key anything-command-map (kbd "C-x C-w") 'anything-write-file) -(define-key anything-command-map (kbd "C-x i") 'anything-insert-file) -(define-key anything-command-map (kbd "M-s o") 'anything-occur) -(define-key anything-command-map (kbd "M-g s") 'anything-do-grep) -(define-key anything-command-map (kbd "c") 'anything-colors) -(define-key anything-command-map (kbd "F") 'anything-select-xfont) -(define-key anything-command-map (kbd "C-c f") 'anything-recentf) -(define-key anything-command-map (kbd "C-c g") 'anything-google-suggest) -(define-key anything-command-map (kbd "h i") 'anything-info-at-point) -(define-key anything-command-map (kbd "h r") 'anything-info-emacs) -(define-key anything-command-map (kbd "h g") 'anything-info-gnus) -(define-key anything-command-map (kbd "C-x C-b") 'anything-buffers-list) -(define-key anything-command-map (kbd "C-c C-b") 'anything-browse-code) -(define-key anything-command-map (kbd "C-x r i") 'anything-register) -(define-key anything-command-map (kbd "C-c C-x") 'anything-c-run-external-command) +(define-key helm-command-map (kbd "") 'helm-execute-helm-command) +(define-key helm-command-map (kbd "a") 'helm-c-apropos) +(define-key helm-command-map (kbd "e") 'helm-c-etags-select) +(define-key helm-command-map (kbd "l") 'helm-locate) +(define-key helm-command-map (kbd "s") 'helm-surfraw) +(define-key helm-command-map (kbd "r") 'helm-regexp) +(define-key helm-command-map (kbd "w") 'helm-w3m-bookmarks) +(define-key helm-command-map (kbd "x") 'helm-firefox-bookmarks) +(define-key helm-command-map (kbd "#") 'helm-emms) +(define-key helm-command-map (kbd "m") 'helm-man-woman) +(define-key helm-command-map (kbd "t") 'helm-top) +(define-key helm-command-map (kbd "i") 'helm-imenu) +(define-key helm-command-map (kbd "") 'helm-lisp-completion-at-point) +(define-key helm-command-map (kbd "p") 'helm-list-emacs-process) +(define-key helm-command-map (kbd "C-x r b") 'helm-c-pp-bookmarks) +(define-key helm-command-map (kbd "M-y") 'helm-show-kill-ring) +(define-key helm-command-map (kbd "C-c ") 'helm-all-mark-rings) +(define-key helm-command-map (kbd "C-x C-f") 'helm-find-files) +(define-key helm-command-map (kbd "f") 'helm-for-files) +(define-key helm-command-map (kbd "C-:") 'helm-eval-expression-with-eldoc) +(define-key helm-command-map (kbd "C-,") 'helm-calcul-expression) +(define-key helm-command-map (kbd "M-x") 'helm-M-x) +(define-key helm-command-map (kbd "C-x C-w") 'helm-write-file) +(define-key helm-command-map (kbd "C-x i") 'helm-insert-file) +(define-key helm-command-map (kbd "M-s o") 'helm-occur) +(define-key helm-command-map (kbd "M-g s") 'helm-do-grep) +(define-key helm-command-map (kbd "c") 'helm-colors) +(define-key helm-command-map (kbd "F") 'helm-select-xfont) +(define-key helm-command-map (kbd "C-c f") 'helm-recentf) +(define-key helm-command-map (kbd "C-c g") 'helm-google-suggest) +(define-key helm-command-map (kbd "h i") 'helm-info-at-point) +(define-key helm-command-map (kbd "h r") 'helm-info-emacs) +(define-key helm-command-map (kbd "h g") 'helm-info-gnus) +(define-key helm-command-map (kbd "C-x C-b") 'helm-buffers-list) +(define-key helm-command-map (kbd "C-c C-b") 'helm-browse-code) +(define-key helm-command-map (kbd "C-x r i") 'helm-register) +(define-key helm-command-map (kbd "C-c C-x") 'helm-c-run-external-command) ;; In Emacs 23.1.50, minibuffer-local-must-match-filename-map was renamed to ;; minibuffer-local-filename-must-match-map. @@ -1550,7 +1535,7 @@ automatically.") minibuffer-local-isearch-map minibuffer-local-must-match-map minibuffer-local-ns-map)) - (define-key map "\C-r" 'anything-minibuffer-history)) + (define-key map "\C-r" 'helm-minibuffer-history)) @@ -1558,205 +1543,205 @@ automatically.") ;; ;; (easy-menu-define nil global-map - "`anything' menu" - '("Anything" - ["All anything commands" anything-execute-anything-command t] - ["Find any Files/Buffers" anything-for-files t] - ["Anything Everywhere (Toggle)" ac-mode t] + "`helm' menu" + '("Helm" + ["All helm commands" helm-execute-helm-command t] + ["Find any Files/Buffers" helm-for-files t] + ["Helm Everywhere (Toggle)" helm-mode t] "----" ("Files:" - ["Find files" anything-find-files t] - ["Recent Files" anything-recentf t] - ["Locate" anything-locate t] - ["Bookmarks" anything-c-pp-bookmarks t]) + ["Find files" helm-find-files t] + ["Recent Files" helm-recentf t] + ["Locate" helm-locate t] + ["Bookmarks" helm-c-pp-bookmarks t]) ("Buffers:" - ["Find buffers" anything-buffers-list t]) + ["Find buffers" helm-buffers-list t]) ("Commands:" - ["Emacs Commands" anything-M-x t] - ["Externals Commands" anything-c-run-external-command t]) + ["Emacs Commands" helm-M-x t] + ["Externals Commands" helm-c-run-external-command t]) ("Help:" - ["Anything Apropos" anything-c-apropos t]) + ["Helm Apropos" helm-c-apropos t]) ("Info:" - ["Info at point" anything-info-at-point t] - ["Emacs Manual index" anything-info-emacs t] - ["Gnus Manual index" anything-info-gnus t]) + ["Info at point" helm-info-at-point t] + ["Emacs Manual index" helm-info-emacs t] + ["Gnus Manual index" helm-info-gnus t]) ("Org:" - ["Org keywords" anything-org-keywords t] - ["Org headlines" anything-org-headlines t]) + ["Org keywords" helm-org-keywords t] + ["Org headlines" helm-org-headlines t]) ("Tools:" - ["Occur" anything-occur t] - ["Grep" anything-do-grep t] - ["Etags" anything-c-etags-select t] - ["Lisp complete at point" anything-lisp-completion-at-point t] - ["Browse Kill ring" anything-show-kill-ring t] - ["Browse register" anything-register t] - ["Browse code" anything-browse-code t] - ["Mark Ring" anything-all-mark-rings t] - ["Regexp handler" anything-regexp t] - ["Colors & Faces" anything-colors t] - ["Show xfonts" anything-select-xfont t] - ["Ucs Symbols" anything-ucs t] - ["Imenu" anything-imenu t] - ["Google Suggest" anything-google-suggest t] - ["Eval expression" anything-eval-expression-with-eldoc t] - ["Calcul expression" anything-calcul-expression t] - ["Man pages" anything-man-woman t] - ["Top externals process" anything-top t] - ["Emacs internals process" anything-list-emacs-process t]) + ["Occur" helm-occur t] + ["Grep" helm-do-grep t] + ["Etags" helm-c-etags-select t] + ["Lisp complete at point" helm-lisp-completion-at-point t] + ["Browse Kill ring" helm-show-kill-ring t] + ["Browse register" helm-register t] + ["Browse code" helm-browse-code t] + ["Mark Ring" helm-all-mark-rings t] + ["Regexp handler" helm-regexp t] + ["Colors & Faces" helm-colors t] + ["Show xfonts" helm-select-xfont t] + ["Ucs Symbols" helm-ucs t] + ["Imenu" helm-imenu t] + ["Google Suggest" helm-google-suggest t] + ["Eval expression" helm-eval-expression-with-eldoc t] + ["Calcul expression" helm-calcul-expression t] + ["Man pages" helm-man-woman t] + ["Top externals process" helm-top t] + ["Emacs internals process" helm-list-emacs-process t]) "----" - ["Prefered Options" anything-configuration t])) + ["Prefered Options" helm-configuration t])) -;;; Anything map add ons +;;; Helm map add ons ;; ;; -(define-key anything-map (kbd "C-x C-f") 'anything-quit-and-find-file) -(define-key anything-map (kbd "M-m") 'anything-toggle-all-marks) -(define-key anything-map (kbd "C-w") 'anything-yank-text-at-point) +(define-key helm-map (kbd "C-x C-f") 'helm-quit-and-find-file) +(define-key helm-map (kbd "M-m") 'helm-toggle-all-marks) +(define-key helm-map (kbd "C-w") 'helm-yank-text-at-point) ;;; Specialized keymaps ;; ;; -(defvar anything-c-buffer-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-c ?") 'anything-c-buffer-help) +(defvar helm-c-buffer-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-c ?") 'helm-c-buffer-help) ;; No need to have separate command for grep and zgrep ;; as we don't use recursivity for buffers. ;; So use zgrep for both as it is capable to handle non--compressed files. - (define-key map (kbd "M-g s") 'anything-buffer-run-zgrep) - (define-key map (kbd "C-c o") 'anything-buffer-switch-other-window) - (define-key map (kbd "C-c C-o") 'anything-buffer-switch-other-frame) - (define-key map (kbd "C-c =") 'anything-buffer-run-ediff) - (define-key map (kbd "M-=") 'anything-buffer-run-ediff-merge) - (define-key map (kbd "C-=") 'anything-buffer-diff-persistent) - (define-key map (kbd "M-U") 'anything-buffer-revert-persistent) - (define-key map (kbd "M-D") 'anything-buffer-run-kill-buffers) - (define-key map (kbd "C-x C-s") 'anything-buffer-save-persistent) - (define-key map (kbd "C-M-%") 'anything-buffer-run-query-replace-regexp) - (define-key map (kbd "M-%") 'anything-buffer-run-query-replace) - (define-key map (kbd "M-m") 'anything-toggle-all-marks) - (define-key map (kbd "M-a") 'anything-mark-all) + (define-key map (kbd "M-g s") 'helm-buffer-run-zgrep) + (define-key map (kbd "C-c o") 'helm-buffer-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame) + (define-key map (kbd "C-c =") 'helm-buffer-run-ediff) + (define-key map (kbd "M-=") 'helm-buffer-run-ediff-merge) + (define-key map (kbd "C-=") 'helm-buffer-diff-persistent) + (define-key map (kbd "M-U") 'helm-buffer-revert-persistent) + (define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers) + (define-key map (kbd "C-x C-s") 'helm-buffer-save-persistent) + (define-key map (kbd "C-M-%") 'helm-buffer-run-query-replace-regexp) + (define-key map (kbd "M-%") 'helm-buffer-run-query-replace) + (define-key map (kbd "M-m") 'helm-toggle-all-marks) + (define-key map (kbd "M-a") 'helm-mark-all) (when (locate-library "elscreen") - (define-key map (kbd "") 'anything-buffer-switch-to-elscreen)) + (define-key map (kbd "") 'helm-buffer-switch-to-elscreen)) (delq nil map)) - "Keymap for buffer sources in anything.") + "Keymap for buffer sources in helm.") -(defvar anything-find-files-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-]") 'anything-ff-run-toggle-basename) - (define-key map (kbd "C-x C-f") 'anything-ff-run-locate) - (define-key map (kbd "M-g s") 'anything-ff-run-grep) - (define-key map (kbd "M-g p") 'anything-ff-run-pdfgrep) - (define-key map (kbd "M-g z") 'anything-ff-run-zgrep) - (define-key map (kbd "M-.") 'anything-ff-run-etags) - (define-key map (kbd "M-R") 'anything-ff-run-rename-file) - (define-key map (kbd "M-C") 'anything-ff-run-copy-file) - (define-key map (kbd "M-B") 'anything-ff-run-byte-compile-file) - (define-key map (kbd "M-L") 'anything-ff-run-load-file) - (define-key map (kbd "M-S") 'anything-ff-run-symlink-file) - (define-key map (kbd "M-H") 'anything-ff-run-hardlink-file) - (define-key map (kbd "M-D") 'anything-ff-run-delete-file) - (define-key map (kbd "M-K") 'anything-ff-run-kill-buffer-persistent) - (define-key map (kbd "C-d") 'anything-ff-persistent-delete) - (define-key map (kbd "M-e") 'anything-ff-run-switch-to-eshell) - (define-key map (kbd "") 'anything-ff-run-complete-fn-at-point) - (define-key map (kbd "C-c o") 'anything-ff-run-switch-other-window) - (define-key map (kbd "C-c C-o") 'anything-ff-run-switch-other-frame) - (define-key map (kbd "C-c C-x") 'anything-ff-run-open-file-externally) - (define-key map (kbd "M-!") 'anything-ff-run-eshell-command-on-file) - (define-key map (kbd "C-=") 'anything-ff-run-ediff-file) - (define-key map (kbd "C-c =") 'anything-ff-run-ediff-merge-file) - (define-key map (kbd "M-p") 'anything-ff-run-switch-to-history) - (define-key map (kbd "M-i") 'anything-ff-properties-persistent) - (define-key map (kbd "C-c ?") 'anything-ff-help) - (define-key map (kbd "C-}") 'anything-narrow-window) - (define-key map (kbd "C-{") 'anything-enlarge-window) - (define-key map (kbd "C-") 'anything-ff-run-toggle-auto-update) - (define-key map (kbd "M-a") 'anything-mark-all) - (define-key map (kbd "M-m") 'anything-toggle-all-marks) - (define-key map (kbd "M-u") 'anything-unmark-all) - (define-key map (kbd "C-c C-a") 'anything-ff-run-gnus-attach-files) - (define-key map (kbd "C-c p") 'anything-ff-run-print-file) +(defvar helm-find-files-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) + (define-key map (kbd "C-x C-f") 'helm-ff-run-locate) + (define-key map (kbd "M-g s") 'helm-ff-run-grep) + (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) + (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) + (define-key map (kbd "M-.") 'helm-ff-run-etags) + (define-key map (kbd "M-R") 'helm-ff-run-rename-file) + (define-key map (kbd "M-C") 'helm-ff-run-copy-file) + (define-key map (kbd "M-B") 'helm-ff-run-byte-compile-file) + (define-key map (kbd "M-L") 'helm-ff-run-load-file) + (define-key map (kbd "M-S") 'helm-ff-run-symlink-file) + (define-key map (kbd "M-H") 'helm-ff-run-hardlink-file) + (define-key map (kbd "M-D") 'helm-ff-run-delete-file) + (define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent) + (define-key map (kbd "C-d") 'helm-ff-persistent-delete) + (define-key map (kbd "M-e") 'helm-ff-run-switch-to-eshell) + (define-key map (kbd "") 'helm-ff-run-complete-fn-at-point) + (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) + (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) + (define-key map (kbd "M-!") 'helm-ff-run-eshell-command-on-file) + (define-key map (kbd "C-=") 'helm-ff-run-ediff-file) + (define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file) + (define-key map (kbd "M-p") 'helm-ff-run-switch-to-history) + (define-key map (kbd "M-i") 'helm-ff-properties-persistent) + (define-key map (kbd "C-c ?") 'helm-ff-help) + (define-key map (kbd "C-}") 'helm-narrow-window) + (define-key map (kbd "C-{") 'helm-enlarge-window) + (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "M-a") 'helm-mark-all) + (define-key map (kbd "M-m") 'helm-toggle-all-marks) + (define-key map (kbd "M-u") 'helm-unmark-all) + (define-key map (kbd "C-c C-a") 'helm-ff-run-gnus-attach-files) + (define-key map (kbd "C-c p") 'helm-ff-run-print-file) ;; Next 2 have no effect if candidate is not an image file. - (define-key map (kbd "M-l") 'anything-ff-rotate-left-persistent) - (define-key map (kbd "M-r") 'anything-ff-rotate-right-persistent) - (define-key map (kbd "C-.") 'anything-find-files-down-one-level) - (define-key map (kbd "C-l") 'anything-find-files-down-one-level) - (define-key map (kbd "C-h C-b") 'anything-send-bug-report-from-anything) - (define-key map (kbd "C-h C-d") 'anything-debug-output) - (when anything-ff-lynx-style-map - (define-key map (kbd "") 'anything-find-files-down-one-level) - (define-key map (kbd "") 'anything-execute-persistent-action)) + (define-key map (kbd "M-l") 'helm-ff-rotate-left-persistent) + (define-key map (kbd "M-r") 'helm-ff-rotate-right-persistent) + (define-key map (kbd "C-.") 'helm-find-files-down-one-level) + (define-key map (kbd "C-l") 'helm-find-files-down-one-level) + (define-key map (kbd "C-h C-b") 'helm-send-bug-report-from-helm) + (define-key map (kbd "C-h C-d") 'helm-debug-output) + (when helm-ff-lynx-style-map + (define-key map (kbd "") 'helm-find-files-down-one-level) + (define-key map (kbd "") 'helm-execute-persistent-action)) (delq nil map)) - "Keymap for `anything-find-files'.") + "Keymap for `helm-find-files'.") -(defvar anything-c-read-file-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-]") 'anything-ff-run-toggle-basename) - (define-key map (kbd "C-.") 'anything-find-files-down-one-level) - (define-key map (kbd "C-l") 'anything-find-files-down-one-level) - (define-key map (kbd "C-") 'anything-ff-run-toggle-auto-update) - (define-key map (kbd "C-c ?") 'anything-read-file-name-help) - (when anything-ff-lynx-style-map - (define-key map (kbd "") 'anything-find-files-down-one-level) - (define-key map (kbd "") 'anything-execute-persistent-action) +(defvar helm-c-read-file-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) + (define-key map (kbd "C-.") 'helm-find-files-down-one-level) + (define-key map (kbd "C-l") 'helm-find-files-down-one-level) + (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "C-c ?") 'helm-read-file-name-help) + (when helm-ff-lynx-style-map + (define-key map (kbd "") 'helm-find-files-down-one-level) + (define-key map (kbd "") 'helm-execute-persistent-action) (define-key map (kbd "C-o") nil) - (define-key map (kbd "") 'anything-previous-source) - (define-key map (kbd "") 'anything-next-source)) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-next-source)) (delq nil map)) - "Keymap for `anything-c-read-file-name'.") + "Keymap for `helm-c-read-file-name'.") -(defvar anything-generic-files-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-g s") 'anything-ff-run-grep) - (define-key map (kbd "M-g z") 'anything-ff-run-zgrep) - (define-key map (kbd "M-g p") 'anything-ff-run-pdfgrep) - (define-key map (kbd "M-D") 'anything-ff-run-delete-file) - (define-key map (kbd "C-=") 'anything-ff-run-ediff-file) - (define-key map (kbd "C-c =") 'anything-ff-run-ediff-merge-file) - (define-key map (kbd "C-c o") 'anything-ff-run-switch-other-window) - (define-key map (kbd "M-i") 'anything-ff-properties-persistent) - (define-key map (kbd "C-c C-x") 'anything-ff-run-open-file-externally) - (define-key map (kbd "C-w") 'anything-yank-text-at-point) - (define-key map (kbd "C-c ?") 'anything-generic-file-help) +(defvar helm-generic-files-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-g s") 'helm-ff-run-grep) + (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) + (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) + (define-key map (kbd "M-D") 'helm-ff-run-delete-file) + (define-key map (kbd "C-=") 'helm-ff-run-ediff-file) + (define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file) + (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) + (define-key map (kbd "M-i") 'helm-ff-properties-persistent) + (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-generic-file-help) map) "Generic Keymap for files.") -(defvar anything-c-grep-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-") 'anything-c-goto-next-file) - (define-key map (kbd "M-") 'anything-c-goto-precedent-file) - (define-key map (kbd "C-c o") 'anything-c-grep-run-other-window-action) - (define-key map (kbd "C-w") 'anything-yank-text-at-point) - (define-key map (kbd "C-x C-s") 'anything-c-grep-run-save-buffer) - (when anything-c-grep-use-ioccur-style-keys - (define-key map (kbd "") 'anything-c-grep-run-persistent-action) - (define-key map (kbd "") 'anything-c-grep-run-default-action)) - (define-key map (kbd "C-c ?") 'anything-grep-help) +(defvar helm-c-grep-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-") 'helm-c-goto-next-file) + (define-key map (kbd "M-") 'helm-c-goto-precedent-file) + (define-key map (kbd "C-c o") 'helm-c-grep-run-other-window-action) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-x C-s") 'helm-c-grep-run-save-buffer) + (when helm-c-grep-use-ioccur-style-keys + (define-key map (kbd "") 'helm-c-grep-run-persistent-action) + (define-key map (kbd "") 'helm-c-grep-run-default-action)) + (define-key map (kbd "C-c ?") 'helm-grep-help) (delq nil map)) "Keymap used in Grep sources.") -(defvar anything-c-pdfgrep-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-") 'anything-c-goto-next-file) - (define-key map (kbd "M-") 'anything-c-goto-precedent-file) - (define-key map (kbd "C-w") 'anything-yank-text-at-point) - (define-key map (kbd "C-c ?") 'anything-pdfgrep-help) +(defvar helm-c-pdfgrep-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-") 'helm-c-goto-next-file) + (define-key map (kbd "M-") 'helm-c-goto-precedent-file) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-pdfgrep-help) map) "Keymap used in pdfgrep.") -(defvar anything-c-etags-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-") 'anything-c-goto-next-file) - (define-key map (kbd "M-") 'anything-c-goto-precedent-file) - (define-key map (kbd "C-w") 'anything-yank-text-at-point) - (define-key map (kbd "C-c ?") 'anything-etags-help) +(defvar helm-c-etags-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-") 'helm-c-goto-next-file) + (define-key map (kbd "M-") 'helm-c-goto-precedent-file) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-etags-help) map) "Keymap used in Etags.") -(defvar anything-eval-expression-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "") 'anything-eval-new-line-and-indent) +(defvar helm-eval-expression-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "") 'helm-eval-new-line-and-indent) (define-key map (kbd "") 'lisp-indent-line) (define-key map (kbd "") 'lisp-complete-symbol) (define-key map (kbd "C-p") 'previous-line) @@ -1767,61 +1752,61 @@ automatically.") (define-key map (kbd "") 'backward-char) map)) -(defvar anything-c-ucs-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "") 'anything-c-ucs-persistent-delete) - (define-key map (kbd "") 'anything-c-ucs-persistent-backward) - (define-key map (kbd "") 'anything-c-ucs-persistent-forward) - (define-key map (kbd "") 'anything-c-ucs-persistent-insert) - (define-key map (kbd "C-c ?") 'anything-c-ucs-help) +(defvar helm-c-ucs-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "") 'helm-c-ucs-persistent-delete) + (define-key map (kbd "") 'helm-c-ucs-persistent-backward) + (define-key map (kbd "") 'helm-c-ucs-persistent-forward) + (define-key map (kbd "") 'helm-c-ucs-persistent-insert) + (define-key map (kbd "C-c ?") 'helm-c-ucs-help) map) - "Keymap for `anything-ucs'.") + "Keymap for `helm-ucs'.") -(defvar anything-c-bookmark-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-c o") 'anything-c-bookmark-run-jump-other-window) - (define-key map (kbd "C-d") 'anything-c-bookmark-run-delete) +(defvar helm-c-bookmark-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-c o") 'helm-c-bookmark-run-jump-other-window) + (define-key map (kbd "C-d") 'helm-c-bookmark-run-delete) (when (locate-library "bookmark-extensions") - (define-key map (kbd "M-e") 'anything-c-bmkext-run-edit)) - (define-key map (kbd "C-c ?") 'anything-c-bookmark-help) + (define-key map (kbd "M-e") 'helm-c-bmkext-run-edit)) + (define-key map (kbd "C-c ?") 'helm-c-bookmark-help) (delq nil map)) "Generic Keymap for emacs bookmark sources.") -(defvar anything-esh-on-file-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-c ?") 'anything-esh-help) +(defvar helm-esh-on-file-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-c ?") 'helm-esh-help) map) - "Keymap for `anything-find-files-eshell-command-on-file'.") + "Keymap for `helm-find-files-eshell-command-on-file'.") -(defvar anything-eshell-history-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-p") 'anything-next-line) +(defvar helm-eshell-history-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-p") 'helm-next-line) map) - "Keymap for `anything-eshell-history'.") + "Keymap for `helm-eshell-history'.") -(defvar anything-kill-ring-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "M-y") 'anything-next-line) - (define-key map (kbd "M-u") 'anything-previous-line) +(defvar helm-kill-ring-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "M-y") 'helm-next-line) + (define-key map (kbd "M-u") 'helm-previous-line) map) - "Keymap for `anything-show-kill-ring'.") + "Keymap for `helm-show-kill-ring'.") -(defvar anything-occur-map - (let ((map (copy-keymap anything-map))) - (define-key map (kbd "C-M-%") 'anything-occur-run-query-replace-regexp) +(defvar helm-occur-map + (let ((map (copy-keymap helm-map))) + (define-key map (kbd "C-M-%") 'helm-occur-run-query-replace-regexp) map) - "Keymap for `anything-occur'.") + "Keymap for `helm-occur'.") ;;; Embeded documentation. ;; ;; -(defun anything-c-list-preconfigured-anything () - "Collect preconfigured anything functions in this file." +(defun helm-c-list-preconfigured-helm () + "Collect preconfigured helm functions in this file." (loop with doc with sym for entry in (cdr (assoc - (file-truename (locate-library "anything-config")) + (file-truename (locate-library "helm-config")) load-history)) if (and (consp entry) (eq (car entry) 'defun) @@ -1830,18 +1815,18 @@ automatically.") "")))) collect (cons sym (match-string 0 doc)))) -(defun anything-c-format-preconfigured-anything () +(defun helm-c-format-preconfigured-helm () (mapcar (lambda (x) (format "\\[%s] : %s\n" (car x) (cdr x))) - (anything-c-list-preconfigured-anything))) + (helm-c-list-preconfigured-helm))) -;;; Global help message - Used by `anything-help' +;;; Global help message - Used by `helm-help' ;; ;; -(setq anything-help-message +(setq helm-help-message (lambda () (concat - "\\" - "`anything' is QuickSilver-like candidate-selection framework. + "\\" + "`helm' is QuickSilver-like candidate-selection framework. Narrow the list by typing some pattern, Multiple patterns are allowed by splitting by space. @@ -1849,7 +1834,7 @@ Select with natural Emacs operations, choose with RET. If you have any problems, press C-c C-x C-b!! Feel free to send bug reports. I'll fix them. -The steps are described in the beginning of anything.el file. +The steps are described in the beginning of helm.el file. == Basic Operations == C-p, Up: Previous Line @@ -1866,310 +1851,310 @@ Tab, C-i : Show action list Left : Previous Source Right, C-o : Next Source C-k : Delete pattern -C-z : Persistent Action (Execute action with anything session kept) +C-z : Persistent Action (Execute action with helm session kept) C-c C-x C-b: Send a bug report == Shortcuts For 2nd/3rd Action == -\\[anything-select-2nd-action-or-end-of-line] : Execute 2nd Action (if the minibuffer cursor is at end of line) -\\[anything-select-3rd-action] : Execute 3rd Action +\\[helm-select-2nd-action-or-end-of-line] : Execute 2nd Action (if the minibuffer cursor is at end of line) +\\[helm-select-3rd-action] : Execute 3rd Action == Visible Marks == Visible marks store candidate. Some actions uses marked candidates. -\\[anything-toggle-visible-mark] : Toggle Visible Mark -\\[anything-prev-visible-mark] : Previous Mark -\\[anything-next-visible-mark] : Next Mark +\\[helm-toggle-visible-mark] : Toggle Visible Mark +\\[helm-prev-visible-mark] : Previous Mark +\\[helm-next-visible-mark] : Next Mark == Miscellaneous Commands == -\\[anything-toggle-resplit-window] : Toggle vertical/horizontal split anything window -\\[anything-quit-and-find-file] : Drop into `find-file' -\\[anything-delete-current-selection] : Delete Selected Item (visually) -\\[anything-kill-selection-and-quit] : Set Item Into the kill-ring And Quit -\\[anything-yank-selection] : Yank Selected Item Into Pattern -\\[anything-follow-mode] : Toggle Automatical Execution Of Persistent Action -\\[anything-force-update] : Recalculate And Redisplay Candidates +\\[helm-toggle-resplit-window] : Toggle vertical/horizontal split helm window +\\[helm-quit-and-find-file] : Drop into `find-file' +\\[helm-delete-current-selection] : Delete Selected Item (visually) +\\[helm-kill-selection-and-quit] : Set Item Into the kill-ring And Quit +\\[helm-yank-selection] : Yank Selected Item Into Pattern +\\[helm-follow-mode] : Toggle Automatical Execution Of Persistent Action +\\[helm-force-update] : Recalculate And Redisplay Candidates == Global Commands == -\\\\[anything-resume] revives last `anything' session. +\\\\[helm-resume] revives last `helm' session. It is very useful, so you should bind any key. -Single source is executed by \\[anything-call-source]. +Single source is executed by \\[helm-call-source]. -== Preconfigured `anything' == -Preconfigured `anything' is commands that uses `anything' interface. +== Preconfigured `helm' == +Preconfigured `helm' is commands that uses `helm' interface. You can use them without configuration. " - (apply 'concat (anything-c-format-preconfigured-anything)) + (apply 'concat (helm-c-format-preconfigured-helm)) " Enjoy!"))) -;;; `anything-buffer-list' help +;;; `helm-buffer-list' help ;; ;; -(defvar anything-c-buffer-help-message - "== Anything Buffer == +(defvar helm-c-buffer-help-message + "== Helm Buffer == \nTips: You can enter a partial name of major-mode (e.g lisp, sh) to narrow down buffers. Enter then a space and a pattern to narrow down to buffers matching this pattern. -\nSpecific commands for `anything-buffers-list': -\\ -\\[anything-buffer-run-zgrep]\t\t->Grep Buffer(s) works as zgrep too. (C-u grep all buffers but non--file buffers). -\\[anything-buffer-switch-other-window]\t\t->Switch other window. -\\[anything-buffer-switch-other-frame]\t\t->Switch other frame. -\\[anything-buffer-run-query-replace-regexp]\t\t->Query replace regexp in marked buffers. -\\[anything-buffer-run-query-replace]\t\t->Query replace in marked buffers. -\\[anything-buffer-switch-to-elscreen]\t\t->Find buffer in Elscreen. -\\[anything-buffer-run-ediff]\t\t->Ediff current buffer with candidate. If two marked buffers ediff those buffers. -\\[anything-buffer-run-ediff-merge]\t\t->Ediff merge current buffer with candidate. If two marked buffers ediff merge those buffers. -\\[anything-buffer-diff-persistent]\t\t->Toggle Diff buffer with saved file without quitting. -\\[anything-buffer-revert-persistent]\t\t->Revert buffer without quitting. -\\[anything-buffer-save-persistent]\t\t->Save buffer without quitting. -\\[anything-buffer-run-kill-buffers]\t\t->Delete marked buffers and quit. -\\[anything-toggle-all-marks]\t\t->Toggle all marks. -\\[anything-mark-all]\t\t->Mark all. -\\[anything-c-buffer-help]\t\t->Display this help. -\n== Anything Map == -\\{anything-map}") +\nSpecific commands for `helm-buffers-list': +\\ +\\[helm-buffer-run-zgrep]\t\t->Grep Buffer(s) works as zgrep too. (C-u grep all buffers but non--file buffers). +\\[helm-buffer-switch-other-window]\t\t->Switch other window. +\\[helm-buffer-switch-other-frame]\t\t->Switch other frame. +\\[helm-buffer-run-query-replace-regexp]\t\t->Query replace regexp in marked buffers. +\\[helm-buffer-run-query-replace]\t\t->Query replace in marked buffers. +\\[helm-buffer-switch-to-elscreen]\t\t->Find buffer in Elscreen. +\\[helm-buffer-run-ediff]\t\t->Ediff current buffer with candidate. If two marked buffers ediff those buffers. +\\[helm-buffer-run-ediff-merge]\t\t->Ediff merge current buffer with candidate. If two marked buffers ediff merge those buffers. +\\[helm-buffer-diff-persistent]\t\t->Toggle Diff buffer with saved file without quitting. +\\[helm-buffer-revert-persistent]\t\t->Revert buffer without quitting. +\\[helm-buffer-save-persistent]\t\t->Save buffer without quitting. +\\[helm-buffer-run-kill-buffers]\t\t->Delete marked buffers and quit. +\\[helm-toggle-all-marks]\t\t->Toggle all marks. +\\[helm-mark-all]\t\t->Mark all. +\\[helm-c-buffer-help]\t\t->Display this help. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-c-buffer-help () - "Help command for anything buffers." +(defun helm-c-buffer-help () + "Help command for helm buffers." (interactive) - (let ((anything-help-message anything-c-buffer-help-message)) - (anything-help))) + (let ((helm-help-message helm-c-buffer-help-message)) + (helm-help))) -;;; Find files help (`anything-find-files') +;;; Find files help (`helm-find-files') ;; ;; -(defvar anything-ff-help-message - "== Anything Find Files == +(defvar helm-ff-help-message + "== Helm Find Files == \nTips: \n- Enter `~/' at end of pattern to quickly reach home directory. - Enter `/' at end of pattern to quickly reach root of your file system. - Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session). - You can complete with partial basename \(e.g \"fb\" will complete \"foobar\"\). - Use `C-u C-z' to watch an image. -- To browse images directories turn on `anything-follow-mode' and navigate with arrow keys. +- To browse images directories turn on `helm-follow-mode' and navigate with arrow keys. - When entered ediff, hitting `C-g' will ask you to use locate to find the file to ediff with. -\nSpecific commands for `anything-find-files': -\\ -\\[anything-ff-run-locate]\t\t->Run Locate on basename of candidate (C-u to specify locate db). -\\[anything-ff-run-grep]\t\t->Run Grep (C-u Recursive). -\\[anything-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. -\\[anything-ff-run-zgrep]\t\t->Run zgrep (C-u Recursive). -\\[anything-ff-run-etags]\t\t->Run Etags (C-u use thing-at-point `C-u C-u' reload cache) -\\[anything-ff-run-rename-file]\t\t->Rename File (C-u Follow). -\\[anything-ff-run-copy-file]\t\t->Copy File (C-u Follow). -\\[anything-ff-run-byte-compile-file]\t\t->Byte Compile File (C-u Load). -\\[anything-ff-run-load-file]\t\t->Load File. -\\[anything-ff-run-symlink-file]\t\t->Symlink File. -\\[anything-ff-run-hardlink-file]\t\t->Hardlink file. -\\[anything-ff-run-delete-file]\t\t->Delete File. -\\[anything-ff-run-kill-buffer-persistent]\t\t->Kill buffer candidate without quitting. -\\[anything-ff-persistent-delete]\t\t->Delete file without quitting. -\\[anything-ff-run-switch-to-eshell]\t\t->Switch to Eshell. -\\[anything-ff-run-eshell-command-on-file]\t\t->Eshell command on file (C-u Run on all marked files at once). -\\[anything-ff-run-ediff-file]\t\t->Ediff file. -\\[anything-ff-run-ediff-merge-file]\t\t->Ediff merge file. -\\[anything-ff-run-complete-fn-at-point]\t\t->Complete file name at point. -\\[anything-ff-run-switch-other-window]\t\t->Switch other window. -\\[anything-ff-run-switch-other-frame]\t\t->Switch other frame. -\\[anything-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). -\\[anything-ff-rotate-left-persistent]\t\t->Rotate Image Left. -\\[anything-ff-rotate-right-persistent]\t\t->Rotate Image Right. -\\[anything-find-files-down-one-level]\t\t->Go down precedent directory. -\\[anything-ff-run-switch-to-history]\t\t->Switch to anything find-files history. -\\[anything-ff-properties-persistent]\t\t->Show file properties in a tooltip. -\\[anything-mark-all]\t\t->Mark all visibles candidates. -\\[anything-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories. -\\[anything-unmark-all]\t\t->Unmark all candidates, visibles and invisibles. -\\[anything-ff-run-gnus-attach-files]\t\t->Gnus attach files to message buffer. -\\[anything-ff-run-print-file]\t\t->Print file, (C-u to refresh printers list). -\\[anything-enlarge-window]\t\t->Enlarge anything window. -\\[anything-narrow-window]\t\t->Narrow anything window. -\\[anything-ff-run-toggle-basename]\t\t->Toggle basename/fullpath. -\\[anything-send-bug-report-from-anything]\t\t->Send Bug report. -\\[anything-ff-help]\t\t->Display this help info. -\n== Anything Map == -\\{anything-map}") +\nSpecific commands for `helm-find-files': +\\ +\\[helm-ff-run-locate]\t\t->Run Locate on basename of candidate (C-u to specify locate db). +\\[helm-ff-run-grep]\t\t->Run Grep (C-u Recursive). +\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. +\\[helm-ff-run-zgrep]\t\t->Run zgrep (C-u Recursive). +\\[helm-ff-run-etags]\t\t->Run Etags (C-u use thing-at-point `C-u C-u' reload cache) +\\[helm-ff-run-rename-file]\t\t->Rename File (C-u Follow). +\\[helm-ff-run-copy-file]\t\t->Copy File (C-u Follow). +\\[helm-ff-run-byte-compile-file]\t\t->Byte Compile File (C-u Load). +\\[helm-ff-run-load-file]\t\t->Load File. +\\[helm-ff-run-symlink-file]\t\t->Symlink File. +\\[helm-ff-run-hardlink-file]\t\t->Hardlink file. +\\[helm-ff-run-delete-file]\t\t->Delete File. +\\[helm-ff-run-kill-buffer-persistent]\t\t->Kill buffer candidate without quitting. +\\[helm-ff-persistent-delete]\t\t->Delete file without quitting. +\\[helm-ff-run-switch-to-eshell]\t\t->Switch to Eshell. +\\[helm-ff-run-eshell-command-on-file]\t\t->Eshell command on file (C-u Run on all marked files at once). +\\[helm-ff-run-ediff-file]\t\t->Ediff file. +\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. +\\[helm-ff-run-complete-fn-at-point]\t\t->Complete file name at point. +\\[helm-ff-run-switch-other-window]\t\t->Switch other window. +\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame. +\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). +\\[helm-ff-rotate-left-persistent]\t\t->Rotate Image Left. +\\[helm-ff-rotate-right-persistent]\t\t->Rotate Image Right. +\\[helm-find-files-down-one-level]\t\t->Go down precedent directory. +\\[helm-ff-run-switch-to-history]\t\t->Switch to helm find-files history. +\\[helm-ff-properties-persistent]\t\t->Show file properties in a tooltip. +\\[helm-mark-all]\t\t->Mark all visibles candidates. +\\[helm-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories. +\\[helm-unmark-all]\t\t->Unmark all candidates, visibles and invisibles. +\\[helm-ff-run-gnus-attach-files]\t\t->Gnus attach files to message buffer. +\\[helm-ff-run-print-file]\t\t->Print file, (C-u to refresh printers list). +\\[helm-enlarge-window]\t\t->Enlarge helm window. +\\[helm-narrow-window]\t\t->Narrow helm window. +\\[helm-ff-run-toggle-basename]\t\t->Toggle basename/fullpath. +\\[helm-send-bug-report-from-helm]\t\t->Send Bug report. +\\[helm-ff-help]\t\t->Display this help info. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-ff-help () - "Help command for `anything-find-files'." +(defun helm-ff-help () + "Help command for `helm-find-files'." (interactive) - (let ((anything-help-message anything-ff-help-message)) - (anything-help))) + (let ((helm-help-message helm-ff-help-message)) + (helm-help))) -;;; Help for `anything-c-read-file-name' +;;; Help for `helm-c-read-file-name' ;; ;; -(defvar anything-read-file-name-help-message - "== Anything read file name Map ==\ -\nSpecific commands for anything-c-read-file-name: -\\ -\\[anything-find-files-down-one-level]\t\t->Go down precedent directory. -\\[anything-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories. -\\[anything-next-source]\t->Goto next source. -\\[anything-previous-source]\t->Goto previous source. -\\[anything-read-file-name-help]\t\t->Display this help info. -\n== Anything Map == -\\{anything-map}") +(defvar helm-read-file-name-help-message + "== Helm read file name Map ==\ +\nSpecific commands for helm-c-read-file-name: +\\ +\\[helm-find-files-down-one-level]\t\t->Go down precedent directory. +\\[helm-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories. +\\[helm-next-source]\t->Goto next source. +\\[helm-previous-source]\t->Goto previous source. +\\[helm-read-file-name-help]\t\t->Display this help info. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-read-file-name-help () +(defun helm-read-file-name-help () (interactive) - (let ((anything-help-message anything-read-file-name-help-message)) - (anything-help))) + (let ((helm-help-message helm-read-file-name-help-message)) + (helm-help))) ;;; Generic file help - Used by locate. ;; ;; -(defvar anything-generic-file-help-message - "== Anything Generic files Map ==\ -\nSpecific commands for anything locate and others files sources: -\\ -\\[anything-ff-run-grep]\t\t->Run grep (C-u recurse). -\\[anything-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. -\\[anything-ff-run-delete-file]\t\t->Delete file. -\\[anything-ff-run-ediff-file]\t\t->Ediff file. -\\[anything-ff-run-ediff-merge-file]\t\t->Ediff merge file. -\\[anything-ff-run-switch-other-window]\t\t->Switch other window. -\\[anything-ff-properties-persistent]\t\t->Show file properties. -\\[anything-yank-text-at-point]\t\t->Yank text at point. -\\[anything-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). +(defvar helm-generic-file-help-message + "== Helm Generic files Map ==\ +\nSpecific commands for helm locate and others files sources: +\\ +\\[helm-ff-run-grep]\t\t->Run grep (C-u recurse). +\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. +\\[helm-ff-run-delete-file]\t\t->Delete file. +\\[helm-ff-run-ediff-file]\t\t->Ediff file. +\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. +\\[helm-ff-run-switch-other-window]\t\t->Switch other window. +\\[helm-ff-properties-persistent]\t\t->Show file properties. +\\[helm-yank-text-at-point]\t\t->Yank text at point. +\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). \nLocate tips: You can add after writing search pattern any of the locate command line options. e.g -b, -e, -n ...etc. See Man locate for more infos. -\n== Anything Map == -\\{anything-map}") +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-generic-file-help () +(defun helm-generic-file-help () (interactive) - (let ((anything-help-message anything-generic-file-help-message)) - (anything-help))) + (let ((helm-help-message helm-generic-file-help-message)) + (helm-help))) ;;; Grep help ;; ;; -(defvar anything-grep-help-message - "== Anything Grep Map ==\ -\nAnything Grep tips: +(defvar helm-grep-help-message + "== Helm Grep Map ==\ +\nHelm Grep tips: You can start grep with a prefix arg to recurse in subdirectories. You can use wild card when selecting files (e.g *.el) You can grep in many differents directories by marking files or wild cards. You can save your results in a grep-mode buffer, see below. -\nSpecific commands for Anything Grep: -\\ -\\[anything-c-goto-next-file]\t->Next File. -\\[anything-c-goto-precedent-file]\t\t->Precedent File. -\\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[anything-c-grep-run-other-window-action]\t\t->Jump other window. -\\[anything-c-grep-run-persistent-action]\t\t->Run persistent action (Same as `C-z'). -\\[anything-c-grep-run-default-action]\t\t->Run default action (Same as RET). -\\[anything-c-grep-run-save-buffer]\t\t->Save to a `grep-mode' enabled buffer. -\\[anything-grep-help]\t\t->Show this help. -\n== Anything Map == -\\{anything-map}") +\nSpecific commands for Helm Grep: +\\ +\\[helm-c-goto-next-file]\t->Next File. +\\[helm-c-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-c-grep-run-other-window-action]\t\t->Jump other window. +\\[helm-c-grep-run-persistent-action]\t\t->Run persistent action (Same as `C-z'). +\\[helm-c-grep-run-default-action]\t\t->Run default action (Same as RET). +\\[helm-c-grep-run-save-buffer]\t\t->Save to a `grep-mode' enabled buffer. +\\[helm-grep-help]\t\t->Show this help. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-grep-help () +(defun helm-grep-help () (interactive) - (let ((anything-help-message anything-grep-help-message)) - (anything-help))) + (let ((helm-help-message helm-grep-help-message)) + (helm-help))) ;;; Pdf grep help ;; ;; -(defvar anything-pdfgrep-help-message - "== Anything PdfGrep Map ==\ +(defvar helm-pdfgrep-help-message + "== Helm PdfGrep Map ==\ \nSpecific commands for Pdf Grep: -\\ -\\[anything-c-goto-next-file]\t->Next File. -\\[anything-c-goto-precedent-file]\t\t->Precedent File. -\\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[anything-pdfgrep-help]\t\t->Show this help. -\n== Anything Map == -\\{anything-map}") +\\ +\\[helm-c-goto-next-file]\t->Next File. +\\[helm-c-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-pdfgrep-help]\t\t->Show this help. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-pdfgrep-help () +(defun helm-pdfgrep-help () (interactive) - (let ((anything-help-message anything-pdfgrep-help-message)) - (anything-help))) + (let ((helm-help-message helm-pdfgrep-help-message)) + (helm-help))) ;;; Etags help ;; ;; -(defvar anything-etags-help-message - "== Anything Etags Map ==\ +(defvar helm-etags-help-message + "== Helm Etags Map ==\ \nSpecific commands for Etags: -\\ -\\[anything-c-goto-next-file]\t->Next File. -\\[anything-c-goto-precedent-file]\t\t->Precedent File. -\\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[anything-etags-help]\t\t->Show this help. -\n== Anything Map == -\\{anything-map}") +\\ +\\[helm-c-goto-next-file]\t->Next File. +\\[helm-c-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-etags-help]\t\t->Show this help. +\n== Helm Map == +\\{helm-map}") ;;;###autoload -(defun anything-etags-help () +(defun helm-etags-help () "The help function for etags." (interactive) - (let ((anything-help-message anything-etags-help-message)) - (anything-help))) + (let ((helm-help-message helm-etags-help-message)) + (helm-help))) ;;; Ucs help ;; ;; -(defvar anything-c-ucs-help-message - "== Anything Ucs == -\nSpecific commands for `anything-ucs': -\\ -\\[anything-c-ucs-persistent-insert]\t->Insert char. -\\[anything-c-ucs-persistent-forward]\t->Forward char. -\\[anything-c-ucs-persistent-backward]\t->Backward char. -\\[anything-c-ucs-persistent-delete]\t->Delete char backward. -\\[anything-c-ucs-help]\t\t->Show this help. +(defvar helm-c-ucs-help-message + "== Helm Ucs == +\nSpecific commands for `helm-ucs': +\\ +\\[helm-c-ucs-persistent-insert]\t->Insert char. +\\[helm-c-ucs-persistent-forward]\t->Forward char. +\\[helm-c-ucs-persistent-backward]\t->Backward char. +\\[helm-c-ucs-persistent-delete]\t->Delete char backward. +\\[helm-c-ucs-help]\t\t->Show this help. -\n== Anything Map == -\\{anything-map}") +\n== Helm Map == +\\{helm-map}") -(defun anything-c-ucs-help () - "Help command for `anything-ucs'." +(defun helm-c-ucs-help () + "Help command for `helm-ucs'." (interactive) - (let ((anything-help-message anything-c-ucs-help-message)) - (anything-help))) + (let ((helm-help-message helm-c-ucs-help-message)) + (helm-help))) ;;; Bookmark help ;; ;; -(defvar anything-bookmark-help-message - "== Anything bookmark name Map ==\ +(defvar helm-bookmark-help-message + "== Helm bookmark name Map ==\ \nSpecific commands for bookmarks: -\\ -\\[anything-c-bookmark-run-jump-other-window]\t\t->Jump other window. -\\[anything-c-bookmark-run-delete]\t\t->Delete bookmark. -\\[anything-c-bmkext-run-edit]\t\t->Edit bookmark (only for bmkext). -\\[anything-c-bookmark-help]\t\t->Run this help. -\n== Anything Map == -\\{anything-map}") +\\ +\\[helm-c-bookmark-run-jump-other-window]\t\t->Jump other window. +\\[helm-c-bookmark-run-delete]\t\t->Delete bookmark. +\\[helm-c-bmkext-run-edit]\t\t->Edit bookmark (only for bmkext). +\\[helm-c-bookmark-help]\t\t->Run this help. +\n== Helm Map == +\\{helm-map}") -(defun anything-c-bookmark-help () +(defun helm-c-bookmark-help () "Help command for bookmarks." (interactive) - (let ((anything-help-message anything-bookmark-help-message)) - (anything-help))) + (let ((helm-help-message helm-bookmark-help-message)) + (helm-help))) ;;; Eshell command on file help ;; ;; -(defvar anything-c-esh-help-message - "== Anything eshell on file == +(defvar helm-c-esh-help-message + "== Helm eshell on file == \nTips: - Passing extra args after filename: @@ -2190,134 +2175,134 @@ But you can also pass an argument or more after 'candidate_file' like this: e.g file1 file2 ... -Please restart and use a prefix arg to call `anything-find-files-eshell-command-on-file'. +Please restart and use a prefix arg to call `helm-find-files-eshell-command-on-file'. Otherwise your command will be called many times like this: file1 file2 etc... -\nSpecific commands for `anything-find-files-eshell-command-on-file': -\\ -\\[anything-esh-help]\t\t->Display this help. -\n== Anything Map == -\\{anything-map}") +\nSpecific commands for `helm-find-files-eshell-command-on-file': +\\ +\\[helm-esh-help]\t\t->Display this help. +\n== Helm Map == +\\{helm-map}") -(defun anything-esh-help () - "Help command for `anything-find-files-eshell-command-on-file'." +(defun helm-esh-help () + "Help command for `helm-find-files-eshell-command-on-file'." (interactive) - (let ((anything-help-message anything-c-esh-help-message)) - (anything-help))) + (let ((helm-help-message helm-c-esh-help-message)) + (helm-help))) ;;; Mode line strings ;; ;; -(defvar anything-buffer-mode-line-string +(defvar helm-buffer-mode-line-string '("Buffer(s)" - "\\\ -\\[anything-c-buffer-help]:Help, \ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." - "String displayed in mode-line in `anything-c-source-buffers-list'")) + "\\\ +\\[helm-c-buffer-help]:Help, \ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." + "String displayed in mode-line in `helm-c-source-buffers-list'")) -(defvar anything-ff-mode-line-string - "\\\ -\\[anything-ff-help]:Help, \ -\\[anything-send-bug-report-from-anything]:BugReport, \ -\\\ -\\[anything-select-action]:Acts, \ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct" - "String displayed in mode-line in `anything-c-source-find-files'") +(defvar helm-ff-mode-line-string + "\\\ +\\[helm-ff-help]:Help, \ +\\[helm-send-bug-report-from-helm]:BugReport, \ +\\\ +\\[helm-select-action]:Acts, \ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct" + "String displayed in mode-line in `helm-c-source-find-files'") -(defvar anything-read-file-name-mode-line-string - "\\\ -\\[anything-read-file-name-help]:Help, \ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct" - "String displayed in mode-line in `anything-c-source-find-files'") +(defvar helm-read-file-name-mode-line-string + "\\\ +\\[helm-read-file-name-help]:Help, \ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct" + "String displayed in mode-line in `helm-c-source-find-files'") -(defvar anything-generic-file-mode-line-string - "\\\ -\\[anything-generic-file-help]:Help, \ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." +(defvar helm-generic-file-mode-line-string + "\\\ +\\[helm-generic-file-help]:Help, \ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." "String displayed in mode-line in Locate.") -(defvar anything-grep-mode-line-string - "\\\ -\\[anything-grep-help]:Help,\ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." - "String displayed in mode-line in `anything-do-grep'.") +(defvar helm-grep-mode-line-string + "\\\ +\\[helm-grep-help]:Help,\ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." + "String displayed in mode-line in `helm-do-grep'.") -(defvar anything-pdfgrep-mode-line-string - "\\\ -\\[anything-pdfgrep-help]:Help,\ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." - "String displayed in mode-line in `anything-do-pdfgrep'.") +(defvar helm-pdfgrep-mode-line-string + "\\\ +\\[helm-pdfgrep-help]:Help,\ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." + "String displayed in mode-line in `helm-do-pdfgrep'.") -(defvar anything-etags-mode-line-string - "\\\ -\\[anything-etags-help]:Help,\ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." - "String displayed in mode-line in `anything-c-etags-select'.") +(defvar helm-etags-mode-line-string + "\\\ +\\[helm-etags-help]:Help,\ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." + "String displayed in mode-line in `helm-c-etags-select'.") -(defvar anything-c-ucs-mode-line-string - "\\\ -\\[anything-c-ucs-help]:Help, \ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct." - "String displayed in mode-line in `anything-ucs'.") +(defvar helm-c-ucs-mode-line-string + "\\\ +\\[helm-c-ucs-help]:Help, \ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct." + "String displayed in mode-line in `helm-ucs'.") -(defvar anything-bookmark-mode-line-string +(defvar helm-bookmark-mode-line-string '("Bookmark(s)" - "\\\ -\\[anything-c-bookmark-help]:Help, \ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport." - "String displayed in mode-line in `anything-c-source-buffers-list'")) + "\\\ +\\[helm-c-bookmark-help]:Help, \ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport." + "String displayed in mode-line in `helm-c-source-buffers-list'")) -(defvar anything-occur-mode-line - "\\\ -\\[anything-help]:Help,\ -\\\ -\\[anything-occur-run-query-replace-regexp]:Query replace regexp,\ -\\\ -\\[anything-select-action]:Acts,\ -\\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\ -\\[anything-select-3rd-action]:NthAct,\ -\\[anything-send-bug-report-from-anything]:BugReport.") +(defvar helm-occur-mode-line + "\\\ +\\[helm-help]:Help,\ +\\\ +\\[helm-occur-run-query-replace-regexp]:Query replace regexp,\ +\\\ +\\[helm-select-action]:Acts,\ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct,\ +\\[helm-send-bug-report-from-helm]:BugReport.") ;;; Utilities Functions ;; ;; -(defun anything-ff-find-printers () +(defun helm-ff-find-printers () "Return a list of available printers on Unix systems." (when (executable-find "lpstat") (let ((printer-list (with-temp-buffer @@ -2329,12 +2314,12 @@ Otherwise your command will be called many times like this: collect printer)))) ;; Shut up byte compiler in emacs24*. -(defun anything-c-switch-to-buffer (buffer-or-name) +(defun helm-c-switch-to-buffer (buffer-or-name) "Same as `switch-to-buffer' whithout warnings at compile time." (with-no-warnings (switch-to-buffer buffer-or-name))) -(defun* anything-c-position (item seq &key (test 'eq) all) +(defun* helm-c-position (item seq &key (test 'eq) all) "A simple and faster replacement of CL `position'. Return position of first occurence of ITEM found in SEQ. Argument SEQ can be a string, in this case ITEM have to be a char. @@ -2349,7 +2334,7 @@ all ITEM found in SEQ." else return index finally return ls)))) -(defun anything-c-get-pid-from-process-name (process-name) +(defun helm-c-get-pid-from-process-name (process-name) "Get pid from running process PROCESS-NAME." (loop with process-list = (list-system-processes) for pid in process-list @@ -2357,20 +2342,20 @@ all ITEM found in SEQ." when (and process (string-match process-name process)) return pid)) -(defun* anything-current-buffer-narrowed-p (&optional - (buffer anything-current-buffer)) +(defun* helm-current-buffer-narrowed-p (&optional + (buffer helm-current-buffer)) "Check if BUFFER is narrowed. -Default is `anything-current-buffer'." +Default is `helm-current-buffer'." (with-current-buffer buffer (let ((beg (point-min)) (end (point-max)) (total (buffer-size))) (or (/= beg 1) (/= end (1+ total)))))) -(defun anything-region-active-p () +(defun helm-region-active-p () (and transient-mark-mode mark-active (/= (mark) (point)))) -(defun anything-goto-char (loc) +(defun helm-goto-char (loc) "Go to char, revealing if necessary." (goto-char loc) (when (or (eq major-mode 'org-mode) @@ -2379,105 +2364,67 @@ Default is `anything-current-buffer'." (require 'org) ; On some old Emacs versions org may not be loaded. (org-reveal))) -(defun anything-goto-line (lineno &optional noanim) +(defun helm-goto-line (lineno &optional noanim) "Goto LINENO opening only outline headline if needed. Animation is used unless NOANIM is non--nil." (goto-char (point-min)) - (anything-goto-char (point-at-bol lineno)) + (helm-goto-char (point-at-bol lineno)) (unless noanim - (anything-match-line-color-current-line) + (helm-match-line-color-current-line) (sit-for 0.3) - (anything-match-line-cleanup))) + (helm-match-line-cleanup))) -(defun anything-show-this-source-only () +(defun helm-show-this-source-only () "Show all candidates of this source." (interactive) - (let (anything-candidate-number-limit) - (anything-set-source-filter - (list (assoc-default 'name (anything-get-current-source)))))) + (let (helm-candidate-number-limit) + (helm-set-source-filter + (list (assoc-default 'name (helm-get-current-source)))))) ;;;###autoload -(defun anything-test-sources () - "List all anything sources for test. +(defun helm-test-sources () + "List all helm sources for test. The output is sexps which are evaluated by \\[eval-last-sexp]." (interactive) - (with-output-to-temp-buffer "*Anything Test Sources*" - (mapc (lambda (s) (princ (format ";; (anything '%s)\n" s))) - (apropos-internal "^anything-c-source" #'boundp)) + (with-output-to-temp-buffer "*Helm Test Sources*" + (mapc (lambda (s) (princ (format ";; (helm '%s)\n" s))) + (apropos-internal "^helm-c-source" #'boundp)) (pop-to-buffer standard-output))) -(defun anything-displaying-source-names () +(defun helm-displaying-source-names () "Display sources name." - (with-current-buffer anything-buffer + (with-current-buffer helm-buffer (goto-char (point-min)) (loop with pos - while (setq pos (next-single-property-change (point) 'anything-header)) + while (setq pos (next-single-property-change (point) 'helm-header)) do (goto-char pos) collect (buffer-substring-no-properties (point-at-bol)(point-at-eol)) do (forward-line 1)))) -;; [Obsolete] -(defun anything-select-source () - "[OBSOLETE] Select source." - (interactive) - (let ((default (assoc-default 'name (anything-get-current-source))) - (source-names (anything-displaying-source-names)) - (all-source-names (mapcar (lambda (s) (assoc-default 'name s)) - (anything-get-sources)))) - (setq anything-candidate-number-limit 9999) - (anything-aif - (let (anything-source-filter) - (anything-nest '(((name . "Anything Source") - (candidates . source-names) - (action . identity)) - ((name . "Anything Source (ALL)") - (candidates . all-source-names) - (action . identity))) - nil "Source: " nil - default "*anything select source*")) - (anything-set-source-filter (list it)) - (anything-set-source-filter nil)))) +(defun helm-c-match-on-file-name (candidate) + "Return non-nil if `helm-pattern' match basename of filename CANDIDATE." + (string-match helm-pattern (file-name-nondirectory candidate))) -(defun anything-insert-string (str) - "Insert STR." - (anything-set-pattern str 'noupdate)) +(defun helm-c-match-on-directory-name (candidate) + "Return non-nil if `helm-pattern' match directory part of CANDIDATE." + (helm-aif (file-name-directory candidate) + (string-match helm-pattern it))) -;;;###autoload -(defun anything-insert-buffer-name () - "Insert buffer name." - (interactive) - (anything-set-pattern - (with-anything-current-buffer - (if buffer-file-name (file-name-nondirectory buffer-file-name) - (buffer-name))))) +(defun helm-c-match-on-basename (candidate) + "Return non-nil if `helm-pattern' match basename of filename CANDIDATE." + (string-match helm-pattern (helm-c-basename candidate))) -(defalias 'anything-insert-symbol 'next-history-element) -(defalias 'anything-insert-selection 'anything-yank-selection) - -(defun anything-c-match-on-file-name (candidate) - "Return non-nil if `anything-pattern' match basename of filename CANDIDATE." - (string-match anything-pattern (file-name-nondirectory candidate))) - -(defun anything-c-match-on-directory-name (candidate) - "Return non-nil if `anything-pattern' match directory part of CANDIDATE." - (anything-aif (file-name-directory candidate) - (string-match anything-pattern it))) - -(defun anything-c-match-on-basename (candidate) - "Return non-nil if `anything-pattern' match basename of filename CANDIDATE." - (string-match anything-pattern (anything-c-basename candidate))) - -(defun anything-c-string-match (candidate) - "Return non-nil if `anything-pattern' match CANDIDATE. +(defun helm-c-string-match (candidate) + "Return non-nil if `helm-pattern' match CANDIDATE. The match is done with `string-match'." - (string-match anything-pattern candidate)) + (string-match helm-pattern candidate)) -(defun anything-c-skip-entries (list regexp) +(defun helm-c-skip-entries (list regexp) "Remove entries which matches REGEXP from LIST." (remove-if (lambda (x) (and (stringp x) (string-match regexp x))) list)) -(defun anything-c-shadow-entries (list regexp) +(defun helm-c-shadow-entries (list regexp) "Display elements of LIST matching REGEXP with the `file-name-shadow' face." (mapcar (lambda (file) ;; Add shadow face property to boring files. @@ -2490,40 +2437,40 @@ The match is done with `string-match'." file) list)) -(defsubst anything-c-stringify (str-or-sym) +(defsubst helm-c-stringify (str-or-sym) "Get string of STR-OR-SYM." (if (stringp str-or-sym) str-or-sym (symbol-name str-or-sym))) -(defsubst anything-c-symbolify (str-or-sym) +(defsubst helm-c-symbolify (str-or-sym) "Get symbol of STR-OR-SYM." (if (symbolp str-or-sym) str-or-sym (intern str-or-sym))) -(defun anything-c-describe-function (func) +(defun helm-c-describe-function (func) "FUNC is symbol or string." - (describe-function (anything-c-symbolify func))) + (describe-function (helm-c-symbolify func))) -(defun anything-c-describe-variable (var) +(defun helm-c-describe-variable (var) "VAR is symbol or string." - (describe-variable (anything-c-symbolify var))) + (describe-variable (helm-c-symbolify var))) -(defun anything-c-find-function (func) +(defun helm-c-find-function (func) "FUNC is symbol or string." - (find-function (anything-c-symbolify func))) + (find-function (helm-c-symbolify func))) -(defun anything-c-find-variable (var) +(defun helm-c-find-variable (var) "VAR is symbol or string." - (find-variable (anything-c-symbolify var))) + (find-variable (helm-c-symbolify var))) -(defun anything-c-kill-new (candidate &optional replace) +(defun helm-c-kill-new (candidate &optional replace) "CANDIDATE is symbol or string. See `kill-new' for argument REPLACE." - (kill-new (anything-c-stringify candidate) replace)) + (kill-new (helm-c-stringify candidate) replace)) -(defun* anything-fast-remove-dups (seq &key (test 'eq)) +(defun* helm-fast-remove-dups (seq &key (test 'eq)) "Remove duplicates elements in list SEQ. This is same as `remove-duplicates' but with memoisation. It is much faster, especially in large lists. @@ -2536,35 +2483,35 @@ Default is `eq'." finally return (loop for i being the hash-values in cont collect i))) -(defadvice eval-defun (after anything-source-hack activate) - "Allow immediate execution of anything source when evaling it. -See `anything-c-enable-eval-defun-hack'." - (when anything-c-enable-eval-defun-hack +(defadvice eval-defun (after helm-source-hack activate) + "Allow immediate execution of helm source when evaling it. +See `helm-c-enable-eval-defun-hack'." + (when helm-c-enable-eval-defun-hack (let ((varsym (save-excursion (beginning-of-defun) (forward-char 1) (when (memq (read (current-buffer)) '(defvar setq)) (read (current-buffer)))))) - (when (string-match "^anything-c-source-" (symbol-name varsym)) - (anything varsym))))) -;; (progn (ad-disable-advice 'eval-defun 'after 'anything-source-hack) (ad-update 'eval-defun)) + (when (string-match "^helm-c-source-" (symbol-name varsym)) + (helm varsym))))) +;; (progn (ad-disable-advice 'eval-defun 'after 'helm-source-hack) (ad-update 'eval-defun)) -;; Move this function from anything.el and redefine here +;; Move this function from helm.el and redefine here ;; to avoid an unneeded defadvice. -(defun anything-quit-and-find-file () - "Drop into `anything-find-files' from `anything'. -If current selection is a buffer or a file, `anything-find-files' +(defun helm-quit-and-find-file () + "Drop into `helm-find-files' from `helm'. +If current selection is a buffer or a file, `helm-find-files' from its directory." (interactive) - (anything-run-after-quit + (helm-run-after-quit (lambda (f) (if (file-exists-p f) - (anything-find-files-1 (file-name-directory f) - (if anything-ff-transformer-show-only-basename - (anything-c-basename f) f)) - (anything-find-files-1 f))) - (anything-aif (get-buffer (anything-get-selection)) + (helm-find-files-1 (file-name-directory f) + (if helm-ff-transformer-show-only-basename + (helm-c-basename f) f)) + (helm-find-files-1 f))) + (helm-aif (get-buffer (helm-get-selection)) (or (buffer-file-name it) (car (rassoc it dired-buffers)) (and (with-current-buffer it @@ -2572,7 +2519,7 @@ from its directory." org-directory (expand-file-name org-directory)) default-directory) - (let ((sel (anything-get-selection))) + (let ((sel (helm-get-selection))) (cond ((or (file-remote-p sel) (file-exists-p sel)) (expand-file-name sel)) @@ -2581,7 +2528,7 @@ from its directory." (t default-directory)))))) -(defmacro* anything-c-walk-directory (directory &key path (directories t) match) +(defmacro* helm-c-walk-directory (directory &key path (directories t) match) "Walk through DIRECTORY tree. PATH can be one of basename, relative, or full. DIRECTORIES when non--nil (default) return also directories names, otherwise @@ -2608,62 +2555,62 @@ MATCH match only filenames matching regexp MATCH." (ls-R ,directory) (nreverse result)))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Applications ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Helm Applications ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Anything regexp. +;;; Helm regexp. ;; ;; -(defvar anything-build-regexp-history nil) -(defun anything-c-query-replace-regexp (candidate) - "Query replace regexp from `anything-regexp'. +(defvar helm-build-regexp-history nil) +(defun helm-c-query-replace-regexp (candidate) + "Query replace regexp from `helm-regexp'. With a prefix arg replace only matches surrounded by word boundaries, i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." - (let ((regexp (funcall (anything-attr 'regexp)))) + (let ((regexp (funcall (helm-attr 'regexp)))) (apply 'query-replace-regexp - (anything-c-query-replace-args regexp)))) + (helm-c-query-replace-args regexp)))) -(defun anything-c-kill-regexp-as-sexp (candidate) +(defun helm-c-kill-regexp-as-sexp (candidate) "Kill regexp in a format usable in lisp code." - (anything-c-regexp-kill-new - (prin1-to-string (funcall (anything-attr 'regexp))))) + (helm-c-regexp-kill-new + (prin1-to-string (funcall (helm-attr 'regexp))))) -(defun anything-c-kill-regexp (candidate) - "Kill regexp as it is in `anything-pattern'." - (anything-c-regexp-kill-new (funcall (anything-attr 'regexp)))) +(defun helm-c-kill-regexp (candidate) + "Kill regexp as it is in `helm-pattern'." + (helm-c-regexp-kill-new (funcall (helm-attr 'regexp)))) -(defun anything-c-query-replace-args (regexp) - "create arguments of `query-replace-regexp' action in `anything-regexp'." - (let ((region-only (anything-region-active-p))) +(defun helm-c-query-replace-args (regexp) + "create arguments of `query-replace-regexp' action in `helm-regexp'." + (let ((region-only (helm-region-active-p))) (list regexp (query-replace-read-to regexp (format "Query replace %sregexp %s" - (if anything-current-prefix-arg "word " "") + (if helm-current-prefix-arg "word " "") (if region-only "in region " "")) t) - anything-current-prefix-arg + helm-current-prefix-arg (when region-only (region-beginning)) (when region-only (region-end))))) -(defvar anything-c-source-regexp +(defvar helm-c-source-regexp '((name . "Regexp Builder") (init . (lambda () - (anything-candidate-buffer anything-current-buffer))) + (helm-candidate-buffer helm-current-buffer))) (candidates-in-buffer) - (get-line . anything-c-regexp-get-line) - (persistent-action . anything-c-regexp-persistent-action) + (get-line . helm-c-regexp-get-line) + (persistent-action . helm-c-regexp-persistent-action) (persistent-help . "Show this line") (multiline) (delayed) (requires-pattern . 2) (mode-line . "Press TAB to select action.") - (regexp . (lambda () anything-input)) - (action . (("Kill Regexp as sexp" . anything-c-kill-regexp-as-sexp) + (regexp . (lambda () helm-input)) + (action . (("Kill Regexp as sexp" . helm-c-kill-regexp-as-sexp) ("Query Replace Regexp (C-u Not inside word.)" - . anything-c-query-replace-regexp) - ("Kill Regexp" . anything-c-kill-regexp))))) + . helm-c-query-replace-regexp) + ("Kill Regexp" . helm-c-kill-regexp))))) -(defun anything-c-regexp-get-line (s e) +(defun helm-c-regexp-get-line (s e) (propertize (apply 'concat ;; Line contents @@ -2674,20 +2621,20 @@ i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." (if (zerop i) "Group 0: " (format "Group %d: " i)) (match-string i)))) ;; match beginning - ;; KLUDGE: point of anything-candidate-buffer is +1 than that of anything-current-buffer. + ;; KLUDGE: point of helm-candidate-buffer is +1 than that of helm-current-buffer. ;; It is implementation problem of candidates-in-buffer. - 'anything-realvalue + 'helm-realvalue (1- s))) -(defun anything-c-regexp-persistent-action (pt) - (anything-goto-char pt) - (anything-persistent-highlight-point)) +(defun helm-c-regexp-persistent-action (pt) + (helm-goto-char pt) + (helm-persistent-highlight-point)) -(defun anything-c-regexp-kill-new (input) +(defun helm-c-regexp-kill-new (input) (kill-new input) (message "Killed: %s" input)) -(defun anything-quote-whitespace (candidate) +(defun helm-quote-whitespace (candidate) "Quote whitespace, if some, in string CANDIDATE." (replace-regexp-in-string " " "\\\\ " candidate)) @@ -2696,14 +2643,14 @@ i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." ;; ;; ;;;###autoload -(defun anything-mark-all () +(defun helm-mark-all () "Mark all visible unmarked candidates in current source." (interactive) - (with-anything-window + (with-helm-window (save-excursion - (goto-char (anything-get-previous-header-pos)) - (anything-next-line) - (let* ((next-head (anything-get-next-header-pos)) + (goto-char (helm-get-previous-header-pos)) + (helm-next-line) + (let* ((next-head (helm-get-next-header-pos)) (end (and next-head (save-excursion (goto-char next-head) @@ -2711,91 +2658,91 @@ i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." (point)))) (maxpoint (or end (point-max)))) (while (< (point) maxpoint) - (anything-mark-current-line) + (helm-mark-current-line) (let* ((prefix (get-text-property (point-at-bol) 'display)) - (cand (anything-get-selection)) - (bn (and (anything-file-completion-source-p) - (anything-c-basename cand))) - (src (assoc-default 'name (anything-get-current-source)))) - (when (and (not (anything-this-visible-mark)) + (cand (helm-get-selection)) + (bn (and (helm-file-completion-source-p) + (helm-c-basename cand))) + (src (assoc-default 'name (helm-get-current-source)))) + (when (and (not (helm-this-visible-mark)) (not (or (string= prefix "[?]") (string= prefix "[@]")))) ;; Don't mark possibles directories ending with . or .. ;; autosave files/links and non--existent file. (unless - (and (or (anything-file-completion-source-p) + (and (or (helm-file-completion-source-p) (equal src "Files from Current Directory")) (or (string-match "^\\.#.*\\|^#.*#$\\|\\.$" bn) ;; We need to test here when not using a transformer ;; that tag prefix (i.e on tramp) (not (file-exists-p cand)))) - (anything-make-visible-mark)))) + (helm-make-visible-mark)))) (forward-line 1) (end-of-line)))) - (anything-mark-current-line) - (message "%s candidates marked" (length anything-marked-candidates)))) + (helm-mark-current-line) + (message "%s candidates marked" (length helm-marked-candidates)))) ;;;###autoload -(defun anything-unmark-all () - "Unmark all candidates in all sources of current anything session." +(defun helm-unmark-all () + "Unmark all candidates in all sources of current helm session." (interactive) - (with-anything-window - (let ((len (length anything-marked-candidates))) + (with-helm-window + (let ((len (length helm-marked-candidates))) (save-excursion - (anything-clear-visible-mark)) - (setq anything-marked-candidates nil) - (anything-mark-current-line) + (helm-clear-visible-mark)) + (setq helm-marked-candidates nil) + (helm-mark-current-line) (message "%s candidates unmarked" len)))) ;;;###autoload -(defun anything-toggle-all-marks () +(defun helm-toggle-all-marks () "Toggle all marks. Mark all visible candidates of current source or unmark all candidates -visible or invisible in all sources of current anything session" +visible or invisible in all sources of current helm session" (interactive) - (let ((marked (anything-marked-candidates))) + (let ((marked (helm-marked-candidates))) (if (and (>= (length marked) 1) - (with-anything-window anything-visible-mark-overlays)) - (anything-unmark-all) - (anything-mark-all)))) + (with-helm-window helm-visible-mark-overlays)) + (helm-unmark-all) + (helm-mark-all)))) ;;; Buffers ;; ;; -(defun anything-c-buffer-list () +(defun helm-c-buffer-list () "Return a list of buffer names. The first buffer in the list will be the last recently used buffer that is not the current buffer unless -`anything-allow-skipping-current-buffer' is nil." +`helm-allow-skipping-current-buffer' is nil." (let ((buffers (mapcar 'buffer-name (buffer-list)))) - (if anything-allow-skipping-current-buffer + (if helm-allow-skipping-current-buffer (progn - (setq buffers (remove (buffer-name anything-current-buffer) buffers)) + (setq buffers (remove (buffer-name helm-current-buffer) buffers)) (append (cdr buffers) (list (car buffers)))) buffers))) -(defvar anything-c-source-buffers +(defvar helm-c-source-buffers '((name . "Buffers") - (candidates . anything-c-buffer-list) + (candidates . helm-c-buffer-list) (type . buffer))) -(defvar anything-c-source-buffer-not-found +(defvar helm-c-source-buffer-not-found `((name . "Create buffer") (dummy) (filtered-candidate-transformer (lambda (cands source) - (list anything-pattern))) - (keymap . ,anything-map) + (list helm-pattern))) + (keymap . ,helm-map) (action . (lambda (candidate) - (anything-c-switch-to-buffer (get-buffer-create candidate)))))) + (helm-c-switch-to-buffer (get-buffer-create candidate)))))) ;;; Buffers-list (was buffers+) ;; ;; -(defun anything-c-highlight-buffers (buffers) +(defun helm-c-highlight-buffers (buffers) "Transformer function to highlight BUFFERS list. Should be called after others transformers i.e (boring buffers)." - (loop with buflist = (if anything-allow-skipping-current-buffer + (loop with buflist = (if helm-allow-skipping-current-buffer buffers (cons (pop (cdr buffers)) buffers)) for i in buflist @@ -2804,35 +2751,35 @@ Should be called after others transformers i.e (boring buffers)." collect (cond (;; A dired buffer. (rassoc buf dired-buffers) - (propertize i 'face 'anything-ff-directory + (propertize i 'face 'helm-ff-directory 'help-echo (car (rassoc buf dired-buffers)))) ;; A buffer file modified somewhere outside of emacs. ((and bfname (not (file-remote-p bfname)) (file-exists-p bfname) (not (verify-visited-file-modtime buf))) - (propertize i 'face 'anything-buffer-saved-out + (propertize i 'face 'helm-buffer-saved-out 'help-echo bfname)) ;; A new buffer file not already saved on disk. ((and bfname (not (file-remote-p bfname)) (not (verify-visited-file-modtime buf))) - (propertize i 'face 'anything-buffer-not-saved + (propertize i 'face 'helm-buffer-not-saved 'help-echo bfname)) ;; A Remote buffer file modified and not saved on disk. ((and bfname (file-remote-p bfname) (buffer-modified-p buf)) (let ((prefix (propertize " " 'display - (propertize "@ " 'face 'anything-ff-prefix)))) - (cons (concat prefix (propertize i 'face 'anything-ff-symlink + (propertize "@ " 'face 'helm-ff-prefix)))) + (cons (concat prefix (propertize i 'face 'helm-ff-symlink 'help-echo bfname)) i))) ;; A buffer file modified and not saved on disk. ((and bfname (buffer-modified-p buf)) - (propertize i 'face 'anything-ff-symlink + (propertize i 'face 'helm-ff-symlink 'help-echo bfname)) ;; A remote buffer file not modified and saved on disk. ((and bfname (file-remote-p bfname)) (let ((prefix (propertize " " 'display - (propertize "@ " 'face 'anything-ff-prefix)))) + (propertize "@ " 'face 'helm-ff-prefix)))) (cons (concat prefix (propertize i 'face 'font-lock-type-face 'help-echo bfname)) i))) ;; A buffer file not modified and saved on disk. @@ -2843,22 +2790,22 @@ Should be called after others transformers i.e (boring buffers)." (t (propertize i 'face 'italic))))) -(defvar anything-c-source-buffers-list +(defvar helm-c-source-buffers-list `((name . "Buffers") - (candidates . anything-c-buffer-list) + (candidates . helm-c-buffer-list) (type . buffer) - (match anything-c-buffer-match-major-mode) - (candidate-transformer anything-c-skip-boring-buffers - anything-c-highlight-buffers) - (persistent-action . anything-c-buffers-list-persistent-action) - (keymap . ,anything-c-buffer-map) + (match helm-c-buffer-match-major-mode) + (candidate-transformer helm-c-skip-boring-buffers + helm-c-highlight-buffers) + (persistent-action . helm-c-buffers-list-persistent-action) + (keymap . ,helm-c-buffer-map) (volatile) - (mode-line . anything-buffer-mode-line-string) - (persistent-help . "Show this buffer / C-u \\[anything-execute-persistent-action]: Kill this buffer"))) + (mode-line . helm-buffer-mode-line-string) + (persistent-help . "Show this buffer / C-u \\[helm-execute-persistent-action]: Kill this buffer"))) -(defvaralias 'anything-c-source-buffers+ 'anything-c-source-buffers-list) +(defvaralias 'helm-c-source-buffers+ 'helm-c-source-buffers-list) -(defun anything-c-buffer-match-major-mode (candidate) +(defun helm-c-buffer-match-major-mode (candidate) "Match maybe buffer by major-mode. If you give a major-mode or partial major-mode, it will list all buffers of this major-mode and/or buffers with name @@ -2873,21 +2820,21 @@ with name matching pattern." (when buf (with-current-buffer buf (let ((mjm (symbol-name major-mode)) - (split (split-string anything-pattern))) - (cond ((string-match "\\s-$" anything-pattern) + (split (split-string helm-pattern))) + (cond ((string-match "\\s-$" helm-pattern) (string-match (car split) mjm)) - ((string-match "\\s-" anything-pattern) + ((string-match "\\s-" helm-pattern) (and (string-match (car split) mjm) (string-match (cadr split) cand))) - (t (or (string-match anything-pattern mjm) - (string-match anything-pattern cand))))))))) + (t (or (string-match helm-pattern mjm) + (string-match helm-pattern cand))))))))) -(defun anything-c-buffer-query-replace-1 (&optional regexp-flag) +(defun helm-c-buffer-query-replace-1 (&optional regexp-flag) "Query replace in marked buffers. If REGEXP-FLAG is given use `query-replace-regexp'." (let ((fn (if regexp-flag 'query-replace-regexp 'query-replace)) (prompt (if regexp-flag "Query replace regexp" "Query replace")) - (bufs (anything-marked-candidates))) + (bufs (helm-marked-candidates))) (loop with replace = (query-replace-read-from prompt regexp-flag) with tostring = (unless (consp replace) @@ -2896,7 +2843,7 @@ If REGEXP-FLAG is given use `query-replace-regexp'." for buf in bufs do (save-window-excursion - (anything-c-switch-to-buffer buf) + (helm-c-switch-to-buffer buf) (save-excursion (let ((case-fold-search t)) (goto-char (point-min)) @@ -2904,112 +2851,112 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (apply fn (list (car replace) (cdr replace))) (apply fn (list replace tostring))))))))) -(defun anything-c-buffer-query-replace-regexp (candidate) - (anything-c-buffer-query-replace-1 'regexp)) +(defun helm-c-buffer-query-replace-regexp (candidate) + (helm-c-buffer-query-replace-1 'regexp)) -(defun anything-c-buffer-query-replace (candidate) - (anything-c-buffer-query-replace-1)) +(defun helm-c-buffer-query-replace (candidate) + (helm-c-buffer-query-replace-1)) -(defun anything-buffer-toggle-diff (candidate) +(defun helm-buffer-toggle-diff (candidate) "Toggle diff buffer CANDIDATE with it's file." (if (get-buffer-window "*Diff*") (kill-buffer "*Diff*") (diff-buffer-with-file (get-buffer candidate)))) ;;;###autoload -(defun anything-buffer-diff-persistent () - "Toggle diff buffer without quitting anything." +(defun helm-buffer-diff-persistent () + "Toggle diff buffer without quitting helm." (interactive) - (anything-attrset 'diff-action 'anything-buffer-toggle-diff) - (anything-execute-persistent-action 'diff-action)) + (helm-attrset 'diff-action 'helm-buffer-toggle-diff) + (helm-execute-persistent-action 'diff-action)) -(defun anything-buffer-revert-and-update (candidate) - (let ((marked (anything-marked-candidates))) - (loop for buf in marked do (anything-revert-buffer buf)) - (anything-force-update candidate))) +(defun helm-buffer-revert-and-update (candidate) + (let ((marked (helm-marked-candidates))) + (loop for buf in marked do (helm-revert-buffer buf)) + (helm-force-update candidate))) ;;;###autoload -(defun anything-buffer-revert-persistent () - "Revert buffer without quitting anything." +(defun helm-buffer-revert-persistent () + "Revert buffer without quitting helm." (interactive) - (anything-attrset 'revert-action 'anything-buffer-revert-and-update) - (anything-execute-persistent-action 'revert-action 'onewindow)) + (helm-attrset 'revert-action 'helm-buffer-revert-and-update) + (helm-execute-persistent-action 'revert-action 'onewindow)) -(defun anything-buffer-save-and-update (candidate) - (let ((marked (anything-marked-candidates)) +(defun helm-buffer-save-and-update (candidate) + (let ((marked (helm-marked-candidates)) (enable-recursive-minibuffers t)) (loop for buf in marked do (with-current-buffer (get-buffer buf) (save-buffer))) - (anything-force-update candidate))) + (helm-force-update candidate))) ;;;###autoload -(defun anything-buffer-save-persistent () - "Save buffer without quitting anything." +(defun helm-buffer-save-persistent () + "Save buffer without quitting helm." (interactive) - (anything-attrset 'save-action 'anything-buffer-save-and-update) - (anything-execute-persistent-action 'save-action 'onewindow)) + (helm-attrset 'save-action 'helm-buffer-save-and-update) + (helm-execute-persistent-action 'save-action 'onewindow)) ;;;###autoload -(defun anything-buffer-run-kill-buffers () - "Run kill buffer action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-kill-buffers () + "Run kill buffer action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-kill-marked-buffers)) + (helm-c-quit-and-execute-action 'helm-kill-marked-buffers)) ;;;###autoload -(defun anything-buffer-run-grep () - "Run Grep action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-grep () + "Run Grep action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-grep-buffers)) + (helm-c-quit-and-execute-action 'helm-c-grep-buffers)) ;;;###autoload -(defun anything-buffer-run-zgrep () - "Run Grep action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-zgrep () + "Run Grep action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-zgrep-buffers)) + (helm-c-quit-and-execute-action 'helm-c-zgrep-buffers)) ;;;###autoload -(defun anything-buffer-run-query-replace-regexp () - "Run Query replace regexp action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-query-replace-regexp () + "Run Query replace regexp action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-buffer-query-replace-regexp)) + (helm-c-quit-and-execute-action 'helm-c-buffer-query-replace-regexp)) ;;;###autoload -(defun anything-buffer-run-query-replace () - "Run Query replace action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-query-replace () + "Run Query replace action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-buffer-query-replace)) + (helm-c-quit-and-execute-action 'helm-c-buffer-query-replace)) ;;;###autoload -(defun anything-buffer-switch-other-window () - "Run switch to other window action from `anything-c-source-buffers-list'." +(defun helm-buffer-switch-other-window () + "Run switch to other window action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'switch-to-buffer-other-window)) + (helm-c-quit-and-execute-action 'switch-to-buffer-other-window)) ;;;###autoload -(defun anything-buffer-switch-other-frame () - "Run switch to other frame action from `anything-c-source-buffers-list'." +(defun helm-buffer-switch-other-frame () + "Run switch to other frame action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'switch-to-buffer-other-frame)) + (helm-c-quit-and-execute-action 'switch-to-buffer-other-frame)) ;;;###autoload -(defun anything-buffer-switch-to-elscreen () - "Run switch to elscreen action from `anything-c-source-buffers-list'." +(defun helm-buffer-switch-to-elscreen () + "Run switch to elscreen action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-find-buffer-on-elscreen)) + (helm-c-quit-and-execute-action 'helm-find-buffer-on-elscreen)) ;;;###autoload -(defun anything-buffer-run-ediff () - "Run ediff action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-ediff () + "Run ediff action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-ediff-marked-buffers)) + (helm-c-quit-and-execute-action 'helm-ediff-marked-buffers)) -(defun anything-buffer-run-ediff-merge () - "Run ediff action from `anything-c-source-buffers-list'." +(defun helm-buffer-run-ediff-merge () + "Run ediff action from `helm-c-source-buffers-list'." (interactive) - (anything-c-quit-and-execute-action 'anything-ediff-marked-buffers-merge)) + (helm-c-quit-and-execute-action 'helm-ediff-marked-buffers-merge)) -(defun anything-c-buffers-persistent-kill (buffer) +(defun helm-c-buffers-persistent-kill (buffer) "Persistent action to kill buffer." (with-current-buffer (get-buffer buffer) (if (and (buffer-modified-p) @@ -3018,136 +2965,136 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (save-buffer) (kill-buffer buffer)) (kill-buffer buffer))) - (anything-delete-current-selection)) + (helm-delete-current-selection)) -(defun anything-c-buffers-list-persistent-action (candidate) +(defun helm-c-buffers-list-persistent-action (candidate) (if current-prefix-arg - (anything-c-buffers-persistent-kill candidate) - (anything-c-switch-to-buffer candidate))) + (helm-c-buffers-persistent-kill candidate) + (helm-c-switch-to-buffer candidate))) ;;;; ;; ;; ;;; File name history -(defvar anything-c-source-file-name-history +(defvar helm-c-source-file-name-history '((name . "File Name History") (candidates . file-name-history) - (match anything-c-match-on-basename) + (match helm-c-match-on-basename) (type . file))) ;;; Files in current dir ;; ;; -(defvar anything-c-source-files-in-current-dir +(defvar helm-c-source-files-in-current-dir '((name . "Files from Current Directory") (candidates . (lambda () - (with-anything-current-buffer - (directory-files (anything-c-current-directory))))) + (with-helm-current-buffer + (directory-files (helm-c-current-directory))))) ;; volatile is not needed, I think. (type . file))) -(defun anything-c-highlight-files (files) +(defun helm-c-highlight-files (files) (loop for i in files if (file-directory-p i) collect (propertize (file-name-nondirectory i) - 'face 'anything-ff-directory + 'face 'helm-ff-directory 'help-echo (expand-file-name i)) else collect (propertize (file-name-nondirectory i) - 'face 'anything-ff-file + 'face 'helm-ff-file 'help-echo (expand-file-name i)))) -(defvar anything-c-source-files-in-current-dir+ +(defvar helm-c-source-files-in-current-dir+ `((name . "Files from Current Directory") (candidates . (lambda () - (with-anything-current-buffer - (directory-files (anything-c-current-directory) t)))) - (keymap . ,anything-generic-files-map) - (help-message . anything-generic-file-help-message) - (mode-line . anything-generic-file-mode-line-string) - (candidate-transformer anything-c-highlight-files) + (with-helm-current-buffer + (directory-files (helm-c-current-directory) t)))) + (keymap . ,helm-generic-files-map) + (help-message . helm-generic-file-help-message) + (mode-line . helm-generic-file-mode-line-string) + (candidate-transformer helm-c-highlight-files) ;; volatile is not needed, I think. (type . file))) -;;; Anything-find-files - The anything files browser. +;;; Helm-find-files - The helm files browser. ;; ;; ;; Internal. -(defvar anything-c-find-files-doc-header " (`C-l': Go to precedent level)" +(defvar helm-c-find-files-doc-header " (`C-l': Go to precedent level)" "*The doc that is inserted in the Name header of a find-files or dired source.") -(defvar anything-ff-auto-update-flag nil - "Internal, flag to turn on/off auto-update in `anything-find-files'. -Don't set it directly, use instead `anything-ff-auto-update-initial-value'.") -(defvar anything-ff-last-expanded nil +(defvar helm-ff-auto-update-flag nil + "Internal, flag to turn on/off auto-update in `helm-find-files'. +Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") +(defvar helm-ff-last-expanded nil "Store last expanded directory or file.") -(defvar anything-ff-default-directory nil) -(defvar anything-ff-history nil) -(defvar anything-ff-cand-to-mark nil) -(defvar anything-ff-url-regexp +(defvar helm-ff-default-directory nil) +(defvar helm-ff-history nil) +(defvar helm-ff-cand-to-mark nil) +(defvar helm-ff-url-regexp "\\`\\(news\\(post\\)?:\\|nntp:\\|mailto:\\|file:\\|\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\):/?/?\\).*" "Same as `ffap-url-regexp' but match earlier possible url.") -(defvar anything-c-source-find-files +(defvar helm-c-source-find-files `((name . "Find Files") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) (init . (lambda () - (setq anything-ff-auto-update-flag - anything-ff-auto-update-initial-value))) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (setq helm-ff-auto-update-flag + helm-ff-auto-update-initial-value))) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Hit1 Expand Candidate, Hit2 or (C-u) Find file") - (mode-line . anything-ff-mode-line-string) + (mode-line . helm-ff-mode-line-string) (volatile) (candidate-number-limit . 9999) - (action-transformer . anything-find-files-action-transformer) + (action-transformer . helm-find-files-action-transformer) (action . ,(delq nil - `(("Find File" . anything-c-find-file-or-marked) - ("Find file in Dired" . anything-c-point-file-in-dired) + `(("Find File" . helm-c-find-file-or-marked) + ("Find file in Dired" . helm-c-point-file-in-dired) ,(and (locate-library "elscreen") - '("Find file in Elscreen" . anything-elscreen-find-file)) + '("Find file in Elscreen" . helm-elscreen-find-file)) ,(and (locate-library "popwin") '("Find file in popup window" . popwin:find-file)) - ("Checksum File" . anything-ff-checksum) + ("Checksum File" . helm-ff-checksum) ("Complete at point `M-tab'" - . anything-c-insert-file-name-completion-at-point) + . helm-c-insert-file-name-completion-at-point) ("Open file externally `C-c C-x, C-u to choose'" - . anything-c-open-file-externally) - ("Grep File(s) `M-g s, C-u Recurse'" . anything-find-files-grep) - ("Zgrep File(s) `M-g z, C-u Recurse'" . anything-ff-zgrep) - ("Switch to Eshell `M-e'" . anything-ff-switch-to-eshell) - ("Etags `M-., C-u tap, C-u C-u reload tag file'" . anything-ff-etags-select) + . helm-c-open-file-externally) + ("Grep File(s) `M-g s, C-u Recurse'" . helm-find-files-grep) + ("Zgrep File(s) `M-g z, C-u Recurse'" . helm-ff-zgrep) + ("Switch to Eshell `M-e'" . helm-ff-switch-to-eshell) + ("Etags `M-., C-u tap, C-u C-u reload tag file'" . helm-ff-etags-select) ("Eshell command on file(s) `M-!, C-u run on all marked at once.'" - . anything-find-files-eshell-command-on-file) - ("Find file as root" . anything-find-file-as-root) + . helm-find-files-eshell-command-on-file) + ("Find file as root" . helm-find-file-as-root) ("Find file in hex dump" . hexl-find-file) - ("Ediff File `C-='" . anything-find-files-ediff-files) - ("Ediff Merge File `C-c ='" . anything-find-files-ediff-merge-files) - ("Delete File(s) `M-D'" . anything-delete-marked-files) - ("Copy file(s) `M-C, C-u to follow'" . anything-find-files-copy) - ("Copy file(s) Async" . anything-ff-copy-async) - ("Rename file(s) `M-R, C-u to follow'" . anything-find-files-rename) - ("Serial rename files" . anything-ff-serial-rename) - ("Serial rename by symlinking files" . anything-ff-serial-rename-by-symlink) - ("Serial rename by copying files" . anything-ff-serial-rename-by-copying) - ("Symlink files(s) `M-S, C-u to follow'" . anything-find-files-symlink) - ("Relsymlink file(s) `C-u to follow'" . anything-find-files-relsymlink) - ("Hardlink file(s) `M-H, C-u to follow'" . anything-find-files-hardlink) + ("Ediff File `C-='" . helm-find-files-ediff-files) + ("Ediff Merge File `C-c ='" . helm-find-files-ediff-merge-files) + ("Delete File(s) `M-D'" . helm-delete-marked-files) + ("Copy file(s) `M-C, C-u to follow'" . helm-find-files-copy) + ("Copy file(s) Async" . helm-ff-copy-async) + ("Rename file(s) `M-R, C-u to follow'" . helm-find-files-rename) + ("Serial rename files" . helm-ff-serial-rename) + ("Serial rename by symlinking files" . helm-ff-serial-rename-by-symlink) + ("Serial rename by copying files" . helm-ff-serial-rename-by-copying) + ("Symlink files(s) `M-S, C-u to follow'" . helm-find-files-symlink) + ("Relsymlink file(s) `C-u to follow'" . helm-find-files-relsymlink) + ("Hardlink file(s) `M-H, C-u to follow'" . helm-find-files-hardlink) ("Find file other window `C-o'" . find-file-other-window) - ("Switch to history `M-p'" . anything-find-files-switch-to-hist) + ("Switch to history `M-p'" . helm-find-files-switch-to-hist) ("Find file other frame `C-c C-o'" . find-file-other-frame) - ("Print File `C-c p, C-u to refresh'" . anything-ff-print) - ("Locate `C-x C-f, C-u to specify locate db'" . anything-ff-locate)))))) + ("Print File `C-c p, C-u to refresh'" . helm-ff-print) + ("Locate `C-x C-f, C-u to specify locate db'" . helm-ff-locate)))))) -(defun anything-find-files-set-prompt-for-action (action files) +(defun helm-find-files-set-prompt-for-action (action files) "Set prompt for action ACTION for FILES." (let ((len (length files))) (format "%s *%s File(s)\n%s to: " @@ -3155,138 +3102,138 @@ Don't set it directly, use instead `anything-ff-auto-update-initial-value'.") (mapconcat (lambda (f) (format "- %s\n" f)) files "")))) -(defun anything-dwim-target-directory () +(defun helm-dwim-target-directory () "Return value of `default-directory' of buffer in other window. If there is only one window return the value ot `default-directory' for current buffer." - (with-anything-current-buffer + (with-helm-current-buffer (let ((num-windows (length (window-list)))) (if (> num-windows 1) (save-selected-window (other-window 1) default-directory) - (car anything-ff-history))))) + (car helm-ff-history))))) -(defun anything-find-files-do-action (action) - "Generic function for creating action from `anything-c-source-find-files'. -ACTION must be an action supported by `anything-dired-action'." +(defun helm-find-files-do-action (action) + "Generic function for creating action from `helm-c-source-find-files'. +ACTION must be an action supported by `helm-dired-action'." (let* ((ifiles (mapcar 'expand-file-name ; Allow modify '/foo/.' -> '/foo' - (anything-marked-candidates))) - (cand (anything-get-selection)) ; Target - (prompt (anything-find-files-set-prompt-for-action + (helm-marked-candidates))) + (cand (helm-get-selection)) ; Target + (prompt (helm-find-files-set-prompt-for-action (capitalize (symbol-name action)) ifiles)) - (parg anything-current-prefix-arg) - (dest (anything-c-read-file-name + (parg helm-current-prefix-arg) + (dest (helm-c-read-file-name prompt - :preselect (if anything-ff-transformer-show-only-basename - (anything-c-basename cand) cand) - :initial-input (anything-dwim-target-directory) - :history (anything-find-files-history :comp-read nil)))) - (anything-dired-action + :preselect (if helm-ff-transformer-show-only-basename + (helm-c-basename cand) cand) + :initial-input (helm-dwim-target-directory) + :history (helm-find-files-history :comp-read nil)))) + (helm-dired-action dest :files ifiles :action action :follow parg))) -(defun anything-find-files-copy (candidate) - "Copy files from `anything-find-files'." - (anything-find-files-do-action 'copy)) +(defun helm-find-files-copy (candidate) + "Copy files from `helm-find-files'." + (helm-find-files-do-action 'copy)) -(defun anything-find-files-rename (candidate) - "Rename files from `anything-find-files'." - (anything-find-files-do-action 'rename)) +(defun helm-find-files-rename (candidate) + "Rename files from `helm-find-files'." + (helm-find-files-do-action 'rename)) -(defun anything-find-files-symlink (candidate) - "Symlink files from `anything-find-files'." - (anything-find-files-do-action 'symlink)) +(defun helm-find-files-symlink (candidate) + "Symlink files from `helm-find-files'." + (helm-find-files-do-action 'symlink)) -(defun anything-find-files-relsymlink (candidate) - "Relsymlink files from `anything-find-files'." - (anything-find-files-do-action 'relsymlink)) +(defun helm-find-files-relsymlink (candidate) + "Relsymlink files from `helm-find-files'." + (helm-find-files-do-action 'relsymlink)) -(defun anything-find-files-hardlink (candidate) - "Hardlink files from `anything-find-files'." - (anything-find-files-do-action 'hardlink)) +(defun helm-find-files-hardlink (candidate) + "Hardlink files from `helm-find-files'." + (helm-find-files-do-action 'hardlink)) -(defun anything-find-files-byte-compile (candidate) - "Byte compile elisp files from `anything-find-files'." - (let ((files (anything-marked-candidates)) - (parg anything-current-prefix-arg)) +(defun helm-find-files-byte-compile (candidate) + "Byte compile elisp files from `helm-find-files'." + (let ((files (helm-marked-candidates)) + (parg helm-current-prefix-arg)) (loop for fname in files do (byte-compile-file fname parg)))) -(defun anything-find-files-load-files (candidate) - "Load elisp files from `anything-find-files'." - (let ((files (anything-marked-candidates))) +(defun helm-find-files-load-files (candidate) + "Load elisp files from `helm-find-files'." + (let ((files (helm-marked-candidates))) (loop for fname in files do (load fname)))) -(defun anything-find-files-ediff-files-1 (candidate &optional merge) - "Generic function to ediff/merge files in `anything-find-files'." - (let ((bname (anything-c-basename candidate)) +(defun helm-find-files-ediff-files-1 (candidate &optional merge) + "Generic function to ediff/merge files in `helm-find-files'." + (let ((bname (helm-c-basename candidate)) (prompt (if merge "Ediff Merge `%s' With File: " "Ediff `%s' With File: ")) (fun (if merge 'ediff-merge-files 'ediff-files))) (funcall fun candidate (condition-case quit - (anything-c-read-file-name + (helm-c-read-file-name (format prompt bname)) (quit ;; Hit C-g ask user to fallback to locate. (if (y-or-n-p "Search file for ediff with locate? ") - (anything-c-locate-read-file-name + (helm-c-locate-read-file-name (format prompt bname) ;; Check if -b option is available. (if (and (eq system-type 'windows-nt) - (string-match "^es" anything-c-locate-command)) + (string-match "^es" helm-c-locate-command)) bname (concat bname " -b"))) (error "Error: Ediff Operation aborted"))))))) -(defun anything-find-files-ediff-files (candidate) - (anything-find-files-ediff-files-1 candidate)) +(defun helm-find-files-ediff-files (candidate) + (helm-find-files-ediff-files-1 candidate)) -(defun anything-find-files-ediff-merge-files (candidate) - (anything-find-files-ediff-files-1 candidate 'merge)) +(defun helm-find-files-ediff-merge-files (candidate) + (helm-find-files-ediff-files-1 candidate 'merge)) -(defun anything-find-files-grep (candidate) - "Default action to grep files from `anything-find-files'." - (anything-do-grep-1 (anything-marked-candidates) - anything-current-prefix-arg)) +(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)) -(defun anything-ff-zgrep (candidate) - "Default action to zgrep files from `anything-find-files'." - (let ((prefarg anything-current-prefix-arg) - (ls (anything-marked-candidates))) - (anything-ff-zgrep-1 ls prefarg))) +(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))) -(defun anything-ff-pdfgrep (candidate) - "Default action to pdfgrep files from `anything-find-files'." - (let ((cands (loop for file in (anything-marked-candidates) +(defun helm-ff-pdfgrep (candidate) + "Default action to pdfgrep files from `helm-find-files'." + (let ((cands (loop for file in (helm-marked-candidates) if (or (string= (file-name-extension file) "pdf") (string= (file-name-extension file) "PDF")) collect file)) - (anything-c-pdfgrep-default-function 'anything-c-pdfgrep-init)) + (helm-c-pdfgrep-default-function 'helm-c-pdfgrep-init)) (when cands - (anything-do-pdfgrep-1 cands)))) + (helm-do-pdfgrep-1 cands)))) -(defun anything-ff-etags-select (candidate) - "Default action to jump to etags from `anything-find-files'." - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) - (let ((default-directory anything-ff-default-directory)) - (anything-c-etags-select anything-current-prefix-arg))) +(defun helm-ff-etags-select (candidate) + "Default action to jump to etags from `helm-find-files'." + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (let ((default-directory helm-ff-default-directory)) + (helm-c-etags-select helm-current-prefix-arg))) -(defun anything-find-files-switch-to-hist (candidate) - "Switch to anything-find-files history." - (anything-find-files t)) +(defun helm-find-files-switch-to-hist (candidate) + "Switch to helm-find-files history." + (helm-find-files t)) ;;; Asynchronous copy of files. ;; ;; -(defun anything-c-copy-files-async-1 (flist dest) +(defun helm-c-copy-files-async-1 (flist dest) "Copy a list of Files FLIST to DEST asynchronously. It use another emacs process to do the job. Communication with background emacs is done with temp file -`anything-c-copy-files-async-log-file'." - (start-file-process "emacs-batch" nil anything-c-copy-async-prefered-emacs +`helm-c-copy-files-async-log-file'." + (start-file-process "emacs-batch" nil helm-c-copy-async-prefered-emacs "-Q" "--batch" "--eval" (format "(progn (require 'dired) (require 'cl) @@ -3325,37 +3272,37 @@ Communication with background emacs is done with temp file (and (/= ovw-count 0) (insert (concat (int-to-string ovw-count) \" File(s) Overwrited\n\"))) (and failures (insert (concat (int-to-string (length failures)) \" File(s) Failed to copy\n\"))) (save-buffer))))" - flist dest dest dest anything-c-copy-files-async-log-file dest))) + flist dest dest dest helm-c-copy-files-async-log-file dest))) -(defun anything-c-copy-async-with-log (flist dest) +(defun helm-c-copy-async-with-log (flist dest) "Copy file list FLIST to DEST showing log. -Log is send to `anything-c-copy-files-async-log-file'. -Copying is done asynchronously with `anything-c-copy-files-async-1'." +Log is send to `helm-c-copy-files-async-log-file'. +Copying is done asynchronously with `helm-c-copy-files-async-1'." (declare (special auto-revert-interval)) - (pop-to-buffer (find-file-noselect anything-c-copy-files-async-log-file)) + (pop-to-buffer (find-file-noselect helm-c-copy-files-async-log-file)) (set (make-local-variable 'auto-revert-interval) 1) (erase-buffer) (insert "Wait copying files...\n") (sit-for 0.5) (save-buffer) (goto-char (point-max)) (auto-revert-mode 1) - (anything-c-copy-files-async-1 flist dest)) + (helm-c-copy-files-async-1 flist dest)) -(defun anything-ff-copy-async (candidate) - "Anything find files action to copy files async. -Copying is done asynchronously with `anything-c-copy-files-async-1'." - (let* ((flist (anything-marked-candidates)) - (dest (anything-c-read-file-name - (anything-find-files-set-prompt-for-action +(defun helm-ff-copy-async (candidate) + "Helm find files action to copy files async. +Copying is done asynchronously with `helm-c-copy-files-async-1'." + (let* ((flist (helm-marked-candidates)) + (dest (helm-c-read-file-name + (helm-find-files-set-prompt-for-action "Copy Async" flist) :preselect candidate - :initial-input (car anything-ff-history) - :history (anything-find-files-history :comp-read nil)))) - (anything-c-copy-async-with-log flist dest))) + :initial-input (car helm-ff-history) + :history (helm-find-files-history :comp-read nil)))) + (helm-c-copy-async-with-log flist dest))) (defvar eshell-command-aliases-list nil) -(defvar anything-eshell-command-on-file-input-history nil) -(defun anything-find-files-eshell-command-on-file-1 (candidate &optional map) +(defvar helm-eshell-command-on-file-input-history nil) +(defun helm-find-files-eshell-command-on-file-1 (candidate &optional map) "Run `eshell-command' on CANDIDATE or marked candidates. This is done possibly with an eshell alias, if no alias found, you can type in an eshell command. @@ -3387,12 +3334,12 @@ will not be loaded first time you use this." (when (or eshell-command-aliases-list (y-or-n-p "Eshell is not loaded, run eshell-command without alias anyway? ")) (and eshell-command-aliases-list (eshell-read-aliases-list)) - (let* ((cand-list (anything-marked-candidates)) - (default-directory (or anything-ff-default-directory + (let* ((cand-list (helm-marked-candidates)) + (default-directory (or helm-ff-default-directory ;; If candidate is an url *-ff-default-directory is nil ;; so keep value of default-directory. default-directory)) - (command (anything-comp-read + (command (helm-comp-read "Command: " (loop for (a . c) in eshell-command-aliases-list when (string-match "\\(\\$1\\|\\$\\*\\)$" (car c)) @@ -3400,23 +3347,23 @@ will not be loaded first time you use this." finally return (sort ls 'string<)) :buffer "*esh command on file*" :name "Eshell command" - :keymap anything-esh-on-file-map + :keymap helm-esh-on-file-map :mode-line '("Eshell alias" "C-c ?: Help, \\[universal-argument]: Insert output at point") :input-history - 'anything-eshell-command-on-file-input-history)) + 'helm-eshell-command-on-file-input-history)) (alias-value (car (assoc-default command eshell-command-aliases-list)))) (when (and (= (length cand-list) 1) - (string-match "[*]" (anything-c-basename (car cand-list)))) + (string-match "[*]" (helm-c-basename (car cand-list)))) (setq cand-list (file-expand-wildcards (car cand-list) t))) ;; Be sure output don't go in current buffer ;; but allow sending output to current buffer ;; if a prefix arg have been passed during the - ;; `anything-comp-read' call. - (setq current-prefix-arg anything-current-prefix-arg) - ;; MAP have been set before calling `anything-comp-read' - ;; by `anything-current-prefix-arg'. + ;; `helm-comp-read' call. + (setq current-prefix-arg helm-current-prefix-arg) + ;; MAP have been set before calling `helm-comp-read' + ;; by `helm-current-prefix-arg'. (if (and (or map ; prefix-arg (and alias-value ;; If command is an alias be sure it accept @@ -3432,7 +3379,7 @@ will not be loaded first time you use this." ;; Run eshell-command on EACH marked files. (loop for i in cand-list - for bn = (anything-c-basename i) + for bn = (helm-c-basename i) for files = (format "'%s'" i) for com = (if (string-match "'%s'\\|\"%s\"\\|%s" command) ;; [1] This allow to enter other args AFTER filename @@ -3441,68 +3388,68 @@ will not be loaded first time you use this." (format "%s %s" command files)) do (eshell-command com)))))) -(defun anything-find-files-eshell-command-on-file (candidate) +(defun helm-find-files-eshell-command-on-file (candidate) "Run `eshell-command' on CANDIDATE or marked candidates. -See `anything-find-files-eshell-command-on-file-1' for more info." - (anything-find-files-eshell-command-on-file-1 - candidate anything-current-prefix-arg)) +See `helm-find-files-eshell-command-on-file-1' for more info." + (helm-find-files-eshell-command-on-file-1 + candidate helm-current-prefix-arg)) -(defun anything-ff-switch-to-eshell (candidate) - "Switch to eshell and cd to `anything-ff-default-directory'." +(defun helm-ff-switch-to-eshell (candidate) + "Switch to eshell and cd to `helm-ff-default-directory'." (flet ((cd-eshell () (goto-char (point-max)) (insert - (format "cd '%s'" anything-ff-default-directory)) + (format "cd '%s'" helm-ff-default-directory)) (eshell-send-input))) (if (get-buffer "*eshell*") (progn - (anything-c-switch-to-buffer "*eshell*") + (helm-c-switch-to-buffer "*eshell*") (cd-eshell)) (call-interactively 'eshell) (cd-eshell)))) -(defun anything-ff-serial-rename-action (method) - "Rename all marked files to `anything-ff-default-directory' with METHOD. -See `anything-ff-serial-rename-1'." - (let* ((cands (anything-marked-candidates)) +(defun helm-ff-serial-rename-action (method) + "Rename all marked files to `helm-ff-default-directory' with METHOD. +See `helm-ff-serial-rename-1'." + (let* ((cands (helm-marked-candidates)) (def-name (car cands)) (name (read-string "NewName: " (replace-regexp-in-string "[0-9]+$" "" - (anything-c-basename + (helm-c-basename def-name (file-name-extension def-name))))) (start (read-number "StartAtNumber: ")) (extension (read-string "Extension: " (file-name-extension (car cands)))) (dir (expand-file-name - (anything-c-read-file-name + (helm-c-read-file-name "Serial Rename to directory: " :initial-input - (expand-file-name anything-ff-default-directory) + (expand-file-name helm-ff-default-directory) :test 'file-directory-p :must-match t))) (res (loop for f in cands - for bn = (anything-c-basename f) + for bn = (helm-c-basename f) for count from start concat (format "%s <-> %s%s.%s\n" bn name count extension)))) (if (y-or-n-p (format "Result:\n %sRename like this to <%s> ? " res dir)) (progn - (anything-ff-serial-rename-1 + (helm-ff-serial-rename-1 dir cands name start extension :method method) (message nil) - (anything-find-files-1 dir)) + (helm-find-files-1 dir)) (message "Operation aborted")))) -(defun anything-ff-member-directory-p (file directory) +(defun helm-ff-member-directory-p (file directory) (let ((dir-file (expand-file-name (file-name-as-directory (file-name-directory file)))) (cur-dir (expand-file-name (file-name-as-directory directory)))) (string= dir-file cur-dir))) -(defun* anything-ff-serial-rename-1 +(defun* helm-ff-serial-rename-1 (directory collection new-name start-at-num extension &key (method 'rename)) "rename files in COLLECTION to DIRECTORY with the prefix name NEW-NAME. Rename start at number START-AT-NUM - ex: prefixname-01.jpg. @@ -3516,7 +3463,7 @@ Default METHOD is rename." (setq collection (remove-if 'file-directory-p collection)) (flet ((symlink-file (file dest) (let ((flist (list file))) - (anything-dired-action + (helm-dired-action dest :action 'symlink :files flist)))) (let* ((tmp-dir (file-name-as-directory @@ -3541,7 +3488,7 @@ Default METHOD is rename." (format ".%s" (replace-regexp-in-string "[.]" "" extension)) (file-name-extension i 'dot))) - do (if (anything-ff-member-directory-p i directory) + do (if (helm-ff-member-directory-p i directory) (rename-file i nname) (funcall fn i nname))) ;; Now move all from tmp-dir to destination. @@ -3551,220 +3498,220 @@ Default METHOD is rename." (if (file-symlink-p f) (symlink-file (file-truename f) (concat (file-name-as-directory directory) - (anything-c-basename f))) + (helm-c-basename f))) (rename-file f directory)))) (delete-directory tmp-dir t))))) -(defun anything-ff-serial-rename (candidate) - "Serial rename all marked files to `anything-ff-default-directory'. +(defun helm-ff-serial-rename (candidate) + "Serial rename all marked files to `helm-ff-default-directory'. Rename only file of current directory, and symlink files coming from other directories. -See `anything-ff-serial-rename-1'." - (anything-ff-serial-rename-action 'rename)) +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'rename)) -(defun anything-ff-serial-rename-by-symlink (candidate) - "Serial rename all marked files to `anything-ff-default-directory'. +(defun helm-ff-serial-rename-by-symlink (candidate) + "Serial rename all marked files to `helm-ff-default-directory'. Rename only file of current directory, and symlink files coming from other directories. -See `anything-ff-serial-rename-1'." - (anything-ff-serial-rename-action 'symlink)) +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'symlink)) -(defun anything-ff-serial-rename-by-copying (candidate) - "Serial rename all marked files to `anything-ff-default-directory'. +(defun helm-ff-serial-rename-by-copying (candidate) + "Serial rename all marked files to `helm-ff-default-directory'. Rename only file of current directory, and copy files coming from other directories. -See `anything-ff-serial-rename-1'." - (anything-ff-serial-rename-action 'copy)) +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'copy)) -(defun anything-c-quit-and-execute-action (action) - "Quit current anything session and execute ACTION." - (setq anything-saved-action action) - (anything-exit-minibuffer)) +(defun helm-c-quit-and-execute-action (action) + "Quit current helm session and execute ACTION." + (setq helm-saved-action action) + (helm-exit-minibuffer)) -(defun anything-ff-toggle-auto-update (candidate) - (setq anything-ff-auto-update-flag (not anything-ff-auto-update-flag)) +(defun helm-ff-toggle-auto-update (candidate) + (setq helm-ff-auto-update-flag (not helm-ff-auto-update-flag)) (message "[Auto expansion %s]" - (if anything-ff-auto-update-flag "enabled" "disabled"))) + (if helm-ff-auto-update-flag "enabled" "disabled"))) ;;;###autoload -(defun anything-ff-run-toggle-auto-update () +(defun helm-ff-run-toggle-auto-update () (interactive) - (when (anything-file-completion-source-p) - (anything-attrset 'toggle-auto-update 'anything-ff-toggle-auto-update) - (anything-execute-persistent-action 'toggle-auto-update))) + (when (helm-file-completion-source-p) + (helm-attrset 'toggle-auto-update 'helm-ff-toggle-auto-update) + (helm-execute-persistent-action 'toggle-auto-update))) ;;;###autoload -(defun anything-ff-run-switch-to-history () - "Run Switch to history action from `anything-c-source-find-files'." +(defun helm-ff-run-switch-to-history () + "Run Switch to history action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-switch-to-hist))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-switch-to-hist))) ;;;###autoload -(defun anything-ff-run-grep () - "Run Grep action from `anything-c-source-find-files'." +(defun helm-ff-run-grep () + "Run Grep action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-grep))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-grep))) ;;;###autoload -(defun anything-ff-run-pdfgrep () - "Run Pdfgrep action from `anything-c-source-find-files'." +(defun helm-ff-run-pdfgrep () + "Run Pdfgrep action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-pdfgrep))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-pdfgrep))) ;;;###autoload -(defun anything-ff-run-zgrep () - "Run Grep action from `anything-c-source-find-files'." +(defun helm-ff-run-zgrep () + "Run Grep action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-zgrep))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-zgrep))) ;;;###autoload -(defun anything-ff-run-copy-file () - "Run Copy file action from `anything-c-source-find-files'." +(defun helm-ff-run-copy-file () + "Run Copy file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-copy))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-copy))) ;;;###autoload -(defun anything-ff-run-rename-file () - "Run Rename file action from `anything-c-source-find-files'." +(defun helm-ff-run-rename-file () + "Run Rename file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-rename))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-rename))) ;;;###autoload -(defun anything-ff-run-byte-compile-file () - "Run Byte compile file action from `anything-c-source-find-files'." +(defun helm-ff-run-byte-compile-file () + "Run Byte compile file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-byte-compile))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-byte-compile))) ;;;###autoload -(defun anything-ff-run-load-file () - "Run Load file action from `anything-c-source-find-files'." +(defun helm-ff-run-load-file () + "Run Load file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-load-files))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-load-files))) ;;;###autoload -(defun anything-ff-run-eshell-command-on-file () - "Run eshell command on file action from `anything-c-source-find-files'." +(defun helm-ff-run-eshell-command-on-file () + "Run eshell command on file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action - 'anything-find-files-eshell-command-on-file))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action + 'helm-find-files-eshell-command-on-file))) ;;;###autoload -(defun anything-ff-run-ediff-file () - "Run Ediff file action from `anything-c-source-find-files'." +(defun helm-ff-run-ediff-file () + "Run Ediff file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-ediff-files))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-ediff-files))) ;;;###autoload -(defun anything-ff-run-ediff-merge-file () - "Run Ediff merge file action from `anything-c-source-find-files'." +(defun helm-ff-run-ediff-merge-file () + "Run Ediff merge file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action - 'anything-find-files-ediff-merge-files))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action + 'helm-find-files-ediff-merge-files))) ;;;###autoload -(defun anything-ff-run-symlink-file () - "Run Symlink file action from `anything-c-source-find-files'." +(defun helm-ff-run-symlink-file () + "Run Symlink file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-symlink))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-symlink))) ;;;###autoload -(defun anything-ff-run-hardlink-file () - "Run Hardlink file action from `anything-c-source-find-files'." +(defun helm-ff-run-hardlink-file () + "Run Hardlink file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-find-files-hardlink))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-find-files-hardlink))) ;;;###autoload -(defun anything-ff-run-delete-file () - "Run Delete file action from `anything-c-source-find-files'." +(defun helm-ff-run-delete-file () + "Run Delete file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-delete-marked-files))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-delete-marked-files))) ;;;###autoload -(defun anything-ff-run-complete-fn-at-point () - "Run complete file name action from `anything-c-source-find-files'." +(defun helm-ff-run-complete-fn-at-point () + "Run complete file name action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action - 'anything-c-insert-file-name-completion-at-point))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action + 'helm-c-insert-file-name-completion-at-point))) ;;;###autoload -(defun anything-ff-run-switch-to-eshell () - "Run switch to eshell action from `anything-c-source-find-files'." +(defun helm-ff-run-switch-to-eshell () + "Run switch to eshell action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-switch-to-eshell))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-switch-to-eshell))) ;;;###autoload -(defun anything-ff-run-switch-other-window () - "Run switch to other window action from `anything-c-source-find-files'." +(defun helm-ff-run-switch-other-window () + "Run switch to other window action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'find-file-other-window))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'find-file-other-window))) ;;;###autoload -(defun anything-ff-run-switch-other-frame () - "Run switch to other frame action from `anything-c-source-find-files'." +(defun helm-ff-run-switch-other-frame () + "Run switch to other frame action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'find-file-other-frame))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'find-file-other-frame))) ;;;###autoload -(defun anything-ff-run-open-file-externally () - "Run open file externally command action from `anything-c-source-find-files'." +(defun helm-ff-run-open-file-externally () + "Run open file externally command action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-c-open-file-externally))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-c-open-file-externally))) -(defun anything-ff-locate (candidate) - "Locate action function for `anything-find-files'." - (let ((input (concat (anything-c-basename +(defun helm-ff-locate (candidate) + "Locate action function for `helm-find-files'." + (let ((input (concat (helm-c-basename (expand-file-name candidate - anything-ff-default-directory)) + helm-ff-default-directory)) ;; The locate '-b' option doesn't exists ;; in everything. (unless (and (eq system-type 'windows-nt) - (string-match "^es" anything-c-locate-command)) + (string-match "^es" helm-c-locate-command)) " -b"))) - (anything-mp-highlight-delay 0.7)) - (anything-locate-1 anything-current-prefix-arg input 'from-ff))) + (helm-mp-highlight-delay 0.7)) + (helm-locate-1 helm-current-prefix-arg input 'from-ff))) ;;;###autoload -(defun anything-ff-run-locate () - "Run locate action from `anything-c-source-find-files'." +(defun helm-ff-run-locate () + "Run locate action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-locate))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-locate))) ;;;###autoload -(defun anything-ff-run-gnus-attach-files () - "Run gnus attach files command action from `anything-c-source-find-files'." +(defun helm-ff-run-gnus-attach-files () + "Run gnus attach files command action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-gnus-attach-files))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-gnus-attach-files))) ;;;###autoload -(defun anything-ff-run-etags () - "Run Etags command action from `anything-c-source-find-files'." +(defun helm-ff-run-etags () + "Run Etags command action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-etags-select))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-etags-select))) -(defun anything-ff-print (candidate) +(defun helm-ff-print (candidate) "Print marked files. You have to set in order variables `lpr-command',`lpr-switches' and/or `printer-name'. @@ -3774,16 +3721,16 @@ e.g: \(setq lpr-switches '(\"-P\")\) \(setq printer-name \"Epson-Stylus-Photo-R265\"\) -Same as `dired-do-print' but for anything." - (when (or anything-current-prefix-arg - (not anything-ff-printer-list)) - (setq anything-ff-printer-list - (anything-ff-find-printers))) - (let* ((file-list (anything-marked-candidates)) +Same as `dired-do-print' but for helm." + (when (or helm-current-prefix-arg + (not helm-ff-printer-list)) + (setq helm-ff-printer-list + (helm-ff-find-printers))) + (let* ((file-list (helm-marked-candidates)) (len (length file-list)) - (printer-name (if anything-ff-printer-list - (anything-comp-read - "Printer: " anything-ff-printer-list) + (printer-name (if helm-ff-printer-list + (helm-comp-read + "Printer: " helm-ff-printer-list) printer-name)) (command (read-string (format "Print *%s File(s):\n%s with: " @@ -3806,17 +3753,17 @@ Same as `dired-do-print' but for anything." file-list " ")) (cmd-line (concat command " " file-args))) (if command - (start-process-shell-command "anything-print" nil cmd-line) + (start-process-shell-command "helm-print" nil cmd-line) (error "Error: Please verify your printer settings in Emacs.")))) ;;;###autoload -(defun anything-ff-run-print-file () - "Run Print file action from `anything-c-source-find-files'." +(defun helm-ff-run-print-file () + "Run Print file action from `helm-c-source-find-files'." (interactive) - (when (anything-file-completion-source-p) - (anything-c-quit-and-execute-action 'anything-ff-print))) + (when (helm-file-completion-source-p) + (helm-c-quit-and-execute-action 'helm-ff-print))) -(defun anything-ff-checksum (file) +(defun helm-ff-checksum (file) "Calculate the checksum of FILE. Provide completion on different algorithms to use on Emacs24. On Emacs23 only 'sha1' is available. @@ -3826,7 +3773,7 @@ The checksum is copied to kill-ring." (kill-new (if algo-list (secure-hash (intern - (anything-comp-read + (helm-comp-read "Algorithm: " algo-list)) file) (sha1 (with-temp-buffer @@ -3834,20 +3781,20 @@ The checksum is copied to kill-ring." (buffer-string))))) (message "Checksum copied to kill-ring."))) -(defun anything-ff-toggle-basename (candidate) - (setq anything-ff-transformer-show-only-basename - (not anything-ff-transformer-show-only-basename)) - (let ((target (if anything-ff-transformer-show-only-basename - (anything-c-basename candidate) candidate))) - (anything-force-update target))) +(defun helm-ff-toggle-basename (candidate) + (setq helm-ff-transformer-show-only-basename + (not helm-ff-transformer-show-only-basename)) + (let ((target (if helm-ff-transformer-show-only-basename + (helm-c-basename candidate) candidate))) + (helm-force-update target))) -(defun anything-ff-run-toggle-basename () +(defun helm-ff-run-toggle-basename () (interactive) - (when (anything-file-completion-source-p) - (anything-attrset 'toggle-basename 'anything-ff-toggle-basename) - (anything-execute-persistent-action 'toggle-basename))) + (when (helm-file-completion-source-p) + (helm-attrset 'toggle-basename 'helm-ff-toggle-basename) + (helm-execute-persistent-action 'toggle-basename))) -(defun* anything-reduce-file-name (fname level &key unix-close expand) +(defun* helm-reduce-file-name (fname level &key unix-close expand) "Reduce FNAME by LEVEL from end or beginning depending LEVEL value. If LEVEL is positive reduce from end else from beginning. If UNIX-CLOSE is non--nil close filename with /. @@ -3874,172 +3821,172 @@ If EXPAND is non--nil expand-file-name." (concat "/" result))))))) ;; Internal -(defvar anything-file-completion-sources +(defvar helm-file-completion-sources '("Find Files" "Read File Name" "Read File Name History" "Copy Files" "Rename Files" "Symlink Files" "Hardlink Files" "Write File" "Insert File") "Sources that use the *find-files mechanism can be added here. -Sources generated by `ac-mode' don't need to be added here, it will +Sources generated by `helm-mode' don't need to be added here, it will be done automatically. You should not modify this yourself unless you know what you do.") -(defun anything-file-completion-source-p () +(defun helm-file-completion-source-p () "Return non--nil if current source is a file completion source. A source is a file completion source if it is -one of `anything-file-completion-sources'. -Return nil if anything is not running." - (let ((cur-source (cdr (assoc 'name (anything-get-current-source))))) - (loop for i in anything-file-completion-sources +one of `helm-file-completion-sources'. +Return nil if helm is not running." + (let ((cur-source (cdr (assoc 'name (helm-get-current-source))))) + (loop for i in helm-file-completion-sources thereis (string= cur-source i)))) -(defun anything-find-files-down-one-level (arg) +(defun helm-find-files-down-one-level (arg) "Go down one level like unix command `cd ..'. If prefix numeric arg is given go ARG level down." (interactive "p") - (when (and (anything-file-completion-source-p) - (not (anything-ff-invalid-tramp-name-p))) - (with-anything-window - (setq anything-follow-mode nil)) + (when (and (helm-file-completion-source-p) + (not (helm-ff-invalid-tramp-name-p))) + (with-helm-window + (setq helm-follow-mode nil)) ;; When going to precedent level we want to be at the line ;; corresponding to actual directory, so store this info - ;; in `anything-ff-last-expanded'. - (if (and (not (file-directory-p anything-pattern)) - (file-exists-p anything-pattern)) - (setq anything-ff-last-expanded anything-pattern) - (setq anything-ff-last-expanded anything-ff-default-directory)) - (let ((new-pattern (anything-reduce-file-name anything-pattern arg + ;; in `helm-ff-last-expanded'. + (if (and (not (file-directory-p helm-pattern)) + (file-exists-p helm-pattern)) + (setq helm-ff-last-expanded helm-pattern) + (setq helm-ff-last-expanded helm-ff-default-directory)) + (let ((new-pattern (helm-reduce-file-name helm-pattern arg :unix-close t :expand t))) - (anything-set-pattern new-pattern)))) + (helm-set-pattern new-pattern)))) -(defun anything-ff-retrieve-last-expanded () - "Move overlay to last visited directory `anything-ff-last-expanded'. -This happen after using `anything-find-files-down-one-level', +(defun helm-ff-retrieve-last-expanded () + "Move overlay to last visited directory `helm-ff-last-expanded'. +This happen after using `helm-find-files-down-one-level', or hitting C-z on \"..\"." - (when (and anything-ff-last-expanded - (anything-file-completion-source-p)) - (let ((presel (if anything-ff-transformer-show-only-basename - (anything-c-basename - (directory-file-name anything-ff-last-expanded)) - (directory-file-name anything-ff-last-expanded)))) - (with-anything-window + (when (and helm-ff-last-expanded + (helm-file-completion-source-p)) + (let ((presel (if helm-ff-transformer-show-only-basename + (helm-c-basename + (directory-file-name helm-ff-last-expanded)) + (directory-file-name helm-ff-last-expanded)))) + (with-helm-window (when (re-search-forward (concat "^" (regexp-quote presel) "$") nil t) (forward-line 0) - (anything-mark-current-line))) - (setq anything-ff-last-expanded nil)))) -(add-hook 'anything-after-update-hook 'anything-ff-retrieve-last-expanded) + (helm-mark-current-line))) + (setq helm-ff-last-expanded nil)))) +(add-hook 'helm-after-update-hook 'helm-ff-retrieve-last-expanded) -;; Auto-update - anything-find-files auto expansion of directories. +;; Auto-update - helm-find-files auto expansion of directories. ;; -(defun anything-ff-update-when-only-one-matched () +(defun helm-ff-update-when-only-one-matched () "Expand to directory when sole completion. When only one candidate is remaining and it is a directory, expand to this directory." - (when (and anything-ff-auto-update-flag - (anything-file-completion-source-p) - (not (anything-ff-invalid-tramp-name-p))) + (when (and helm-ff-auto-update-flag + (helm-file-completion-source-p) + (not (helm-ff-invalid-tramp-name-p))) (let* ((history-p (string= (assoc-default - 'name (anything-get-current-source)) + 'name (helm-get-current-source)) "Read File Name History")) (pat (if (string-match tramp-file-name-regexp - anything-pattern) - (anything-create-tramp-name anything-pattern) - anything-pattern)) + helm-pattern) + (helm-create-tramp-name helm-pattern) + helm-pattern)) (completed-p (string= (file-name-as-directory pat) - anything-ff-default-directory))) + helm-ff-default-directory))) (when (and (or ;; Only one candidate remaining ;; and at least 2 char in basename. - (and (<= (anything-approximate-candidate-number) 2) - (>= (length (anything-c-basename anything-pattern)) 2)) + (and (<= (helm-approximate-candidate-number) 2) + (>= (length (helm-c-basename helm-pattern)) 2)) ;; Already completed. completed-p) (not history-p)) ; Don't try to auto complete in history. - (with-anything-window + (with-helm-window (let ((cur-cand (prog2 (unless completed-p ;; Only one non--existing candidate ;; and one directory candidate, move to it. - (anything-next-line)) - (anything-get-selection)))) + (helm-next-line)) + (helm-get-selection)))) (when (and (stringp cur-cand) (file-directory-p cur-cand)) (if (and (not (string-match "^.*[.]\\{1,2\\}$" cur-cand)) ; [1] ;; Maybe we are here because completed-p is true ;; but check this again to be sure. (Windows fix) - (<= (anything-approximate-candidate-number) 2)) ; [2] + (<= (helm-approximate-candidate-number) 2)) ; [2] ;; If after going to next line the candidate ;; is not one of "." or ".." [1] ;; and only one candidate is remaining [2], ;; assume candidate is a new directory to expand, and do it. - (anything-set-pattern (file-name-as-directory cur-cand)) + (helm-set-pattern (file-name-as-directory cur-cand)) ;; The candidate is one of "." or ".." ;; that mean we have entered the last letter of the directory name ;; in prompt, so expansion is already done, just add the "/" at end - ;; of name unless anything-pattern ends with "." + ;; of name unless helm-pattern ends with "." ;; (i.e we are writing something starting with ".") - (unless (string-match "^.*[.]\\{1\\}$" anything-pattern) - (anything-set-pattern + (unless (string-match "^.*[.]\\{1\\}$" helm-pattern) + (helm-set-pattern ;; Need to expand-file-name to avoid e.g /ssh:host:./ in prompt. - (expand-file-name (file-name-as-directory anything-pattern))))) - (anything-check-minibuffer-input-1)))))))) -(add-hook 'anything-after-update-hook 'anything-ff-update-when-only-one-matched) + (expand-file-name (file-name-as-directory helm-pattern))))) + (helm-check-minibuffer-input-1)))))))) +(add-hook 'helm-after-update-hook 'helm-ff-update-when-only-one-matched) ;; Allow expanding to home directory or root ;; when entering respectively "~/" or "//" at end of pattern. -;; e.g /home/thierry/labo/anything-config-qp/~/ +;; e.g /home/thierry/labo/helm-config-qp/~/ ;; will expand to "~/" -;; and /home/thierry/labo/anything-config-qp// +;; and /home/thierry/labo/helm-config-qp// ;; will expand to "/" -(defun anything-ff-auto-expand-to-home-or-root () +(defun helm-ff-auto-expand-to-home-or-root () "Goto home, root or default directory when pattern ends with ~/, /, or ./. This happen only in function using sources that are -`anything-file-completion-source-p' compliant." - (when (and (anything-file-completion-source-p) +`helm-file-completion-source-p' compliant." + (when (and (helm-file-completion-source-p) (string-match ".*\\(/~/\\|/\\{2\\}\\|/[.]\\{1\\}/\\)$" - anything-pattern) - (not (string-match anything-ff-url-regexp anything-pattern))) - (let ((match (match-string 1 anything-pattern))) + helm-pattern) + (not (string-match helm-ff-url-regexp helm-pattern))) + (let ((match (match-string 1 helm-pattern))) (cond ((string= match "//") ;; Expand to "/" or "c:/" - (setq anything-pattern (expand-file-name "/"))) + (setq helm-pattern (expand-file-name "/"))) ((string= match "/~/") (if (eq system-type 'windows-nt) - (setq anything-pattern (file-name-as-directory (getenv "HOME"))) - (setq anything-pattern "~/"))) + (setq helm-pattern (file-name-as-directory (getenv "HOME"))) + (setq helm-pattern "~/"))) ((string= match "/./") - (setq anything-pattern - (with-anything-current-buffer + (setq helm-pattern + (with-helm-current-buffer (expand-file-name default-directory)))))) - (setq anything-ff-default-directory anything-pattern) + (setq helm-ff-default-directory helm-pattern) ;; For some reasons, i must use here with-current-buffer => mini buffer - ;; and not `anything-set-pattern' that use with-selected-window => mini win. + ;; and not `helm-set-pattern' that use with-selected-window => mini win. (with-current-buffer (window-buffer (minibuffer-window)) (delete-minibuffer-contents) - (insert anything-pattern)))) + (insert helm-pattern)))) -(add-hook 'anything-after-update-hook 'anything-ff-auto-expand-to-home-or-root) +(add-hook 'helm-after-update-hook 'helm-ff-auto-expand-to-home-or-root) -(defun anything-c-point-file-in-dired (file) +(defun helm-c-point-file-in-dired (file) "Put point on filename FILE in dired buffer." (dired (file-name-directory file)) (dired-goto-file file)) -(defun anything-create-tramp-name (fname) - "Build filename for `anything-pattern' like /su:: or /sudo::." +(defun helm-create-tramp-name (fname) + "Build filename for `helm-pattern' like /su:: or /sudo::." (apply #'tramp-make-tramp-file-name (loop with v = (tramp-dissect-file-name fname) for i across v collect i))) -(defun* anything-ff-tramp-hostnames (&optional (pattern anything-pattern)) - "Get a list of hosts for tramp method found in `anything-pattern'. -Argument PATTERN default to `anything-pattern', it is here only for debugging +(defun* helm-ff-tramp-hostnames (&optional (pattern helm-pattern)) + "Get a list of hosts for tramp method found in `helm-pattern'. +Argument PATTERN default to `helm-pattern', it is here only for debugging purpose." (when (string-match tramp-file-name-regexp pattern) (let ((method (match-string 1 pattern)) (tn (match-string 0 pattern)) (all-methods (mapcar 'car tramp-methods))) - (anything-fast-remove-dups + (helm-fast-remove-dups (loop for (f . h) in (tramp-get-completion-function method) append (loop for e in (funcall f (car h)) for host = (and (consp e) (cadr e)) @@ -4047,31 +3994,31 @@ purpose." collect (concat tn host))) :test 'equal)))) -(defun anything-ff-before-action-hook-fn () - "Exit anything when user try to execute action on an invalid tramp fname." - (let ((cand (anything-get-selection))) - (when (and (anything-file-completion-source-p) - (anything-ff-invalid-tramp-name-p cand) ; Check candidate. - (anything-ff-invalid-tramp-name-p)) ; check anything-pattern. +(defun helm-ff-before-action-hook-fn () + "Exit helm when user try to execute action on an invalid tramp fname." + (let ((cand (helm-get-selection))) + (when (and (helm-file-completion-source-p) + (helm-ff-invalid-tramp-name-p cand) ; Check candidate. + (helm-ff-invalid-tramp-name-p)) ; check helm-pattern. (error "Error: Unknow file or directory `%s'" cand)))) -(add-hook 'anything-before-action-hook 'anything-ff-before-action-hook-fn) +(add-hook 'helm-before-action-hook 'helm-ff-before-action-hook-fn) -(defun* anything-ff-invalid-tramp-name-p (&optional (pattern anything-pattern)) +(defun* helm-ff-invalid-tramp-name-p (&optional (pattern helm-pattern)) "Return non--nil when PATTERN is an invalid tramp filename." - (string= (anything-ff-set-pattern pattern) + (string= (helm-ff-set-pattern pattern) "Invalid tramp file name")) -(defun anything-ff-set-pattern (pattern) - "Handle tramp filenames in `anything-pattern'." +(defun helm-ff-set-pattern (pattern) + "Handle tramp filenames in `helm-pattern'." (let ((methods (mapcar 'car tramp-methods)) (reg "\\`/\\([^[/:]+\\|[^/]+]\\):.*:") cur-method tramp-name) (cond ((string= pattern "") "") ((string-match ".*\\(~?/?[.]\\{1\\}/\\)$" pattern) - (with-anything-current-buffer + (with-helm-current-buffer (expand-file-name default-directory))) ((and (string-match ".*\\(~//\\|//\\)$" pattern) - (not (string-match anything-ff-url-regexp anything-pattern))) + (not (string-match helm-ff-url-regexp helm-pattern))) (expand-file-name "/") ; Expand to "/" or "c:/" ) ((string-match "^~\\|.*/~/$" pattern) @@ -4081,78 +4028,78 @@ purpose." ((and (string-match reg pattern) (setq cur-method (match-string 1 pattern)) (member cur-method methods)) - (setq tramp-name (anything-create-tramp-name + (setq tramp-name (helm-create-tramp-name (match-string 0 pattern))) (replace-match tramp-name nil t pattern)) ;; Match "/hostname:" ((and (string-match tramp-file-name-regexp pattern) (setq cur-method (match-string 1 pattern)) (and cur-method (not (member cur-method methods)))) - (setq tramp-name (anything-create-tramp-name + (setq tramp-name (helm-create-tramp-name (match-string 0 pattern))) (replace-match tramp-name nil t pattern)) ;; Match "/method:" in this case don't try to connect. ((and (not (string-match reg pattern)) (string-match tramp-file-name-regexp pattern) (member (match-string 1 pattern) methods)) - "Invalid tramp file name") ; Write in anything-buffer. + "Invalid tramp file name") ; Write in helm-buffer. ;; PATTERN is a directory, end it with "/". ;; This will make PATTERN not ending yet with "/" - ;; candidate for `anything-ff-default-directory', - ;; allowing `anything-ff-retrieve-last-expanded' to retrieve it + ;; candidate for `helm-ff-default-directory', + ;; allowing `helm-ff-retrieve-last-expanded' to retrieve it ;; when descending level. ((file-directory-p pattern) (file-name-as-directory pattern)) ;; Return PATTERN unchanged. (t pattern)))) -(defun anything-find-files-get-candidates (&optional require-match) - "Create candidate list for `anything-c-source-find-files'." - (let* ((path (anything-ff-set-pattern anything-pattern)) +(defun helm-find-files-get-candidates (&optional require-match) + "Create candidate list for `helm-c-source-find-files'." + (let* ((path (helm-ff-set-pattern helm-pattern)) (path-name-dir (if (file-directory-p path) (file-name-as-directory path) (file-name-directory path))) - (tramp-verbose anything-tramp-verbose)) ; No tramp message when 0. + (tramp-verbose helm-tramp-verbose)) ; No tramp message when 0. (set-text-properties 0 (length path) nil path) - ;; Don't set now `anything-pattern' if `path' == "Invalid tramp file name" + ;; Don't set now `helm-pattern' if `path' == "Invalid tramp file name" ;; like that the actual value (e.g /ssh:) is passed to - ;; `anything-ff-tramp-hostnames'. + ;; `helm-ff-tramp-hostnames'. (unless (string= path "Invalid tramp file name") - (setq anything-pattern (anything-ff-transform-fname-for-completion path))) - (setq anything-ff-default-directory - (if (string= anything-pattern "") + (setq helm-pattern (helm-ff-transform-fname-for-completion path))) + (setq helm-ff-default-directory + (if (string= helm-pattern "") (expand-file-name "/") ; Expand to "/" or "c:/" ;; If path is an url *default-directory have to be nil. - (unless (or (string-match anything-ff-url-regexp path) + (unless (or (string-match helm-ff-url-regexp path) (string-match ffap-url-regexp path)) path-name-dir))) (cond ((string= path "Invalid tramp file name") - (or (anything-ff-tramp-hostnames) ; Hostnames completion. + (or (helm-ff-tramp-hostnames) ; Hostnames completion. (prog2 - ;; `anything-pattern' have not been modified yet. + ;; `helm-pattern' have not been modified yet. ;; Set it here to the value of `path' that should be now ;; "Invalid tramp file name" and set the candidates list - ;; to ("Invalid tramp file name") to make `anything-pattern' + ;; to ("Invalid tramp file name") to make `helm-pattern' ;; match single candidate "Invalid tramp file name". - (setq anything-pattern path) + (setq helm-pattern path) ;; "Invalid tramp file name" is now printed - ;; in `anything-buffer'. + ;; in `helm-buffer'. (list path)))) ((or (file-regular-p path) ;; `ffap-url-regexp' don't match until url is complete. - (string-match anything-ff-url-regexp path) + (string-match helm-ff-url-regexp path) (and (not (file-exists-p path)) (string-match "/$" path)) (and ffap-url-regexp (string-match ffap-url-regexp path))) (list path)) - ((string= path "") (anything-ff-directory-files "/" t)) + ((string= path "") (helm-ff-directory-files "/" t)) ((and (file-directory-p path) (not (file-readable-p path))) (list (format "Opening directory: access denied, `%s'" path))) - ((file-directory-p path) (anything-ff-directory-files path t)) + ((file-directory-p path) (helm-ff-directory-files path t)) (t - (append (unless require-match (list path)) - (anything-ff-directory-files path-name-dir t)))))) + (append (list path) ; No need to check for must-match. + (helm-ff-directory-files path-name-dir t)))))) -(defun anything-ff-directory-files (directory &optional full) +(defun helm-ff-directory-files (directory &optional full) "List contents of DIRECTORY. Argument FULL mean absolute path. It is same as `directory-files' but always returns the @@ -4173,95 +4120,95 @@ systems." (append (list dot dot2) lsdir)) ls))) -(defun anything-ff-transform-fname-for-completion (fname) +(defun helm-ff-transform-fname-for-completion (fname) "Return FNAME with it's basename modified as a regexp. e.g foo => f.*o.*o . If basename contain one or more space or FNAME is a valid directory name return FNAME unchanged." - (let ((bn (anything-c-basename fname))) - (if (or (not anything-ff-smart-completion) + (let ((bn (helm-c-basename fname))) + (if (or (not helm-ff-smart-completion) (string-match "\\s-" bn) (string-match "/$" fname) ; Allow mkdir. (file-directory-p fname) - (string-match anything-ff-url-regexp fname)) + (string-match helm-ff-url-regexp fname)) fname ; Fall back to match-plugin. (setq bn (if (> (length bn) 2) ; Normal completion on first 2 char. (mapconcat 'identity (split-string bn "" t) ".*") bn)) (concat (file-name-directory fname) bn)))) -(defun anything-ff-save-history () - "Store the last value of `anything-ff-default-directory' \ -in `anything-ff-history'." - (when (and anything-ff-default-directory - (anything-file-completion-source-p)) - (push anything-ff-default-directory anything-ff-history))) -(add-hook 'anything-cleanup-hook 'anything-ff-save-history) +(defun helm-ff-save-history () + "Store the last value of `helm-ff-default-directory' \ +in `helm-ff-history'." + (when (and helm-ff-default-directory + (helm-file-completion-source-p)) + (push helm-ff-default-directory helm-ff-history))) +(add-hook 'helm-cleanup-hook 'helm-ff-save-history) -(defun anything-ff-valid-symlink-p (file) +(defun helm-ff-valid-symlink-p (file) (file-exists-p (file-truename file))) -(defun anything-ff-properties (candidate) +(defun helm-ff-properties (candidate) "Show file properties of CANDIDATE in a tooltip or message." - (let ((type (anything-ff-attributes candidate :type t)) - (dired-line (anything-ff-attributes candidate :dired t :human-size t))) + (let ((type (helm-ff-attributes candidate :type t)) + (dired-line (helm-ff-attributes candidate :dired t :human-size t))) (if (window-system) (tooltip-show (concat - (anything-c-basename candidate) "\n" + (helm-c-basename candidate) "\n" "Type: " type "\n" (when (string= type "symlink") (format "True name: '%s'\n" - (cond ((string-match "^\.#" (anything-c-basename candidate)) + (cond ((string-match "^\.#" (helm-c-basename candidate)) "Autosave symlink") - ((anything-ff-valid-symlink-p candidate) + ((helm-ff-valid-symlink-p candidate) (file-truename candidate)) (t "Invalid Symlink")))) dired-line)) (message dired-line) (sit-for 5)))) ;;;###autoload -(defun anything-ff-properties-persistent () - "Show properties without quitting anything." +(defun helm-ff-properties-persistent () + "Show properties without quitting helm." (interactive) - (anything-attrset 'properties-action 'anything-ff-properties) - (anything-execute-persistent-action 'properties-action)) + (helm-attrset 'properties-action 'helm-ff-properties) + (helm-execute-persistent-action 'properties-action)) ;;;###autoload -(defun anything-ff-persistent-delete () +(defun helm-ff-persistent-delete () "Delete current candidate without quitting." (interactive) - (anything-attrset 'quick-delete 'anything-ff-quick-delete) - (anything-execute-persistent-action 'quick-delete)) + (helm-attrset 'quick-delete 'helm-ff-quick-delete) + (helm-execute-persistent-action 'quick-delete)) -(defun anything-ff-dot-file-p (file) +(defun helm-ff-dot-file-p (file) "Check if FILE is `.' or `..'." - (member (anything-c-basename file) '("." ".."))) + (member (helm-c-basename file) '("." ".."))) -(defun anything-ff-quick-delete (candidate) +(defun helm-ff-quick-delete (candidate) "Delete file CANDIDATE without quitting." (let ((presel (prog1 (save-excursion (let (sel) - (anything-next-line) - (setq sel (anything-get-selection)) + (helm-next-line) + (setq sel (helm-get-selection)) (if (string= sel candidate) - (progn (anything-previous-line) - (anything-get-selection)) + (progn (helm-previous-line) + (helm-get-selection)) sel))) - (anything-mark-current-line)))) - (setq presel (if (and anything-ff-transformer-show-only-basename - (not (anything-ff-dot-file-p presel))) - (anything-c-basename presel) presel)) - (if anything-ff-quick-delete-dont-prompt-for-deletion - (anything-c-delete-file candidate - anything-ff-signal-error-on-dot-files) + (helm-mark-current-line)))) + (setq presel (if (and helm-ff-transformer-show-only-basename + (not (helm-ff-dot-file-p presel))) + (helm-c-basename presel) presel)) + (if helm-ff-quick-delete-dont-prompt-for-deletion + (helm-c-delete-file candidate + helm-ff-signal-error-on-dot-files) (save-selected-window (when (y-or-n-p (format "Really Delete file `%s'? " candidate)) - (anything-c-delete-file candidate - anything-ff-signal-error-on-dot-files) + (helm-c-delete-file candidate + helm-ff-signal-error-on-dot-files) (message nil)))) - (anything-force-update presel))) + (helm-force-update presel))) -(defun anything-ff-kill-buffer-fname (candidate) +(defun helm-ff-kill-buffer-fname (candidate) (let* ((buf (get-file-buffer candidate)) (buf-name (buffer-name buf))) (if buf @@ -4269,38 +4216,38 @@ in `anything-ff-history'." (kill-buffer buf) (message "Buffer `%s' killed" buf)) (message "No buffer to kill")))) -(defun anything-ff-kill-or-find-buffer-fname (candidate) +(defun helm-ff-kill-or-find-buffer-fname (candidate) "Find file CANDIDATE or kill it's buffer if it is visible. -Never kill `anything-current-buffer'. +Never kill `helm-current-buffer'. Never kill buffer modified. This is called normally on third hit of \ -\\\\[anything-execute-persistent-action] -in `anything-find-files-persistent-action'." +\\\\[helm-execute-persistent-action] +in `helm-find-files-persistent-action'." (let* ((buf (get-file-buffer candidate)) (buf-name (buffer-name buf))) (if (and buf (get-buffer-window buf) - (not (eq buf (get-buffer anything-current-buffer))) + (not (eq buf (get-buffer helm-current-buffer))) (not (buffer-modified-p buf))) (progn (kill-buffer buf) (message "Buffer `%s' killed" buf-name)) (find-file candidate)))) ;;;###autoload -(defun anything-ff-run-kill-buffer-persistent () - "Execute `anything-ff-kill-buffer-fname' whitout quitting." +(defun helm-ff-run-kill-buffer-persistent () + "Execute `helm-ff-kill-buffer-fname' whitout quitting." (interactive) - (when (anything-file-completion-source-p) - (anything-attrset 'kill-buffer-fname 'anything-ff-kill-buffer-fname) - (anything-execute-persistent-action 'kill-buffer-fname))) + (when (helm-file-completion-source-p) + (helm-attrset 'kill-buffer-fname 'helm-ff-kill-buffer-fname) + (helm-execute-persistent-action 'kill-buffer-fname))) -(defun anything-ff-human-size (size) +(defun helm-ff-human-size (size) "Return a string showing SIZE of a file in human readable form. SIZE can be an integer or a float depending it's value. `file-attributes' will take care of that to avoid overflow error. KBSIZE if a floating point number, default value is 1024.0." - (let ((M (cons "M" (/ size (expt anything-ff-default-kbsize 2)))) - (G (cons "G" (/ size (expt anything-ff-default-kbsize 3)))) - (K (cons "K" (/ size anything-ff-default-kbsize))) + (let ((M (cons "M" (/ size (expt helm-ff-default-kbsize 2)))) + (G (cons "G" (/ size (expt helm-ff-default-kbsize 3)))) + (K (cons "K" (/ size helm-ff-default-kbsize))) (B (cons "B" size))) (loop with result = B for (a . b) in @@ -4311,7 +4258,7 @@ KBSIZE if a floating point number, default value is 1024.0." (format "%s" size) (format "%.1f%s" (cdr result) (car result)))))) -(defun* anything-ff-attributes +(defun* helm-ff-attributes (file &key type links uid gid access-time modif-time status size mode gid-change inode device-num dired human-size) "Easy interface for `file-attributes'." @@ -4346,7 +4293,7 @@ KBSIZE if a floating point number, default value is 1024.0." (format-time-string "%Y-%m-%d %R" (getf all :modif-time))) (status (format-time-string "%Y-%m-%d %R" (getf all :status))) - (size (if human-size (anything-ff-human-size (getf all :size)) + (size (if human-size (helm-ff-human-size (getf all :size)) (getf all :size))) (mode (getf all :mode)) (gid-change (getf all :gid-change)) @@ -4358,12 +4305,12 @@ KBSIZE if a floating point number, default value is 1024.0." (number-to-string (getf all :links)) " " (getf all :uid) ":" (getf all :gid) " " - (if human-size (anything-ff-human-size (getf all :size)) + (if human-size (helm-ff-human-size (getf all :size)) (int-to-string (getf all :size))) " " (format-time-string "%Y-%m-%d %R" (getf all :modif-time)))) (t all)))) -(defun anything-ff-prefix-filename (fname &optional file-or-symlinkp new-file) +(defun helm-ff-prefix-filename (fname &optional file-or-symlinkp new-file) "Return filename FNAME maybe prefixed with [?] or [@]. If FILE-OR-SYMLINKP is non--nil this mean we assume FNAME is an existing filename or valid symlink and there is no need to test it. @@ -4371,84 +4318,84 @@ NEW-FILE when non--nil mean FNAME is a non existing file and return FNAME prefixed with [?]." (let* ((prefix-new (propertize " " 'display - (propertize "[?]" 'face 'anything-ff-prefix))) + (propertize "[?]" 'face 'helm-ff-prefix))) (prefix-url (propertize " " 'display - (propertize "[@]" 'face 'anything-ff-prefix)))) + (propertize "[@]" 'face 'helm-ff-prefix)))) (cond ((or file-or-symlinkp (file-exists-p fname)) fname) - ((or (string-match anything-ff-url-regexp fname) + ((or (string-match helm-ff-url-regexp fname) (string-match ffap-url-regexp fname)) (concat prefix-url " " fname)) ((or new-file (not (file-exists-p fname))) (concat prefix-new " " fname))))) -(defun anything-c-find-files-transformer (files sources) - "Transformer for `anything-c-source-find-files'. -Tramp files are not highlighted unless `anything-ff-tramp-not-fancy' +(defun helm-c-find-files-transformer (files sources) + "Transformer for `helm-c-source-find-files'. +Tramp files are not highlighted unless `helm-ff-tramp-not-fancy' is non--nil." - (if (and (string-match tramp-file-name-regexp anything-pattern) - anything-ff-tramp-not-fancy) - (if anything-ff-transformer-show-only-basename + (if (and (string-match tramp-file-name-regexp helm-pattern) + helm-ff-tramp-not-fancy) + (if helm-ff-transformer-show-only-basename (loop for i in files collect (if (string-match "[.]\\{1,2\\}$" i) - i (cons (anything-c-basename i) i))) + i (cons (helm-c-basename i) i))) files) - (anything-ff-highlight-files files sources))) + (helm-ff-highlight-files files sources))) -(defun anything-ff-highlight-files (files sources) - "Candidate transformer for `anything-c-source-find-files' without icons." +(defun helm-ff-highlight-files (files sources) + "Candidate transformer for `helm-c-source-find-files' without icons." (loop for i in files - for disp = (if (and anything-ff-transformer-show-only-basename + for disp = (if (and helm-ff-transformer-show-only-basename (not (string-match "[.]\\{1,2\\}$" i)) (not (string-match ffap-url-regexp i)) - (not (string-match anything-ff-url-regexp i))) - (anything-c-basename i) i) + (not (string-match helm-ff-url-regexp i))) + (helm-c-basename i) i) collect (cond ((and (stringp (car (file-attributes i))) - (not (anything-ff-valid-symlink-p i)) - (not (string-match "^\.#" (anything-c-basename i)))) - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-invalid-symlink) t) + (not (helm-ff-valid-symlink-p i)) + (not (string-match "^\.#" (helm-c-basename i)))) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-invalid-symlink) t) i)) ((stringp (car (file-attributes i))) - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-symlink) t) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-symlink) t) i)) ((eq t (car (file-attributes i))) - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-directory) t) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-directory) t) i)) ((file-executable-p i) - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-executable) t) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-executable) t) i)) ((file-exists-p i) - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-file) t) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-file) t) i)) (t - (cons (anything-ff-prefix-filename - (propertize disp 'face 'anything-ff-file) nil 'new-file) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-file) nil 'new-file) i))))) -(defun anything-find-files-action-transformer (actions candidate) - "Action transformer for `anything-c-source-find-files'." - (cond ((with-anything-current-buffer +(defun helm-find-files-action-transformer (actions candidate) + "Action transformer for `helm-c-source-find-files'." + (cond ((with-helm-current-buffer (eq major-mode 'message-mode)) (append (subseq actions 0 4) - '(("Gnus attach file(s)" . anything-ff-gnus-attach-files)) + '(("Gnus attach file(s)" . helm-ff-gnus-attach-files)) (subseq actions 4))) ((string-match (image-file-name-regexp) candidate) (append (subseq actions 0 4) - '(("Rotate image right `M-r'" . anything-ff-rotate-image-right) - ("Rotate image left `M-l'" . anything-ff-rotate-image-left)) + '(("Rotate image right `M-r'" . helm-ff-rotate-image-right) + ("Rotate image left `M-l'" . helm-ff-rotate-image-left)) (subseq actions 4))) - ((string-match "\.el$" (anything-aif (anything-marked-candidates) + ((string-match "\.el$" (helm-aif (helm-marked-candidates) (car it) candidate)) (append (subseq actions 0 4) '(("Byte compile lisp file(s) `M-B, C-u to load'" - . anything-find-files-byte-compile) - ("Load File(s) `M-L'" . anything-find-files-load-files)) + . helm-find-files-byte-compile) + ("Load File(s) `M-L'" . helm-find-files-load-files)) (subseq actions 4))) ((and (string-match "\.html?$" candidate) (file-exists-p candidate)) @@ -4458,16 +4405,16 @@ is non--nil." ((or (string= (file-name-extension candidate) "pdf") (string= (file-name-extension candidate) "PDF")) (append (subseq actions 0 4) - '(("Pdfgrep File(s)" . anything-ff-pdfgrep)) + '(("Pdfgrep File(s)" . helm-ff-pdfgrep)) (subseq actions 5))) (t actions))) -(defun anything-ff-gnus-attach-files (candidate) - "Run `gnus-dired-attach' on `anything-marked-candidates' or CANDIDATE." - (let ((flist (anything-marked-candidates))) +(defun helm-ff-gnus-attach-files (candidate) + "Run `gnus-dired-attach' on `helm-marked-candidates' or CANDIDATE." + (let ((flist (helm-marked-candidates))) (gnus-dired-attach flist))) -(defun anything-ff-rotate-current-image-1 (file &optional num-arg) +(defun helm-ff-rotate-current-image-1 (file &optional num-arg) "Rotate current image at NUM-ARG degrees. This is a destructive operation on FILE made by external tool mogrify." (declare (special image-dired-display-image-buffer)) @@ -4486,51 +4433,51 @@ This is a destructive operation on FILE made by external tool mogrify." (display-buffer (get-buffer image-dired-display-image-buffer))) (error "mogrify not found")))) -(defun anything-ff-rotate-image-left (candidate) +(defun helm-ff-rotate-image-left (candidate) "Rotate image file CANDIDATE left. This affect directly file CANDIDATE." - (anything-ff-rotate-current-image-1 candidate -90)) + (helm-ff-rotate-current-image-1 candidate -90)) -(defun anything-ff-rotate-image-right (candidate) +(defun helm-ff-rotate-image-right (candidate) "Rotate image file CANDIDATE right. This affect directly file CANDIDATE." - (anything-ff-rotate-current-image-1 candidate)) + (helm-ff-rotate-current-image-1 candidate)) -(defun anything-ff-rotate-left-persistent () - "Rotate image left without quitting anything." +(defun helm-ff-rotate-left-persistent () + "Rotate image left without quitting helm." (interactive) - (anything-attrset 'image-action1 'anything-ff-rotate-image-left) - (anything-execute-persistent-action 'image-action1)) + (helm-attrset 'image-action1 'helm-ff-rotate-image-left) + (helm-execute-persistent-action 'image-action1)) -(defun anything-ff-rotate-right-persistent () - "Rotate image right without quitting anything." +(defun helm-ff-rotate-right-persistent () + "Rotate image right without quitting helm." (interactive) - (anything-attrset 'image-action2 'anything-ff-rotate-image-right) - (anything-execute-persistent-action 'image-action2)) + (helm-attrset 'image-action2 'helm-ff-rotate-image-right) + (helm-execute-persistent-action 'image-action2)) -(defun anything-ff-exif-data (candidate) - "Extract exif data from file CANDIDATE using `anything-ff-exif-data-program'." - (if (and anything-ff-exif-data-program - (executable-find anything-ff-exif-data-program)) +(defun helm-ff-exif-data (candidate) + "Extract exif data from file CANDIDATE using `helm-ff-exif-data-program'." + (if (and helm-ff-exif-data-program + (executable-find helm-ff-exif-data-program)) (shell-command-to-string (format "%s %s %s" - anything-ff-exif-data-program - anything-ff-exif-data-program-args + helm-ff-exif-data-program + helm-ff-exif-data-program-args candidate)) (format "No program %s found to extract exif" - anything-ff-exif-data-program))) + helm-ff-exif-data-program))) -(defun anything-find-files-persistent-action (candidate) - "Open subtree CANDIDATE without quitting anything. +(defun helm-find-files-persistent-action (candidate) + "Open subtree CANDIDATE without quitting helm. If CANDIDATE is not a directory expand CANDIDATE filename. If CANDIDATE is alone, open file CANDIDATE filename. That's mean: First hit on C-z expand CANDIDATE second hit open file. -If a prefix arg is given or `anything-follow-mode' is on open file." +If a prefix arg is given or `helm-follow-mode' is on open file." (let ((follow (buffer-local-value - 'anything-follow-mode - (get-buffer-create anything-buffer))) - (new-pattern (anything-get-selection)) - (num-lines-buf (with-current-buffer anything-buffer + 'helm-follow-mode + (get-buffer-create helm-buffer))) + (new-pattern (helm-get-selection)) + (num-lines-buf (with-current-buffer helm-buffer (count-lines (point-min) (point-max))))) (flet ((insert-in-minibuffer (fname) (with-selected-window (minibuffer-window) @@ -4538,12 +4485,12 @@ If a prefix arg is given or `anything-follow-mode' is on open file." (delete-minibuffer-contents) (set-text-properties 0 (length fname) nil fname) (insert fname))))) - (cond ((and (string= (anything-ff-set-pattern anything-pattern) + (cond ((and (string= (helm-ff-set-pattern helm-pattern) "Invalid tramp file name") (string-match tramp-file-name-regexp candidate)) ;; First hit insert hostname and ;; second hit insert ":" and expand. - (if (string= candidate anything-pattern) + (if (string= candidate helm-pattern) (insert-in-minibuffer (concat candidate ":")) (insert-in-minibuffer candidate))) (;; A symlink directory, expand it's truename. @@ -4553,8 +4500,8 @@ If a prefix arg is given or `anything-follow-mode' is on open file." (expand-file-name candidate))))) ;; A directory, open it. ((file-directory-p candidate) - (when (string= (anything-c-basename candidate) "..") - (setq anything-ff-last-expanded anything-ff-default-directory)) + (when (string= (helm-c-basename candidate) "..") + (setq helm-ff-last-expanded helm-ff-default-directory)) (insert-in-minibuffer (file-name-as-directory (expand-file-name candidate)))) ;; A symlink file, expand to it's true name. (first hit) @@ -4570,31 +4517,31 @@ If a prefix arg is given or `anything-follow-mode' is on open file." (kill-buffer image-dired-display-image-buffer)) (image-dired-display-image candidate) (message nil) - (anything-c-switch-to-buffer image-dired-display-image-buffer) + (helm-c-switch-to-buffer image-dired-display-image-buffer) (with-current-buffer image-dired-display-image-buffer - (let ((exif-data (anything-ff-exif-data candidate))) + (let ((exif-data (helm-ff-exif-data candidate))) (image-dired-update-property 'help-echo exif-data)))) ;; Allow browsing archive on avfs fs. ;; Assume volume is already mounted with mountavfs. - ((and anything-ff-avfs-directory + ((and helm-ff-avfs-directory (string-match - (regexp-quote (expand-file-name anything-ff-avfs-directory)) + (regexp-quote (expand-file-name helm-ff-avfs-directory)) (file-name-directory candidate)) - (anything-ff-file-compressed-p candidate)) + (helm-ff-file-compressed-p candidate)) (insert-in-minibuffer (concat candidate "#"))) ;; On second hit we open file. ;; On Third hit we kill it's buffer maybe. (t - (anything-ff-kill-or-find-buffer-fname candidate)))))) + (helm-ff-kill-or-find-buffer-fname candidate)))))) -(defun anything-ff-file-compressed-p (candidate) +(defun helm-ff-file-compressed-p (candidate) "Whether CANDIDATE is a compressed file or not." (member (file-name-extension candidate) - anything-ff-file-compressed-list)) + helm-ff-file-compressed-list)) -(defun anything-c-insert-file-name-completion-at-point (candidate) +(defun helm-c-insert-file-name-completion-at-point (candidate) "Insert file name completion at point." - (with-anything-current-buffer + (with-helm-current-buffer (if buffer-read-only (error "Error: Buffer `%s' is read-only" (buffer-name)) (let* ((end (point)) @@ -4612,59 +4559,59 @@ If a prefix arg is given or `anything-follow-mode' is on open file." (abbreviate-file-name candidate)))) (error "Aborting completion: No valid file name at point")))))) -(defun* anything-find-files-history (&key (comp-read t)) - "The `anything-find-files' history. -Show the first `anything-ff-history-max-length' elements of -`anything-ff-history' in an `anything-comp-read'." - (let ((history (when anything-ff-history - (anything-fast-remove-dups anything-ff-history +(defun* helm-find-files-history (&key (comp-read t)) + "The `helm-find-files' history. +Show the first `helm-ff-history-max-length' elements of +`helm-ff-history' in an `helm-comp-read'." + (let ((history (when helm-ff-history + (helm-fast-remove-dups helm-ff-history :test 'equal)))) (when history - (setq anything-ff-history - (if (>= (length history) anything-ff-history-max-length) - (subseq history 0 anything-ff-history-max-length) + (setq helm-ff-history + (if (>= (length history) helm-ff-history-max-length) + (subseq history 0 helm-ff-history-max-length) history)) (if comp-read - (anything-comp-read + (helm-comp-read "Switch to Directory: " - anything-ff-history - :name "Anything Find Files History" + helm-ff-history + :name "Helm Find Files History" :must-match t) - anything-ff-history)))) + helm-ff-history)))) -(defun anything-find-files-1 (fname &optional preselect) - "Find FNAME with `anything' completion. -Like `find-file' but with `anything' support. -Use it for non--interactive calls of `anything-find-files'." - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) - (let ((anything-mp-highlight-delay nil) +(defun helm-find-files-1 (fname &optional preselect) + "Find FNAME with `helm' completion. +Like `find-file' but with `helm' support. +Use it for non--interactive calls of `helm-find-files'." + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (let ((helm-mp-highlight-delay nil) ;; Be sure we don't erase the precedent minibuffer if some. - (anything-ff-auto-update-initial-value - (and anything-ff-auto-update-initial-value + (helm-ff-auto-update-initial-value + (and helm-ff-auto-update-initial-value (not (minibuffer-window-active-p (minibuffer-window))))) - anything-samewindow) - (anything :sources 'anything-c-source-find-files + helm-samewindow) + (helm :sources 'helm-c-source-find-files :input fname :preselect preselect - :keymap anything-find-files-map + :keymap helm-find-files-map :prompt "Find Files or Url: " - :buffer "*Anything Find Files*"))) + :buffer "*Helm Find Files*"))) -(defun anything-find-files-initial-input (&optional input) +(defun helm-find-files-initial-input (&optional input) "Return INPUT if present, otherwise try to guess it." (or (and input (or (and (file-remote-p input) input) (expand-file-name input))) - (anything-find-files-input + (helm-find-files-input (ffap-guesser) (thing-at-point 'filename)))) -(defun anything-find-files-input (fap tap) - "Default input of `anything-find-files'." - (let* ((def-dir (anything-c-current-directory)) - (lib (anything-find-library-at-point)) - (url (anything-ff-find-url-at-point)) +(defun helm-find-files-input (fap tap) + "Default input of `helm-find-files'." + (let* ((def-dir (helm-c-current-directory)) + (lib (helm-find-library-at-point)) + (url (helm-ff-find-url-at-point)) (remp (and fap (file-remote-p fap))) (file-p (and (not remp) fap @@ -4679,14 +4626,14 @@ Use it for non--interactive calls of `anything-find-files'." (file-p (expand-file-name tap def-dir)) (t (and (not (string= fap "")) fap))))) -(defun anything-c-current-directory () +(defun helm-c-current-directory () "Return current-directory name at point. Useful in dired buffers when there is inserted subdirs." (if (eq major-mode 'dired-mode) (dired-current-directory) default-directory)) -(defun anything-ff-find-url-at-point () +(defun helm-ff-find-url-at-point () "Try to find link to an url in text-property at point." (let* ((he (get-text-property (point) 'help-echo)) (ov (overlays-at (point))) @@ -4700,7 +4647,7 @@ Useful in dired buffers when there is inserted subdirs." (loop for i in (list he ov-he w3m-l nt-prop) thereis (and (stringp i) (string-match ffap-url-regexp i) i)))) -(defun anything-find-library-at-point () +(defun helm-find-library-at-point () "Try to find library path at point. Find inside `require' and `declare-function' sexp." (require 'find-func) @@ -4724,117 +4671,117 @@ Find inside `require' and `declare-function' sexp." (third (split-string sexp))))) (t nil))))) -;;; Anything completion for `write-file'.==> C-x C-w -(defvar anything-c-source-write-file +;;; Helm completion for `write-file'.==> C-x C-w +(defvar helm-c-source-write-file `((name . "Write File") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Write File" . (lambda (candidate) (write-file candidate 'confirm))))))) -;;; Anything completion for `insert-file'.==> C-x i -(defvar anything-c-source-insert-file +;;; Helm completion for `insert-file'.==> C-x i +(defvar helm-c-source-insert-file `((name . "Insert File") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Insert File" . (lambda (candidate) (when (y-or-n-p (format "Really insert %s in %s " - candidate anything-current-buffer)) + candidate helm-current-buffer)) (insert-file-contents candidate)))))))) -;;; Anything completion for copy, rename and (rel)sym/hard/link files from dired. -(defvar anything-c-source-copy-files +;;; Helm completion for copy, rename and (rel)sym/hard/link files from dired. +(defvar helm-c-source-copy-files `((name . "Copy Files") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Copy File" . (lambda (candidate) - (anything-dired-action candidate :action 'copy))) + (helm-dired-action candidate :action 'copy))) ("Copy and Follow" . (lambda (candidate) - (anything-dired-action candidate :action 'copy :follow t))))))) + (helm-dired-action candidate :action 'copy :follow t))))))) -(defvar anything-c-source-rename-files +(defvar helm-c-source-rename-files `((name . "Rename Files") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Rename File" . (lambda (candidate) - (anything-dired-action candidate :action 'rename))) + (helm-dired-action candidate :action 'rename))) ("Rename and Follow" . (lambda (candidate) - (anything-dired-action candidate :action 'rename :follow t))))))) + (helm-dired-action candidate :action 'rename :follow t))))))) -(defvar anything-c-source-symlink-files +(defvar helm-c-source-symlink-files `((name . "Symlink Files") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Symlink File" . (lambda (candidate) - (anything-dired-action candidate :action 'symlink))) + (helm-dired-action candidate :action 'symlink))) ("RelSymlink File" . (lambda (candidate) - (anything-dired-action candidate :action 'relsymlink))))))) + (helm-dired-action candidate :action 'relsymlink))))))) -(defvar anything-c-source-hardlink-files +(defvar helm-c-source-hardlink-files `((name . "Hardlink Files") (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (candidates . anything-find-files-get-candidates) - (filtered-candidate-transformer anything-c-find-files-transformer) - (persistent-action . anything-find-files-persistent-action) + (candidates . helm-find-files-get-candidates) + (filtered-candidate-transformer helm-c-find-files-transformer) + (persistent-action . helm-find-files-persistent-action) (persistent-help . "Expand Candidate") (volatile) (action . (("Hardlink File" . (lambda (candidate) - (anything-dired-action candidate :action 'hardlink))))))) + (helm-dired-action candidate :action 'hardlink))))))) -(defun* anything-dired-action (candidate &key action follow (files (dired-get-marked-files))) +(defun* helm-dired-action (candidate &key action follow (files (dired-get-marked-files))) "Copy, rename or symlink file at point or marked files in dired to CANDIDATE. ACTION is a key that can be one of 'copy, 'rename, 'symlink, 'relsymlink." (when (get-buffer dired-log-buffer) (kill-buffer dired-log-buffer)) @@ -4866,21 +4813,21 @@ ACTION is a key that can be one of 'copy, 'rename, 'symlink, 'relsymlink." (if (file-directory-p candidate) (expand-file-name candidate) (file-name-directory candidate))) - anything-ff-history) + helm-ff-history) (when (and follow (not (get-buffer dired-log-buffer))) (let ((target (directory-file-name candidate))) (unwind-protect (progn - (setq anything-ff-cand-to-mark - (anything-get-dest-fnames-from-list files candidate dirflag)) + (setq helm-ff-cand-to-mark + (helm-get-dest-fnames-from-list files candidate dirflag)) (if (and dirflag (eq action 'rename)) - (anything-find-files-1 (file-name-directory target) - (if anything-ff-transformer-show-only-basename - (anything-c-basename target) target)) - (anything-find-files-1 (expand-file-name candidate)))) - (setq anything-ff-cand-to-mark nil)))))) + (helm-find-files-1 (file-name-directory target) + (if helm-ff-transformer-show-only-basename + (helm-c-basename target) target)) + (helm-find-files-1 (expand-file-name candidate)))) + (setq helm-ff-cand-to-mark nil)))))) -(defun anything-c-basename (fname &optional ext) +(defun helm-c-basename (fname &optional ext) "Print FNAME with any leading directory components removed. If specified, also remove filename extension EXT." (if (and ext (or (string= (file-name-extension fname) ext) @@ -4889,7 +4836,7 @@ If specified, also remove filename extension EXT." (file-name-sans-extension (file-name-nondirectory fname)) (file-name-nondirectory (directory-file-name fname)))) -(defun anything-get-dest-fnames-from-list (flist dest-cand rename-dir-flag) +(defun helm-get-dest-fnames-from-list (flist dest-cand rename-dir-flag) "Transform filenames of FLIST to abs of DEST-CAND. If RENAME-DIR-FLAG is non--nil collect the `directory-file-name' of transformed members of FLIST." @@ -4898,7 +4845,7 @@ members of FLIST." (loop with dest = (expand-file-name dest-cand) for src in flist - for basename-src = (anything-c-basename src) + for basename-src = (helm-c-basename src) for fname = (cond (rename-dir-flag (directory-file-name dest)) ((file-directory-p dest) (concat (file-name-as-directory dest) basename-src)) @@ -4907,98 +4854,98 @@ members of FLIST." collect fname into tmp-list finally return (sort tmp-list 'string<))) -(defun anything-ff-maybe-mark-candidates () - "Mark all candidates of list `anything-ff-cand-to-mark'." - (when (and (string= (assoc-default 'name (anything-get-current-source)) - (assoc-default 'name anything-c-source-find-files)) - anything-ff-cand-to-mark) - (with-anything-window - (while anything-ff-cand-to-mark - (if (string= (car anything-ff-cand-to-mark) (anything-get-selection)) +(defun helm-ff-maybe-mark-candidates () + "Mark all candidates of list `helm-ff-cand-to-mark'." + (when (and (string= (assoc-default 'name (helm-get-current-source)) + (assoc-default 'name helm-c-source-find-files)) + helm-ff-cand-to-mark) + (with-helm-window + (while helm-ff-cand-to-mark + (if (string= (car helm-ff-cand-to-mark) (helm-get-selection)) (progn - (anything-make-visible-mark) - (anything-next-line) - (setq anything-ff-cand-to-mark (cdr anything-ff-cand-to-mark))) - (anything-next-line))) - (unless (anything-this-visible-mark) - (anything-prev-visible-mark))))) + (helm-make-visible-mark) + (helm-next-line) + (setq helm-ff-cand-to-mark (cdr helm-ff-cand-to-mark))) + (helm-next-line))) + (unless (helm-this-visible-mark) + (helm-prev-visible-mark))))) -(add-hook 'anything-after-update-hook #'anything-ff-maybe-mark-candidates) +(add-hook 'helm-after-update-hook #'helm-ff-maybe-mark-candidates) -(defun* anything-dired-do-action-on-file (&key action) +(defun* helm-dired-do-action-on-file (&key action) (let* ((files (dired-get-marked-files)) (len (length files)) (fname (if (> len 1) (format "* %d Files" len) (car files))) (source (case action - ('copy 'anything-c-source-copy-files) - ('rename 'anything-c-source-rename-files) - ('symlink 'anything-c-source-symlink-files) - ('hardlink 'anything-c-source-hardlink-files))) + ('copy 'helm-c-source-copy-files) + ('rename 'helm-c-source-rename-files) + ('symlink 'helm-c-source-symlink-files) + ('hardlink 'helm-c-source-hardlink-files))) (prompt-fm (case action ('copy "Copy %s to: ") ('rename "Rename %s to: ") ('symlink "Symlink %s to: ") ('hardlink "Hardlink %s to: "))) (buffer (case action - ('copy "*Anything Copy Files*") - ('rename "*Anything Rename Files*") - ('symlink "*Anything Symlink Files*") - ('hardlink "*Anything Hardlink Files*"))) - (anything-mp-highlight-delay nil)) - (anything :sources source + ('copy "*Helm Copy Files*") + ('rename "*Helm Rename Files*") + ('symlink "*Helm Symlink Files*") + ('hardlink "*Helm Hardlink Files*"))) + (helm-mp-highlight-delay nil)) + (helm :sources source :input (or (dired-dwim-target-directory) - (expand-file-name (anything-c-current-directory))) + (expand-file-name (helm-c-current-directory))) :preselect (dired-get-filename) :prompt (format prompt-fm fname) - :keymap anything-c-read-file-map + :keymap helm-c-read-file-map :buffer buffer))) ;;;###autoload -(define-minor-mode anything-dired-mode () - "Enable anything completion in Dired functions. +(define-minor-mode helm-dired-mode () + "Enable helm completion in Dired functions. Bindings affected are C, R, S, H. -This is deprecated for Emacs24+ users, use `ac-mode' instead." - :group 'anything-config +This is deprecated for Emacs24+ users, use `helm-mode' instead." + :group 'helm-config :global t - (if anything-dired-mode + (if helm-dired-mode (progn (substitute-key-definition - 'dired-do-copy 'anything-dired-copy-file dired-mode-map) + 'dired-do-copy 'helm-dired-copy-file dired-mode-map) (substitute-key-definition - 'dired-do-rename 'anything-dired-rename-file dired-mode-map) + 'dired-do-rename 'helm-dired-rename-file dired-mode-map) (substitute-key-definition - 'dired-do-symlink 'anything-dired-symlink-file dired-mode-map) + 'dired-do-symlink 'helm-dired-symlink-file dired-mode-map) (substitute-key-definition - 'dired-do-hardlink 'anything-dired-hardlink-file dired-mode-map)) + 'dired-do-hardlink 'helm-dired-hardlink-file dired-mode-map)) (substitute-key-definition - 'anything-dired-copy-file 'dired-do-copy dired-mode-map) + 'helm-dired-copy-file 'dired-do-copy dired-mode-map) (substitute-key-definition - 'anything-dired-rename-file 'dired-do-rename dired-mode-map) + 'helm-dired-rename-file 'dired-do-rename dired-mode-map) (substitute-key-definition - 'anything-dired-symlink-file 'dired-do-symlink dired-mode-map) + 'helm-dired-symlink-file 'dired-do-symlink dired-mode-map) (substitute-key-definition - 'anything-dired-hardlink-file 'dired-do-hardlink dired-mode-map))) + 'helm-dired-hardlink-file 'dired-do-hardlink dired-mode-map))) -(defalias 'anything-dired-bindings 'anything-dired-mode) +(defalias 'helm-dired-bindings 'helm-dired-mode) -(defun* anything-c-read-file-name +(defun* helm-c-read-file-name (prompt &key (name "Read File Name") (initial-input (expand-file-name default-directory)) - (buffer "*Anything Completions*") + (buffer "*Helm Completions*") test (preselect nil) (history nil) must-match (marked-candidates nil) (alistp t) - (persistent-action 'anything-find-files-persistent-action) + (persistent-action 'helm-find-files-persistent-action) (persistent-help "Hit1 Expand Candidate, Hit2 or (C-u) Find file")) - "Read a file name with anything completion. -It is anything `read-file-name' emulation. + "Read a file name with helm completion. +It is helm `read-file-name' emulation. Argument PROMPT is the default prompt to use. @@ -5008,11 +4955,11 @@ Keys description: - INITIAL-INPUT: Where to start read file name, default to `default-directory'. -- BUFFER: `anything-buffer' name default to \"*Anything Completions*\". +- BUFFER: `helm-buffer' name default to \"*Helm Completions*\". - TEST: A predicate called with one arg 'candidate'. -- PRESELECT: anything preselection. +- PRESELECT: helm preselection. - HISTORY: Display HISTORY in a special source. @@ -5025,8 +4972,8 @@ Keys description: - PERSISTENT-ACTION: a persistent action function. - PERSISTENT-HELP: persistent help message." - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) ;; Assume completion have been already required, ;; so always use 'confirm. @@ -5035,61 +4982,63 @@ Keys description: (flet ((action-fn (candidate) (if marked-candidates - (anything-marked-candidates) + (helm-marked-candidates) (identity candidate)))) - (let* ((anything-mp-highlight-delay nil) + (let* ((helm-mp-highlight-delay nil) ;; Be sure we don't erase the underlying minibuffer if some. - (anything-ff-auto-update-initial-value - (and anything-ff-auto-update-initial-value + (helm-ff-auto-update-initial-value + (and helm-ff-auto-update-initial-value (not (minibuffer-window-active-p (minibuffer-window))))) - anything-same-window - (hist (and history (anything-comp-read-get-candidates + helm-same-window + (hist (and history (helm-comp-read-get-candidates history nil nil alistp))) (minibuffer-completion-confirm must-match) (must-match-map (when must-match (let ((map (make-sparse-keymap))) (define-key map (kbd "RET") - 'anything-confirm-and-exit-minibuffer) + 'helm-confirm-and-exit-minibuffer) map))) - (anything-map (if must-match-map + (helm-map (if must-match-map (make-composed-keymap - must-match-map anything-c-read-file-map) - anything-c-read-file-map))) + must-match-map helm-c-read-file-map) + helm-c-read-file-map))) - (or (anything + (or (helm :sources `(((name . ,(format "%s History" name)) (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) (disable-shortcuts) - (mode-line . anything-read-file-name-mode-line-string) + (mode-line . helm-read-file-name-mode-line-string) (candidates . hist) (persistent-action . ,persistent-action) (persistent-help . ,persistent-help) (action . ,'action-fn)) ((name . ,name) (header-name . (lambda (name) - (concat name anything-c-find-files-doc-header))) + (concat name helm-c-find-files-doc-header))) (init . (lambda () - (setq anything-ff-auto-update-flag - anything-ff-auto-update-initial-value))) + (setq helm-ff-auto-update-flag + helm-ff-auto-update-initial-value))) ;; It is needed for filenames with capital letters (disable-shortcuts) - (mode-line . anything-read-file-name-mode-line-string) + (mode-line . helm-read-file-name-mode-line-string) (candidates . (lambda () (if test - (loop with hn = (anything-ff-tramp-hostnames) - for i in (anything-find-files-get-candidates + (loop with hn = (helm-ff-tramp-hostnames) + for i in (helm-find-files-get-candidates must-match) - when (or (member i hn) (funcall test i)) + when (or (member i hn) ; A tramp host + (funcall test i) ; Test ok + (not (file-exists-p i))) ; A new file. collect i) - (anything-find-files-get-candidates must-match)))) - (filtered-candidate-transformer anything-c-find-files-transformer) + (helm-find-files-get-candidates must-match)))) + (filtered-candidate-transformer helm-c-find-files-transformer) (persistent-action . ,persistent-action) (candidate-number-limit . 9999) - (toggle-auto-update . anything-ff-toggle-auto-update) + (toggle-auto-update . helm-ff-toggle-auto-update) (persistent-help . ,persistent-help) (volatile) (action . ,'action-fn))) @@ -5098,37 +5047,37 @@ Keys description: :resume 'noresume :buffer buffer :preselect preselect) - (when (and (not (string= anything-pattern "")) - (eq anything-exit-status 0) + (when (and (not (string= helm-pattern "")) + (eq helm-exit-status 0) (eq must-match 'confirm)) - (identity anything-pattern)) + (identity helm-pattern)) (keyboard-quit))))) ;;; File Cache -(defvar anything-c-file-cache-initialized-p nil) +(defvar helm-c-file-cache-initialized-p nil) -(defvar anything-c-file-cache-files nil) +(defvar helm-c-file-cache-files nil) -(defvar anything-c-source-file-cache +(defvar helm-c-source-file-cache `((name . "File Cache") (init . (lambda () (require 'filecache nil t) - (unless anything-c-file-cache-initialized-p - (setq anything-c-file-cache-files + (unless helm-c-file-cache-initialized-p + (setq helm-c-file-cache-files (loop for item in file-cache-alist append (destructuring-bind (base &rest dirs) item (loop for dir in dirs collect (concat dir base))))) (defadvice file-cache-add-file (after file-cache-list activate) - (add-to-list 'anything-c-file-cache-files (expand-file-name file))) - (setq anything-c-file-cache-initialized-p t)))) - (keymap . ,anything-generic-files-map) - (help-message . anything-generic-file-help-message) - (mode-line . anything-generic-file-mode-line-string) - (candidates . anything-c-file-cache-files) - (match anything-c-match-on-basename) + (add-to-list 'helm-c-file-cache-files (expand-file-name file))) + (setq helm-c-file-cache-initialized-p t)))) + (keymap . ,helm-generic-files-map) + (help-message . helm-generic-file-help-message) + (mode-line . helm-generic-file-mode-line-string) + (candidates . helm-c-file-cache-files) + (match helm-c-match-on-basename) (type . file))) @@ -5139,67 +5088,67 @@ Keys description: ;; You have to install Everything with his command line interface here: ;; http://www.voidtools.com/download.php -(defun anything-ff-find-locatedb (&optional from-ff) +(defun helm-ff-find-locatedb (&optional from-ff) "Try to find if a local locatedb file is available. -The search is done in `anything-ff-default-directory' or +The search is done in `helm-ff-default-directory' or fall back to `default-directory' if FROM-FF is nil." - (when anything-ff-locate-db-filename - (cond ((and anything-ff-default-directory + (when helm-ff-locate-db-filename + (cond ((and helm-ff-default-directory from-ff (file-exists-p (expand-file-name - anything-ff-locate-db-filename - anything-ff-default-directory)) + helm-ff-locate-db-filename + helm-ff-default-directory)) (expand-file-name - anything-ff-locate-db-filename - anything-ff-default-directory))) + helm-ff-locate-db-filename + helm-ff-default-directory))) ((and (not from-ff) (file-exists-p (expand-file-name - anything-ff-locate-db-filename + helm-ff-locate-db-filename default-directory)) (expand-file-name - anything-ff-locate-db-filename + helm-ff-locate-db-filename default-directory)))))) -(defun anything-locate-1 (&optional localdb init from-ff) +(defun helm-locate-1 (&optional localdb init from-ff) "Generic function to run Locate. if LOCALDB is non--nil search and use a local locate db file. INIT is a string to use as initial input in prompt. -See `anything-locate-with-db' and `anything-locate'." - (anything-locate-with-db +See `helm-locate-with-db' and `helm-locate'." + (helm-locate-with-db (and localdb - (or (anything-ff-find-locatedb from-ff) - (anything-c-read-file-name + (or (helm-ff-find-locatedb from-ff) + (helm-c-read-file-name "LocateDBFiles: " - :initial-input (or anything-ff-default-directory + :initial-input (or helm-ff-default-directory default-directory) :marked-candidates t - :preselect anything-locate-db-file-regexp + :preselect helm-locate-db-file-regexp :test #'(lambda (x) - (if anything-locate-db-file-regexp + (if helm-locate-db-file-regexp ;; Select only locate db files and directories ;; to allow navigation. (or (string-match - anything-locate-db-file-regexp x) + helm-locate-db-file-regexp x) (file-directory-p x)) x))))) init)) -;; (anything-locate-1 t) +;; (helm-locate-1 t) -(defun anything-locate-with-db (&optional db initial-input) +(defun helm-locate-with-db (&optional db initial-input) "Run locate -d DB. If DB is not given or nil use locate without -d option. Argument DB can be given as a string or list of db files. Argument INITIAL-INPUT is a string to use as initial-input. -See also `anything-locate'." +See also `helm-locate'." (when (and db (stringp db)) (setq db (list db))) - (unless anything-c-locate-command - (setq anything-c-locate-command + (unless helm-c-locate-command + (setq helm-c-locate-command (case system-type ('gnu/linux "locate -i -r %s") ('berkeley-unix "locate -i %s") ('windows-nt "es -i -r %s") (t "locate %s")))) - (let ((anything-c-locate-command + (let ((helm-c-locate-command (if db (replace-regexp-in-string "locate" @@ -5210,16 +5159,16 @@ See also `anything-locate'." (loop for i in db unless (file-directory-p i) collect i) ":")) - anything-c-locate-command) - anything-c-locate-command))) - (anything :sources 'anything-c-source-locate - :buffer "*anything locate*" + helm-c-locate-command) + helm-c-locate-command))) + (helm :sources 'helm-c-source-locate + :buffer "*helm locate*" :input initial-input - :keymap anything-generic-files-map))) -;; (anything-locate-with-db "~/locate.db") + :keymap helm-generic-files-map))) +;; (helm-locate-with-db "~/locate.db") -(defun anything-c-locate-init () - "Initialize async locate process for `anything-c-source-locate'." +(defun helm-c-locate-init () + "Initialize async locate process for `helm-c-source-locate'." (setq mode-line-format '(" " mode-line-buffer-identification " " (line-number-mode "%l") " " @@ -5227,93 +5176,93 @@ See also `anything-locate'." 'face '((:foreground "red")))))) (prog1 (start-process-shell-command "locate-process" nil - (format anything-c-locate-command - anything-pattern)) + (format helm-c-locate-command + helm-pattern)) (set-process-sentinel (get-process "locate-process") #'(lambda (process event) (when (string= event "finished\n") - (with-anything-window + (with-helm-window (force-mode-line-update nil) - (anything-update-move-first-line))))))) + (helm-update-move-first-line))))))) -(defvar anything-c-source-locate +(defvar helm-c-source-locate `((name . "Locate") - (candidates . anything-c-locate-init) + (candidates . helm-c-locate-init) (type . file) (requires-pattern . 3) - (keymap . ,anything-generic-files-map) - (help-message . anything-generic-file-help-message) + (keymap . ,helm-generic-files-map) + (help-message . helm-generic-file-help-message) (candidate-number-limit . 9999) - (mode-line . anything-generic-file-mode-line-string) + (mode-line . helm-generic-file-mode-line-string) (delayed)) "Find files matching the current input pattern with locate.") -(defun anything-c-locate-read-file-name (prompt &optional init) +(defun helm-c-locate-read-file-name (prompt &optional init) "Search a file with locate and return it's filename. -Use argument PROMPT and INIT for `anything' arguments +Use argument PROMPT and INIT for `helm' arguments prompt and input." - (anything :sources + (helm :sources '((name . "Locate") - (candidates . anything-c-locate-init) + (candidates . helm-c-locate-init) (action . identity) (requires-pattern . 3) (candidate-number-limit . 9999) - (mode-line . anything-generic-file-mode-line-string) + (mode-line . helm-generic-file-mode-line-string) (delayed)) :prompt prompt :input init - :buffer "*anything locate rfn*")) + :buffer "*helm locate rfn*")) -;;; Anything Incremental Grep. +;;; Helm Incremental Grep. ;; ;; -;; Allow to grep incrementally with anything interface. +;; Allow to grep incrementally with helm interface. ;; It allow also to Grep files recursively without using 'find' shell command. ;; On Windows you will need at least Grep version 2.5.4 of Gnuwin32. -(defvar anything-c-grep-default-command +(defvar helm-c-grep-default-command "grep -d skip %e -niH -e %p %f" - "Default grep format command for `anything-do-grep-1'. + "Default grep format command for `helm-do-grep-1'. Where: '%e' format spec is for --exclude or --include grep options. '%p' format spec is for pattern. '%f' format spec is for filenames.") -(defvar anything-c-grep-default-recurse-command +(defvar helm-c-grep-default-recurse-command "grep -d recurse %e -niH -e %p %f" - "Default recursive grep format command for `anything-do-grep-1'. -See `anything-c-grep-default-command' for format specs.") + "Default recursive grep format command for `helm-do-grep-1'. +See `helm-c-grep-default-command' for format specs.") -(defvar anything-c-default-zgrep-command "zgrep -niH -e %p %f") +(defvar helm-c-default-zgrep-command "zgrep -niH -e %p %f") -(defvar anything-c-rzgrep-cache (make-hash-table :test 'equal)) +(defvar helm-c-rzgrep-cache (make-hash-table :test 'equal)) -(defvar anything-c-grep-default-function 'anything-c-grep-init) +(defvar helm-c-grep-default-function 'helm-c-grep-init) -(defvar anything-c-grep-debug-command-line nil - "Turn on anything grep command-line debugging when non--nil.") +(defvar helm-c-grep-debug-command-line nil + "Turn on helm grep command-line debugging when non--nil.") -(defvar anything-c-zgrep-recurse-flag nil) +(defvar helm-c-zgrep-recurse-flag nil) -(defvar anything-c-grep-history nil) +(defvar helm-c-grep-history nil) -(defvar anything-c-grep-max-length-history 100 - "*Max number of elements to save in `anything-c-grep-history'.") +(defvar helm-c-grep-max-length-history 100 + "*Max number of elements to save in `helm-c-grep-history'.") -(defun anything-c-grep-prepare-candidates (candidates) +(defun helm-c-grep-prepare-candidates (candidates) "Prepare filenames and directories CANDIDATES for grep command line." ;; If one or more candidate is a directory, search in all files ;; of this candidate (e.g /home/user/directory/*). ;; If r option is enabled search also in subdidrectories. ;; We need here to expand wildcards to support crap windows filenames ;; as grep doesn't accept quoted wildcards (e.g "dir/*.el"). - (if anything-c-zgrep-recurse-flag + (if helm-c-zgrep-recurse-flag (mapconcat 'shell-quote-argument candidates " ") (loop for i in candidates append (cond ( ;; Candidate is a directory and we use recursion. (and (file-directory-p i) - (anything-c-grep-recurse-p)) + (helm-c-grep-recurse-p)) (list (expand-file-name i))) ;; Candidate is a directory, search in all files. ((file-directory-p i) @@ -5322,28 +5271,28 @@ See `anything-c-grep-default-command' for format specs.") ;; Candidate is a file or wildcard and we use recursion, use the ;; current directory instead of candidate. ((and (or (file-exists-p i) (string-match "\*" i)) - (anything-c-grep-recurse-p)) + (helm-c-grep-recurse-p)) (list (expand-file-name (directory-file-name ; Needed for windoze. (file-name-directory (directory-file-name i)))))) ;; Candidate use wildcard. - ((string-match "^\*" (anything-c-basename i)) + ((string-match "^\*" (helm-c-basename i)) (file-expand-wildcards i t)) ;; Else should be one or more file. (t (list i))) into all-files finally return (mapconcat 'shell-quote-argument all-files " ")))) -(defun anything-c-grep-recurse-p () - "Check if `anything-do-grep-1' have switched to recursive." +(defun helm-c-grep-recurse-p () + "Check if `helm-do-grep-1' have switched to recursive." (let ((args (replace-regexp-in-string - "grep" "" anything-c-grep-default-command))) + "grep" "" helm-c-grep-default-command))) (string-match-p "r\\|recurse" args))) -(defun anything-c-grep-init (only-files &optional include zgrep) +(defun helm-c-grep-init (only-files &optional include zgrep) "Start an asynchronous grep process in ONLY-FILES list." - (let* ((fnargs (anything-c-grep-prepare-candidates - (if (file-remote-p anything-ff-default-directory) + (let* ((fnargs (helm-c-grep-prepare-candidates + (if (file-remote-p helm-ff-default-directory) (mapcar #'(lambda (x) (file-remote-p x 'localname)) only-files) @@ -5357,16 +5306,16 @@ See `anything-c-grep-default-command' for format specs.") #'(lambda (x) (concat "--exclude-dir=" (shell-quote-argument x))) grep-find-ignored-directories " ")) - (exclude (if (anything-c-grep-recurse-p) + (exclude (if (helm-c-grep-recurse-p) (concat (or include ignored-files) " " ignored-dirs) ignored-files)) (cmd-line (format-spec - anything-c-grep-default-command + helm-c-grep-default-command (delq nil (list (unless zgrep (cons ?e exclude)) - (cons ?p (shell-quote-argument anything-pattern)) + (cons ?p (shell-quote-argument helm-pattern)) (cons ?f fnargs)))))) - (when anything-c-grep-debug-command-line + (when helm-c-grep-debug-command-line (with-current-buffer (get-buffer-create "*any grep debug*") (goto-char (point-max)) (insert (concat ">>> " cmd-line "\n\n")))) @@ -5375,18 +5324,18 @@ See `anything-c-grep-default-command' for format specs.") (line-number-mode "%l") " " (:eval (when (get-process "grep-process") (propertize "[Grep Process Running] " - 'face 'anything-grep-running))))) + 'face 'helm-grep-running))))) (force-mode-line-update nil) (prog1 - (let ((default-directory anything-ff-default-directory)) + (let ((default-directory helm-ff-default-directory)) (start-file-process-shell-command "grep-process" nil cmd-line)) (message nil) (set-process-sentinel (get-process "grep-process") #'(lambda (process event) (when (string= event "finished\n") - (with-anything-window - (anything-update-move-first-line) + (with-helm-window + (helm-update-move-first-line) (setq mode-line-format '(" " mode-line-buffer-identification " " (line-number-mode "%l") " " @@ -5396,65 +5345,65 @@ See `anything-c-grep-default-command' for format specs.") (point-min) (point-max))))) (if (> nlines 0) nlines 0))) - 'face 'anything-grep-finish)))) + 'face 'helm-grep-finish)))) (force-mode-line-update nil)))))))) -(defun anything-c-grep-action (candidate &optional where mark) - "Define a default action for `anything-do-grep' on CANDIDATE. +(defun helm-c-grep-action (candidate &optional where mark) + "Define a default action for `helm-do-grep' on CANDIDATE. WHERE can be one of other-window, elscreen, other-frame." - (let* ((split (anything-c-grep-split-line candidate)) + (let* ((split (helm-c-grep-split-line candidate)) (lineno (string-to-number (nth 1 split))) (loc-fname (car split)) - (tramp-method (file-remote-p anything-ff-default-directory 'method)) - (tramp-host (file-remote-p anything-ff-default-directory 'host)) + (tramp-method (file-remote-p helm-ff-default-directory 'method)) + (tramp-host (file-remote-p helm-ff-default-directory 'host)) (tramp-prefix (concat "/" tramp-method ":" tramp-host ":")) (fname (if tramp-host (concat tramp-prefix loc-fname) loc-fname))) (case where (other-window (find-file-other-window fname)) - (elscreen (anything-elscreen-find-file fname)) + (elscreen (helm-elscreen-find-file fname)) (other-frame (find-file-other-frame fname)) - (grep (anything-c-grep-save-results-1)) + (grep (helm-c-grep-save-results-1)) (t (find-file fname))) (unless (eq where 'grep) - (anything-goto-line lineno)) + (helm-goto-line lineno)) (when mark (set-marker (mark-marker) (point)) (push-mark (point) 'nomsg)) ;; Save history - (unless (or anything-in-persistent-action - (string= anything-pattern "")) - (setq anything-c-grep-history - (cons anything-pattern - (delete anything-pattern anything-c-grep-history))) - (when (> (length anything-c-grep-history) - anything-c-grep-max-length-history) - (setq anything-c-grep-history - (delete (car (last anything-c-grep-history)) - anything-c-grep-history)))))) + (unless (or helm-in-persistent-action + (string= helm-pattern "")) + (setq helm-c-grep-history + (cons helm-pattern + (delete helm-pattern helm-c-grep-history))) + (when (> (length helm-c-grep-history) + helm-c-grep-max-length-history) + (setq helm-c-grep-history + (delete (car (last helm-c-grep-history)) + helm-c-grep-history)))))) -(defun anything-c-grep-other-window (candidate) - "Jump to result in other window from anything grep." - (anything-c-grep-action candidate 'other-window)) +(defun helm-c-grep-other-window (candidate) + "Jump to result in other window from helm grep." + (helm-c-grep-action candidate 'other-window)) -(defun anything-c-grep-other-frame (candidate) - "Jump to result in other frame from anything grep." - (anything-c-grep-action candidate 'other-frame)) +(defun helm-c-grep-other-frame (candidate) + "Jump to result in other frame from helm grep." + (helm-c-grep-action candidate 'other-frame)) -(defun anything-c-grep-jump-elscreen (candidate) - "Jump to result in elscreen from anything grep." - (anything-c-grep-action candidate 'elscreen)) +(defun helm-c-grep-jump-elscreen (candidate) + "Jump to result in elscreen from helm grep." + (helm-c-grep-action candidate 'elscreen)) -(defun anything-c-grep-save-results (_candidate) - (anything-c-grep-action _candidate 'grep)) +(defun helm-c-grep-save-results (_candidate) + (helm-c-grep-action _candidate 'grep)) -(defun anything-c-grep-save-results-1 () - "Save anything grep result in a `grep-mode' buffer." +(defun helm-c-grep-save-results-1 () + "Save helm grep result in a `grep-mode' buffer." (let ((buf "*grep*") new-buf) (when (get-buffer buf) (setq new-buf (read-string "GrepBufferName: " buf)) - (loop for b in (anything-c-buffer-list) + (loop for b in (helm-c-buffer-list) when (and (string= new-buf b) (not (y-or-n-p (format "Buffer `%s' already exists overwrite? " @@ -5465,23 +5414,23 @@ WHERE can be one of other-window, elscreen, other-frame." (let ((inhibit-read-only t)) (erase-buffer) (insert "-*- mode: grep -*-\n\n" - (format "Grep Results for `%s':\n\n" anything-pattern)) + (format "Grep Results for `%s':\n\n" helm-pattern)) (save-excursion - (insert (with-current-buffer anything-buffer + (insert (with-current-buffer helm-buffer (goto-char (point-min)) (forward-line 1) (buffer-substring (point) (point-max)))) (grep-mode)))) - (message "Anything Grep Results saved in `%s' buffer" buf))) + (message "Helm Grep Results saved in `%s' buffer" buf))) -(defun anything-c-grep-persistent-action (candidate) - "Persistent action for `anything-do-grep'. +(defun helm-c-grep-persistent-action (candidate) + "Persistent action for `helm-do-grep'. With a prefix arg record CANDIDATE in `mark-ring'." (if current-prefix-arg - (anything-c-grep-action candidate nil 'mark) - (anything-c-grep-action candidate)) - (anything-match-line-color-current-line)) + (helm-c-grep-action candidate nil 'mark) + (helm-c-grep-action candidate)) + (helm-match-line-color-current-line)) -(defun anything-c-grep-guess-extensions (files) +(defun helm-c-grep-guess-extensions (files) "Try to guess file extensions in FILES list when using grep recurse. These extensions will be added to command line with --include arg of grep." (loop @@ -5501,31 +5450,31 @@ These extensions will be added to command line with --include arg of grep." collect glob into glob-list finally return glob-list)) -(defun anything-do-grep-1 (only &optional recurse zgrep) +(defun helm-do-grep-1 (only &optional recurse zgrep) "Launch grep with a list of ONLY files. When RECURSE is given use -r option of grep and prompt user to set the --include args of grep. You can give more than one arg separated by space. e.g *.el *.py *.tex. If it's empty --exclude `grep-find-ignored-files' is used instead." - (let* ((anything-compile-source-functions - ;; rule out anything-match-plugin because the input is one regexp. - (delq 'anything-compile-source--match-plugin - (copy-sequence anything-compile-source-functions))) - (exts (anything-c-grep-guess-extensions only)) + (let* ((helm-compile-source-functions + ;; rule out helm-match-plugin because the input is one regexp. + (delq 'helm-compile-source--match-plugin + (copy-sequence helm-compile-source-functions))) + (exts (helm-c-grep-guess-extensions only)) (globs (and (not zgrep) (mapconcat 'identity exts " "))) (include-files (and recurse (not zgrep) (read-string "OnlyExt(*.[ext]): " globs))) ;; Set `minibuffer-history' AFTER includes-files ;; to avoid storing wild-cards here. - (minibuffer-history anything-c-grep-history) - (anything-c-grep-default-command (cond ((and recurse zgrep) anything-c-default-zgrep-command) - (recurse anything-c-grep-default-recurse-command) - (zgrep anything-c-default-zgrep-command) - (t anything-c-grep-default-command))) + (minibuffer-history helm-c-grep-history) + (helm-c-grep-default-command (cond ((and recurse zgrep) helm-c-default-zgrep-command) + (recurse helm-c-grep-default-recurse-command) + (zgrep helm-c-default-zgrep-command) + (t helm-c-grep-default-command))) ;; Disable match-plugin and use here own highlighting. - (anything-mp-highlight-delay nil)) + (helm-mp-highlight-delay nil)) (when include-files (setq include-files (and (not (string= include-files "")) @@ -5534,59 +5483,59 @@ If it's empty --exclude `grep-find-ignored-files' is used instead." (split-string include-files) " ")))) ;; When called as action from an other source e.g *-find-files ;; we have to kill action buffer. - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) - ;; `anything-find-files' haven't already started, - ;; give a default value to `anything-ff-default-directory'. - (setq anything-ff-default-directory (or anything-ff-default-directory + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + ;; `helm-find-files' haven't already started, + ;; give a default value to `helm-ff-default-directory'. + (setq helm-ff-default-directory (or helm-ff-default-directory default-directory)) - (anything + (helm :sources `(((name . "Grep") (header-name . (lambda (name) (concat name "(C-c ? Help)"))) (candidates . (lambda () - (funcall anything-c-grep-default-function only include-files zgrep))) - (filtered-candidate-transformer anything-c-grep-cand-transformer) + (funcall helm-c-grep-default-function only include-files zgrep))) + (filtered-candidate-transformer helm-c-grep-cand-transformer) (candidate-number-limit . 9999) - (mode-line . anything-grep-mode-line-string) - (keymap . ,anything-c-grep-map) + (mode-line . helm-grep-mode-line-string) + (keymap . ,helm-c-grep-map) (action . ,(delq nil - `(("Find File" . anything-c-grep-action) - ("Find file other frame" . anything-c-grep-other-frame) + `(("Find File" . helm-c-grep-action) + ("Find file other frame" . helm-c-grep-other-frame) ,(and (locate-library "elscreen") '("Find file in Elscreen" - . anything-c-grep-jump-elscreen)) - ("Save results in grep buffer" . anything-c-grep-save-results) - ("Find file other window" . anything-c-grep-other-window)))) - (persistent-action . anything-c-grep-persistent-action) + . helm-c-grep-jump-elscreen)) + ("Save results in grep buffer" . helm-c-grep-save-results) + ("Find file other window" . helm-c-grep-other-window)))) + (persistent-action . helm-c-grep-persistent-action) (persistent-help . "Jump to line (`C-u' Record in mark ring)") (requires-pattern . 3) (delayed))) - :buffer "*anything grep*"))) + :buffer "*helm grep*"))) -(defun anything-ff-zgrep-1 (flist recursive) +(defun helm-ff-zgrep-1 (flist recursive) (unwind-protect - (let* ((def-dir (or anything-ff-default-directory + (let* ((def-dir (or helm-ff-default-directory default-directory)) (only (if recursive - (or (gethash def-dir anything-c-rzgrep-cache) + (or (gethash def-dir helm-c-rzgrep-cache) (puthash def-dir - (anything-c-walk-directory + (helm-c-walk-directory def-dir :directories nil :path 'full :match ".*\\(\.gz\\|\.bz\\|\.xz\\|\.lzma\\)$") - anything-c-rzgrep-cache)) + helm-c-rzgrep-cache)) flist))) - (when recursive (setq anything-c-zgrep-recurse-flag t)) - (anything-do-grep-1 only recursive 'zgrep)) - (setq anything-c-zgrep-recurse-flag nil))) + (when recursive (setq helm-c-zgrep-recurse-flag t)) + (helm-do-grep-1 only recursive 'zgrep)) + (setq helm-c-zgrep-recurse-flag nil))) -(defun anything-c-grep-split-line (line) +(defun helm-c-grep-split-line (line) "Split a grep output line." (let (beg fname lineno str) ;; Don't print until grep line is valid. @@ -5604,41 +5553,41 @@ If it's empty --exclude `grep-find-ignored-files' is used instead." (setq str (buffer-substring-no-properties (point) (point-at-eol)))) (list fname lineno str)))) -(defun anything-c-grep-cand-transformer (candidates sources) - "Filtered candidate transformer function for `anything-do-grep'." +(defun helm-c-grep-cand-transformer (candidates sources) + "Filtered candidate transformer function for `helm-do-grep'." (loop for i in candidates - for split = (and i (anything-c-grep-split-line i)) + for split = (and i (helm-c-grep-split-line i)) for fname = (car split) for lineno = (nth 1 split) for str = (nth 2 split) when (and fname lineno str) collect (cons (concat (propertize (file-name-nondirectory fname) - 'face 'anything-grep-file + 'face 'helm-grep-file 'help-echo fname) ":" - (propertize lineno 'face 'anything-grep-lineno) ":" - (anything-c-grep-highlight-match str)) + (propertize lineno 'face 'helm-grep-lineno) ":" + (helm-c-grep-highlight-match str)) i))) -(defun anything-c-grep-highlight-match (str) - "Highlight in string STR all occurences matching `anything-pattern'." +(defun helm-c-grep-highlight-match (str) + "Highlight in string STR all occurences matching `helm-pattern'." (condition-case nil (with-temp-buffer (insert str) (goto-char (point-min)) - (while (and (re-search-forward anything-pattern nil t) + (while (and (re-search-forward helm-pattern nil t) (> (- (match-end 0) (match-beginning 0)) 0)) (add-text-properties (match-beginning 0) (match-end 0) - '(face anything-grep-match))) + '(face helm-grep-match))) (buffer-string)) (error nil))) ;; Go to next or precedent file (common to etags and grep). -(defun anything-c-goto-next-or-prec-file (n) - "Go to next or precedent candidate file in anything grep/etags buffers. +(defun helm-c-goto-next-or-prec-file (n) + "Go to next or precedent candidate file in helm grep/etags buffers. If N is positive go forward otherwise go backward." - (with-anything-window + (with-helm-window (let* ((current-line-list (split-string (buffer-substring (point-at-bol) @@ -5649,65 +5598,65 @@ If N is positive go forward otherwise go backward." (while (not (funcall fn-b-o-f)) (forward-line n) ; Go forward or backward depending of n value. (unless (search-forward current-fname (point-at-eol) t) - (anything-mark-current-line) + (helm-mark-current-line) (throw 'break nil)))) (cond ((and (eq n 1) (eobp)) (re-search-backward ".") (forward-line 0) - (anything-mark-current-line)) + (helm-mark-current-line)) ((and (< n 1) (bobp)) (forward-line 1) - (anything-mark-current-line)))))) + (helm-mark-current-line)))))) ;;;###autoload -(defun anything-c-goto-precedent-file () - "Go to precedent file in anything grep/etags buffers." +(defun helm-c-goto-precedent-file () + "Go to precedent file in helm grep/etags buffers." (interactive) - (anything-c-goto-next-or-prec-file -1)) + (helm-c-goto-next-or-prec-file -1)) ;;;###autoload -(defun anything-c-goto-next-file () - "Go to precedent file in anything grep/etags buffers." +(defun helm-c-goto-next-file () + "Go to precedent file in helm grep/etags buffers." (interactive) - (anything-c-goto-next-or-prec-file 1)) + (helm-c-goto-next-or-prec-file 1)) ;;;###autoload -(defun anything-c-grep-run-persistent-action () - "Run grep persistent action from `anything-do-grep-1'." +(defun helm-c-grep-run-persistent-action () + "Run grep persistent action from `helm-do-grep-1'." (interactive) - (anything-attrset 'jump-persistent 'anything-c-grep-persistent-action) - (anything-execute-persistent-action 'jump-persistent)) + (helm-attrset 'jump-persistent 'helm-c-grep-persistent-action) + (helm-execute-persistent-action 'jump-persistent)) ;;;###autoload -(defun anything-c-grep-run-default-action () - "Run grep default action from `anything-do-grep-1'." +(defun helm-c-grep-run-default-action () + "Run grep default action from `helm-do-grep-1'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-grep-action)) + (helm-c-quit-and-execute-action 'helm-c-grep-action)) ;;;###autoload -(defun anything-c-grep-run-other-window-action () - "Run grep goto other window action from `anything-do-grep-1'." +(defun helm-c-grep-run-other-window-action () + "Run grep goto other window action from `helm-do-grep-1'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-grep-other-window)) + (helm-c-quit-and-execute-action 'helm-c-grep-other-window)) ;;;###autoload -(defun anything-c-grep-run-save-buffer () - "Run grep save results action from `anything-do-grep-1'." +(defun helm-c-grep-run-save-buffer () + "Run grep save results action from `helm-do-grep-1'." (interactive) - (anything-c-quit-and-execute-action 'anything-c-grep-save-results)) + (helm-c-quit-and-execute-action 'helm-c-grep-save-results)) ;; Grep buffers -(defun anything-c-grep-buffers-1 (candidate &optional zgrep) +(defun helm-c-grep-buffers-1 (candidate &optional zgrep) "Run grep on all file--buffers or CANDIDATE if it is a file--buffer. If one of selected buffers is not a file--buffer, it is ignored and grep will run on all others file--buffers. If only one candidate is selected and it is not a file--buffer, -switch to this buffer and run `anything-occur'. +switch to this buffer and run `helm-occur'. If a prefix arg is given run grep on all buffers ignoring non--file-buffers." - (let* ((prefarg (or current-prefix-arg anything-current-prefix-arg)) + (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) (cands (if prefarg (buffer-list) - (anything-marked-candidates))) + (helm-marked-candidates))) (win-conf (current-window-configuration)) ;; Non--fname buffers are ignored. (bufs (loop for buf in cands @@ -5716,46 +5665,46 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers." collect (expand-file-name fname)))) (if bufs (if zgrep - (anything-do-grep-1 bufs nil 'zgrep) - (anything-do-grep-1 bufs)) + (helm-do-grep-1 bufs nil 'zgrep) + (helm-do-grep-1 bufs)) ;; bufs is empty, thats mean we have only CANDIDATE ;; and it is not a buffer-filename, fallback to occur. - (anything-c-switch-to-buffer candidate) - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) - (anything-occur) - (when (eq anything-exit-status 1) + (helm-c-switch-to-buffer candidate) + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (helm-occur) + (when (eq helm-exit-status 1) (set-window-configuration win-conf))))) -(defun anything-c-grep-buffers (candidate) +(defun helm-c-grep-buffers (candidate) "Action to grep buffers." - (anything-c-grep-buffers-1 candidate)) + (helm-c-grep-buffers-1 candidate)) -(defun anything-c-zgrep-buffers (candidate) +(defun helm-c-zgrep-buffers (candidate) "Action to zgrep buffers." - (anything-c-grep-buffers-1 candidate 'zgrep)) + (helm-c-grep-buffers-1 candidate 'zgrep)) -;;; Anything interface for pdfgrep +;;; Helm interface for pdfgrep ;; pdfgrep program ;; and a pdf-reader (e.g xpdf) are needed. ;; -(defvar anything-c-pdfgrep-default-command "pdfgrep --color never -niH %s %s") -(defvar anything-c-pdfgrep-default-function 'anything-c-pdfgrep-init) -(defvar anything-c-pdfgrep-debug-command-line nil) +(defvar helm-c-pdfgrep-default-command "pdfgrep --color never -niH %s %s") +(defvar helm-c-pdfgrep-default-function 'helm-c-pdfgrep-init) +(defvar helm-c-pdfgrep-debug-command-line nil) -(defun anything-c-pdfgrep-init (only-files) +(defun helm-c-pdfgrep-init (only-files) "Start an asynchronous pdfgrep process in ONLY-FILES list." - (let* ((fnargs (anything-c-grep-prepare-candidates - (if (file-remote-p anything-ff-default-directory) + (let* ((fnargs (helm-c-grep-prepare-candidates + (if (file-remote-p helm-ff-default-directory) (mapcar #'(lambda (x) (file-remote-p x 'localname)) only-files) only-files))) - (cmd-line (format anything-c-pdfgrep-default-command - anything-pattern + (cmd-line (format helm-c-pdfgrep-default-command + helm-pattern fnargs))) - (when anything-c-pdfgrep-debug-command-line + (when helm-c-pdfgrep-debug-command-line (with-current-buffer (get-buffer-create "*any pdfgrep debug*") (goto-char (point-max)) (insert (concat ">>> " cmd-line "\n\n")))) @@ -5765,60 +5714,60 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers." (:eval (propertize "(Pdfgrep Process Running) " 'face '((:foreground "red")))))) (prog1 - (let ((default-directory anything-ff-default-directory)) + (let ((default-directory helm-ff-default-directory)) (start-file-process-shell-command "pdfgrep-process" nil cmd-line)) (message nil) (set-process-sentinel (get-process "pdfgrep-process") #'(lambda (process event) (when (string= event "finished\n") - (with-anything-window - (anything-update-move-first-line)) + (with-helm-window + (helm-update-move-first-line)) (force-mode-line-update nil))))))) -(defun anything-do-pdfgrep-1 (only) +(defun helm-do-pdfgrep-1 (only) "Launch pdfgrep with a list of ONLY files." (unless (executable-find "pdfgrep") (error "Error: No such program `pdfgrep'.")) - (let* ((anything-compile-source-functions - ;; rule out anything-match-plugin because the input is one regexp. - (delq 'anything-compile-source--match-plugin - (copy-sequence anything-compile-source-functions))) + (let* ((helm-compile-source-functions + ;; rule out helm-match-plugin because the input is one regexp. + (delq 'helm-compile-source--match-plugin + (copy-sequence helm-compile-source-functions))) ;; Disable match-plugin and use here own highlighting. - (anything-mp-highlight-delay nil)) + (helm-mp-highlight-delay nil)) ;; When called as action from an other source e.g *-find-files ;; we have to kill action buffer. - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) - ;; If `anything-find-files' haven't already started, - ;; give a default value to `anything-ff-default-directory'. - (setq anything-ff-default-directory (or anything-ff-default-directory + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + ;; If `helm-find-files' haven't already started, + ;; give a default value to `helm-ff-default-directory'. + (setq helm-ff-default-directory (or helm-ff-default-directory default-directory)) - (anything + (helm :sources `(((name . "PdfGrep") (candidates . (lambda () - (funcall anything-c-pdfgrep-default-function only))) - (filtered-candidate-transformer anything-c-grep-cand-transformer) + (funcall helm-c-pdfgrep-default-function only))) + (filtered-candidate-transformer helm-c-grep-cand-transformer) (candidate-number-limit . 9999) - (mode-line . anything-pdfgrep-mode-line-string) - (action . anything-c-pdfgrep-action) + (mode-line . helm-pdfgrep-mode-line-string) + (action . helm-c-pdfgrep-action) (persistent-help . "Jump to PDF Page") (requires-pattern . 3) (delayed))) - :keymap anything-c-pdfgrep-map - :buffer "*anything grep*"))) + :keymap helm-c-pdfgrep-map + :buffer "*helm grep*"))) -(defun anything-c-pdfgrep-action (candidate) - (let* ((split (anything-c-grep-split-line candidate)) +(defun helm-c-pdfgrep-action (candidate) + (let* ((split (helm-c-grep-split-line candidate)) (pageno (nth 1 split)) (fname (car split))) (start-file-process-shell-command "pdf-reader" nil - (format-spec anything-c-pdfgrep-default-read-command + (format-spec helm-c-pdfgrep-default-read-command (list (cons ?f fname) (cons ?p pageno)))))) @@ -5826,39 +5775,39 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers." ;; ;; ;; Internal -(defvar anything-yank-point nil) +(defvar helm-yank-point nil) ;;;###autoload -(defun anything-yank-text-at-point () +(defun helm-yank-text-at-point () "Yank text at point in minibuffer." (interactive) (let (input) (flet ((insert-in-minibuffer (word) (with-selected-window (minibuffer-window) - (let ((str anything-pattern)) + (let ((str helm-pattern)) (delete-minibuffer-contents) (set-text-properties 0 (length word) nil word) (insert (concat str word)))))) - (with-anything-current-buffer + (with-helm-current-buffer ;; Start to initial point if C-w have never been hit. - (unless anything-yank-point (setq anything-yank-point (point))) - (and anything-yank-point (goto-char anything-yank-point)) + (unless helm-yank-point (setq helm-yank-point (point))) + (and helm-yank-point (goto-char helm-yank-point)) (forward-word 1) - (setq input (buffer-substring-no-properties anything-yank-point (point))) - (setq anything-yank-point (point))) ; End of last forward-word + (setq input (buffer-substring-no-properties helm-yank-point (point))) + (setq helm-yank-point (point))) ; End of last forward-word (insert-in-minibuffer input)))) -(defun anything-reset-yank-point () - (setq anything-yank-point nil)) +(defun helm-reset-yank-point () + (setq helm-yank-point nil)) -(add-hook 'anything-after-persistent-action-hook 'anything-reset-yank-point) -(add-hook 'anything-cleanup-hook 'anything-reset-yank-point) +(add-hook 'helm-after-persistent-action-hook 'helm-reset-yank-point) +(add-hook 'helm-cleanup-hook 'helm-reset-yank-point) ;;; Recentf files ;; ;; -(defvar anything-c-source-recentf +(defvar helm-c-source-recentf `((name . "Recentf") (init . (lambda () (require 'recentf) @@ -5866,68 +5815,68 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers." ;; Needed for filenames with capitals letters. (disable-shortcuts) (candidates . recentf-list) - (keymap . ,anything-generic-files-map) - (help-message . anything-generic-file-help-message) - (mode-line . anything-generic-file-mode-line-string) - (match anything-c-match-on-basename) + (keymap . ,helm-generic-files-map) + (help-message . helm-generic-file-help-message) + (mode-line . helm-generic-file-mode-line-string) + (match helm-c-match-on-basename) (type . file)) "See (info \"(emacs)File Conveniences\"). Set `recentf-max-saved-items' to a bigger value if default is too small.") ;;; ffap (eval-when-compile (require 'ffap)) -(defvar anything-c-source-ffap-guesser +(defvar helm-c-source-ffap-guesser `((name . "File at point") (init . (lambda () (require 'ffap))) (candidates . (lambda () - (anything-aif - (with-anything-current-buffer + (helm-aif + (with-helm-current-buffer (ffap-guesser)) (list it)))) - (keymap . ,anything-generic-files-map) - (help-message . anything-generic-file-help-message) - (mode-line . anything-generic-file-mode-line-string) + (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 anything-c-ffap-file-line-at-point () +(defun helm-c-ffap-file-line-at-point () "Get (FILENAME . LINENO) at point." - (anything-aif (let (ffap-alist) (ffap-file-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 anything-c-ffap-line-candidates () - (with-anything-current-buffer - (anything-attrset 'ffap-line-location (anything-c-ffap-file-line-at-point))) - (anything-aif (anything-attr 'ffap-line-location) +(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 `anything-c-source-ffap-line'. -(defun anything-c-ffap-line-goto-line () - (when (car (anything-attr 'ffap-line-location)) +;;; 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 (anything-attr 'ffap-line-location)))) - (anything-goto-line (cdr (anything-attr 'ffap-line-location))))) - (anything-attrset 'ffap-line-location nil)))) -(add-hook 'anything-after-action-hook 'anything-c-ffap-line-goto-line) -(add-hook 'anything-after-persistent-action-hook 'anything-c-ffap-line-goto-line) + (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 anything-c-source-ffap-line +(defvar helm-c-source-ffap-line `((name . "File/Lineno at point") (init . (lambda () (require 'ffap))) - (candidates . anything-c-ffap-line-candidates) - (keymap . ,anything-map) + (candidates . helm-c-ffap-line-candidates) + (keymap . ,helm-map) (type . file))) ;;; list of files gleaned from every dired buffer -(defun anything-c-files-in-all-dired-candidates () +(defun helm-c-files-in-all-dired-candidates () (save-excursion (mapcan (lambda (dir) @@ -5947,32 +5896,23 @@ Set `recentf-max-saved-items' to a bigger value if default is too small.") (buffer-list)))))) ;; (dired '("~/" "~/.emacs-custom.el" "~/.emacs.bmk")) -(defvar anything-c-source-files-in-all-dired +(defvar helm-c-source-files-in-all-dired '((name . "Files in all dired buffer.") - (candidates . anything-c-files-in-all-dired-candidates) + (candidates . helm-c-files-in-all-dired-candidates) (type . file))) -(defvar anything-c-source-filelist - '((name . "FileList") - (grep-candidates . anything-c-filelist-file-name) - (candidate-number-limit . 200) - (requires-pattern . 4) - (type . file)) - "Source to find files instantly. -See `anything-c-filelist-file-name' docstring for usage.") - ;;;; ;;; Info pages -(defvar anything-c-info-pages nil +(defvar helm-c-info-pages nil "All info pages on system. -Will be calculated the first time you invoke anything with this +Will be calculated the first time you invoke helm with this source.") -(defun anything-c-info-pages-init () +(defun helm-c-info-pages-init () "Collect candidates for initial Info node Top." - (if anything-c-info-pages - anything-c-info-pages + (if helm-c-info-pages + helm-c-info-pages (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.") topics) (require 'info) @@ -5982,12 +5922,12 @@ source.") (while (re-search-forward info-topic-regexp nil t) (push (match-string-no-properties 1) topics)) (kill-buffer)) - (setq anything-c-info-pages topics)))) + (setq helm-c-info-pages topics)))) -(defvar anything-c-source-info-pages +(defvar helm-c-source-info-pages `((name . "Info Pages") - (init . anything-c-info-pages-init) - (candidates . anything-c-info-pages) + (init . helm-c-info-pages-init) + (candidates . helm-c-info-pages) (action . (("Show with Info" .(lambda (node-str) (info (replace-regexp-in-string "^[^:]+: " "" node-str)))))) @@ -5997,18 +5937,18 @@ source.") ;;; Man and woman UI ;; ;; -(defvar anything-c-man-pages nil +(defvar helm-c-man-pages nil "All man pages on system. -Will be calculated the first time you invoke anything with this +Will be calculated the first time you invoke helm with this source.") -(defun anything-c-man-default-action (candidate) - "Default action for jumping to a woman or man page from anything." +(defun helm-c-man-default-action (candidate) + "Default action for jumping to a woman or man page from helm." (let ((wfiles (woman-file-name-all-completions candidate))) (condition-case err (if (> (length wfiles) 1) (woman-find-file - (anything-comp-read + (helm-comp-read "ManFile: " wfiles :must-match t)) (woman candidate)) ;; If woman is unable to format correctly @@ -6017,19 +5957,19 @@ source.") (let ((Man-notify-method 'meek)) (Man-getpage-in-background candidate)))))) -(defvar anything-c-source-man-pages +(defvar helm-c-source-man-pages `((name . "Manual Pages") (candidates . (lambda () - (if anything-c-man-pages - anything-c-man-pages + (if helm-c-man-pages + helm-c-man-pages ;; XEmacs doesn't have a woman :) - (setq anything-c-man-pages + (setq helm-c-man-pages (ignore-errors (require 'woman) (woman-file-name "") (sort (mapcar 'car woman-topic-all-completions) 'string-lessp)))))) - (action ("Show with Woman" . anything-c-man-default-action)) + (action ("Show with Woman" . helm-c-man-default-action)) ;; Woman does not work OS X ;; http://xahlee.org/emacs/modernization_man_page.html (action-transformer . (lambda (actions candidate) @@ -6040,26 +5980,26 @@ source.") ;;;; -;;; Anything M-x - Enhanced M-x UI +;;; Helm M-x - Enhanced M-x UI ;; ;; ;; Another replacement of `M-x' that act exactly like the ;; vanilla Emacs one, no problem of windows configuration, prefix args ;; can be passed before calling `M-x' (e.g C-u M-x..) but also during -;; anything invocation. +;; helm invocation. ;; Documentation of commands available without quitting, ;; Show keybindings of commands. ;; Show history. -(defvar anything-M-x-input-history nil) +(defvar helm-M-x-input-history nil) -(defun* anything-M-x-get-major-mode-command-alist (mode-map) +(defun* helm-M-x-get-major-mode-command-alist (mode-map) "Return alist of MODE-MAP." (loop for key being the key-seqs of mode-map using (key-bindings com) for str-key = (key-description key) for ismenu = (string-match "" str-key) unless ismenu collect (cons str-key com))) -(defun anything-get-mode-map-from-mode (mode) +(defun helm-get-mode-map-from-mode (mode) "Guess the mode-map name according to MODE. Some modes don't use conventional mode-map name so we need to guess mode-map name. e.g python-mode ==> py-mode-map. @@ -6077,18 +6017,18 @@ Return nil if no mode-map found." do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode")))) finally return mode-map)) -(defun anything-M-x-current-mode-map-alist () +(defun helm-M-x-current-mode-map-alist () "Return mode-map alist of current `major-mode'." - (let ((map (anything-get-mode-map-from-mode major-mode))) + (let ((map (helm-get-mode-map-from-mode major-mode))) (when (and map (boundp map)) - (anything-M-x-get-major-mode-command-alist (symbol-value map))))) + (helm-M-x-get-major-mode-command-alist (symbol-value map))))) -(defun anything-M-x-transformer (candidates sources) +(defun helm-M-x-transformer (candidates sources) "filtered-candidate-transformer to show bindings in emacs commands. Show global bindings and local bindings according to current `major-mode'." - (with-anything-current-buffer - (loop with local-map = (anything-M-x-current-mode-map-alist) + (with-helm-current-buffer + (loop with local-map = (helm-M-x-current-mode-map-alist) for cand in candidates for local-key = (car (rassq cand local-map)) for key = (substitute-command-keys (format "\\[%s]" cand)) @@ -6097,12 +6037,12 @@ Show global bindings and local bindings according to current `major-mode'." (format "%s (%s)" cand (propertize local-key - 'face 'anything-M-x-key-face))) + 'face 'helm-M-x-key-face))) ((string-match "^M-x" key) cand) (t (format "%s (%s)" cand (propertize key - 'face 'anything-M-x-key-face)))) + 'face 'helm-M-x-key-face)))) cand) into ls finally return (sort ls #'(lambda (x y) (string-lessp (car x) (car y))))))) @@ -6111,25 +6051,25 @@ Show global bindings and local bindings according to current `major-mode'." ;;; Complex command history ;; ;; -(defvar anything-c-source-complex-command-history +(defvar helm-c-source-complex-command-history '((name . "Complex Command History") (candidates . (lambda () (mapcar 'prin1-to-string command-history))) (type . sexp))) -;;; M-x history (not related to `anything-M-x') +;;; M-x history (not related to `helm-M-x') ;; ;; -(defvar anything-c-source-extended-command-history +(defvar helm-c-source-extended-command-history '((name . "Emacs Commands History") (candidates . (lambda () - (anything-fast-remove-dups extended-command-history :test 'equal))) + (helm-fast-remove-dups extended-command-history :test 'equal))) (type . command))) ;;; Emacs commands (Basic source for emacs commands) ;; ;; -(defvar anything-c-source-emacs-commands +(defvar helm-c-source-emacs-commands '((name . "Emacs Commands") (candidates . (lambda () (let (commands) @@ -6145,14 +6085,14 @@ A command is a function with interactive spec that can be invoked with `M-x'. To get non-interactive functions listed, use -`anything-c-source-emacs-functions'.") +`helm-c-source-emacs-functions'.") ;;;; ;;; Emacs functions ;; ;; -(defvar anything-c-source-emacs-functions +(defvar helm-c-source-emacs-functions '((name . "Emacs Functions") (candidates . (lambda () (let (commands) @@ -6167,46 +6107,46 @@ To get non-interactive functions listed, use ;;; With abbrev expansion ;;; Similar to my exec-abbrev-cmd.el ;;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el -(defvar anything-c-function-abbrev-regexp nil - "The regexp for `anything-c-source-emacs-functions-with-abbrevs'. -Regexp built from the current `anything-pattern' interpreting it +(defvar helm-c-function-abbrev-regexp nil + "The regexp for `helm-c-source-emacs-functions-with-abbrevs'. +Regexp built from the current `helm-pattern' interpreting it as abbreviation. Only for internal use.") -(defun anything-c-match-function-by-abbrev (candidate) - "Return non-nil if `anything-pattern' is an abbreviation of the function CANDIDATE. +(defun helm-c-match-function-by-abbrev (candidate) + "Return non-nil if `helm-pattern' is an abbreviation of the function CANDIDATE. Abbreviations are made by taking the first character from each word in the function's name, e.g. \"bb\" is an abbrev for -`bury-buffer', \"stb\" is an abbrev for `anything-c-switch-to-buffer'." - (string-match anything-c-function-abbrev-regexp candidate)) +`bury-buffer', \"stb\" is an abbrev for `helm-c-switch-to-buffer'." + (string-match helm-c-function-abbrev-regexp candidate)) -(defvar anything-c-source-emacs-functions-with-abbrevs - (append anything-c-source-emacs-functions - '((match anything-c-match-function-by-abbrev - anything-c-string-match)) +(defvar helm-c-source-emacs-functions-with-abbrevs + (append helm-c-source-emacs-functions + '((match helm-c-match-function-by-abbrev + helm-c-string-match)) '((init . (lambda () - (defadvice anything-update - (before anything-c-update-function-abbrev-regexp activate) - (let ((char-list (append anything-pattern nil)) + (defadvice helm-update + (before helm-c-update-function-abbrev-regexp activate) + (let ((char-list (append helm-pattern nil)) (str "^")) (dolist (c char-list) (setq str (concat str (list c) "[^-]*-"))) (setq str (concat (substring str 0 (1- (length str))) "$")) - (setq anything-c-function-abbrev-regexp str)))))))) + (setq helm-c-function-abbrev-regexp str)))))))) -(defvar anything-c-source-advice +(defvar helm-c-source-advice '((name . "Function Advice") - (candidates . anything-c-advice-candidates) - (action ("Toggle Enable/Disable" . anything-c-advice-toggle)) - (persistent-action . anything-c-advice-persistent-action) + (candidates . helm-c-advice-candidates) + (action ("Toggle Enable/Disable" . helm-c-advice-toggle)) + (persistent-action . helm-c-advice-persistent-action) (multiline) (persistent-help . "Describe function / C-u C-z: Toggle advice"))) -;; (let ((debug-on-signal t))(anything 'anything-c-source-advice)) +;; (let ((debug-on-signal t))(helm 'helm-c-source-advice)) ;; (testadvice) -(defun anything-c-advice-candidates () +(defun helm-c-advice-candidates () (require 'advice) (loop for (fname) in ad-advised-functions for function = (intern fname) @@ -6222,12 +6162,12 @@ word in the function's name, e.g. \"bb\" is an abbrev for (ad-make-single-advice-docstring advice class nil)) (list function class advice)))))) -(defun anything-c-advice-persistent-action (func-class-advice) +(defun helm-c-advice-persistent-action (func-class-advice) (if current-prefix-arg - (anything-c-advice-toggle func-class-advice) + (helm-c-advice-toggle func-class-advice) (describe-function (car func-class-advice)))) -(defun anything-c-advice-toggle (func-class-advice) +(defun helm-c-advice-toggle (func-class-advice) (destructuring-bind (function class advice) func-class-advice (cond ((ad-advice-enabled advice) (ad-advice-set-enabled advice nil) @@ -6236,11 +6176,11 @@ word in the function's name, e.g. \"bb\" is an abbrev for (ad-advice-set-enabled advice t) (message "Enabled"))) (ad-activate function) - (and anything-in-persistent-action - (anything-c-advice-update-current-display-string)))) + (and helm-in-persistent-action + (helm-c-advice-update-current-display-string)))) -(defun anything-c-advice-update-current-display-string () - (anything-edit-current-selection +(defun helm-c-advice-update-current-display-string () + (helm-edit-current-selection (let ((newword (cond ((looking-at "Disabled") "Enabled") ((looking-at "Enabled") "Disabled"))) realvalue) @@ -6253,7 +6193,7 @@ word in the function's name, e.g. \"bb\" is an abbrev for ;;; Emacs variables ;; ;; -(defvar anything-c-source-emacs-variables +(defvar helm-c-source-emacs-variables '((name . "Emacs Variables") (candidates . (lambda () (sort (all-completions "" obarray 'boundp) 'string-lessp))) @@ -6263,12 +6203,12 @@ word in the function's name, e.g. \"bb\" is an abbrev for ;;; LaCarte -(defvar anything-c-source-lacarte +(defvar helm-c-source-lacarte '((name . "Lacarte") (init . (lambda () (require 'lacarte ))) (candidates . (lambda () (delete '(nil) (lacarte-get-overall-menu-item-alist)))) (candidate-number-limit . 9999) - (action . anything-c-call-interactively)) + (action . helm-c-call-interactively)) "Needs lacarte.el. http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el") @@ -6278,12 +6218,12 @@ http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el") ;; ;; ;; Bind some faces for bookmarks. -(defvar anything-c-bookmarks-face1 'anything-ff-directory) -(defvar anything-c-bookmarks-face2 'anything-ff-file) -(defvar anything-c-bookmarks-face3 'anything-bookmarks-su-face) +(defvar helm-c-bookmarks-face1 'helm-ff-directory) +(defvar helm-c-bookmarks-face2 'helm-ff-file) +(defvar helm-c-bookmarks-face3 'helm-bookmarks-su-face) (eval-when-compile (require 'bookmark)) -(defvar anything-c-source-bookmarks +(defvar helm-c-source-bookmarks `((name . "Bookmarks") (init . (lambda () (require 'bookmark))) @@ -6292,7 +6232,7 @@ http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el") "See (info \"(emacs)Bookmarks\").") ;;; bookmark-set -(defvar anything-c-source-bookmark-set +(defvar helm-c-source-bookmark-set '((name . "Set Bookmark") (dummy) (action . bookmark-set)) @@ -6303,21 +6243,21 @@ http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el") ;; http://d.hatena.ne.jp/grandVin/20080911/1221114327 -(defvar anything-c-source-bm +(defvar helm-c-source-bm '((name . "Visible Bookmarks") - (init . anything-c-bm-init) + (init . helm-c-bm-init) (candidates-in-buffer) (type . line)) "Needs bm.el. http://www.nongnu.org/bm/") -(defun anything-c-bm-init () - "Init function for `anything-c-source-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 (anything-candidate-buffer 'global))) + (buf (helm-candidate-buffer 'global))) (dolist (bm (sort* (append (car bookmarks) (cdr bookmarks)) '< :key 'overlay-start)) (let ((start (overlay-start bm)) @@ -6331,36 +6271,36 @@ http://www.nongnu.org/bm/") (with-current-buffer buf (insert str)))))))))) ;;; Special bookmarks -(defvar anything-c-source-bookmarks-ssh +(defvar helm-c-source-bookmarks-ssh '((name . "Bookmarks-ssh") (init . (lambda () (require 'bookmark))) - (candidates . (lambda () (anything-c-collect-bookmarks :ssh t))) + (candidates . (lambda () (helm-c-collect-bookmarks :ssh t))) (type . bookmark)) "See (info \"(emacs)Bookmarks\").") -(defvar anything-c-source-bookmarks-su +(defvar helm-c-source-bookmarks-su '((name . "Bookmarks-root") (init . (lambda () (require 'bookmark))) - (candidates . (lambda () (anything-c-collect-bookmarks :su t))) - (filtered-candidate-transformer anything-c-highlight-bookmark-su) + (candidates . (lambda () (helm-c-collect-bookmarks :su t))) + (filtered-candidate-transformer helm-c-highlight-bookmark-su) (type . bookmark)) "See (info \"(emacs)Bookmarks\").") -(defvar anything-c-source-bookmarks-local +(defvar helm-c-source-bookmarks-local '((name . "Bookmarks-Local") (init . (lambda () (require 'bookmark))) - (candidates . (lambda () (anything-c-collect-bookmarks :local t))) + (candidates . (lambda () (helm-c-collect-bookmarks :local t))) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark)) "See (info \"(emacs)Bookmarks\").") -(defun* anything-c-collect-bookmarks (&key local su sudo ssh) +(defun* helm-c-collect-bookmarks (&key local su sudo ssh) (let* ((lis-all (bookmark-all-names)) (lis-loc (cond (local (loop for i in lis-all unless (string-match "^(ssh)\\|^(su)" i) @@ -6376,22 +6316,22 @@ http://www.nongnu.org/bm/") collect i))))) (sort lis-loc 'string-lessp))) -(defun anything-c-bookmark-root-logged-p () +(defun helm-c-bookmark-root-logged-p () (catch 'break (dolist (i (mapcar #'buffer-name (buffer-list))) - (when (string-match (format "*tramp/%s ." anything-su-or-sudo) i) + (when (string-match (format "*tramp/%s ." helm-su-or-sudo) i) (throw 'break t))))) -(defun anything-c-highlight-bookmark-su (files source) - (if (anything-c-bookmark-root-logged-p) - (anything-c-highlight-bookmark files source) - (anything-c-highlight-not-logged files source))) +(defun helm-c-highlight-bookmark-su (files source) + (if (helm-c-bookmark-root-logged-p) + (helm-c-highlight-bookmark files source) + (helm-c-highlight-not-logged files source))) -(defun anything-c-highlight-not-logged (files source) +(defun helm-c-highlight-not-logged (files source) (loop for i in files - collect (propertize i 'face anything-c-bookmarks-face3))) + collect (propertize i 'face helm-c-bookmarks-face3))) -(defun anything-c-highlight-bookmark (bookmarks source) +(defun helm-c-highlight-bookmark (bookmarks source) "Used as `candidate-transformer' to colorize bookmarks. Work both with standard Emacs bookmarks and bookmark-extensions.el." (loop for i in bookmarks @@ -6417,43 +6357,43 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." do (setq i (concat "*" i)) collect (cond (;; info buffers isinfo - (propertize i 'face 'anything-bmkext-info 'help-echo isfile)) + (propertize i 'face 'helm-bmkext-info 'help-echo isfile)) (;; w3m buffers isw3m - (propertize i 'face 'anything-bmkext-w3m 'help-echo isfile)) + (propertize i 'face 'helm-bmkext-w3m 'help-echo isfile)) (;; gnus buffers isgnus - (propertize i 'face 'anything-bmkext-gnus 'help-echo isfile)) + (propertize i 'face 'helm-bmkext-gnus 'help-echo isfile)) (;; Man Woman (or iswoman isman) - (propertize i 'face 'anything-bmkext-man 'help-echo isfile)) + (propertize i 'face 'helm-bmkext-man 'help-echo isfile)) (;; Addressbook isabook (propertize i 'face '((:foreground "Tomato")))) (;; directories (and isfile (file-directory-p isfile)) - (propertize i 'face anything-c-bookmarks-face1 'help-echo isfile)) + (propertize i 'face helm-c-bookmarks-face1 'help-echo isfile)) (;; regular files t - (propertize i 'face 'anything-bmkext-file 'help-echo isfile))))) + (propertize i 'face 'helm-bmkext-file 'help-echo isfile))))) -(defun anything-c-bookmark-jump (candidate) +(defun helm-c-bookmark-jump (candidate) "Jump to bookmark from keyboard." - (let ((current-prefix-arg anything-current-prefix-arg)) + (let ((current-prefix-arg helm-current-prefix-arg)) (bookmark-jump candidate))) ;;;###autoload -(defun anything-c-bookmark-run-jump-other-window () +(defun helm-c-bookmark-run-jump-other-window () "Jump to bookmark from keyboard." (interactive) - (anything-c-quit-and-execute-action 'bookmark-jump-other-window)) + (helm-c-quit-and-execute-action 'bookmark-jump-other-window)) ;;;###autoload -(defun anything-c-bookmark-run-delete () +(defun helm-c-bookmark-run-delete () "Delete bookmark from keyboard." (interactive) (when (y-or-n-p "Delete bookmark?") - (anything-c-quit-and-execute-action 'anything-delete-marked-bookmarks))) + (helm-c-quit-and-execute-action 'helm-delete-marked-bookmarks))) ;;; Sources to filter bookmark-extensions bookmarks. @@ -6464,7 +6404,7 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." ;; Julien Danjou google-maps-el package available here: ;; http://julien.danjou.info/google-maps-el.html -(defun anything-c-bmkext-filter-setup-alist (fn &rest args) +(defun helm-c-bmkext-filter-setup-alist (fn &rest args) "Return a filtered `bookmark-alist' sorted alphabetically." (loop with alist = (if args @@ -6476,44 +6416,44 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." finally return (sort sa 'string-lessp))) ;;;###autoload -(defun anything-c-bmkext-run-edit () +(defun helm-c-bmkext-run-edit () "Run `bmkext-edit-bookmark' from keyboard." (interactive) - (anything-c-quit-and-execute-action 'bmkext-edit-bookmark)) + (helm-c-quit-and-execute-action 'bmkext-edit-bookmark)) ;;; Addressbook. ;; ;; -(defvar anything-c-source-bmkext-addressbook +(defvar helm-c-source-bmkext-addressbook '((name . "Bookmark Addressbook") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bmkext-addressbook-setup-alist) + (candidates . helm-c-bmkext-addressbook-setup-alist) (persistent-action . (lambda (candidate) - (let ((bmk (anything-bookmark-get-bookmark-from-name + (let ((bmk (helm-bookmark-get-bookmark-from-name candidate))) (bookmark--jump-via bmk 'pop-to-buffer)))) (persistent-help . "Show contact - Prefix with C-u to append") (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (action . (("Show Contact(s)" . (lambda (candidate) - (let* ((contacts (anything-marked-candidates)) - (current-prefix-arg (or anything-current-prefix-arg + (let* ((contacts (helm-marked-candidates)) + (current-prefix-arg (or helm-current-prefix-arg (> (length contacts) 1)))) (bookmark-jump - (anything-bookmark-get-bookmark-from-name (car contacts))) - (anything-aif (cdr contacts) + (helm-bookmark-get-bookmark-from-name (car contacts))) + (helm-aif (cdr contacts) (loop for bmk in it do (bookmark-jump - (anything-bookmark-get-bookmark-from-name bmk))))))) + (helm-bookmark-get-bookmark-from-name bmk))))))) ("Send Mail" . (lambda (candidate) - (let* ((contacts (anything-marked-candidates)) - (bmk (anything-bookmark-get-bookmark-from-name + (let* ((contacts (helm-marked-candidates)) + (bmk (helm-bookmark-get-bookmark-from-name (car contacts))) (append (message-buffers))) (if append @@ -6525,13 +6465,13 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." (addressbook-set-mail-buffer1 bmk 'append)))))) ("Edit Bookmark" . (lambda (candidate) - (let ((bmk (anything-bookmark-get-bookmark-from-name + (let ((bmk (helm-bookmark-get-bookmark-from-name candidate))) (addressbook-bookmark-edit (assoc bmk bookmark-alist))))) ("Insert Email at point" . (lambda (candidate) - (let* ((bmk (anything-bookmark-get-bookmark-from-name + (let* ((bmk (helm-bookmark-get-bookmark-from-name candidate)) (mlist (split-string (assoc-default @@ -6539,145 +6479,145 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." ", "))) (insert (if (> (length mlist) 1) - (anything-comp-read + (helm-comp-read "Insert Mail Address: " mlist :must-match t) (car mlist)))))) ("Show annotation" . (lambda (candidate) - (let ((bmk (anything-bookmark-get-bookmark-from-name + (let ((bmk (helm-bookmark-get-bookmark-from-name candidate))) (bookmark-show-annotation bmk)))) ("Edit annotation" . (lambda (candidate) - (let ((bmk (anything-bookmark-get-bookmark-from-name + (let ((bmk (helm-bookmark-get-bookmark-from-name candidate))) (bookmark-edit-annotation bmk)))) ("Show Google map" . (lambda (candidate) - (let* ((bmk (anything-bookmark-get-bookmark-from-name + (let* ((bmk (helm-bookmark-get-bookmark-from-name candidate)) (full-bmk (assoc bmk bookmark-alist))) (addressbook-google-map full-bmk)))))))) -(defun anything-c-bmkext-addressbook-setup-alist () +(defun helm-c-bmkext-addressbook-setup-alist () "Specialized filter function for bookmarks w3m." - (anything-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only)) ;; W3m bookmarks from bookmark-extensions. -(defvar anything-c-source-bookmark-w3m +(defvar helm-c-source-bookmark-w3m '((name . "Bookmark W3m") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-w3m-setup-alist) + (candidates . helm-c-bookmark-w3m-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-w3m-setup-alist () +(defun helm-c-bookmark-w3m-setup-alist () "Specialized filter function for bookmarks w3m." - (anything-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only)) ;; Images -(defvar anything-c-source-bookmark-images +(defvar helm-c-source-bookmark-images '((name . "Bookmark Images") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-images-setup-alist) + (candidates . helm-c-bookmark-images-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-images-setup-alist () +(defun helm-c-bookmark-images-setup-alist () "Specialized filter function for images bookmarks." - (anything-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only)) ;; Woman Man -(defvar anything-c-source-bookmark-man +(defvar helm-c-source-bookmark-man '((name . "Bookmark Woman&Man") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-man-setup-alist) + (candidates . helm-c-bookmark-man-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-man-setup-alist () +(defun helm-c-bookmark-man-setup-alist () "Specialized filter function for bookmarks w3m." - (append (anything-c-bmkext-filter-setup-alist 'bmkext-man-alist-only) - (anything-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only))) + (append (helm-c-bmkext-filter-setup-alist 'bmkext-man-alist-only) + (helm-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only))) ;; Gnus -(defvar anything-c-source-bookmark-gnus +(defvar helm-c-source-bookmark-gnus '((name . "Bookmark Gnus") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-gnus-setup-alist) + (candidates . helm-c-bookmark-gnus-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-gnus-setup-alist () +(defun helm-c-bookmark-gnus-setup-alist () "Specialized filter function for bookmarks gnus." - (anything-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only)) ;; Info -(defvar anything-c-source-bookmark-info +(defvar helm-c-source-bookmark-info '((name . "Bookmark Info") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-info-setup-alist) + (candidates . helm-c-bookmark-info-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-info-setup-alist () +(defun helm-c-bookmark-info-setup-alist () "Specialized filter function for bookmarks info." - (anything-c-bmkext-filter-setup-alist 'bmkext-info-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-info-alist-only)) ;; Local Files&directories -(defvar anything-c-source-bookmark-files&dirs +(defvar helm-c-source-bookmark-files&dirs '((name . "Bookmark Files&Directories") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-local-files-setup-alist) + (candidates . helm-c-bookmark-local-files-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark) + helm-c-adaptive-sort + helm-c-highlight-bookmark) (type . bookmark))) -(defun anything-c-bookmark-local-files-setup-alist () +(defun helm-c-bookmark-local-files-setup-alist () "Specialized filter function for bookmarks locals files." - (anything-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only)) + (helm-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only)) ;; Su Files&directories -(defvar anything-c-source-bookmark-su-files&dirs +(defvar helm-c-source-bookmark-su-files&dirs '((name . "Bookmark Root-Files&Directories") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-su-files-setup-alist) + (candidates . helm-c-bookmark-su-files-setup-alist) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-bookmark-su) + helm-c-adaptive-sort + helm-c-highlight-bookmark-su) (type . bookmark))) -(defun anything-c-bookmark-su-files-setup-alist () +(defun helm-c-bookmark-su-files-setup-alist () "Specialized filter function for bookmarks su/sudo files." (declare (special bmkext-su-or-sudo-regexp)) (loop - with l = (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only) + with l = (helm-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only) for i in l for isfile = (bookmark-get-filename i) for istramp = (and isfile (boundp 'tramp-file-name-regexp) @@ -6689,19 +6629,19 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." collect i)) ;; Ssh Files&directories -(defvar anything-c-source-bookmark-ssh-files&dirs +(defvar helm-c-source-bookmark-ssh-files&dirs '((name . "Bookmark Ssh-Files&Directories") (init . (lambda () (require 'bookmark-extensions) (bookmark-maybe-load-default-file))) - (candidates . anything-c-bookmark-ssh-files-setup-alist) - (filtered-candidate-transformer . anything-c-adaptive-sort) + (candidates . helm-c-bookmark-ssh-files-setup-alist) + (filtered-candidate-transformer . helm-c-adaptive-sort) (type . bookmark))) -(defun anything-c-bookmark-ssh-files-setup-alist () +(defun helm-c-bookmark-ssh-files-setup-alist () "Specialized filter function for bookmarks ssh files." (loop - with l = (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only) + with l = (helm-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only) for i in l for isfile = (bookmark-get-filename i) for istramp = (and isfile (boundp 'tramp-file-name-regexp) @@ -6726,10 +6666,10 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." ;; user_pref("browser.bookmarks.autoExportHTML", true); ;; NOTE: This is also working in the same way for mozilla aka seamonkey. -(defvar anything-firefox-bookmark-url-regexp "\\(https\\|http\\|ftp\\|about\\|file\\)://[^ \"]*") -(defvar anything-firefox-bookmarks-regexp ">\\([^><]+.[^]\\)") +(defvar helm-firefox-bookmark-url-regexp "\\(https\\|http\\|ftp\\|about\\|file\\)://[^ \"]*") +(defvar helm-firefox-bookmarks-regexp ">\\([^><]+.[^]\\)") -(defun anything-get-firefox-user-init-dir () +(defun helm-get-firefox-user-init-dir () "Guess the default Firefox user directory name." (let* ((moz-dir (concat (getenv "HOME") "/.mozilla/firefox/")) (moz-user-dir @@ -6741,11 +6681,11 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." (kill-buffer))))) (file-name-as-directory (concat moz-dir moz-user-dir)))) -(defun anything-guess-firefox-bookmark-file () +(defun helm-guess-firefox-bookmark-file () "Return the path of the Firefox bookmarks file." - (concat (anything-get-firefox-user-init-dir) "bookmarks.html")) + (concat (helm-get-firefox-user-init-dir) "bookmarks.html")) -(defun anything-html-bookmarks-to-alist (file url-regexp bmk-regexp) +(defun helm-html-bookmarks-to-alist (file url-regexp bmk-regexp) "Parse html bookmark FILE and return an alist with (title . url) as elements." (let (bookmarks-alist url title) (with-temp-buffer @@ -6761,41 +6701,41 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." (forward-line))) (nreverse bookmarks-alist))) -(defvar anything-c-firefox-bookmarks-alist nil) -(defvar anything-c-source-firefox-bookmarks +(defvar helm-c-firefox-bookmarks-alist nil) +(defvar helm-c-source-firefox-bookmarks '((name . "Firefox Bookmarks") (init . (lambda () - (setq anything-c-firefox-bookmarks-alist - (anything-html-bookmarks-to-alist - (anything-guess-firefox-bookmark-file) - anything-firefox-bookmark-url-regexp - anything-firefox-bookmarks-regexp)))) + (setq helm-c-firefox-bookmarks-alist + (helm-html-bookmarks-to-alist + (helm-guess-firefox-bookmark-file) + helm-firefox-bookmark-url-regexp + helm-firefox-bookmarks-regexp)))) (candidates . (lambda () - (mapcar #'car anything-c-firefox-bookmarks-alist))) + (mapcar #'car helm-c-firefox-bookmarks-alist))) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-firefox-bookmarks) + helm-c-adaptive-sort + helm-c-highlight-firefox-bookmarks) (action . (("Browse Url" . (lambda (candidate) - (anything-c-browse-url - (anything-c-firefox-bookmarks-get-value candidate)))) + (helm-c-browse-url + (helm-c-firefox-bookmarks-get-value candidate)))) ("Copy Url" . (lambda (elm) - (kill-new (anything-c-w3m-bookmarks-get-value elm)))))))) + (kill-new (helm-c-w3m-bookmarks-get-value elm)))))))) -(defun anything-c-firefox-bookmarks-get-value (elm) - (assoc-default elm anything-c-firefox-bookmarks-alist)) +(defun helm-c-firefox-bookmarks-get-value (elm) + (assoc-default elm helm-c-firefox-bookmarks-alist)) -(defun anything-c-highlight-firefox-bookmarks (bookmarks source) +(defun helm-c-highlight-firefox-bookmarks (bookmarks source) (loop for i in bookmarks collect (propertize i 'face '((:foreground "YellowGreen")) - 'help-echo (anything-c-firefox-bookmarks-get-value i)))) + 'help-echo (helm-c-firefox-bookmarks-get-value i)))) -;;; W3m bookmark - anything interface. +;;; W3m bookmark - helm interface. ;; ;; ;; Some users have the emacs-w3m library in load-path @@ -6807,66 +6747,66 @@ Work both with standard Emacs bookmarks and bookmark-extensions.el." (require 'w3m-bookmark nil t))) (defvar w3m-bookmark-file "~/.w3m/bookmark.html") -(defvar anything-w3m-bookmarks-regexp ">\\([^><]+.[^]\\)") -(defvar anything-w3m-bookmark-url-regexp "\\(https\\|http\\|ftp\\|file\\)://[^>]*") -(defvar anything-c-w3m-bookmarks-alist nil) -(defvar anything-c-source-w3m-bookmarks +(defvar helm-w3m-bookmarks-regexp ">\\([^><]+.[^]\\)") +(defvar helm-w3m-bookmark-url-regexp "\\(https\\|http\\|ftp\\|file\\)://[^>]*") +(defvar helm-c-w3m-bookmarks-alist nil) +(defvar helm-c-source-w3m-bookmarks '((name . "W3m Bookmarks") (init . (lambda () - (setq anything-c-w3m-bookmarks-alist - (anything-html-bookmarks-to-alist + (setq helm-c-w3m-bookmarks-alist + (helm-html-bookmarks-to-alist w3m-bookmark-file - anything-w3m-bookmark-url-regexp - anything-w3m-bookmarks-regexp)))) + helm-w3m-bookmark-url-regexp + helm-w3m-bookmarks-regexp)))) (candidates . (lambda () - (mapcar #'car anything-c-w3m-bookmarks-alist))) + (mapcar #'car helm-c-w3m-bookmarks-alist))) (filtered-candidate-transformer - anything-c-adaptive-sort - anything-c-highlight-w3m-bookmarks) + helm-c-adaptive-sort + helm-c-highlight-w3m-bookmarks) (action . (("Browse Url" . (lambda (candidate) - (anything-c-w3m-browse-bookmark candidate))) + (helm-c-w3m-browse-bookmark candidate))) ("Copy Url" . (lambda (elm) - (kill-new (anything-c-w3m-bookmarks-get-value elm)))) + (kill-new (helm-c-w3m-bookmarks-get-value elm)))) ("Browse Url Externally" . (lambda (candidate) - (anything-c-w3m-browse-bookmark candidate t))) + (helm-c-w3m-browse-bookmark candidate t))) ("Delete Bookmark" . (lambda (candidate) - (anything-c-w3m-delete-bookmark candidate))) + (helm-c-w3m-delete-bookmark candidate))) ("Rename Bookmark" . (lambda (candidate) - (anything-c-w3m-rename-bookmark candidate))))) + (helm-c-w3m-rename-bookmark candidate))))) (persistent-action . (lambda (candidate) (if current-prefix-arg - (anything-c-w3m-browse-bookmark candidate t) - (anything-c-w3m-browse-bookmark candidate nil t)))) + (helm-c-w3m-browse-bookmark candidate t) + (helm-c-w3m-browse-bookmark candidate nil t)))) (persistent-help . "Open URL with emacs-w3m in new tab / \ -C-u \\[anything-execute-persistent-action]: Open URL with Firefox")) +C-u \\[helm-execute-persistent-action]: Open URL with Firefox")) "Needs w3m and emacs-w3m. http://w3m.sourceforge.net/ http://emacs-w3m.namazu.org/") -(defun anything-c-w3m-bookmarks-get-value (elm) +(defun helm-c-w3m-bookmarks-get-value (elm) (replace-regexp-in-string - "\"" "" (cdr (assoc elm anything-c-w3m-bookmarks-alist)))) + "\"" "" (cdr (assoc elm helm-c-w3m-bookmarks-alist)))) -(defun anything-c-w3m-browse-bookmark (elm &optional use-external new-tab) - (let* ((fn (if use-external 'anything-c-browse-url 'w3m-browse-url)) +(defun helm-c-w3m-browse-bookmark (elm &optional use-external new-tab) + (let* ((fn (if use-external 'helm-c-browse-url 'w3m-browse-url)) (arg (and (eq fn 'w3m-browse-url) new-tab))) - (funcall fn (anything-c-w3m-bookmarks-get-value elm) arg))) + (funcall fn (helm-c-w3m-bookmarks-get-value elm) arg))) -(defun anything-c-highlight-w3m-bookmarks (bookmarks source) +(defun helm-c-highlight-w3m-bookmarks (bookmarks source) (loop for i in bookmarks collect (propertize - i 'face 'anything-w3m-bookmarks-face - 'help-echo (anything-c-w3m-bookmarks-get-value i)))) + i 'face 'helm-w3m-bookmarks-face + 'help-echo (helm-c-w3m-bookmarks-get-value i)))) -(defun anything-c-w3m-delete-bookmark (elm) +(defun helm-c-w3m-delete-bookmark (elm) "Delete w3m bookmark from `w3m-bookmark-file'." (with-current-buffer (find-file-literally w3m-bookmark-file) @@ -6879,7 +6819,7 @@ http://emacs-w3m.namazu.org/") (save-buffer) (kill-buffer))) -(defun anything-c-w3m-rename-bookmark (elm) +(defun helm-c-w3m-rename-bookmark (elm) "Rename w3m bookmark in `w3m-bookmark-file'." (let* ((old-title (replace-regexp-in-string ">" "" elm)) (new-title (read-string "NewTitle: " old-title))) @@ -6898,9 +6838,9 @@ http://emacs-w3m.namazu.org/") ;;; Elisp library scan ;; ;; -(defvar anything-c-source-elisp-library-scan +(defvar helm-c-source-elisp-library-scan '((name . "Elisp libraries (Scan)") - (init . (anything-c-elisp-library-scan-init)) + (init . (helm-c-elisp-library-scan-init)) (candidates-in-buffer) (action ("Find library" . (lambda (candidate) (find-file (find-library-name candidate)))) @@ -6910,15 +6850,15 @@ http://emacs-w3m.namazu.org/") ("Load library" . (lambda (candidate) (load-library candidate)))))) -(defun anything-c-elisp-library-scan-init () - "Init anything buffer status." - (let ((anything-buffer (anything-candidate-buffer 'global)) - (library-list (anything-c-elisp-library-scan-list))) - (with-current-buffer anything-buffer +(defun helm-c-elisp-library-scan-init () + "Init helm buffer status." + (let ((helm-buffer (helm-candidate-buffer 'global)) + (library-list (helm-c-elisp-library-scan-list))) + (with-current-buffer helm-buffer (dolist (library library-list) (insert (format "%s\n" library)))))) -(defun anything-c-elisp-library-scan-list (&optional dirs string) +(defun helm-c-elisp-library-scan-list (&optional dirs string) "Do completion for file names passed to `locate-file'. DIRS is directory to search path. STRING is string to match." @@ -6954,24 +6894,24 @@ STRING is string to match." ;;; Imenu ;; ;; -(defvar anything-c-imenu-delimiter " / ") +(defvar helm-c-imenu-delimiter " / ") -(defvar anything-c-imenu-index-filter nil) -(make-variable-buffer-local 'anything-c-imenu-index-filter) +(defvar helm-c-imenu-index-filter nil) +(make-variable-buffer-local 'helm-c-imenu-index-filter) -(defvar anything-c-cached-imenu-alist nil) -(make-variable-buffer-local 'anything-c-cached-imenu-alist) +(defvar helm-c-cached-imenu-alist nil) +(make-variable-buffer-local 'helm-c-cached-imenu-alist) -(defvar anything-c-cached-imenu-candidates nil) -(make-variable-buffer-local 'anything-c-cached-imenu-candidates) +(defvar helm-c-cached-imenu-candidates nil) +(make-variable-buffer-local 'helm-c-cached-imenu-candidates) -(defvar anything-c-cached-imenu-tick nil) -(make-variable-buffer-local 'anything-c-cached-imenu-tick) +(defvar helm-c-cached-imenu-tick nil) +(make-variable-buffer-local 'helm-c-cached-imenu-tick) (eval-when-compile (require 'imenu)) (setq imenu-auto-rescan t) -(defun anything-imenu-create-candidates (entry) +(defun helm-imenu-create-candidates (entry) "Create candidates with ENTRY." (if (listp (cdr entry)) (mapcan @@ -6979,53 +6919,53 @@ STRING is string to match." (if (consp (cdr sub)) (mapcar (lambda (subentry) - (concat (car entry) anything-c-imenu-delimiter subentry)) - (anything-imenu-create-candidates sub)) - (list (concat (car entry) anything-c-imenu-delimiter (car sub))))) + (concat (car entry) helm-c-imenu-delimiter subentry)) + (helm-imenu-create-candidates sub)) + (list (concat (car entry) helm-c-imenu-delimiter (car sub))))) (cdr entry)) (list entry))) -(defvar anything-c-source-imenu +(defvar helm-c-source-imenu '((name . "Imenu") (init . (lambda () (require 'imenu))) - (candidates . anything-c-imenu-candidates) + (candidates . helm-c-imenu-candidates) (persistent-action . (lambda (elm) - (anything-c-imenu-default-action elm) + (helm-c-imenu-default-action elm) (unless (fboundp 'semantic-imenu-tag-overlay) - (anything-match-line-color-current-line)))) + (helm-match-line-color-current-line)))) (persistent-help . "Show this entry") - (action . anything-c-imenu-default-action)) + (action . helm-c-imenu-default-action)) "See (info \"(emacs)Imenu\")") -(defun anything-c-imenu-candidates () - (with-anything-current-buffer +(defun helm-c-imenu-candidates () + (with-helm-current-buffer (let ((tick (buffer-modified-tick))) - (if (eq anything-c-cached-imenu-tick tick) - anything-c-cached-imenu-candidates + (if (eq helm-c-cached-imenu-tick tick) + helm-c-cached-imenu-candidates (setq imenu--index-alist nil) - (setq anything-c-cached-imenu-tick tick - anything-c-cached-imenu-candidates + (setq helm-c-cached-imenu-tick tick + helm-c-cached-imenu-candidates (ignore-errors (mapcan - 'anything-imenu-create-candidates - (setq anything-c-cached-imenu-alist + 'helm-imenu-create-candidates + (setq helm-c-cached-imenu-alist (let ((index (imenu--make-index-alist))) - (if anything-c-imenu-index-filter - (funcall anything-c-imenu-index-filter index) + (if helm-c-imenu-index-filter + (funcall helm-c-imenu-index-filter index) index)))))) - (setq anything-c-cached-imenu-candidates + (setq helm-c-cached-imenu-candidates (mapcar #'(lambda (x) (if (stringp x) x (car x))) - anything-c-cached-imenu-candidates)))))) + helm-c-cached-imenu-candidates)))))) (setq imenu-default-goto-function 'imenu-default-goto-function) -(defun anything-c-imenu-default-action (elm) - "The default action for `anything-c-source-imenu'." - (let ((path (split-string elm anything-c-imenu-delimiter)) - (alist anything-c-cached-imenu-alist)) +(defun helm-c-imenu-default-action (elm) + "The default action for `helm-c-source-imenu'." + (let ((path (split-string elm helm-c-imenu-delimiter)) + (alist helm-c-cached-imenu-alist)) (dolist (elm path) (setq alist (assoc elm alist))) (imenu alist))) @@ -7035,21 +6975,21 @@ STRING is string to match." ;;; Ctags ;; ;; -(defvar anything-c-ctags-modes +(defvar helm-c-ctags-modes '( c-mode c++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode scheme-mode sh-mode slang-mode sql-mode tcl-mode )) -(defun anything-c-source-ctags-init () +(defun helm-c-source-ctags-init () (when (and buffer-file-name - (memq major-mode anything-c-ctags-modes) - (anything-current-buffer-is-modified)) - (with-current-buffer (anything-candidate-buffer 'local) + (memq major-mode helm-c-ctags-modes) + (helm-current-buffer-is-modified)) + (with-current-buffer (helm-candidate-buffer 'local) (call-process-shell-command - (if (string-match "\\.el\\.gz$" anything-buffer-file-name) + (if (string-match "\\.el\\.gz$" helm-buffer-file-name) (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) " - anything-buffer-file-name) - (format "ctags -e -u -f- --fields=n %s " anything-buffer-file-name)) + helm-buffer-file-name) + (format "ctags -e -u -f- --fields=n %s " helm-buffer-file-name)) nil (current-buffer)) (goto-char (point-min)) (forward-line 2) @@ -7066,9 +7006,9 @@ STRING is string to match." (delete-region (1- (point)) (point-at-eol)) (forward-line 1))))) -(defvar anything-c-source-ctags +(defvar helm-c-source-ctags '((name . "Exuberant ctags") - (init . anything-c-source-ctags-init) + (init . helm-c-source-ctags-init) (candidates-in-buffer) (adjust) (type . line)) @@ -7080,47 +7020,47 @@ http://ctags.sourceforge.net/") ;;; Etags ;; ;; -;; anything-etags.el is deprecated, if this file is found, +;; helm-etags.el is deprecated, if this file is found, ;; warn user at compile time. (eval-when-compile - (when (locate-library "anything-etags.el") + (when (locate-library "helm-etags.el") (display-warning - '(anything-config) - "You are using obsolete library `anything-etags.el' and should remove it." + '(helm-config) + "You are using obsolete library `helm-etags.el' and should remove it." :warning))) -(defvar anything-c-etags-tag-file-dir nil +(defvar helm-c-etags-tag-file-dir nil "Etags file directory.") -(defvar anything-c-etags-mtime-alist nil +(defvar helm-c-etags-mtime-alist nil "Store the last modification time of etags files here.") -(defvar anything-c-etags-cache (make-hash-table :test 'equal) +(defvar helm-c-etags-cache (make-hash-table :test 'equal) "Cache content of etags files used here for faster access.") -(defun anything-c-etags-get-tag-file (&optional directory) +(defun helm-c-etags-get-tag-file (&optional directory) "Return the path of etags file if found." ;; Get tag file from `default-directory' or upper directory. - (let ((current-dir (anything-c-etags-find-tag-file-directory + (let ((current-dir (helm-c-etags-find-tag-file-directory (or directory default-directory)))) ;; Return nil if not find tag file. (when current-dir ;; Set tag file directory. - (setq anything-c-etags-tag-file-dir current-dir) - (expand-file-name anything-c-etags-tag-file-name current-dir)))) + (setq helm-c-etags-tag-file-dir current-dir) + (expand-file-name helm-c-etags-tag-file-name current-dir)))) -(defun anything-c-etags-find-tag-file-directory (current-dir) +(defun helm-c-etags-find-tag-file-directory (current-dir) "Try to find the directory containing tag file. If not found in CURRENT-DIR search in upper directory." (flet ((file-exists? (dir) (let ((tag-path (expand-file-name - anything-c-etags-tag-file-name dir))) + helm-c-etags-tag-file-name dir))) (and (stringp tag-path) (file-regular-p tag-path) (file-readable-p tag-path))))) (loop with count = 0 until (file-exists? current-dir) ;; Return nil if outside the value of - ;; `anything-c-etags-tag-file-search-limit'. - if (= count anything-c-etags-tag-file-search-limit) + ;; `helm-c-etags-tag-file-search-limit'. + if (= count helm-c-etags-tag-file-search-limit) do (return nil) ;; Or search upper directories. else @@ -7128,14 +7068,14 @@ If not found in CURRENT-DIR search in upper directory." (setq current-dir (expand-file-name (concat current-dir "../"))) finally return current-dir))) -(defun anything-c-source-etags-header-name (x) - "Create header name for this anything etags session." +(defun helm-c-source-etags-header-name (x) + "Create header name for this helm etags session." (concat "Etags in " - (with-anything-current-buffer - (anything-c-etags-get-tag-file)))) + (with-helm-current-buffer + (helm-c-etags-get-tag-file)))) -(defmacro anything-c-etags-create-buffer (file) - "Create the `anything-buffer' based on contents of etags tag FILE." +(defmacro helm-c-etags-create-buffer (file) + "Create the `helm-buffer' based on contents of etags tag FILE." `(let* ((tag-fname ,file) max (split (with-current-buffer (find-file-noselect tag-fname) @@ -7149,7 +7089,7 @@ If not found in CURRENT-DIR search in upper directory." with cand for i in split for count from 0 for elm = (unless (string-match "^\x0c" i) - (anything-aif (string-match "\177" i) + (helm-aif (string-match "\177" i) (substring i 0 it) i)) do (cond ((and elm (string-match "^\\(.+\\),[0-9]+" elm)) @@ -7160,79 +7100,79 @@ If not found in CURRENT-DIR search in upper directory." (insert (concat cand "\n")) (progress-reporter-update progress-reporter count))))) -(defun anything-c-etags-init () - "Feed `anything-buffer' using `anything-c-etags-cache' or tag file. +(defun helm-c-etags-init () + "Feed `helm-buffer' using `helm-c-etags-cache' or tag file. If no entry in cache, create one." - (let ((tagfile (anything-c-etags-get-tag-file))) + (let ((tagfile (helm-c-etags-get-tag-file))) (when tagfile - (with-current-buffer (anything-candidate-buffer 'global) - (anything-aif (gethash tagfile anything-c-etags-cache) + (with-current-buffer (helm-candidate-buffer 'global) + (helm-aif (gethash tagfile helm-c-etags-cache) ;; An entry is present in cache, insert it. (insert it) ;; No entry, create a new buffer using content of tag file (slower). - (anything-c-etags-create-buffer tagfile) + (helm-c-etags-create-buffer tagfile) ;; Store content of buffer in cache. - (puthash tagfile (buffer-string) anything-c-etags-cache) + (puthash tagfile (buffer-string) helm-c-etags-cache) ;; Store or set the last modification of tag file. - (anything-aif (assoc tagfile anything-c-etags-mtime-alist) + (helm-aif (assoc tagfile helm-c-etags-mtime-alist) ;; If an entry exists modify it. - (setcdr it (anything-c-etags-mtime tagfile)) + (setcdr it (helm-c-etags-mtime tagfile)) ;; No entry create a new one. - (add-to-list 'anything-c-etags-mtime-alist - (cons tagfile (anything-c-etags-mtime tagfile))))))))) + (add-to-list 'helm-c-etags-mtime-alist + (cons tagfile (helm-c-etags-mtime tagfile))))))))) -(defvar anything-c-source-etags-select +(defvar helm-c-source-etags-select '((name . "Etags") - (header-name . anything-c-source-etags-header-name) - (init . anything-c-etags-init) + (header-name . helm-c-source-etags-header-name) + (init . helm-c-etags-init) (candidates-in-buffer) - (search . (anything-c-etags-search-fn)) - (mode-line . anything-etags-mode-line-string) - (action . anything-c-etags-default-action) + (search . (helm-c-etags-search-fn)) + (mode-line . helm-etags-mode-line-string) + (action . helm-c-etags-default-action) (persistent-action . (lambda (candidate) - (anything-c-etags-default-action candidate) - (anything-match-line-color-current-line)))) - "Anything source for Etags.") + (helm-c-etags-default-action candidate) + (helm-match-line-color-current-line)))) + "Helm source for Etags.") -(defun anything-c-etags-search-fn (pattern) - "Search function for `anything-c-source-etags-select'." +(defun helm-c-etags-search-fn (pattern) + "Search function for `helm-c-source-etags-select'." (re-search-forward - (if anything-c-etags-use-regexp-search - (format anything-c-etags-search-regexp pattern) + (if helm-c-etags-use-regexp-search + (format helm-c-etags-search-regexp pattern) pattern) nil t)) -(defun anything-c-etags-default-action (candidate) - "Anything default action to jump to an etags entry." +(defun helm-c-etags-default-action (candidate) + "Helm default action to jump to an etags entry." (let* ((split (split-string candidate ": ")) (fname (expand-file-name - (car split) anything-c-etags-tag-file-dir)) + (car split) helm-c-etags-tag-file-dir)) (elm (cadr split))) (find-file fname) (goto-char (point-min)) (search-forward elm nil t) (goto-char (match-beginning 0)))) -(defun anything-c-etags-mtime (file) +(defun helm-c-etags-mtime (file) "Last modification time of etags tag FILE." (cadr (nth 5 (file-attributes file)))) -(defun anything-c-etags-file-modified-p (file) +(defun helm-c-etags-file-modified-p (file) "Check if tag FILE have been modified in this session. If FILE is nil return nil." (let ((last-modif (and file - (assoc-default file anything-c-etags-mtime-alist)))) + (assoc-default file helm-c-etags-mtime-alist)))) (and last-modif - (/= last-modif (anything-c-etags-mtime file))))) + (/= last-modif (helm-c-etags-mtime file))))) ;;; Semantic ;; ;; -(defvar anything-semantic-candidates nil) +(defvar helm-semantic-candidates nil) -(defun anything-semantic-construct-candidates (tags depth) +(defun helm-semantic-construct-candidates (tags depth) (when (require 'semantic nil t) (apply 'append @@ -7249,28 +7189,28 @@ If FILE is nil return nil." (cons (cons (concat (make-string (* depth 2) ?\s) (semantic-format-tag-summarize tag nil t)) tag) - (anything-semantic-construct-candidates + (helm-semantic-construct-candidates (semantic-tag-components tag) (1+ depth))))))) tags)))) -(defun anything-semantic-default-action (candidate) - (let ((tag (cdr (assoc candidate anything-semantic-candidates)))) +(defun helm-semantic-default-action (candidate) + (let ((tag (cdr (assoc candidate helm-semantic-candidates)))) (semantic-go-to-tag tag))) -(defvar anything-c-source-semantic +(defvar helm-c-source-semantic '((name . "Semantic Tags") (init . (lambda () - (setq anything-semantic-candidates - (ignore-errors (anything-semantic-construct-candidates + (setq helm-semantic-candidates + (ignore-errors (helm-semantic-construct-candidates (semantic-fetch-tags) 0))))) (candidates . (lambda () - (if anything-semantic-candidates - (mapcar 'car anything-semantic-candidates)))) + (if helm-semantic-candidates + (mapcar 'car helm-semantic-candidates)))) (persistent-action . (lambda (elm) - (anything-semantic-default-action elm) - (anything-match-line-color-current-line))) + (helm-semantic-default-action elm) + (helm-match-line-color-current-line))) (persistent-help . "Show this entry") - (action . anything-semantic-default-action) + (action . helm-semantic-default-action) "Needs semantic in CEDET. http://cedet.sourceforge.net/semantic.shtml @@ -7278,37 +7218,37 @@ http://cedet.sourceforge.net/")) -;;; Anything interface of `simple-call-tree.el'. +;;; Helm interface of `simple-call-tree.el'. ;; ;; ;; ;; Function is called by -(defvar anything-c-source-simple-call-tree-functions-callers +(defvar helm-c-source-simple-call-tree-functions-callers '((name . "Function is called by") - (init . anything-c-simple-call-tree-functions-callers-init) + (init . helm-c-simple-call-tree-functions-callers-init) (multiline) - (candidates . anything-c-simple-call-tree-candidates) - (persistent-action . anything-c-simple-call-tree-persistent-action) + (candidates . helm-c-simple-call-tree-candidates) + (persistent-action . helm-c-simple-call-tree-persistent-action) (persistent-help . "Show function definitions by rotation") (action ("Find definition selected by persistent-action" . - anything-c-simple-call-tree-find-definition))) + helm-c-simple-call-tree-find-definition))) "Needs simple-call-tree.el. http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el") -(defvar anything-c-simple-call-tree-tick nil) -(make-variable-buffer-local 'anything-c-simple-call-tree-tick) -(defun anything-c-simple-call-tree-analyze-maybe () - (unless (eq (buffer-chars-modified-tick) anything-c-simple-call-tree-tick) +(defvar helm-c-simple-call-tree-tick nil) +(make-variable-buffer-local 'helm-c-simple-call-tree-tick) +(defun helm-c-simple-call-tree-analyze-maybe () + (unless (eq (buffer-chars-modified-tick) helm-c-simple-call-tree-tick) (simple-call-tree-analyze) - (setq anything-c-simple-call-tree-tick (buffer-chars-modified-tick)))) + (setq helm-c-simple-call-tree-tick (buffer-chars-modified-tick)))) -(defun anything-c-simple-call-tree-init-base (function message) +(defun helm-c-simple-call-tree-init-base (function message) (require 'simple-call-tree) (with-no-warnings - (when (anything-current-buffer-is-modified) - (anything-c-simple-call-tree-analyze-maybe) + (when (helm-current-buffer-is-modified) + (helm-c-simple-call-tree-analyze-maybe) (let ((list (funcall function simple-call-tree-alist))) - (with-current-buffer (anything-candidate-buffer 'local) + (with-current-buffer (helm-candidate-buffer 'local) (dolist (entry list) (let ((funcs (concat " " (mapconcat #'identity (cdr entry) "\n ")))) (insert (car entry) message @@ -7317,69 +7257,69 @@ http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el") funcs) "\n\n")))))))) -(defun anything-c-simple-call-tree-functions-callers-init () - (anything-c-simple-call-tree-init-base 'simple-call-tree-invert +(defun helm-c-simple-call-tree-functions-callers-init () + (helm-c-simple-call-tree-init-base 'simple-call-tree-invert " is called by\n")) -(defun anything-c-simple-call-tree-candidates () - (with-current-buffer (anything-candidate-buffer) +(defun helm-c-simple-call-tree-candidates () + (with-current-buffer (helm-candidate-buffer) (split-string (buffer-string) "\n\n"))) -(defvar anything-c-simple-call-tree-related-functions nil) -(defvar anything-c-simple-call-tree-function-index 0) -(defun anything-c-simple-call-tree-persistent-action (candidate) - (unless (eq last-command 'anything-execute-persistent-action) - (setq anything-c-simple-call-tree-related-functions +(defvar helm-c-simple-call-tree-related-functions nil) +(defvar helm-c-simple-call-tree-function-index 0) +(defun helm-c-simple-call-tree-persistent-action (candidate) + (unless (eq last-command 'helm-execute-persistent-action) + (setq helm-c-simple-call-tree-related-functions (delete "no functions." (split-string (replace-regexp-in-string " \\| is called by\\| calls " "" candidate) "\n"))) - (setq anything-c-simple-call-tree-function-index -1)) - (incf anything-c-simple-call-tree-function-index) - (anything-c-simple-call-tree-find-definition candidate)) + (setq helm-c-simple-call-tree-function-index -1)) + (incf helm-c-simple-call-tree-function-index) + (helm-c-simple-call-tree-find-definition candidate)) -(defun anything-c-simple-call-tree-find-definition (candidate) +(defun helm-c-simple-call-tree-find-definition (candidate) (find-function (intern - (nth (mod anything-c-simple-call-tree-function-index - (length anything-c-simple-call-tree-related-functions)) - anything-c-simple-call-tree-related-functions)))) + (nth (mod helm-c-simple-call-tree-function-index + (length helm-c-simple-call-tree-related-functions)) + helm-c-simple-call-tree-related-functions)))) ;;; Function calls -(defvar anything-c-source-simple-call-tree-callers-functions +(defvar helm-c-source-simple-call-tree-callers-functions '((name . "Function calls") - (init . anything-c-simple-call-tree-callers-functions-init) + (init . helm-c-simple-call-tree-callers-functions-init) (multiline) - (candidates . anything-c-simple-call-tree-candidates) - (persistent-action . anything-c-simple-call-tree-persistent-action) + (candidates . helm-c-simple-call-tree-candidates) + (persistent-action . helm-c-simple-call-tree-persistent-action) (persistent-help . "Show function definitions by rotation") (action ("Find definition selected by persistent-action" . - anything-c-simple-call-tree-find-definition))) + helm-c-simple-call-tree-find-definition))) "Needs simple-call-tree.el. http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el") -(defun anything-c-simple-call-tree-callers-functions-init () - (anything-c-simple-call-tree-init-base 'identity " calls \n")) +(defun helm-c-simple-call-tree-callers-functions-init () + (helm-c-simple-call-tree-init-base 'identity " calls \n")) -;;; Anything UI of auto-document.el +;;; Helm UI of auto-document.el ;; ;; ;; ;; Commands/Options with doc -(defvar anything-c-auto-document-data nil) -(make-variable-buffer-local 'anything-c-auto-document-data) -(defvar anything-c-source-commands-and-options-in-file +(defvar helm-c-auto-document-data nil) +(make-variable-buffer-local 'helm-c-auto-document-data) +(defvar helm-c-source-commands-and-options-in-file '((name . "Commands/Options in file") (header-name . (lambda (x) (format "Commands/Options in %s" (buffer-local-value 'buffer-file-name - anything-current-buffer)))) - (candidates . anything-command-and-options-candidates) + helm-current-buffer)))) + (candidates . helm-command-and-options-candidates) (multiline) (action . imenu)) "List Commands and Options with doc. It needs auto-document.el . @@ -7387,16 +7327,16 @@ http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el") http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") (eval-when-compile (require 'auto-document nil t)) -(defun anything-command-and-options-candidates () - (with-anything-current-buffer +(defun helm-command-and-options-candidates () + (with-helm-current-buffer (when (and (require 'auto-document nil t) (eq major-mode 'emacs-lisp-mode) - (or (anything-current-buffer-is-modified) - (not anything-c-auto-document-data))) + (or (helm-current-buffer-is-modified) + (not helm-c-auto-document-data))) (or imenu--index-alist (imenu--make-index-alist t)) - (setq anything-c-auto-document-data + (setq helm-c-auto-document-data (destructuring-bind (commands options) - (adoc-construct anything-current-buffer) + (adoc-construct helm-current-buffer) (append (loop for (command . doc) in commands for cmdname = (symbol-name command) @@ -7417,7 +7357,7 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") (adoc-prin1-to-string default)) (assoc optname var-alist))))))) - anything-c-auto-document-data)) + helm-c-auto-document-data)) @@ -7427,13 +7367,13 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") ;;; Customize Face ;; ;; -(defvar anything-c-source-customize-face +(defvar helm-c-source-customize-face '((name . "Customize Face") (init . (lambda () - (unless (anything-candidate-buffer) + (unless (helm-candidate-buffer) (save-selected-window (list-faces-display)) - (anything-candidate-buffer (get-buffer "*Faces*"))))) + (helm-candidate-buffer (get-buffer "*Faces*"))))) (candidates-in-buffer) (get-line . buffer-substring) (action . (lambda (line) @@ -7444,27 +7384,27 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") ;;; Colors browser ;; ;; -(defvar anything-c-source-colors +(defvar helm-c-source-colors '((name . "Colors") - (init . (lambda () (unless (anything-candidate-buffer) + (init . (lambda () (unless (helm-candidate-buffer) (save-selected-window (list-colors-display)) - (anything-candidate-buffer (get-buffer "*Colors*"))))) + (helm-candidate-buffer (get-buffer "*Colors*"))))) (candidates-in-buffer) (get-line . buffer-substring) (action ("Copy Name" . (lambda (candidate) - (kill-new (anything-c-colors-get-name candidate)))) + (kill-new (helm-c-colors-get-name candidate)))) ("Copy RGB" . (lambda (candidate) - (kill-new (anything-c-colors-get-rgb candidate)))) + (kill-new (helm-c-colors-get-rgb candidate)))) ("Insert Name" . (lambda (candidate) - (with-anything-current-buffer - (insert (anything-c-colors-get-name candidate))))) + (with-helm-current-buffer + (insert (helm-c-colors-get-name candidate))))) ("Insert RGB" . (lambda (candidate) - (with-anything-current-buffer - (insert (anything-c-colors-get-rgb candidate)))))))) + (with-helm-current-buffer + (insert (helm-c-colors-get-rgb candidate)))))))) -(defun anything-c-colors-get-name (candidate) +(defun helm-c-colors-get-name (candidate) "Get color name." (replace-regexp-in-string " " "" @@ -7475,7 +7415,7 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") (delete-region (point) (point-max)) (buffer-string)))) -(defun anything-c-colors-get-rgb (candidate) +(defun helm-c-colors-get-rgb (candidate) "Get color RGB." (replace-regexp-in-string " " "" @@ -7489,12 +7429,12 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") ;;;; ;;; Tracker desktop search -(defvar anything-c-source-tracker-search +(defvar helm-c-source-tracker-search '((name . "Tracker Search") (candidates . (lambda () (start-process "tracker-search-process" nil "tracker-search" - anything-pattern))) + helm-pattern))) (type . file) (requires-pattern . 3) (delayed)) @@ -7502,10 +7442,10 @@ http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el") with the tracker desktop search.") ;;; Spotlight (MacOS X desktop search) -(defvar anything-c-source-mac-spotlight +(defvar helm-c-source-mac-spotlight '((name . "mdfind") (candidates - . (lambda () (start-process "mdfind-process" nil "mdfind" anything-pattern))) + . (lambda () (start-process "mdfind-process" nil "mdfind" helm-pattern))) (type . file) (requires-pattern . 3) (delayed)) @@ -7513,7 +7453,7 @@ with the tracker desktop search.") utility mdfind.") ;;; Picklist -(defvar anything-c-source-picklist +(defvar helm-c-source-picklist '((name . "Picklist") (candidates . (lambda () (mapcar 'car picklist-list))) (type . file))) @@ -7523,30 +7463,30 @@ utility mdfind.") ;;; Kill ring ;; ;; -(defvar anything-c-source-kill-ring +(defvar helm-c-source-kill-ring `((name . "Kill Ring") - (init . (lambda () (anything-attrset 'last-command last-command))) - (candidates . anything-c-kill-ring-candidates) - (filtered-candidate-transformer anything-c-kill-ring-transformer) - (action . anything-c-kill-ring-action) - (keymap . ,anything-kill-ring-map) + (init . (lambda () (helm-attrset 'last-command last-command))) + (candidates . helm-c-kill-ring-candidates) + (filtered-candidate-transformer helm-c-kill-ring-transformer) + (action . helm-c-kill-ring-action) + (keymap . ,helm-kill-ring-map) (last-command) (migemo) (multiline)) "Source for browse and insert contents of kill-ring.") -(defun anything-c-kill-ring-candidates () - (loop for kill in (anything-fast-remove-dups kill-ring :test 'equal) - unless (or (< (length kill) anything-kill-ring-threshold) +(defun helm-c-kill-ring-candidates () + (loop for kill in (helm-fast-remove-dups kill-ring :test 'equal) + unless (or (< (length kill) helm-kill-ring-threshold) (string-match "^[\\s\\t]+$" kill)) collect kill)) -(defun anything-c-kill-ring-transformer (candidates source) - "Display only the `anything-c-kill-ring-max-lines-number' lines of candidate." +(defun helm-c-kill-ring-transformer (candidates source) + "Display only the `helm-c-kill-ring-max-lines-number' lines of candidate." (loop for i in candidates for nlines = (with-temp-buffer (insert i) (count-lines (point-min) (point-max))) - if (and anything-c-kill-ring-max-lines-number - (> nlines anything-c-kill-ring-max-lines-number)) + if (and helm-c-kill-ring-max-lines-number + (> nlines helm-c-kill-ring-max-lines-number)) collect (cons (with-temp-buffer (insert i) @@ -7555,17 +7495,17 @@ utility mdfind.") (buffer-substring (point-min) (save-excursion - (forward-line anything-c-kill-ring-max-lines-number) + (forward-line helm-c-kill-ring-max-lines-number) (point))) "[...]")) i) else collect i)) -(defun anything-c-kill-ring-action (str) +(defun helm-c-kill-ring-action (str) "Insert STR in `kill-ring' and set STR to the head. If this action is executed just after `yank', replace with STR as yanked string." (setq kill-ring (delete str kill-ring)) - (if (not (eq (anything-attr 'last-command) 'yank)) + (if (not (eq (helm-attr 'last-command) 'yank)) (insert-for-yank str) ;; from `yank-pop' (let ((inhibit-read-only t) @@ -7590,11 +7530,11 @@ replace with STR as yanked string." ;;;; -;; DO NOT include these sources in `anything-sources' use -;; the commands `anything-mark-ring', `anything-global-mark-ring' or -;; `anything-all-mark-rings' instead. +;; DO NOT include these sources in `helm-sources' use +;; the commands `helm-mark-ring', `helm-global-mark-ring' or +;; `helm-all-mark-rings' instead. -(defun anything-c-source-mark-ring-candidates () +(defun helm-c-source-mark-ring-candidates () (flet ((get-marks (pos) (save-excursion (goto-char pos) @@ -7603,7 +7543,7 @@ replace with STR as yanked string." (when (string= "" line) (setq line "")) (format "%7d: %s" (line-number-at-pos) line))))) - (with-anything-current-buffer + (with-helm-current-buffer (loop with marks = (if (mark) (cons (mark-marker) mark-ring) mark-ring) with recip = nil @@ -7613,41 +7553,41 @@ replace with STR as yanked string." collect m into recip finally return recip)))) -(defvar anything-mark-ring-cache nil) -(defvar anything-c-source-mark-ring +(defvar helm-mark-ring-cache nil) +(defvar helm-c-source-mark-ring '((name . "mark-ring") (init . (lambda () - (setq anything-mark-ring-cache - (ignore-errors (anything-c-source-mark-ring-candidates))))) + (setq helm-mark-ring-cache + (ignore-errors (helm-c-source-mark-ring-candidates))))) (candidates . (lambda () - (anything-aif anything-mark-ring-cache + (helm-aif helm-mark-ring-cache it))) (action . (("Goto line" . (lambda (candidate) - (anything-goto-line (string-to-number candidate)))))) + (helm-goto-line (string-to-number candidate)))))) (persistent-action . (lambda (candidate) - (anything-goto-line (string-to-number candidate)) - (anything-match-line-color-current-line))) + (helm-goto-line (string-to-number candidate)) + (helm-match-line-color-current-line))) (persistent-help . "Show this line"))) ;;; Global-mark-ring -(defvar anything-c-source-global-mark-ring +(defvar helm-c-source-global-mark-ring '((name . "global-mark-ring") - (candidates . anything-c-source-global-mark-ring-candidates) + (candidates . helm-c-source-global-mark-ring-candidates) (action . (("Goto line" . (lambda (candidate) (let ((items (split-string candidate ":"))) - (anything-c-switch-to-buffer (second items)) - (anything-goto-line (string-to-number (car items)))))))) + (helm-c-switch-to-buffer (second items)) + (helm-goto-line (string-to-number (car items)))))))) (persistent-action . (lambda (candidate) (let ((items (split-string candidate ":"))) - (anything-c-switch-to-buffer (second items)) - (anything-goto-line (string-to-number (car items))) - (anything-match-line-color-current-line)))) + (helm-c-switch-to-buffer (second items)) + (helm-goto-line (string-to-number (car items))) + (helm-match-line-color-current-line)))) (persistent-help . "Show this line"))) -(defun anything-c-source-global-mark-ring-candidates () +(defun helm-c-source-global-mark-ring-candidates () (flet ((buf-fn (m) (with-current-buffer (marker-buffer m) (goto-char m) @@ -7675,15 +7615,15 @@ replace with STR as yanked string." ;;;; ;;; Insert from register -(defvar anything-c-source-register +(defvar helm-c-source-register '((name . "Registers") - (candidates . anything-c-register-candidates) - (action-transformer . anything-c-register-action-transformer) + (candidates . helm-c-register-candidates) + (action-transformer . helm-c-register-action-transformer) (multiline) (action)) "See (info \"(emacs)Registers\")") -(defun anything-c-register-candidates () +(defun helm-c-register-candidates () "Collecting register contents and appropriate commands." (loop for (char . val) in register-alist for key = (single-key-description char) @@ -7733,8 +7673,8 @@ replace with STR as yanked string." (list ;; without properties (concat (substring-no-properties - val 0 (min (length val) anything-c-register-max-offset)) - (if (> (length val) anything-c-register-max-offset) + val 0 (min (length val) helm-c-register-max-offset)) + (if (> (length val) helm-c-register-max-offset) "[...]" "")) 'insert-register 'append-to-register @@ -7748,7 +7688,7 @@ replace with STR as yanked string." collect (cons (format "register %3s: %s" key (car string-actions)) (cons char (cdr string-actions))))) -(defun anything-c-register-action-transformer (actions register-and-functions) +(defun helm-c-register-action-transformer (actions register-and-functions) "Decide actions by the contents of register." (loop with func-actions = '((insert-register @@ -7768,7 +7708,7 @@ replace with STR as yanked string." (increment-register "Increment Prefix Arg to Register" . (lambda (c) (increment-register - anything-current-prefix-arg (car c)))) + helm-current-prefix-arg (car c)))) (undo-tree-restore-state-from-register "Restore Undo-tree register" (lambda (c) (and (fboundp 'undo-tree-restore-state-from-register) @@ -7781,7 +7721,7 @@ replace with STR as yanked string." ;;; Latex completion -(defun anything-c-latex-math-candidates () +(defun helm-c-latex-math-candidates () "Collect candidates for latex math completion." (declare (special LaTeX-math-menu)) (loop for i in (cddr LaTeX-math-menu) @@ -7789,26 +7729,26 @@ replace with STR as yanked string." collect (cons (aref s 0) (aref s 1))) append elm)) -(defvar anything-c-source-latex-math +(defvar helm-c-source-latex-math '((name . "Latex Math Menu") (init . (lambda () - (with-anything-current-buffer + (with-helm-current-buffer (LaTeX-math-mode 1)))) (candidate-number-limit . 9999) - (candidates . anything-c-latex-math-candidates) + (candidates . helm-c-latex-math-candidates) (action . (lambda (candidate) (call-interactively candidate))))) ;;;; -(defvar anything-c-source-fixme +(defvar helm-c-source-fixme '((name . "TODO/FIXME/DRY comments") (headline . "^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$") (adjust) (recenter)) "Show TODO/FIXME/DRY comments in current file.") -(defvar anything-c-source-rd-headline +(defvar helm-c-source-rd-headline '((name . "RD HeadLine") (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$") (condition . (memq major-mode '(rdgrep-mode rd-mode))) @@ -7819,7 +7759,7 @@ replace with STR as yanked string." RD is Ruby's POD. http://en.wikipedia.org/wiki/Ruby_Document_format") -(defvar anything-c-source-oddmuse-headline +(defvar helm-c-source-oddmuse-headline '((name . "Oddmuse HeadLine") (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$" "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$") @@ -7828,14 +7768,14 @@ http://en.wikipedia.org/wiki/Ruby_Document_format") (subexp . 1)) "Show Oddmuse headlines, such as EmacsWiki.") -(defvar anything-c-source-emacs-source-defun +(defvar helm-c-source-emacs-source-defun '((name . "Emacs Source DEFUN") (headline . "DEFUN\\|DEFVAR") (condition . (string-match "/emacs2[0-9].+/src/.+c$" (or buffer-file-name "")))) "Show DEFUN/DEFVAR in Emacs C source file.") -(defvar anything-c-source-emacs-lisp-expectations +(defvar helm-c-source-emacs-lisp-expectations '((name . "Emacs Lisp Expectations") (headline . "(desc[ ]\\|(expectations") (condition . (eq major-mode 'emacs-lisp-mode))) @@ -7843,7 +7783,7 @@ http://en.wikipedia.org/wiki/Ruby_Document_format") http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el") -(defvar anything-c-source-emacs-lisp-toplevels +(defvar helm-c-source-emacs-lisp-toplevels '((name . "Emacs Lisp Toplevel / Level 4 Comment / Linkd Star") (headline . "^(\\|(@\\*\\|^;;;;") (get-line . buffer-substring) @@ -7854,29 +7794,29 @@ linkd.el is optional because linkd stars are extracted by regexp. http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el") -;;; Anything yaoddmuse +;;; Helm yaoddmuse ;; ;; Be sure to have yaoddmuse.el installed ;; install-elisp may be required if you want to install elisp file from here. -(defvar anything-yaoddmuse-use-cache-file nil) -(defvar anything-c-yaoddmuse-cache-file "~/.emacs.d/yaoddmuse-cache.el") -(defvar anything-c-yaoddmuse-ew-cache nil) +(defvar helm-yaoddmuse-use-cache-file nil) +(defvar helm-c-yaoddmuse-cache-file "~/.emacs.d/yaoddmuse-cache.el") +(defvar helm-c-yaoddmuse-ew-cache nil) -(defun anything-yaoddmuse-get-candidates () +(defun helm-yaoddmuse-get-candidates () (declare (special yaoddmuse-pages-hash)) - (if anything-yaoddmuse-use-cache-file + (if helm-yaoddmuse-use-cache-file (ignore-errors - (unless anything-c-yaoddmuse-ew-cache - (load anything-c-yaoddmuse-cache-file) - (setq anything-c-yaoddmuse-ew-cache + (unless helm-c-yaoddmuse-ew-cache + (load helm-c-yaoddmuse-cache-file) + (setq helm-c-yaoddmuse-ew-cache (gethash "EmacsWiki" yaoddmuse-pages-hash))) - anything-c-yaoddmuse-ew-cache) + helm-c-yaoddmuse-ew-cache) (yaoddmuse-update-pagename t) (gethash "EmacsWiki" yaoddmuse-pages-hash))) -(defvar anything-c-source-yaoddmuse-emacswiki-edit-or-view +(defvar helm-c-source-yaoddmuse-emacswiki-edit-or-view '((name . "Yaoddmuse Edit or View (EmacsWiki)") - (candidates . anything-yaoddmuse-get-candidates) + (candidates . helm-yaoddmuse-get-candidates) (action . (("Edit page" . (lambda (candidate) (yaoddmuse-edit "EmacsWiki" candidate))) ("Browse page" @@ -7896,24 +7836,24 @@ http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el") (message "Have copy page %s's URL to yank." candidate))) ("Create page" . (lambda (candidate) - (yaoddmuse-edit "EmacsWiki" anything-input))) + (yaoddmuse-edit "EmacsWiki" helm-input))) ("Update cache" . (lambda (candidate) - (if anything-yaoddmuse-use-cache-file + (if helm-yaoddmuse-use-cache-file (progn - (anything-yaoddmuse-cache-pages t) - (setq anything-c-yaoddmuse-ew-cache + (helm-yaoddmuse-cache-pages t) + (setq helm-c-yaoddmuse-ew-cache (gethash "EmacsWiki" yaoddmuse-pages-hash))) (yaoddmuse-update-pagename)))))) - (action-transformer anything-c-yaoddmuse-action-transformer)) + (action-transformer helm-c-yaoddmuse-action-transformer)) "Needs yaoddmuse.el. http://www.emacswiki.org/emacs/download/yaoddmuse.el") -(defvar anything-c-source-yaoddmuse-emacswiki-post-library +(defvar helm-c-source-yaoddmuse-emacswiki-post-library '((name . "Yaoddmuse Post library (EmacsWiki)") - (init . (anything-yaoddmuse-init)) + (init . (helm-yaoddmuse-init)) (candidates-in-buffer) (action . (("Post library and Browse" . (lambda (candidate) @@ -7934,7 +7874,7 @@ http://www.emacswiki.org/emacs/download/yaoddmuse.el") http://www.emacswiki.org/emacs/download/yaoddmuse.el") -(defun anything-c-yaoddmuse-action-transformer (actions candidate) +(defun helm-c-yaoddmuse-action-transformer (actions candidate) "Allow the use of `install-elisp' only on elisp files." (if (string-match "\.el$" candidate) (append actions '(("Install Elisp" @@ -7943,14 +7883,14 @@ http://www.emacswiki.org/emacs/download/yaoddmuse.el") actions)) ;;;###autoload -(defun anything-yaoddmuse-cache-pages (&optional load) +(defun helm-yaoddmuse-cache-pages (&optional load) "Fetch the list of files on emacswiki and create cache file. If load is non--nil load the file and feed `yaoddmuse-pages-hash'." (interactive) (declare (special yaoddmuse-pages-hash)) (yaoddmuse-update-pagename) (save-excursion - (find-file anything-c-yaoddmuse-cache-file) + (find-file helm-c-yaoddmuse-cache-file) (erase-buffer) (insert "(puthash \"EmacsWiki\" '(") (loop for i in (gethash "EmacsWiki" yaoddmuse-pages-hash) @@ -7961,13 +7901,13 @@ If load is non--nil load the file and feed `yaoddmuse-pages-hash'." (kill-buffer (current-buffer)) (when (or current-prefix-arg load) - (load anything-c-yaoddmuse-cache-file)))) + (load helm-c-yaoddmuse-cache-file)))) -(defun anything-yaoddmuse-init () - "Init anything buffer status." - (let ((anything-buffer (anything-candidate-buffer 'global)) +(defun helm-yaoddmuse-init () + "Init helm buffer status." + (let ((helm-buffer (helm-candidate-buffer 'global)) (library-list (yaoddmuse-get-library-list))) - (with-current-buffer anything-buffer + (with-current-buffer helm-buffer ;; Insert library name. (dolist (library library-list) (insert (format "%s\n" library))) @@ -7976,12 +7916,12 @@ If load is non--nil load the file and feed `yaoddmuse-pages-hash'." ;;; Eev anchors -(defvar anything-c-source-eev-anchor +(defvar helm-c-source-eev-anchor '((name . "Anchors") (candidates . (lambda () (ignore-errors - (with-anything-current-buffer + (with-helm-current-buffer (loop initially (goto-char (point-min)) while (re-search-forward (format ee-anchor-format "\\([^\.].+\\)") nil t) @@ -7992,7 +7932,7 @@ If load is non--nil load the file and feed `yaoddmuse-pages-hash'." anchor)))))) (persistent-action . (lambda (item) (ee-to item) - (anything-match-line-color-current-line))) + (helm-match-line-color-current-line))) (persistent-help . "Show this entry") (action . (("Goto link" . ee-to))))) @@ -8000,7 +7940,7 @@ If load is non--nil load the file and feed `yaoddmuse-pages-hash'." ;;; Org headlines ;; ;; -(defvar anything-c-source-org-headline +(defvar helm-c-source-org-headline `((name . "Org HeadLine") (headline ,@(mapcar @@ -8012,32 +7952,32 @@ If load is non--nil load the file and feed `yaoddmuse-pages-hash'." (migemo) (subexp . 1) (persistent-action . (lambda (elm) - (anything-c-action-line-goto elm) + (helm-c-action-line-goto elm) (org-cycle))) (action-transformer . (lambda (actions candidate) - '(("Go to Line" . anything-c-action-line-goto) - ("Refile to this Headline" . anything-c-org-headline-refile) + '(("Go to Line" . helm-c-action-line-goto) + ("Refile to this Headline" . helm-c-org-headline-refile) ("Insert Link to This Headline" - . anything-c-org-headline-insert-link-to-headline))))) + . helm-c-org-headline-insert-link-to-headline))))) "Show Org headlines. org-mode is very very much extended text-mode/outline-mode. See (find-library \"org.el\") See http://orgmode.org for the latest version.") -(defun anything-c-org-headline-insert-link-to-headline (lineno-and-content) +(defun helm-c-org-headline-insert-link-to-headline (lineno-and-content) (insert (save-excursion - (anything-goto-line (car lineno-and-content)) + (helm-goto-line (car lineno-and-content)) (and (looking-at org-complex-heading-regexp) (org-make-link-string (concat "*" (match-string 4))))))) -(defun anything-c-org-headline-refile (lineno-and-content) +(defun helm-c-org-headline-refile (lineno-and-content) "Refile current org entry to LINENO-AND-CONTENT." - (with-anything-current-buffer + (with-helm-current-buffer (org-cut-subtree) - (anything-goto-line (car lineno-and-content)) + (helm-goto-line (car lineno-and-content)) (org-end-of-subtree t t) (let ((org-yank-adjusted-subtrees t)) (org-yank)))) @@ -8046,17 +7986,17 @@ See http://orgmode.org for the latest version.") ;;; Org keywords ;; ;; -(defvar anything-c-source-org-keywords +(defvar helm-c-source-org-keywords '((name . "Org Keywords") - (init . anything-c-org-keywords-init) - (candidates . anything-c-org-keywords-candidates) - (action . anything-c-org-keywords-insert) - (persistent-action . anything-c-org-keywords-show-help) + (init . helm-c-org-keywords-init) + (candidates . helm-c-org-keywords-candidates) + (action . helm-c-org-keywords-insert) + (persistent-action . helm-c-org-keywords-show-help) (persistent-help . "Show an example and info page to describe this keyword.") (keywords-examples) (keywords))) -(defvar anything-c-org-keywords-info-location +(defvar helm-c-org-keywords-info-location '(("#+TITLE:" . "(org)Export options") ("#+AUTHOR:" . "(org)Export options") ("#+DATE:" . "(org)Export options") @@ -8089,10 +8029,10 @@ See http://orgmode.org for the latest version.") ("#+ATTR_HTML" . "(org)Links") ("#+ATTR_LaTeX" . "(org)Images in LaTeX export"))) -(defun anything-c-org-keywords-init () - (unless (anything-attr 'keywords-examples) +(defun helm-c-org-keywords-init () + (unless (helm-attr 'keywords-examples) (require 'org) - (anything-attrset 'keywords-examples + (helm-attrset 'keywords-examples (append (mapcar (lambda (x) @@ -8100,16 +8040,16 @@ See http://orgmode.org for the latest version.") (cons (match-string 2 x) (match-string 1 x))) (org-split-string (org-get-current-options) "\n")) (mapcar 'list org-additional-option-like-keywords))) - (anything-attrset 'keywords (mapcar 'car (anything-attr 'keywords-examples))))) + (helm-attrset 'keywords (mapcar 'car (helm-attr 'keywords-examples))))) -(defun anything-c-org-keywords-candidates () - (and (or (eq (buffer-local-value 'major-mode anything-current-buffer) 'org-mode) - (eq (buffer-local-value 'major-mode anything-current-buffer) 'message-mode)) - (anything-attr 'keywords))) +(defun helm-c-org-keywords-candidates () + (and (or (eq (buffer-local-value 'major-mode helm-current-buffer) 'org-mode) + (eq (buffer-local-value 'major-mode helm-current-buffer) 'message-mode)) + (helm-attr 'keywords))) -(defun anything-c-org-keywords-insert (keyword) +(defun helm-c-org-keywords-insert (keyword) (cond ((and (string-match "BEGIN" keyword) - (anything-region-active-p)) + (helm-region-active-p)) (let ((beg (region-beginning)) (end (region-end))) (goto-char end) @@ -8125,12 +8065,12 @@ See http://orgmode.org for the latest version.") "BEGIN" "END" keyword) "\n"))) (t (insert "#+" keyword " ")))) -(defun anything-c-org-keywords-show-help (keyword) - (info (or (assoc-default (concat "#+" keyword) anything-c-org-keywords-info-location) +(defun helm-c-org-keywords-show-help (keyword) + (info (or (assoc-default (concat "#+" keyword) helm-c-org-keywords-info-location) "(org)In-buffer settings")) (search-forward (concat "#+" keyword) nil t) - (anything-persistent-highlight-point) - (message "%s" (or (cdr (assoc keyword (anything-attr 'keywords-examples))) ""))) + (helm-persistent-highlight-point) + (message "%s" (or (cdr (assoc keyword (helm-attr 'keywords-examples))) ""))) @@ -8140,7 +8080,7 @@ See http://orgmode.org for the latest version.") (defvar bbdb-records) (defvar bbdb-buffer-name) -(defun anything-c-bbdb-candidates () +(defun helm-c-bbdb-candidates () "Return a list of all names in the bbdb database. The format is \"Firstname Lastname\"." (mapcar (lambda (bbdb-record) @@ -8149,14 +8089,14 @@ is \"Firstname Lastname\"." (concat (aref bbdb-record 0) " " (aref bbdb-record 1)))) (bbdb-records))) -(defun anything-c-bbdb-create-contact (actions candidate) +(defun helm-c-bbdb-create-contact (actions candidate) "Action transformer that returns only an entry to add the -current `anything-pattern' as new contact. All other actions are +current `helm-pattern' as new contact. All other actions are removed." (if (string= candidate "*Add to contacts*") '(("Add to contacts" . (lambda (actions) (bbdb-create-internal - (read-from-minibuffer "Name: " anything-c-bbdb-name) + (read-from-minibuffer "Name: " helm-c-bbdb-name) (read-from-minibuffer "Company: ") (read-from-minibuffer "Email: ") nil @@ -8164,50 +8104,50 @@ removed." (read-from-minibuffer "Note: "))))) actions)) -(defun anything-c-bbdb-get-record (candidate) +(defun helm-c-bbdb-get-record (candidate) "Return record that match CANDIDATE." (bbdb candidate nil) (set-buffer "*BBDB*") (bbdb-current-record)) -(defvar anything-c-bbdb-name nil +(defvar helm-c-bbdb-name nil "Only for internal use.") -(defvar anything-c-source-bbdb +(defvar helm-c-source-bbdb '((name . "BBDB") - (candidates . anything-c-bbdb-candidates) - (action ("Send a mail" . anything-c-bbdb-compose-mail) - ("View person's data" . anything-c-bbdb-view-person-action)) + (candidates . helm-c-bbdb-candidates) + (action ("Send a mail" . helm-c-bbdb-compose-mail) + ("View person's data" . helm-c-bbdb-view-person-action)) (filtered-candidate-transformer . (lambda (candidates source) - (setq anything-c-bbdb-name anything-pattern) + (setq helm-c-bbdb-name helm-pattern) (if (not candidates) (list "*Add to contacts*") candidates))) (action-transformer . (lambda (actions candidate) - (anything-c-bbdb-create-contact actions candidate)))) + (helm-c-bbdb-create-contact actions candidate)))) "Needs BBDB. http://bbdb.sourceforge.net/") -(defun anything-c-bbdb-view-person-action (candidate) +(defun helm-c-bbdb-view-person-action (candidate) "View BBDB data of single CANDIDATE or marked candidates." - (anything-aif (anything-marked-candidates) + (helm-aif (helm-marked-candidates) (let ((bbdb-append-records (length it))) (dolist (i it) - (bbdb-redisplay-one-record (anything-c-bbdb-get-record i)))) - (bbdb-redisplay-one-record (anything-c-bbdb-get-record candidate)))) + (bbdb-redisplay-one-record (helm-c-bbdb-get-record i)))) + (bbdb-redisplay-one-record (helm-c-bbdb-get-record candidate)))) -(defun anything-c-bbdb-collect-mail-addresses () +(defun helm-c-bbdb-collect-mail-addresses () "Return a list of all mail addresses of records in bbdb buffer." (with-current-buffer bbdb-buffer-name (loop for i in bbdb-records if (bbdb-record-net (car i)) collect (bbdb-dwim-net-address (car i))))) -(defun anything-c-bbdb-compose-mail (candidate) +(defun helm-c-bbdb-compose-mail (candidate) "Compose a mail with all records of bbdb buffer." - (anything-c-bbdb-view-person-action candidate) - (let* ((address-list (anything-c-bbdb-collect-mail-addresses)) + (helm-c-bbdb-view-person-action candidate) + (let* ((address-list (helm-c-bbdb-collect-mail-addresses)) (address-str (mapconcat 'identity address-list ",\n "))) (compose-mail address-str))) @@ -8216,10 +8156,10 @@ http://bbdb.sourceforge.net/") ;; ;; ;; Internal -(defvar anything-eldoc-active-minibuffers-list nil) -(defvar anything-eval-expression-input-history nil) +(defvar helm-eldoc-active-minibuffers-list nil) +(defvar helm-eval-expression-input-history nil) -(defvar anything-c-source-evaluation-result +(defvar helm-c-source-evaluation-result '((name . "Evaluation Result") (disable-shortcuts) (dummy) @@ -8228,34 +8168,34 @@ http://bbdb.sourceforge.net/") (filtered-candidate-transformer . (lambda (candidates source) (list (condition-case nil - (with-anything-current-buffer + (with-helm-current-buffer (pp-to-string - (eval (read anything-pattern)))) + (eval (read helm-pattern)))) (error "Error"))))) (action . (("Copy result to kill-ring" . (lambda (candidate) - (with-current-buffer anything-buffer + (with-current-buffer helm-buffer (let ((end (save-excursion (goto-char (point-max)) (search-backward "\n") (point)))) (kill-region (point) end))))) ("copy sexp to kill-ring" . (lambda (candidate) - (kill-new anything-input))))))) + (kill-new helm-input))))))) -(defun anything-eval-new-line-and-indent () +(defun helm-eval-new-line-and-indent () (interactive) (newline) (lisp-indent-line)) -(defun anything-eldoc-store-minibuffer () - "Store minibuffer buffer name in `anything-eldoc-active-minibuffers-list'." +(defun helm-eldoc-store-minibuffer () + "Store minibuffer buffer name in `helm-eldoc-active-minibuffers-list'." (with-selected-window (minibuffer-window) - (push (buffer-name) anything-eldoc-active-minibuffers-list))) + (push (buffer-name) helm-eldoc-active-minibuffers-list))) -(defun anything-eldoc-show-in-eval () +(defun helm-eldoc-show-in-eval () "Return eldoc in mode-line for current minibuffer input." (let ((buf (with-selected-window (minibuffer-window) (buffer-name)))) - (when (member buf anything-eldoc-active-minibuffers-list) + (when (member buf helm-eldoc-active-minibuffers-list) (let* ((str-all (with-current-buffer buf (minibuffer-completion-contents))) (sym (when str-all @@ -8268,27 +8208,27 @@ http://bbdb.sourceforge.net/") (doc (or (eldoc-get-var-docstring sym) (eldoc-get-fnsym-args-string (car info-fn) (cadr info-fn))))) - (when doc (funcall anything-c-eldoc-in-minibuffer-show-fn doc)))))) + (when doc (funcall helm-c-eldoc-in-minibuffer-show-fn doc)))))) -(defun anything-c-show-info-in-mode-line (str) +(defun helm-c-show-info-in-mode-line (str) "Display string STR in mode-line." (save-selected-window - (with-current-buffer anything-buffer + (with-current-buffer helm-buffer (let ((mode-line-format (concat " " str))) (force-mode-line-update) - (sit-for anything-c-show-info-in-mode-line-delay)) + (sit-for helm-c-show-info-in-mode-line-delay)) (force-mode-line-update)))) ;;; Calculation Result ;; ;; -(defvar anything-c-source-calculation-result +(defvar helm-c-source-calculation-result '((name . "Calculation Result") (dummy) (filtered-candidate-transformer . (lambda (candidates source) (list (condition-case nil - (calc-eval anything-pattern) + (calc-eval helm-pattern) (error "error"))))) (action ("Copy result to kill-ring" . kill-new)))) @@ -8297,15 +8237,15 @@ http://bbdb.sourceforge.net/") ;; ;; ;; Internal -(defvar anything-ggs-max-length-real-flag 0) -(defvar anything-ggs-max-length-num-flag 0) +(defvar helm-ggs-max-length-real-flag 0) +(defvar helm-ggs-max-length-num-flag 0) -(defun anything-c-google-suggest-fetch (input) +(defun helm-c-google-suggest-fetch (input) "Fetch suggestions for INPUT from XML buffer. Return an alist with elements like (data . number_results)." - (setq anything-ggs-max-length-real-flag 0 - anything-ggs-max-length-num-flag 0) - (let ((request (concat anything-c-google-suggest-url + (setq helm-ggs-max-length-real-flag 0 + helm-ggs-max-length-num-flag 0) + (let ((request (concat helm-c-google-suggest-url (url-hexify-string input)))) (flet ((fetch () (loop @@ -8316,18 +8256,18 @@ Return an alist with elements like (data . number_results)." for i in result-alist for data = (cdr (caadr (assoc 'suggestion i))) for nqueries = (cdr (caadr (assoc 'num_queries i))) - for lqueries = (length (anything-c-ggs-set-number-result + for lqueries = (length (helm-c-ggs-set-number-result nqueries)) for ldata = (length data) do (progn - (when (> ldata anything-ggs-max-length-real-flag) - (setq anything-ggs-max-length-real-flag ldata)) - (when (> lqueries anything-ggs-max-length-num-flag) - (setq anything-ggs-max-length-num-flag lqueries))) + (when (> ldata helm-ggs-max-length-real-flag) + (setq helm-ggs-max-length-real-flag ldata)) + (when (> lqueries helm-ggs-max-length-num-flag) + (setq helm-ggs-max-length-num-flag lqueries))) collect (cons data nqueries) into cont finally return cont))) - (if anything-google-suggest-use-curl-p + (if helm-google-suggest-use-curl-p (with-temp-buffer (call-process "curl" nil t nil request) (fetch)) @@ -8335,48 +8275,48 @@ Return an alist with elements like (data . number_results)." (url-retrieve-synchronously request) (fetch)))))) -(defun anything-c-google-suggest-set-candidates (&optional request-prefix) +(defun helm-c-google-suggest-set-candidates (&optional request-prefix) "Set candidates with result and number of google results found." (let ((suggestions - (loop with suggested-results = (anything-c-google-suggest-fetch + (loop with suggested-results = (helm-c-google-suggest-fetch (or (and request-prefix (concat request-prefix - " " anything-pattern)) - anything-pattern)) + " " helm-pattern)) + helm-pattern)) for (real . numresult) in suggested-results ;; Prepare number of results with "," - for fnumresult = (anything-c-ggs-set-number-result numresult) + for fnumresult = (helm-c-ggs-set-number-result numresult) ;; Calculate number of spaces to add before fnumresult ;; if it is smaller than longest result - ;; `anything-ggs-max-length-num-flag'. + ;; `helm-ggs-max-length-num-flag'. ;; e.g 1,234,567 ;; 345,678 ;; To be sure it is aligned properly. for nspaces = (if (< (length fnumresult) - anything-ggs-max-length-num-flag) - (- anything-ggs-max-length-num-flag + helm-ggs-max-length-num-flag) + (- helm-ggs-max-length-num-flag (length fnumresult)) 0) ;; Add now the spaces before fnumresult. for align-fnumresult = (concat (make-string nspaces ? ) fnumresult) - for interval = (- anything-ggs-max-length-real-flag + for interval = (- helm-ggs-max-length-real-flag (length real)) for spaces = (make-string (+ 2 interval) ? ) for display = (format "%s%s(%s results)" real spaces align-fnumresult) collect (cons display real)))) (if (loop for (disp . dat) in suggestions - thereis (equal dat anything-pattern)) + thereis (equal dat helm-pattern)) suggestions ;; if there is no suggestion exactly matching the input then ;; prepend a Search on Google item to the list (append suggestions - (list (cons (concat "Search for " "'" anything-input "'" " on Google") - anything-input)))))) + (list (cons (concat "Search for " "'" helm-input "'" " on Google") + helm-input)))))) -(defun anything-c-ggs-set-number-result (num) +(defun helm-c-ggs-set-number-result (num) (if num (progn (and (numberp num) (setq num (number-to-string num))) @@ -8391,44 +8331,44 @@ Return an alist with elements like (data . number_results)." "^," "" (mapconcat 'identity (reverse C) "")))) "?")) -(defvar anything-c-google-suggest-default-browser-function nil +(defvar helm-c-google-suggest-default-browser-function nil "*The browse url function you prefer to use with google suggest. When nil, use the first browser function available -See `anything-browse-url-default-browser-alist'.") +See `helm-browse-url-default-browser-alist'.") -(defun anything-c-google-suggest-action (candidate) +(defun helm-c-google-suggest-action (candidate) "Default action to jump to a google suggested candidate." - (let ((arg (concat anything-c-google-suggest-search-url + (let ((arg (concat helm-c-google-suggest-search-url (url-hexify-string candidate)))) - (anything-aif anything-c-google-suggest-default-browser-function + (helm-aif helm-c-google-suggest-default-browser-function (funcall it arg) - (anything-c-browse-url arg)))) + (helm-c-browse-url arg)))) -(defvar anything-c-google-suggest-default-function - 'anything-c-google-suggest-set-candidates - "Default function to use in anything google suggest.") +(defvar helm-c-google-suggest-default-function + 'helm-c-google-suggest-set-candidates + "Default function to use in helm google suggest.") -(defvar anything-c-source-google-suggest +(defvar helm-c-source-google-suggest '((name . "Google Suggest") (candidates . (lambda () - (funcall anything-c-google-suggest-default-function))) - (action . (("Google Search" . anything-c-google-suggest-action))) + (funcall helm-c-google-suggest-default-function))) + (action . (("Google Search" . helm-c-google-suggest-action))) (volatile) (requires-pattern . 3) (delayed))) -(defun anything-c-google-suggest-emacs-lisp () +(defun helm-c-google-suggest-emacs-lisp () "Try to emacs lisp complete with google suggestions." - (anything-c-google-suggest-set-candidates "emacs lisp")) + (helm-c-google-suggest-set-candidates "emacs lisp")) ;;; Yahoo suggestions ;; ;; -(defun anything-c-yahoo-suggest-fetch (input) +(defun helm-c-yahoo-suggest-fetch (input) "Fetch Yahoo suggestions for INPUT from XML buffer. Return an alist with elements like (data . number_results)." - (let ((request (concat anything-c-yahoo-suggest-url + (let ((request (concat helm-c-yahoo-suggest-url (url-hexify-string input)))) (flet ((fetch () (loop @@ -8442,24 +8382,24 @@ Return an alist with elements like (data . number_results)." (url-retrieve-synchronously request) (fetch))))) -(defun anything-c-yahoo-suggest-set-candidates () +(defun helm-c-yahoo-suggest-set-candidates () "Set candidates with Yahoo results found." - (let ((suggestions (anything-c-yahoo-suggest-fetch anything-input))) + (let ((suggestions (helm-c-yahoo-suggest-fetch helm-input))) (or suggestions (append suggestions - (list (cons (concat "Search for " "'" anything-input "'" " on Yahoo") - anything-input)))))) + (list (cons (concat "Search for " "'" helm-input "'" " on Yahoo") + helm-input)))))) -(defun anything-c-yahoo-suggest-action (candidate) +(defun helm-c-yahoo-suggest-action (candidate) "Default action to jump to a Yahoo suggested candidate." - (anything-c-browse-url (concat anything-c-yahoo-suggest-search-url + (helm-c-browse-url (concat helm-c-yahoo-suggest-search-url (url-hexify-string candidate)))) -(defvar anything-c-source-yahoo-suggest +(defvar helm-c-source-yahoo-suggest '((name . "Yahoo Suggest") - (candidates . anything-c-yahoo-suggest-set-candidates) - (action . (("Yahoo Search" . anything-c-yahoo-suggest-action))) + (candidates . helm-c-yahoo-suggest-set-candidates) + (action . (("Yahoo Search" . helm-c-yahoo-suggest-action))) (volatile) (requires-pattern . 3) (delayed))) @@ -8472,14 +8412,14 @@ Return an alist with elements like (data . number_results)." (require 'browse-url) ;; If default setting of `w3m-command' is not ;; what you want you and you modify it, you will have to reeval -;; also `anything-browse-url-default-browser-alist'. +;; also `helm-browse-url-default-browser-alist'. (defvar w3m-command "/usr/bin/w3m") -(defvar anything-c-home-url "http://www.google.fr" +(defvar helm-c-home-url "http://www.google.fr" "*Default url to use as home url.") (defvar ac-browse-url-chromium-program "chromium-browser") (defvar ac-browse-url-uzbl-program "uzbl-browser") -(defvar anything-browse-url-default-browser-alist +(defvar helm-browse-url-default-browser-alist `((,w3m-command . w3m-browse-url) (,browse-url-firefox-program . browse-url-firefox) (,ac-browse-url-chromium-program . ac-browse-url-chromium) @@ -8493,7 +8433,7 @@ Return an alist with elements like (data . number_results)." (,browse-url-xterm-program . browse-url-text-xterm)) "*Alist of \(executable . function\) to try to find a suitable url browser.") -(defun* anything-c-generic-browser (url name &rest args) +(defun* helm-c-generic-browser (url name &rest args) "Browse URL with NAME browser." (let ((proc (concat name " " url))) (message "Starting %s..." name) @@ -8508,28 +8448,28 @@ Return an alist with elements like (data . number_results)." (defun ac-browse-url-chromium (url) "Browse URL with google chrome browser." (interactive "sURL: ") - (anything-c-generic-browser + (helm-c-generic-browser url ac-browse-url-chromium-program)) (defun ac-browse-url-uzbl (url &optional ignore) "Browse URL with uzbl browser." (interactive "sURL: ") - (anything-c-generic-browser url ac-browse-url-uzbl-program "-u")) + (helm-c-generic-browser url ac-browse-url-uzbl-program "-u")) -(defun anything-browse-url-default-browser (url &rest args) +(defun helm-browse-url-default-browser (url &rest args) "Find the first available browser and ask it to load URL." (let ((default-browser-fn - (loop for (exe . fn) in anything-browse-url-default-browser-alist + (loop for (exe . fn) in helm-browse-url-default-browser-alist thereis (and exe (executable-find exe) fn)))) (if default-browser-fn (apply default-browser-fn url args) (error "No usable browser found")))) -(defun anything-c-browse-url (url &rest args) +(defun helm-c-browse-url (url &rest args) "Default command to browse URL." (if browse-url-browser-function (browse-url url args) - (anything-browse-url-default-browser url args))) + (helm-browse-url-default-browser url args))) ;;; Surfraw @@ -8537,15 +8477,15 @@ Return an alist with elements like (data . number_results)." ;; Need external program surfraw. ;; -(defvar anything-surfraw-default-browser-function nil +(defvar helm-surfraw-default-browser-function nil "*The browse url function you prefer to use with surfraw. When nil, fallback to `browse-url-browser-function'.") ;; Internal -(defvar anything-surfraw-engines-history nil) -(defvar anything-surfraw-input-history nil) +(defvar helm-surfraw-engines-history nil) +(defvar helm-surfraw-input-history nil) -(defun anything-c-build-elvi-list () +(defun helm-c-build-elvi-list () "Return list of all engines and descriptions handled by surfraw." (cdr (with-temp-buffer @@ -8557,10 +8497,10 @@ When nil, fallback to `browse-url-browser-function'.") ;;; Emms ;; ;; -(defun anything-emms-stream-edit-bookmark (elm) - "Change the information of current emms-stream bookmark from anything." +(defun helm-emms-stream-edit-bookmark (elm) + "Change the information of current emms-stream bookmark from helm." (declare (special emms-stream-list)) - (let* ((cur-buf anything-current-buffer) + (let* ((cur-buf helm-current-buffer) (bookmark (assoc elm emms-stream-list)) (name (read-from-minibuffer "Description: " (nth 0 bookmark))) @@ -8578,11 +8518,11 @@ When nil, fallback to `browse-url-browser-function'.") (emms-stream-add-bookmark name url (string-to-number fd) type) (emms-stream-save-bookmarks-file) (emms-stream-quit) - (anything-c-switch-to-buffer cur-buf))))) + (helm-c-switch-to-buffer cur-buf))))) -(defun anything-emms-stream-delete-bookmark (candidate) - "Delete emms-streams bookmarks from anything." - (let* ((cands (anything-marked-candidates)) +(defun helm-emms-stream-delete-bookmark (candidate) + "Delete emms-streams bookmarks from helm." + (let* ((cands (helm-marked-candidates)) (bmks (loop for bm in cands collect (car (assoc bm emms-stream-list)))) (bmk-reg (mapconcat 'regexp-quote bmks "\\|^"))) @@ -8598,7 +8538,7 @@ When nil, fallback to `browse-url-browser-function'.") (emms-stream-save-bookmarks-file) (emms-stream-quit))))))) -(defvar anything-c-source-emms-streams +(defvar helm-c-source-emms-streams '((name . "Emms Streams") (init . (lambda () (emms-stream-init))) @@ -8611,12 +8551,12 @@ When nil, fallback to `browse-url-browser-function'.") (fn (intern (concat "emms-play-" (symbol-name (car (last stream)))))) (url (second stream))) (funcall fn url)))) - ("Delete" . anything-emms-stream-delete-bookmark) - ("Edit" . anything-emms-stream-edit-bookmark))) - (filtered-candidate-transformer . anything-c-adaptive-sort))) + ("Delete" . helm-emms-stream-delete-bookmark) + ("Edit" . helm-emms-stream-edit-bookmark))) + (filtered-candidate-transformer . helm-c-adaptive-sort))) ;; Don't forget to set `emms-source-file-default-directory' -(defvar anything-c-source-emms-dired +(defvar helm-c-source-emms-dired '((name . "Music Directory") (candidates . (lambda () (cddr (directory-files emms-source-file-default-directory)))) @@ -8627,14 +8567,14 @@ When nil, fallback to `browse-url-browser-function'.") item emms-source-file-default-directory)))) ("Open dired in file's directory" . (lambda (item) - (anything-c-open-dired + (helm-c-open-dired (expand-file-name item emms-source-file-default-directory)))))) - (filtered-candidate-transformer . anything-c-adaptive-sort))) + (filtered-candidate-transformer . helm-c-adaptive-sort))) -(defun anything-c-emms-files-modifier (candidates source) +(defun helm-c-emms-files-modifier (candidates source) (let ((current-playlist (with-current-emms-playlist (loop with cur-list = (emms-playlist-tracks-in-region (point-min) (point-max)) @@ -8645,18 +8585,18 @@ When nil, fallback to `browse-url-browser-function'.") (loop for i in candidates if (member (cdr i) current-playlist) collect (cons (propertize (car i) - 'face 'anything-emms-playlist) + 'face 'helm-emms-playlist) (cdr i)) into lis else collect i into lis finally return (reverse lis)))) -(defun anything-c-emms-play-current-playlist () +(defun helm-c-emms-play-current-playlist () "Play current playlist." (with-current-emms-playlist (emms-playlist-first) (emms-playlist-mode-play-smart))) -(defvar anything-c-source-emms-files +(defvar helm-c-source-emms-files '((name . "Emms files") (candidates . (lambda () (loop for v being the hash-values in emms-cache-db @@ -8668,22 +8608,22 @@ When nil, fallback to `browse-url-browser-function'.") for info = (concat artist " - " genre " - " tracknum ": " song) unless (string-match "^\\(http\\|mms\\):" name) collect (cons info name)))) - (filtered-candidate-transformer . anything-c-emms-files-modifier) + (filtered-candidate-transformer . helm-c-emms-files-modifier) (candidate-number-limit . 9999) (action . (("Play file" . emms-play-file) ("Add to Playlist and play (C-u clear current)" . (lambda (candidate) - (when anything-current-prefix-arg + (when helm-current-prefix-arg (emms-playlist-current-clear)) (emms-playlist-new) - (mapc 'emms-add-playlist-file (anything-marked-candidates)) + (mapc 'emms-add-playlist-file (helm-marked-candidates)) (unless emms-player-playing-p - (anything-c-emms-play-current-playlist)))))))) + (helm-c-emms-play-current-playlist)))))))) ;;; Jabber Contacts (jabber.el) -(defun anything-c-jabber-online-contacts () +(defun helm-c-jabber-online-contacts () "List online Jabber contacts." (with-no-warnings (let (jids) @@ -8693,26 +8633,26 @@ When nil, fallback to `browse-url-browser-function'.") (cons (get item 'name) item) (cons (symbol-name item) item)) jids)))))) -(defvar anything-c-source-jabber-contacts +(defvar helm-c-source-jabber-contacts '((name . "Jabber Contacts") (init . (lambda () (require 'jabber))) - (candidates . (lambda () (mapcar 'car (anything-c-jabber-online-contacts)))) + (candidates . (lambda () (mapcar 'car (helm-c-jabber-online-contacts)))) (action . (lambda (x) (jabber-chat-with (jabber-read-account) (symbol-name - (cdr (assoc x (anything-c-jabber-online-contacts))))))))) + (cdr (assoc x (helm-c-jabber-online-contacts))))))))) ;;; Call source. -(defvar anything-source-select-buffer "*anything source select*") -(defvar anything-c-source-call-source - `((name . "Call anything 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 "anything-c-source-" obarray) + (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 @@ -8720,32 +8660,32 @@ When nil, fallback to `browse-url-browser-function'.") name (propertize vname 'face 'font-lock-variable-name-face)) var)))) (action - . (("Invoke anything with selected source" + . (("Invoke helm with selected source" . (lambda (candidate) - (setq anything-candidate-number-limit 9999) - (anything candidate nil nil nil nil - anything-source-select-buffer))) + (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 anything-call-source-from-anything () - "Call anything source within `anything' session." +(defun helm-call-source-from-helm () + "Call helm source within `helm' session." (interactive) - (setq anything-input-idle-delay 0) - (anything-set-sources '(anything-c-source-call-source))) + (setq helm-input-idle-delay 0) + (helm-set-sources '(helm-c-source-call-source))) -;;; Execute Preconfigured anything. -(defvar anything-c-source-anything-commands - '((name . "Preconfigured Anything") - (candidates . anything-c-anything-commands-candidates) +;;; Execute Preconfigured helm. +(defvar helm-c-source-helm-commands + '((name . "Preconfigured Helm") + (candidates . helm-c-helm-commands-candidates) (type . command) (candidate-number-limit))) -(defun anything-c-anything-commands-candidates () - (loop for (cmd . desc) in (anything-c-list-preconfigured-anything) +(defun helm-c-helm-commands-candidates () + (loop for (cmd . desc) in (helm-c-list-preconfigured-helm) collect (cons (if (where-is-internal cmd nil t) (substitute-command-keys (format "M-x %s (\\[%s]) : %s" cmd cmd desc)) (substitute-command-keys (format "\\[%s] : %s" cmd desc))) @@ -8755,103 +8695,103 @@ When nil, fallback to `browse-url-browser-function'.") ;;; Occur ;; ;; -(defun anything-c-occur-init () - "Create the initial anything occur buffer. +(defun helm-c-occur-init () + "Create the initial helm occur buffer. If region is active use region as buffer contents instead of whole buffer." - (with-current-buffer (anything-candidate-buffer 'global) + (with-current-buffer (helm-candidate-buffer 'global) (erase-buffer) (let ((buf-contents - (with-anything-current-buffer - (if (anything-region-active-p) + (with-helm-current-buffer + (if (helm-region-active-p) (buffer-substring (region-beginning) (region-end)) (buffer-substring (point-min) (point-max)))))) (insert buf-contents)))) -(defun anything-c-occur-get-line (s e) +(defun helm-c-occur-get-line (s e) (format "%7d:%s" (line-number-at-pos (1- s)) (buffer-substring s e))) -(defun anything-c-occur-query-replace-regexp (candidate) +(defun helm-c-occur-query-replace-regexp (candidate) "Query replace regexp starting from CANDIDATE. If region is active ignore CANDIDATE and replace only in region. With a prefix arg replace only matches surrounded by word boundaries, i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." - (let ((regexp anything-input)) - (unless (anything-region-active-p) - (anything-c-action-line-goto candidate)) + (let ((regexp helm-input)) + (unless (helm-region-active-p) + (helm-c-action-line-goto candidate)) (apply 'query-replace-regexp - (anything-c-query-replace-args regexp)))) + (helm-c-query-replace-args regexp)))) -(defun anything-occur-run-query-replace-regexp () - "Run `query-replace-regexp' in anything occur from keymap." +(defun helm-occur-run-query-replace-regexp () + "Run `query-replace-regexp' in helm occur from keymap." (interactive) - (anything-c-quit-and-execute-action - 'anything-c-occur-query-replace-regexp)) + (helm-c-quit-and-execute-action + 'helm-c-occur-query-replace-regexp)) -(defvar anything-c-source-occur +(defvar helm-c-source-occur `((name . "Occur") - (init . anything-c-occur-init) + (init . helm-c-occur-init) (candidates-in-buffer) (migemo) - (get-line . anything-c-occur-get-line) - (display-to-real . anything-c-display-to-real-line) - (action . (("Go to Line" . anything-c-action-line-goto) + (get-line . helm-c-occur-get-line) + (display-to-real . helm-c-display-to-real-line) + (action . (("Go to Line" . helm-c-action-line-goto) ("Query replace regexp (C-u Not inside word.)" - . anything-c-occur-query-replace-regexp))) + . helm-c-occur-query-replace-regexp))) (recenter) - (mode-line . anything-occur-mode-line) - (keymap . ,anything-occur-map) + (mode-line . helm-occur-mode-line) + (keymap . ,helm-occur-map) (requires-pattern . 1) (delayed))) -;;; Anything browse code. -(defun anything-c-browse-code-get-line (beg end) +;;; Helm browse code. +(defun helm-c-browse-code-get-line (beg end) "Select line if it match the regexp corresponding to current `major-mode'. Line is parsed for BEG position to END position." (let ((str-line (buffer-substring beg end)) (regexp (assoc-default major-mode - anything-c-browse-code-regexp-alist)) - (num-line (if (string= anything-pattern "") beg (1- beg)))) + helm-c-browse-code-regexp-alist)) + (num-line (if (string= helm-pattern "") beg (1- beg)))) (when (and regexp (string-match regexp str-line)) (format "%4d:%s" (line-number-at-pos num-line) str-line)))) -(defvar anything-c-source-browse-code +(defvar helm-c-source-browse-code '((name . "Browse code") (init . (lambda () - (anything-candidate-buffer anything-current-buffer) - (with-anything-current-buffer + (helm-candidate-buffer helm-current-buffer) + (with-helm-current-buffer (jit-lock-fontify-now)))) (candidate-number-limit . 9999) (candidates-in-buffer) - (get-line . anything-c-browse-code-get-line) + (get-line . helm-c-browse-code-get-line) (type . line) (recenter))) ;; Do many actions for input -(defvar anything-c-source-create +(defvar helm-c-source-create '((name . "Create") (dummy) (action) - (action-transformer . anything-create--actions)) - "Do many create actions from `anything-pattern'. -See also `anything-create--actions'.") + (action-transformer . helm-create--actions)) + "Do many create actions from `helm-pattern'. +See also `helm-create--actions'.") -(defun anything-create-from-anything () - "Run `anything-create' from `anything' as a fallback." +(defun helm-create-from-helm () + "Run `helm-create' from `helm' as a fallback." (interactive) - (anything-run-after-quit 'anything-create nil anything-pattern)) + (helm-run-after-quit 'helm-create nil helm-pattern)) -(defun anything-create--actions (&rest ignored) - "Default actions for `anything-create' / `anything-c-source-create'." +(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 anything-create--actions-private + (append helm-create--actions-private '(("find-file" . find-file) ("find-file other window" . find-file-other-window) - ("New buffer" . anything-c-switch-to-buffer) + ("New buffer" . helm-c-switch-to-buffer) ("New buffer other window" . switch-to-buffer-other-window) ("Bookmark Set" . bookmark-set) ("Set Register" . @@ -8867,7 +8807,7 @@ See also `anything-create--actions'.") ;; Minibuffer History ;; ;; -(defvar anything-c-source-minibuffer-history +(defvar helm-c-source-minibuffer-history '((name . "Minibuffer History") (header-name . (lambda (name) (format "%s (%s)" name minibuffer-history-variable))) @@ -8888,7 +8828,7 @@ See also `anything-create--actions'.") ;;; Elscreen ;; ;; -(defvar anything-c-source-elscreen +(defvar helm-c-source-elscreen '((name . "Elscreen") (candidates . (lambda () @@ -8903,7 +8843,7 @@ See also `anything-create--actions'.") (elscreen-goto (- (aref candidate 1) (aref "0" 0))))) ("Kill Screen(s)" . (lambda (candidate) - (dolist (i (anything-marked-candidates)) + (dolist (i (helm-marked-candidates)) (elscreen-goto (- (aref i 1) (aref "0" 0))) (elscreen-kill)))) ("Only Screen" . @@ -8915,52 +8855,52 @@ See also `anything-create--actions'.") ;;;; ;;; Top (process) -(defvar anything-c-top-command "COLUMNS=%s top -b -n 1" +(defvar helm-c-top-command "COLUMNS=%s top -b -n 1" "Top command (batch mode). %s is replaced with `frame-width'.") -(defvar anything-c-source-top +(defvar helm-c-source-top '((name . "Top (Press C-c C-u to refresh)") - (init . anything-c-top-init) + (init . helm-c-top-init) (candidates-in-buffer) - (display-to-real . anything-c-top-display-to-real) - (persistent-action . anything-c-top-sh-persistent-action) + (display-to-real . helm-c-top-display-to-real) + (persistent-action . helm-c-top-sh-persistent-action) (persistent-help . "SIGTERM") (action ("kill (TERM)" . (lambda (pid) - (anything-c-top-sh (format "kill -TERM %s" pid)))) + (helm-c-top-sh (format "kill -TERM %s" pid)))) ("kill (KILL)" . (lambda (pid) - (anything-c-top-sh (format "kill -KILL %s" pid)))) + (helm-c-top-sh (format "kill -KILL %s" pid)))) ("Copy PID" . (lambda (pid) (kill-new pid)))))) -(defun anything-c-top-sh (cmd) +(defun helm-c-top-sh (cmd) (message "Executed %s\n%s" cmd (shell-command-to-string cmd))) -(defun anything-c-top-sh-persistent-action (pid) +(defun helm-c-top-sh-persistent-action (pid) (delete-other-windows) - (anything-c-top-sh (format "kill -TERM %s" pid)) - (anything-force-update)) + (helm-c-top-sh (format "kill -TERM %s" pid)) + (helm-force-update)) -(defun anything-c-top-init () - (with-current-buffer (anything-candidate-buffer 'global) +(defun helm-c-top-init () + (with-current-buffer (helm-candidate-buffer 'global) (call-process-shell-command - (format anything-c-top-command - (- (frame-width) (if anything-enable-digit-shortcuts 4 0))) + (format helm-c-top-command + (- (frame-width) (if helm-enable-digit-shortcuts 4 0))) nil (current-buffer)))) -(defun anything-c-top-display-to-real (line) +(defun helm-c-top-display-to-real (line) (car (split-string line))) ;;; Timers -(defvar anything-c-source-absolute-time-timers +(defvar helm-c-source-absolute-time-timers '((name . "Absolute Time Timers") (candidates . timer-list) (type . timer))) -(defvar anything-c-source-idle-time-timers +(defvar helm-c-source-idle-time-timers '((name . "Idle Time Timers") (candidates . timer-idle-list) (type . timer))) -(defun anything-c-timer-real-to-display (timer) +(defun helm-c-timer-real-to-display (timer) (destructuring-bind (triggered t1 t2 t3 repeat-delay func args idle-delay) (append timer nil) ;use `append' to convert vector->list (format "%s repeat=%5S %s(%s)" @@ -8977,7 +8917,7 @@ See also `anything-create--actions'.") ;; ;;; FIXME I do not care multi-display. -(defun anything-c-xrandr-info () +(defun helm-c-xrandr-info () "Return a pair with current X screen number and current X display name." (with-temp-buffer (call-process "xrandr" nil (current-buffer) nil @@ -8991,21 +8931,21 @@ See also `anything-create--actions'.") (setq output (match-string 1))) (list screen output)))) -(defun anything-c-xrandr-screen () +(defun helm-c-xrandr-screen () "Return current X screen number." - (car (anything-c-xrandr-info))) + (car (helm-c-xrandr-info))) -(defun anything-c-xrandr-output () +(defun helm-c-xrandr-output () "Return current X display name." - (cadr (anything-c-xrandr-info))) + (cadr (helm-c-xrandr-info))) -(defvar anything-c-source-xrandr-change-resolution +(defvar helm-c-source-xrandr-change-resolution '((name . "Change Resolution") (candidates . (lambda () (with-temp-buffer (call-process "xrandr" nil (current-buffer) nil - "--screen" (anything-c-xrandr-screen) "-q") + "--screen" (helm-c-xrandr-screen) "-q") (goto-char 1) (loop with modes = nil while (re-search-forward " \\([0-9]+x[0-9]+\\)" nil t) @@ -9017,14 +8957,14 @@ See also `anything-create--actions'.") ("Change Resolution" . (lambda (mode) (call-process "xrandr" nil nil nil - "--screen" (anything-c-xrandr-screen) - "--output" (anything-c-xrandr-output) + "--screen" (helm-c-xrandr-screen) + "--output" (helm-c-xrandr-output) "--mode" mode)))))) ;;; Xfont selection ;; ;; -(defun anything-c-persistent-xfont-action (elm) +(defun helm-c-persistent-xfont-action (elm) "Show current font temporarily" (let ((current-font (cdr (assoc 'font (frame-parameters)))) (default-font elm)) @@ -9032,28 +8972,28 @@ See also `anything-create--actions'.") (progn (set-frame-font default-font 'keep-size) (sit-for 2)) (set-frame-font current-font)))) -(defvar anything-c-xfonts-cache nil) -(defvar anything-c-source-xfonts +(defvar helm-c-xfonts-cache nil) +(defvar helm-c-source-xfonts '((name . "X Fonts") (init . (lambda () - (unless anything-c-xfonts-cache - (setq anything-c-xfonts-cache + (unless helm-c-xfonts-cache + (setq helm-c-xfonts-cache (x-list-fonts "*"))))) - (candidates . anything-c-xfonts-cache) + (candidates . helm-c-xfonts-cache) (action . (("Copy to kill ring" . (lambda (elm) (kill-new elm))) ("Set Font" . (lambda (elm) (kill-new elm) (set-frame-font elm 'keep-size) (message "New font have been copied to kill ring"))))) - (persistent-action . anything-c-persistent-xfont-action) + (persistent-action . helm-c-persistent-xfont-action) (persistent-help . "Switch to this font temporarily"))) ;;; 𝕌𝕔𝕤 𝕊𝕪𝕞𝕓𝕠𝕝 𝕔𝕠𝕞𝕡𝕝𝕖𝕥𝕚𝕠𝕟 ;; ;; -(defvar anything-c-ucs-max-len 0) -(defun anything-c-calculate-ucs-max-len () +(defvar helm-c-ucs-max-len 0) +(defun helm-c-calculate-ucs-max-len () "Calculate the length of longest `ucs-names' candidate." (loop with count = 0 for (n . v) in (ucs-names) @@ -9062,19 +9002,19 @@ See also `anything-create--actions'.") do (setq count len) finally return count)) -(defun anything-c-ucs-init () - "Initialize an anything buffer with ucs symbols. +(defun helm-c-ucs-init () + "Initialize an helm buffer with ucs symbols. Only math* symbols are collected." - (unless (> anything-c-ucs-max-len 0) - (setq anything-c-ucs-max-len - (anything-c-calculate-ucs-max-len))) - (with-current-buffer (anything-candidate-buffer - (get-buffer-create "*anything ucs*")) + (unless (> helm-c-ucs-max-len 0) + (setq helm-c-ucs-max-len + (helm-c-calculate-ucs-max-len))) + (with-current-buffer (helm-candidate-buffer + (get-buffer-create "*helm ucs*")) ;; `ucs-names' fn will not run again, data is cached in ;; var `ucs-names'. (loop for (n . v) in (ucs-names) for len = (length n) - for diff = (+ (- anything-c-ucs-max-len len) 2) + for diff = (+ (- helm-c-ucs-max-len len) 2) unless (string= "" n) do (progn (insert (concat n ":" @@ -9083,67 +9023,67 @@ Only math* symbols are collected." (ucs-insert v) (insert "\n"))))) -(defun anything-c-ucs-forward-char (candidate) - (with-anything-current-buffer +(defun helm-c-ucs-forward-char (candidate) + (with-helm-current-buffer (forward-char 1))) -(defun anything-c-ucs-backward-char (candidate) - (with-anything-current-buffer +(defun helm-c-ucs-backward-char (candidate) + (with-helm-current-buffer (forward-char -1))) -(defun anything-c-ucs-delete-backward (candidate) - (with-anything-current-buffer +(defun helm-c-ucs-delete-backward (candidate) + (with-helm-current-buffer (delete-char -1))) -(defun anything-c-ucs-insert-char (candidate) - (with-anything-current-buffer +(defun helm-c-ucs-insert-char (candidate) + (with-helm-current-buffer (insert (replace-regexp-in-string " " "" (cadr (split-string candidate ":")))))) -(defun anything-c-ucs-persistent-insert () +(defun helm-c-ucs-persistent-insert () (interactive) - (anything-attrset 'action-insert 'anything-c-ucs-insert-char) - (anything-execute-persistent-action 'action-insert)) + (helm-attrset 'action-insert 'helm-c-ucs-insert-char) + (helm-execute-persistent-action 'action-insert)) -(defun anything-c-ucs-persistent-forward () +(defun helm-c-ucs-persistent-forward () (interactive) - (anything-attrset 'action-forward 'anything-c-ucs-forward-char) - (anything-execute-persistent-action 'action-forward)) + (helm-attrset 'action-forward 'helm-c-ucs-forward-char) + (helm-execute-persistent-action 'action-forward)) -(defun anything-c-ucs-persistent-backward () +(defun helm-c-ucs-persistent-backward () (interactive) - (anything-attrset 'action-back 'anything-c-ucs-backward-char) - (anything-execute-persistent-action 'action-back)) + (helm-attrset 'action-back 'helm-c-ucs-backward-char) + (helm-execute-persistent-action 'action-back)) -(defun anything-c-ucs-persistent-delete () +(defun helm-c-ucs-persistent-delete () (interactive) - (anything-attrset 'action-delete 'anything-c-ucs-delete-backward) - (anything-execute-persistent-action 'action-delete)) + (helm-attrset 'action-delete 'helm-c-ucs-delete-backward) + (helm-execute-persistent-action 'action-delete)) -(defvar anything-c-source-ucs +(defvar helm-c-source-ucs '((name . "Ucs names") - (init . anything-c-ucs-init) + (init . helm-c-ucs-init) (candidate-number-limit . 9999) (candidates-in-buffer) - (mode-line . anything-c-ucs-mode-line-string) - (action . (("Insert" . anything-c-ucs-insert-char) - ("Forward char" . anything-c-ucs-forward-char) - ("Backward char" . anything-c-ucs-backward-char) - ("Delete char backward" . anything-c-ucs-delete-backward)))) + (mode-line . helm-c-ucs-mode-line-string) + (action . (("Insert" . helm-c-ucs-insert-char) + ("Forward char" . helm-c-ucs-forward-char) + ("Backward char" . helm-c-ucs-backward-char) + ("Delete char backward" . helm-c-ucs-delete-backward)))) "Source for collecting `ucs-names' math symbols.") ;;; Emacs process ;; ;; -(defvar anything-c-source-emacs-process +(defvar helm-c-source-emacs-process '((name . "Emacs Process") (candidates . (lambda () (mapcar #'process-name (process-list)))) (persistent-action . (lambda (elm) (delete-process (get-process elm)) - (anything-delete-current-selection))) + (helm-delete-current-selection))) (persistent-help . "Kill Process") (action ("Kill Process" . (lambda (elm) (delete-process (get-process elm))))))) @@ -9151,128 +9091,128 @@ Only math* symbols are collected." ;;; World time ;; ;; -(defvar anything-c-source-time-world +(defvar helm-c-source-time-world '((name . "Time World List") (init . (lambda () - (let ((anything-buffer (anything-candidate-buffer 'global))) - (with-current-buffer anything-buffer + (let ((helm-buffer (helm-candidate-buffer 'global))) + (with-current-buffer helm-buffer (display-time-world-display display-time-world-list))))) (candidates-in-buffer))) -;;; Anything interface for Debian/Ubuntu packages (apt-*) +;;; Helm interface for Debian/Ubuntu packages (apt-*) ;; ;; -(defvar anything-c-source-apt +(defvar helm-c-source-apt '((name . "APT") - (init . anything-c-apt-init) + (init . helm-c-apt-init) (candidates-in-buffer) - (candidate-transformer anything-c-apt-candidate-transformer) - (display-to-real . anything-c-apt-display-to-real) + (candidate-transformer helm-c-apt-candidate-transformer) + (display-to-real . helm-c-apt-display-to-real) (requires-pattern . 2) - (update . anything-c-apt-refresh) + (update . helm-c-apt-refresh) (action - ("Show package description" . anything-c-apt-cache-show) - ("Install package" . anything-c-apt-install) - ("Reinstall package" . anything-c-apt-reinstall) - ("Remove package" . anything-c-apt-uninstall) - ("Purge package" . anything-c-apt-purge)) - (persistent-action . anything-c-apt-persistent-action) + ("Show package description" . helm-c-apt-cache-show) + ("Install package" . helm-c-apt-install) + ("Reinstall package" . helm-c-apt-reinstall) + ("Remove package" . helm-c-apt-uninstall) + ("Purge package" . helm-c-apt-purge)) + (persistent-action . helm-c-apt-persistent-action) (persistent-help . "Show package description"))) -(defvar anything-c-apt-query "emacs") -(defvar anything-c-apt-search-command "apt-cache search '%s'") -(defvar anything-c-apt-show-command "apt-cache show '%s'") -(defvar anything-c-apt-installed-packages nil) -(defvar anything-c-apt-all-packages nil) -(defvar anything-c-apt-input-history nil) +(defvar helm-c-apt-query "emacs") +(defvar helm-c-apt-search-command "apt-cache search '%s'") +(defvar helm-c-apt-show-command "apt-cache show '%s'") +(defvar helm-c-apt-installed-packages nil) +(defvar helm-c-apt-all-packages nil) +(defvar helm-c-apt-input-history nil) -(defun anything-c-apt-refresh () +(defun helm-c-apt-refresh () "Refresh installed candidates list." - (setq anything-c-apt-installed-packages nil) - (setq anything-c-apt-all-packages nil)) + (setq helm-c-apt-installed-packages nil) + (setq helm-c-apt-all-packages nil)) -(defun anything-c-apt-persistent-action (candidate) +(defun helm-c-apt-persistent-action (candidate) "Persistent action for APT source." - (anything-c-apt-cache-show candidate)) + (helm-c-apt-cache-show candidate)) -(defun anything-c-apt-candidate-transformer (candidates) +(defun helm-c-apt-candidate-transformer (candidates) "Show installed CANDIDATES and the ones to deinstall in a different color." (loop for cand in candidates - for name = (anything-c-apt-display-to-real cand) + for name = (helm-c-apt-display-to-real cand) collect (cond ((string= (assoc-default - name anything-c-apt-installed-packages) + name helm-c-apt-installed-packages) "deinstall") - (propertize cand 'face 'anything-apt-deinstalled)) + (propertize cand 'face 'helm-apt-deinstalled)) ((string= (assoc-default - name anything-c-apt-installed-packages) + name helm-c-apt-installed-packages) "install") - (propertize cand 'face 'anything-apt-installed)) + (propertize cand 'face 'helm-apt-installed)) (t cand)))) -(defun anything-c-apt-init () +(defun helm-c-apt-init () "Initialize list of debian packages." (let ((query "")) - (unless (and anything-c-apt-installed-packages - anything-c-apt-all-packages) + (unless (and helm-c-apt-installed-packages + helm-c-apt-all-packages) (message "Loading package list...") - (setq anything-c-apt-installed-packages + (setq helm-c-apt-installed-packages (with-temp-buffer (call-process-shell-command "dpkg --get-selections" nil (current-buffer)) (loop for i in (split-string (buffer-string) "\n" t) for p = (split-string i) collect (cons (car p) (cadr p))))) - (setq anything-c-apt-all-packages + (setq helm-c-apt-all-packages (with-current-buffer - (anything-candidate-buffer - (get-buffer-create (format "*anything-apt*"))) + (helm-candidate-buffer + (get-buffer-create (format "*helm-apt*"))) (erase-buffer) (call-process-shell-command - (format anything-c-apt-search-command query) + (format helm-c-apt-search-command query) nil (current-buffer)))) (message "Loading package list done") (sit-for 0.5)))) -(defun anything-c-apt-display-to-real (line) +(defun helm-c-apt-display-to-real (line) "Return only name of a debian package. LINE is displayed like: package name - description." (car (split-string line " - "))) -(defun anything-c-shell-command-if-needed (command) +(defun helm-c-shell-command-if-needed (command) "Run shell command COMMAND to describe package. If a buffer named COMMAND already exists, just switch to it." (let ((buf (get-buffer command))) - (anything-c-switch-to-buffer (get-buffer-create command)) + (helm-c-switch-to-buffer (get-buffer-create command)) (unless buf (insert (shell-command-to-string command))))) -(defun anything-c-apt-cache-show (package) +(defun helm-c-apt-cache-show (package) "Show information on apt package PACKAGE." - (anything-c-shell-command-if-needed - (format anything-c-apt-show-command package))) + (helm-c-shell-command-if-needed + (format helm-c-apt-show-command package))) -(defun anything-c-apt-install (package) +(defun helm-c-apt-install (package) "Run 'apt-get install' shell command on PACKAGE." - (anything-c-apt-generic-action :action 'install)) + (helm-c-apt-generic-action :action 'install)) -(defun anything-c-apt-reinstall (package) +(defun helm-c-apt-reinstall (package) "Run 'apt-get install --reinstall' shell command on PACKAGE." - (anything-c-apt-generic-action :action 'reinstall)) + (helm-c-apt-generic-action :action 'reinstall)) -(defun anything-c-apt-uninstall (package) +(defun helm-c-apt-uninstall (package) "Run 'apt-get remove' shell command on PACKAGE." - (anything-c-apt-generic-action :action 'uninstall)) + (helm-c-apt-generic-action :action 'uninstall)) -(defun anything-c-apt-purge (package) +(defun helm-c-apt-purge (package) "Run 'apt-get purge' shell command on PACKAGE." - (anything-c-apt-generic-action :action 'purge)) + (helm-c-apt-generic-action :action 'purge)) -(defun* anything-c-apt-generic-action (&key action) +(defun* helm-c-apt-generic-action (&key action) "Run 'apt-get ACTION'. Support install, remove and purge actions." - (ansi-term (getenv "SHELL") "anything apt") + (ansi-term (getenv "SHELL") "helm apt") (term-line-mode) (let ((command (case action ('install "sudo apt-get install ") @@ -9283,111 +9223,111 @@ Support install, remove and purge actions." (beg (point)) end (cand-list (mapconcat #'(lambda (x) (format "'%s'" x)) - (anything-marked-candidates) " "))) + (helm-marked-candidates) " "))) (goto-char (point-max)) (insert (concat command cand-list)) (setq end (point)) (if (y-or-n-p (format "%s package" (symbol-name action))) (progn - (setq anything-c-external-commands-list nil) - (setq anything-c-apt-installed-packages nil) + (setq helm-c-external-commands-list nil) + (setq helm-c-apt-installed-packages nil) (term-char-mode) (term-send-input)) (delete-region beg end) (term-send-eof) (kill-buffer)))) -;; (anything-c-apt-install "jed") +;; (helm-c-apt-install "jed") -;;; Anything UI for gentoo portage. +;;; Helm UI for gentoo portage. ;; ;; -(defvar anything-c-gentoo-use-flags nil) -(defvar anything-c-gentoo-buffer "*anything-gentoo-output*") -(defvar anything-c-cache-gentoo nil) -(defvar anything-c-cache-world nil) -(defvar anything-c-source-gentoo +(defvar helm-c-gentoo-use-flags nil) +(defvar helm-c-gentoo-buffer "*helm-gentoo-output*") +(defvar helm-c-cache-gentoo nil) +(defvar helm-c-cache-world nil) +(defvar helm-c-source-gentoo '((name . "Portage sources") (init . (lambda () - (get-buffer-create anything-c-gentoo-buffer) - (unless anything-c-cache-gentoo - (anything-c-gentoo-setup-cache)) - (unless anything-c-cache-world - (setq anything-c-cache-world (anything-c-gentoo-get-world))) - (anything-c-gentoo-init-list))) + (get-buffer-create helm-c-gentoo-buffer) + (unless helm-c-cache-gentoo + (helm-c-gentoo-setup-cache)) + (unless helm-c-cache-world + (setq helm-c-cache-world (helm-c-gentoo-get-world))) + (helm-c-gentoo-init-list))) (candidates-in-buffer) (match . identity) - (candidate-transformer anything-c-highlight-world) + (candidate-transformer helm-c-highlight-world) (action . (("Show package" . (lambda (elm) - (anything-c-gentoo-eshell-action elm "eix"))) + (helm-c-gentoo-eshell-action elm "eix"))) ("Show history" . (lambda (elm) - (if (member elm anything-c-cache-world) - (anything-c-gentoo-eshell-action elm "genlop -qe") + (if (member elm helm-c-cache-world) + (helm-c-gentoo-eshell-action elm "genlop -qe") (message "No infos on packages not yet installed")))) ("Copy in kill-ring" . kill-new) ("insert at point" . insert) ("Browse HomePage" . (lambda (elm) - (let ((urls (anything-c-gentoo-get-url elm))) - (browse-url (anything-comp-read "Url: " urls :must-match t))))) + (let ((urls (helm-c-gentoo-get-url elm))) + (browse-url (helm-comp-read "Url: " urls :must-match t))))) ("Show extra infos" . (lambda (elm) - (if (member elm anything-c-cache-world) - (anything-c-gentoo-eshell-action elm "genlop -qi") + (if (member elm helm-c-cache-world) + (helm-c-gentoo-eshell-action elm "genlop -qi") (message "No infos on packages not yet installed")))) ("Show use flags" . (lambda (elm) - (anything-c-gentoo-default-action elm "equery" "-C" "u") + (helm-c-gentoo-default-action elm "equery" "-C" "u") (font-lock-add-keywords nil '(("^\+.*" . font-lock-variable-name-face))) (font-lock-mode 1))) ("Run emerge pretend" . (lambda (elm) - (anything-c-gentoo-eshell-action elm "emerge -p"))) + (helm-c-gentoo-eshell-action elm "emerge -p"))) ("Emerge" . (lambda (elm) - (anything-gentoo-install elm :action 'install))) + (helm-gentoo-install elm :action 'install))) ("Unmerge" . (lambda (elm) - (anything-gentoo-install elm :action 'uninstall))) + (helm-gentoo-install elm :action 'uninstall))) ("Show dependencies" . (lambda (elm) - (anything-c-gentoo-default-action elm "equery" "-C" "d"))) + (helm-c-gentoo-default-action elm "equery" "-C" "d"))) ("Show related files" . (lambda (elm) - (anything-c-gentoo-default-action elm "equery" "files"))) + (helm-c-gentoo-default-action elm "equery" "files"))) ("Refresh" . (lambda (elm) - (anything-c-gentoo-setup-cache) - (setq anything-c-cache-world (anything-c-gentoo-get-world)))))))) + (helm-c-gentoo-setup-cache) + (setq helm-c-cache-world (helm-c-gentoo-get-world)))))))) -(defun* anything-gentoo-install (candidate &key action) - (setq anything-c-external-commands-list nil) +(defun* helm-gentoo-install (candidate &key action) + (setq helm-c-external-commands-list nil) (ansi-term (getenv "SHELL") "Gentoo emerge") (term-line-mode) (let ((command (case action ('install "sudo emerge -av ") ('uninstall "sudo emerge -avC ") (t (error "Unknow action")))) - (elms (mapconcat 'identity (anything-marked-candidates) " ")) + (elms (mapconcat 'identity (helm-marked-candidates) " ")) (beg (point)) end) (goto-char (point-max)) (insert (concat command elms)) (setq end (point)) (term-char-mode) (term-send-input))) -(defun anything-c-gentoo-default-action (elm command &rest args) - "Gentoo default action that use `anything-c-gentoo-buffer'." - (if (member elm anything-c-cache-world) +(defun helm-c-gentoo-default-action (elm command &rest args) + "Gentoo default action that use `helm-c-gentoo-buffer'." + (if (member elm helm-c-cache-world) (progn - (anything-c-switch-to-buffer anything-c-gentoo-buffer) + (helm-c-switch-to-buffer helm-c-gentoo-buffer) (erase-buffer) (let ((com-list (append args (list elm)))) (apply #'call-process command nil t nil com-list))) (message "No infos on packages not yet installed"))) -(defvar anything-c-source-use-flags +(defvar helm-c-source-use-flags '((name . "Use Flags") (init . (lambda () - (unless anything-c-gentoo-use-flags - (anything-c-gentoo-setup-use-flags-cache)) - (anything-c-gentoo-get-use))) + (unless helm-c-gentoo-use-flags + (helm-c-gentoo-setup-use-flags-cache)) + (helm-c-gentoo-get-use))) (candidates-in-buffer) (match . identity) - (candidate-transformer anything-c-highlight-local-use) + (candidate-transformer helm-c-highlight-local-use) (action . (("Description" . (lambda (elm) - (anything-c-switch-to-buffer anything-c-gentoo-buffer) + (helm-c-switch-to-buffer helm-c-gentoo-buffer) (erase-buffer) (apply #'call-process "euse" nil t nil `("-i" @@ -9396,16 +9336,16 @@ Support install, remove and purge actions." (font-lock-mode 1))) ("Enable" . (lambda (elm) - (anything-c-gentoo-eshell-action elm "*sudo -p Password: euse -E"))) + (helm-c-gentoo-eshell-action elm "*sudo -p Password: euse -E"))) ("Disable" . (lambda (elm) - (anything-c-gentoo-eshell-action elm "*sudo -p Password: euse -D"))) + (helm-c-gentoo-eshell-action elm "*sudo -p Password: euse -D"))) ("Remove" . (lambda (elm) - (anything-c-gentoo-eshell-action elm "*sudo -p Password: euse -P"))) + (helm-c-gentoo-eshell-action elm "*sudo -p Password: euse -P"))) ("Show which dep use this flag" . (lambda (elm) - (anything-c-switch-to-buffer anything-c-gentoo-buffer) + (helm-c-switch-to-buffer helm-c-gentoo-buffer) (erase-buffer) (apply #'call-process "equery" nil t nil `("-C" @@ -9414,27 +9354,27 @@ Support install, remove and purge actions." -(defun anything-c-gentoo-init-list () +(defun helm-c-gentoo-init-list () "Initialize buffer with all packages in Portage." - (let* ((portage-buf (get-buffer-create "*anything-gentoo*")) - (buf (anything-candidate-buffer 'portage-buf))) + (let* ((portage-buf (get-buffer-create "*helm-gentoo*")) + (buf (helm-candidate-buffer 'portage-buf))) (with-current-buffer buf - (dolist (i anything-c-cache-gentoo) + (dolist (i helm-c-cache-gentoo) (insert (concat i "\n")))))) -(defun anything-c-gentoo-setup-cache () - "Set up `anything-c-cache-gentoo'" - (setq anything-c-cache-gentoo +(defun helm-c-gentoo-setup-cache () + "Set up `helm-c-cache-gentoo'" + (setq helm-c-cache-gentoo (split-string (with-temp-buffer (call-process "eix" nil t nil "--only-names") (buffer-string))))) -(defun anything-c-gentoo-eshell-action (elm command) +(defun helm-c-gentoo-eshell-action (elm command) (when (get-buffer "*EShell Command Output*") (kill-buffer "*EShell Command Output*")) (message "Wait searching...") - (let ((buf-fname (buffer-file-name anything-current-buffer))) + (let ((buf-fname (buffer-file-name helm-current-buffer))) (if (and buf-fname (string-match tramp-file-name-regexp buf-fname)) (progn (save-window-excursion @@ -9443,24 +9383,24 @@ Support install, remove and purge actions." (pop-to-buffer "*EShell Command Output*")) (eshell-command (format "%s %s" command elm))))) -(defun anything-c-gentoo-get-use () +(defun helm-c-gentoo-get-use () "Initialize buffer with all use flags." - (let* ((use-buf (get-buffer-create "*anything-gentoo-use*")) - (buf (anything-candidate-buffer 'use-buf))) + (let* ((use-buf (get-buffer-create "*helm-gentoo-use*")) + (buf (helm-candidate-buffer 'use-buf))) (with-current-buffer buf - (dolist (i anything-c-gentoo-use-flags) + (dolist (i helm-c-gentoo-use-flags) (insert (concat i "\n")))))) -(defun anything-c-gentoo-setup-use-flags-cache () - "Setup `anything-c-gentoo-use-flags'" - (setq anything-c-gentoo-use-flags +(defun helm-c-gentoo-setup-use-flags-cache () + "Setup `helm-c-gentoo-use-flags'" + (setq helm-c-gentoo-use-flags (split-string (with-temp-buffer (call-process "eix" nil t nil "--print-all-useflags") (buffer-string))))) -(defun anything-c-gentoo-get-url (elm) +(defun helm-c-gentoo-get-url (elm) "Return a list of urls from eix output." (loop with url-list = (split-string @@ -9475,14 +9415,14 @@ Support install, remove and purge actions." collect i into all finally return all)) -(defun anything-c-gentoo-get-world () +(defun helm-c-gentoo-get-world () "Return list of all installed package on your system." (split-string (with-temp-buffer (call-process "qlist" nil t nil "-I") (buffer-string)))) -(defun anything-c-gentoo-get-local-use () +(defun helm-c-gentoo-get-local-use () (split-string (with-temp-buffer (call-process "portageq" nil t nil "envvar" @@ -9490,38 +9430,38 @@ Support install, remove and purge actions." (buffer-string)))) -(defun anything-c-highlight-world (eix) +(defun helm-c-highlight-world (eix) "Highlight all installed package." (loop for i in eix - if (member i anything-c-cache-world) - collect (propertize i 'face 'anything-gentoo-match-face) + if (member i helm-c-cache-world) + collect (propertize i 'face 'helm-gentoo-match-face) else collect i)) -(defun anything-c-highlight-local-use (use-flags) - (let ((local-uses (anything-c-gentoo-get-local-use))) +(defun helm-c-highlight-local-use (use-flags) + (let ((local-uses (helm-c-gentoo-get-local-use))) (loop for i in use-flags if (member i local-uses) - collect (propertize i 'face 'anything-gentoo-match-face) + collect (propertize i 'face 'helm-gentoo-match-face) else collect i))) -;;; Anything ratpoison UI +;;; Helm ratpoison UI ;; ;; -(defvar anything-c-source-ratpoison-commands +(defvar helm-c-source-ratpoison-commands '((name . "Ratpoison Commands") - (init . anything-c-ratpoison-commands-init) + (init . helm-c-ratpoison-commands-init) (candidates-in-buffer) - (action ("Execute the command" . anything-c-ratpoison-commands-execute)) - (display-to-real . anything-c-ratpoison-commands-display-to-real) + (action ("Execute the command" . helm-c-ratpoison-commands-execute)) + (display-to-real . helm-c-ratpoison-commands-display-to-real) (candidate-number-limit))) -(defun anything-c-ratpoison-commands-init () - (unless (anything-candidate-buffer) - (with-current-buffer (anything-candidate-buffer 'global) +(defun helm-c-ratpoison-commands-init () + (unless (helm-candidate-buffer) + (with-current-buffer (helm-candidate-buffer 'global) ;; with ratpoison prefix key (save-excursion (call-process "ratpoison" nil (current-buffer) nil "-c" "help")) @@ -9534,39 +9474,39 @@ Support install, remove and purge actions." (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t) (replace-match "\\1: \\2"))))) -(defun anything-c-ratpoison-commands-display-to-real (display) +(defun helm-c-ratpoison-commands-display-to-real (display) (and (string-match ": " display) (substring display (match-end 0)))) -(defun anything-c-ratpoison-commands-execute (candidate) +(defun helm-c-ratpoison-commands-execute (candidate) (call-process "ratpoison" nil nil nil "-ic" candidate)) -;;; Anything `completing-read' replacement +;;; Helm `completing-read' replacement ;; ;; -(defun anything-comp-read-get-candidates (collection &optional test sort-fn alistp) +(defun helm-comp-read-get-candidates (collection &optional test sort-fn alistp) "Convert COLLECTION to list removing elements that don't match TEST. -See `anything-comp-read' about supported COLLECTION arguments. +See `helm-comp-read' about supported COLLECTION arguments. SORT-FN is a predicate to sort COLLECTION. ALISTP when non--nil will not use `all-completions' to collect -candidates because it doesn't handle alists correctly for anything. +candidates because it doesn't handle alists correctly for helm. i.e In `all-completions' the keys \(cars of elements\) -are the possible completions. In anything we want to use the cdr instead +are the possible completions. In helm we want to use the cdr instead like \(display . real\). e.g \(setq A '((a . 1) (b . 2) (c . 3))) ==>((a . 1) (b . 2) (c . 3)) -\(anything-comp-read \"test: \" A :alistp nil +\(helm-comp-read \"test: \" A :alistp nil :exec-when-only-one t :initial-input \"a\") ==>\"a\" -\(anything-comp-read \"test: \" A :alistp t +\(helm-comp-read \"test: \" A :alistp t :exec-when-only-one t :initial-input \"1\") ==>\"1\" @@ -9591,37 +9531,37 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." (t (all-completions "" collection))))) (if sort-fn (sort cands sort-fn) cands))) -(defun anything-cr-default-transformer (candidates source) - "Default filter candidate function for `anything-comp-read'. +(defun helm-cr-default-transformer (candidates source) + "Default filter candidate function for `helm-comp-read'. Do nothing, just return candidate list unmodified." candidates) -(defun* anything-comp-read (prompt collection +(defun* helm-comp-read (prompt collection &key test initial-input default preselect - (buffer "*Anything Completions*") + (buffer "*Helm Completions*") must-match (requires-pattern 0) (history nil) input-history (persistent-action nil) (persistent-help "DoNothing") - (mode-line anything-mode-line-string) - (keymap anything-map) - (name "Anything Completions") + (mode-line helm-mode-line-string) + (keymap helm-map) + (name "Helm Completions") candidates-in-buffer exec-when-only-one (volatile t) sort - (fc-transformer 'anything-cr-default-transformer) + (fc-transformer 'helm-cr-default-transformer) (marked-candidates nil) (alistp t)) - "Read a string in the minibuffer, with anything completion. + "Read a string in the minibuffer, with helm completion. -It is anything `completing-read' equivalent. +It is helm `completing-read' equivalent. - PROMPT is the prompt name to use. @@ -9633,18 +9573,18 @@ Keys description: - TEST: A predicate called with one arg i.e candidate. -- INITIAL-INPUT: Same as input arg in `anything'. +- INITIAL-INPUT: Same as input arg in `helm'. -- PRESELECT: See preselect arg of `anything'. +- PRESELECT: See preselect arg of `helm'. - DEFAULT: This option is used only for compatibility with regular Emacs `completing-read'. -- BUFFER: Name of anything-buffer. +- BUFFER: Name of helm-buffer. - MUST-MATCH: Candidate selected must be one of COLLECTION. -- REQUIRES-PATTERN: Same as anything attribute, default is 0. +- REQUIRES-PATTERN: Same as helm attribute, default is 0. - HISTORY: A list containing specific history, default is nil. When it is non--nil, all elements of HISTORY are displayed in @@ -9659,14 +9599,14 @@ Keys description: - PERSISTENT-HELP: A string to document PERSISTENT-ACTION. - MODE-LINE: A string or list to display in mode line. - (See `anything-mode-line-string') + (See `helm-mode-line-string') -- KEYMAP: A keymap to use in this `anything-comp-read'. +- KEYMAP: A keymap to use in this `helm-comp-read'. (The keymap will be shared with history source) - NAME: The name related to this local source. -- EXEC-WHEN-ONLY-ONE: Bound `anything-execute-action-at-once-if-one' +- EXEC-WHEN-ONLY-ONE: Bound `helm-execute-action-at-once-if-one' to non--nil. (possibles values are t or nil). - VOLATILE: Use volatile attribute \(enabled by default\). @@ -9677,22 +9617,22 @@ Keys description: - MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list. -- ALISTP: \(default is non--nil\) See `anything-comp-read-get-candidates'. +- ALISTP: \(default is non--nil\) See `helm-comp-read-get-candidates'. - CANDIDATES-IN-BUFFER: when non--nil use a source build with - `anything-candidates-in-buffer' which is much faster. + `helm-candidates-in-buffer' which is much faster. Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil. -Any prefix args passed during `anything-comp-read' invocation will be recorded -in `anything-current-prefix-arg', otherwise if prefix args were given before -`anything-comp-read' invocation, the value of `current-prefix-arg' will be used. +Any prefix args passed during `helm-comp-read' invocation will be recorded +in `helm-current-prefix-arg', otherwise if prefix args were given before +`helm-comp-read' invocation, the value of `current-prefix-arg' will be used. That's mean you can pass prefix args before or after calling a command -that use `anything-comp-read' See `anything-M-x' for example." - (when (get-buffer anything-action-buffer) - (kill-buffer anything-action-buffer)) +that use `helm-comp-read' See `helm-M-x' for example." + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) (flet ((action-fn (candidate) (if marked-candidates - (anything-marked-candidates) + (helm-marked-candidates) (identity candidate)))) ;; Assume completion have been already required, ;; so always use 'confirm. @@ -9702,20 +9642,20 @@ that use `anything-comp-read' See `anything-M-x' for example." (must-match-map (when must-match (let ((map (make-sparse-keymap))) (define-key map (kbd "RET") - 'anything-confirm-and-exit-minibuffer) + 'helm-confirm-and-exit-minibuffer) map))) - (anything-map (if must-match-map + (helm-map (if must-match-map (make-composed-keymap - must-match-map (or keymap anything-map)) - (or keymap anything-map))) + must-match-map (or keymap helm-map)) + (or keymap helm-map))) (src-hist `((name . ,(format "%s History" name)) (candidates . (lambda () - (let ((all (anything-comp-read-get-candidates + (let ((all (helm-comp-read-get-candidates history nil nil ,alistp))) (delete "" - (anything-fast-remove-dups + (helm-fast-remove-dups (if (and default (not (string= default ""))) (delq nil (cons default (delete default all))) @@ -9733,10 +9673,10 @@ that use `anything-comp-read' See `anything-M-x' for example." (src `((name . ,name) (candidates . (lambda () - (let ((cands (anything-comp-read-get-candidates + (let ((cands (helm-comp-read-get-candidates collection test sort alistp))) - (unless (or must-match (string= anything-pattern "")) - (setq cands (append (list anything-pattern) cands))) + (unless (or must-match (string= helm-pattern "")) + (setq cands (append (list helm-pattern) cands))) (if (and default (not (string= default ""))) (delq nil (cons default (delete default cands))) cands)))) @@ -9749,11 +9689,11 @@ that use `anything-comp-read' See `anything-M-x' for example." (src-1 `((name . ,name) (init . (lambda () - (let ((cands (anything-comp-read-get-candidates + (let ((cands (helm-comp-read-get-candidates collection test sort alistp))) - (unless (or must-match (string= anything-pattern "")) - (setq cands (append (list anything-pattern) cands))) - (with-current-buffer (anything-candidate-buffer 'global) + (unless (or must-match (string= helm-pattern "")) + (setq cands (append (list helm-pattern) cands))) + (with-current-buffer (helm-candidate-buffer 'global) (loop for i in (if (and default (not (string= default ""))) (delq nil (cons default (delete default cands))) @@ -9772,26 +9712,26 @@ that use `anything-comp-read' See `anything-M-x' for example." (if volatile (append src '((volatile))) src)))) - (anything-execute-action-at-once-if-one exec-when-only-one)) + (helm-execute-action-at-once-if-one exec-when-only-one)) (or - (anything + (helm :sources src-list :input initial-input :default default :preselect preselect :prompt prompt :resume 'noresume - :keymap anything-map + :keymap helm-map :history (and (symbolp input-history) input-history) :buffer buffer) - (when (and (eq anything-exit-status 0) + (when (and (eq helm-exit-status 0) (eq must-match 'confirm)) ;; Return empty string only if it is the DEFAULT - ;; value and anything-pattern is empty. - ;; otherwise return anything-pattern - (if (and (string= anything-pattern "") default) - default (identity anything-pattern))) - (unless (or (eq anything-exit-status 1) + ;; value and helm-pattern is empty. + ;; otherwise return helm-pattern + (if (and (string= helm-pattern "") default) + default (identity helm-pattern))) + (unless (or (eq helm-exit-status 1) must-match) ; FIXME this should not be needed now. default) (keyboard-quit))))) @@ -9805,29 +9745,29 @@ that use `anything-comp-read' See `anything-M-x' for example." ;; Some crap emacs functions may not be supported ;; like ffap-alternate-file (bad use of completing-read) ;; and maybe others. -;; Provide a mode `anything-completion-mode' which turn on -;; anything in all `completing-read' and `read-file-name' in Emacs. +;; Provide a mode `helm-mode' which turn on +;; helm in all `completing-read' and `read-file-name' in Emacs. ;; -(defvar anything-completion-mode-string " AC") +(defvar helm-completion-mode-string " Helm") -(defvar anything-completion-mode-quit-message - "Anything completion disabled") +(defvar helm-completion-mode-quit-message + "Helm completion disabled") -(defvar anything-completion-mode-start-message - "Anything completion enabled") +(defvar helm-completion-mode-start-message + "Helm completion enabled") ;;; Specialized handlers ;; ;; -(defun anything-completing-read-symbols +(defun helm-completing-read-symbols (prompt collection test require-match init hist default inherit-input-method name buffer) - "Specialized function for fast symbols completion in `ac-mode'." + "Specialized function for fast symbols completion in `helm-mode'." (or - (anything + (helm :sources `((name . ,name) (init . (lambda () - (with-current-buffer (anything-candidate-buffer 'global) + (with-current-buffer (helm-candidate-buffer 'global) (goto-char (point-min)) (when (and default (stringp default) ;; Some defaults args result as @@ -9840,7 +9780,7 @@ that use `anything-comp-read' See `anything-M-x' for example." for sym in all unless (and default (eq sym default)) do (insert (concat sym "\n")))))) - (persistent-action . anything-lisp-completion-persistent-action) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . identity)) @@ -9856,16 +9796,16 @@ that use `anything-comp-read' See `anything-M-x' for example." ;;; Generic completing read ;; ;; -(defun anything-completing-read-default-1 +(defun helm-completing-read-default-1 (prompt collection test require-match init hist default inherit-input-method name buffer &optional cands-in-buffer exec-when-only-one) - "Call `anything-comp-read' with same args as `completing-read'. + "Call `helm-comp-read' with same args as `completing-read'. Extra optional arg CANDS-IN-BUFFER mean use `candidates-in-buffer' method which is faster. It should be used when candidate list don't need to rebuild dynamically." (let ((history (or (car-safe hist) hist))) - (anything-comp-read + (helm-comp-read prompt collection :test test :history history @@ -9888,46 +9828,46 @@ It should be used when candidate list don't need to rebuild dynamically." ;; with special characters (e.g nnimap+gmail:) :initial-input (and (stringp init) (regexp-quote init))))) -(defun anything-completing-read-with-cands-in-buffer +(defun helm-completing-read-with-cands-in-buffer (prompt collection test require-match init hist default inherit-input-method name buffer) - "Same as `anything-completing-read-default-1' but use candidates-in-buffer." + "Same as `helm-completing-read-default-1' but use candidates-in-buffer." ;; Some commands like find-tag may use `read-file-name' from inside ;; the calculation of collection. in this case it clash with ;; candidates-in-buffer that reuse precedent data (files) which is wrong. - ;; So (re)calculate collection outside of main anything-session. + ;; So (re)calculate collection outside of main helm-session. (let ((cands (all-completions "" collection))) - (anything-completing-read-default-1 prompt cands test require-match + (helm-completing-read-default-1 prompt cands test require-match init hist default inherit-input-method name buffer t))) -(defun* anything-completing-read-default +(defun* helm-completing-read-default (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) - "An anything replacement of `completing-read'. + "An helm replacement of `completing-read'. This function should be used only as a `completing-read-function'. -Don't use it directly, use instead `anything-comp-read' in your programs. +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 anything-completion-mode)) + (declare (special helm-mode)) (let* ((current-command this-command) (str-command (symbol-name current-command)) - (buf-name (format "*ac-mode-%s*" str-command)) + (buf-name (format "*helm-mode-%s*" str-command)) (entry (assq current-command - anything-completing-read-handlers-alist)) + helm-completing-read-handlers-alist)) (def-com (cdr-safe entry)) (str-defcom (and def-com (symbol-name def-com))) (def-args (list prompt collection predicate require-match initial-input hist def inherit-input-method)) ;; Append the two extra args needed to set the buffer and source name - ;; in anything specialized functions. + ;; in helm specialized functions. (any-args (append def-args (list str-command buf-name))) - anything-completion-mode-start-message ; Be quiet - anything-completion-mode-quit-message + helm-completion-mode-start-message ; Be quiet + helm-completion-mode-quit-message (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) ;; Be sure this pesty *completion* buffer doesn't popup. @@ -9936,25 +9876,25 @@ See documentation of `completing-read' and `all-completions' for details." (when (eq def-com 'ido) (setq def-com 'ido-completing-read)) (unless (or (not entry) def-com) ;; An entry in *read-handlers-alist exists but have - ;; a nil value, so we exit from here, disable `ac-mode' + ;; a nil value, so we exit from here, disable `helm-mode' ;; and run the command again with it original behavior. - ;; `ac-mode' will be restored on exit. - (return-from anything-completing-read-default + ;; `helm-mode' will be restored on exit. + (return-from helm-completing-read-default (unwind-protect (progn - (ac-mode -1) + (helm-mode -1) (apply completing-read-function def-args)) - (ac-mode 1)))) - ;; If we use now `completing-read' we MUST turn off `ac-mode' + (helm-mode 1)))) + ;; If we use now `completing-read' we MUST turn off `helm-mode' ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. (when (or (eq def-com 'completing-read) - ;; All specialized functions are prefixed by "anything" + ;; All specialized functions are prefixed by "helm" (and (stringp str-defcom) - (not (string-match "^anything" str-defcom)))) - (ac-mode -1)) + (not (string-match "^helm" str-defcom)))) + (helm-mode -1)) (unwind-protect - (cond (;; An anything specialized function exists, run it. - (and def-com anything-completion-mode) + (cond (;; An helm specialized function exists, run it. + (and def-com helm-mode) (apply def-com any-args)) (;; Try to handle `ido-completing-read' everywhere. (and def-com (eq def-com 'ido-completing-read)) @@ -9964,25 +9904,25 @@ See documentation of `completing-read' and `all-completions' for details." (;; User set explicitely `completing-read' or something similar ;; in *read-handlers-alist, use this with exactly the same ;; args as in `completing-read'. - ;; If we are here `anything-completion-mode' is now disabled. + ;; If we are here `helm-mode' is now disabled. def-com (apply def-com def-args)) - (t ; Fall back to classic `anything-comp-read'. - (anything-completing-read-default-1 + (t ; Fall back to classic `helm-comp-read'. + (helm-completing-read-default-1 prompt collection predicate require-match initial-input hist def inherit-input-method str-command buf-name))) - (ac-mode 1) + (helm-mode 1) ;; When exiting minibuffer, `this-command' is set to - ;; `anything-exit-minibuffer', which is unwanted when starting + ;; `helm-exit-minibuffer', which is unwanted when starting ;; on another `completing-read', so restore `this-command' to ;; initial value when exiting. (setq this-command current-command)))) -(defun* anything-generic-read-file-name +(defun* helm-generic-read-file-name (prompt &optional dir default-filename mustmatch initial predicate) - "An anything replacement of `read-file-name'." - (declare (special anything-completion-mode)) + "An helm replacement of `read-file-name'." + (declare (special helm-mode)) (let* ((default (and default-filename (if (listp default-filename) (car default-filename) @@ -9991,50 +9931,50 @@ See documentation of `completing-read' and `all-completions' for details." (ini-input (and init (expand-file-name init))) (current-command this-command) (str-command (symbol-name current-command)) - (anything-file-completion-sources + (helm-file-completion-sources (cons str-command - (remove str-command anything-file-completion-sources))) - (buf-name (format "*ac-mode-%s*" str-command)) + (remove str-command helm-file-completion-sources))) + (buf-name (format "*helm-mode-%s*" str-command)) (entry (assq current-command - anything-completing-read-handlers-alist)) + helm-completing-read-handlers-alist)) (def-com (cdr-safe entry)) (str-defcom (symbol-name def-com)) (def-args (list prompt dir default-filename mustmatch initial predicate)) ;; Append the two extra args needed to set the buffer and source name - ;; in anything specialized functions. + ;; in helm specialized functions. (any-args (append def-args (list str-command buf-name))) (ido-state ido-mode) - anything-completion-mode-start-message ; Be quiet - anything-completion-mode-quit-message ; Same here + helm-completion-mode-start-message ; Be quiet + helm-completion-mode-quit-message ; Same here fname) ;; Some functions that normally call `completing-read' can switch ;; brutally to `read-file-name' (e.g find-tag), in this case - ;; the anything specialized function will fail because it is build + ;; the helm specialized function will fail because it is build ;; for `completing-read', so set it to 'incompatible to be sure - ;; we switch to `anything-c-read-file-name' and don't try to call it + ;; we switch to `helm-c-read-file-name' and don't try to call it ;; with wrong number of args. (when (and def-com (> (length (help-function-arglist def-com)) 8)) (setq def-com 'incompatible)) (when (eq def-com 'ido) (setq def-com 'ido-read-file-name)) (unless (or (not entry) def-com) - (return-from anything-generic-read-file-name + (return-from helm-generic-read-file-name (unwind-protect (progn - (ac-mode -1) + (helm-mode -1) (apply read-file-name-function def-args)) - (ac-mode 1)))) - ;; If we use now `read-file-name' we MUST turn off `ac-mode' + (helm-mode 1)))) + ;; If we use now `read-file-name' we MUST turn off `helm-mode' ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. (when (or (eq def-com 'read-file-name) (eq def-com 'ido-read-file-name) (and (stringp str-defcom) - (not (string-match "^anything" str-defcom)))) - (ac-mode -1)) + (not (string-match "^helm" str-defcom)))) + (helm-mode -1)) (unwind-protect (setq fname (cond (;; A specialized function exists, run it - ;; with the two extra args specific to anything.. - (and def-com anything-completion-mode + ;; with the two extra args specific to helm.. + (and def-com helm-mode (not (eq def-com 'ido-read-file-name)) (not (eq def-com 'incompatible))) (apply def-com any-args)) @@ -10047,8 +9987,8 @@ See documentation of `completing-read' and `all-completions' for details." ;; run it with default args. (eq def-com 'read-file-name) (apply def-com def-args)) - (t ; Fall back to classic `anything-c-read-file-name'. - (anything-c-read-file-name + (t ; Fall back to classic `helm-c-read-file-name'. + (helm-c-read-file-name prompt :name str-command :buffer buf-name @@ -10056,51 +9996,46 @@ See documentation of `completing-read' and `all-completions' for details." :alistp nil :must-match mustmatch :test predicate)))) - (ac-mode 1) + (helm-mode 1) (ido-mode (if ido-state 1 -1)) - ;; Same comment as in `anything-completing-read-default'. + ;; Same comment as in `helm-completing-read-default'. (setq this-command current-command)) - (if (and mustmatch (not (file-exists-p fname))) - (if (y-or-n-p "File does not exists, create buffer?") - fname (error "Abort file does not exists")) - fname))) + fname)) ;;;###autoload -(define-minor-mode anything-completion-mode - "Toggle generic anything completion. +(define-minor-mode helm-mode + "Toggle generic helm completion. All functions in Emacs that use `completing-read' -or `read-file-name' and friends will use anything interface +or `read-file-name' and friends will use helm interface when this mode is turned on. However you can modify this behavior for functions of your choice -with `anything-completing-read-handlers-alist'. +with `helm-completing-read-handlers-alist'. Called with a positive arg, turn on unconditionally, with a negative arg turn off. -You can turn it on with `ac-mode'. +You can turn it on with `helm-mode'. Some crap emacs functions may not be supported, e.g `ffap-alternate-file' and maybe others -You can add such functions to `anything-completing-read-handlers-alist' +You can add such functions to `helm-completing-read-handlers-alist' with a nil value. Note: This mode will work only partially on Emacs23." - :group 'anything + :group 'helm :global t - :lighter anything-completion-mode-string + :lighter helm-completion-mode-string (declare (special completing-read-function)) - (if anything-completion-mode + (if helm-mode (progn - (setq completing-read-function 'anything-completing-read-default - read-file-name-function 'anything-generic-read-file-name) - (message anything-completion-mode-start-message)) + (setq completing-read-function 'helm-completing-read-default + read-file-name-function 'helm-generic-read-file-name) + (message helm-completion-mode-start-message)) (setq completing-read-function (and (fboundp 'completing-read-default) 'completing-read-default) read-file-name-function (and (fboundp 'read-file-name-default) 'read-file-name-default)) - (message anything-completion-mode-quit-message))) - -(defalias 'ac-mode 'anything-completion-mode) + (message helm-completion-mode-quit-message))) @@ -10110,34 +10045,34 @@ Note: This mode will work only partially on Emacs23." ;; ;; (add-hook 'eshell-mode-hook ;; #'(lambda () -;; (define-key eshell-mode-map [remap pcomplete] 'anything-esh-pcomplete))) +;; (define-key eshell-mode-map [remap pcomplete] 'helm-esh-pcomplete))) ;; -(defvar anything-c-source-esh +(defvar helm-c-source-esh '((name . "Eshell completions") (init . (lambda () (setq pcomplete-current-completions nil pcomplete-last-completion-raw nil) ;; Eshell-command add this hook in all minibuffers - ;; Remove it for the anything one. (Fixed in Emacs24) + ;; Remove it for the helm one. (Fixed in Emacs24) (remove-hook 'minibuffer-setup-hook 'eshell-mode))) - (candidates . anything-esh-get-candidates) - (action . anything-ec-insert)) - "Anything source for Eshell completion.") + (candidates . helm-esh-get-candidates) + (action . helm-ec-insert)) + "Helm source for Eshell completion.") ;; Internal. -(defvar anything-ec-target "") -(defun anything-ec-insert (candidate) +(defvar helm-ec-target "") +(defun helm-ec-insert (candidate) "Replace text at point with CANDIDATE. -The function that call this should set `anything-ec-target' to thing at point. +The function that call this should set `helm-ec-target' to thing at point. This is the same as `ac-insert', just inlined here for compatibility." (let ((pt (point))) - (when (and anything-ec-target - (search-backward anything-ec-target nil t) - (string= (buffer-substring (point) pt) anything-ec-target)) + (when (and helm-ec-target + (search-backward helm-ec-target nil t) + (string= (buffer-substring (point) pt) helm-ec-target)) (delete-region (point) pt))) - (insert (anything-quote-whitespace candidate))) + (insert (helm-quote-whitespace candidate))) -(defun anything-esh-get-candidates () +(defun helm-esh-get-candidates () "Get candidates for eshell completion using `pcomplete'." (catch 'pcompleted (let* ((pcomplete-stub) @@ -10145,7 +10080,7 @@ This is the same as `ac-insert', just inlined here for compatibility." pcomplete-args pcomplete-last pcomplete-index (pcomplete-autolist pcomplete-autolist) (pcomplete-suffix-list pcomplete-suffix-list)) - (with-anything-current-buffer + (with-helm-current-buffer (loop with table = (pcomplete-completions) with entry = (condition-case nil ;; On Emacs24 `try-completion' return @@ -10153,9 +10088,9 @@ This is the same as `ac-insert', just inlined here for compatibility." ;; Otherwise Emacs23 return nil, which ;; is wrong, in this case use pattern ;; to behave like Emacs24. - (or (try-completion anything-pattern + (or (try-completion helm-pattern (pcomplete-entries)) - anything-pattern) + helm-pattern) ;; In Emacs23 `pcomplete-entries' may fail ;; with error, so try this instead. (error @@ -10181,52 +10116,52 @@ This is the same as `ac-insert', just inlined here for compatibility." ;;; Eshell history. ;; ;; -(defvar anything-c-source-eshell-history +(defvar helm-c-source-eshell-history `((name . "Eshell history") (init . (lambda () (let (eshell-hist-ignoredups) ;; Write the content's of ring to file. (eshell-write-history eshell-history-file-name t) - (with-current-buffer (anything-candidate-buffer 'global) + (with-current-buffer (helm-candidate-buffer 'global) (insert-file-contents eshell-history-file-name))) - ;; Same comment as in `anything-c-source-esh' + ;; Same comment as in `helm-c-source-esh' (remove-hook 'minibuffer-setup-hook 'eshell-mode))) (candidates-in-buffer) - (keymap . ,anything-eshell-history-map) + (keymap . ,helm-eshell-history-map) (filtered-candidate-transformer . (lambda (candidates sources) (reverse candidates))) (candidate-number-limit . 9999) (action . (lambda (candidate) (eshell-kill-input) (insert candidate)))) - "Anything source for Eshell history.") + "Helm source for Eshell history.") -;;; Show completion - an alternative of anything-show-completion.el. +;;; Show completion - an alternative of helm-show-completion.el. ;; -;; Provide show completion with macro `with-anything-show-completion'. +;; Provide show completion with macro `with-helm-show-completion'. -;; Called each time cursor move in anything-buffer. -(defun anything-c-show-completion () - (with-anything-current-buffer - (overlay-put anything-c-show-completion-overlay - 'display (anything-get-selection)))) +;; Called each time cursor move in helm-buffer. +(defun helm-c-show-completion () + (with-helm-current-buffer + (overlay-put helm-c-show-completion-overlay + 'display (helm-get-selection)))) -(defun anything-c-show-completion-init-overlay (beg end) - (and anything-c-turn-on-show-completion - (setq anything-c-show-completion-overlay (make-overlay beg end)) - (overlay-put anything-c-show-completion-overlay - 'face 'anything-lisp-show-completion))) +(defun helm-c-show-completion-init-overlay (beg end) + (and helm-c-turn-on-show-completion + (setq helm-c-show-completion-overlay (make-overlay beg end)) + (overlay-put helm-c-show-completion-overlay + 'face 'helm-lisp-show-completion))) -(defun anything-c-show-completion-display-function (buffer) - "A special resized anything window is used depending on position in BUFFER." +(defun helm-c-show-completion-display-function (buffer) + "A special resized helm window is used depending on position in BUFFER." (with-selected-window (selected-window) (let* ((screen-size (+ (count-screen-lines (window-start) (point) t) 1 ; mode-line (if header-line-format 1 0))) ; header-line (def-size (- (window-height) - anything-c-show-completion-min-window-height)) + helm-c-show-completion-min-window-height)) (upper-height (max window-min-height (min screen-size def-size))) split-window-keep-point) (recenter -1) @@ -10235,35 +10170,35 @@ This is the same as `ac-insert', just inlined here for compatibility." (split-window nil upper-height)) buffer)))) -(defmacro with-anything-show-completion (beg end &rest body) - "Show anything candidate in an overlay at point. +(defmacro with-helm-show-completion (beg end &rest body) + "Show helm candidate in an overlay at point. BEG and END are the beginning and end position of the current completion -in `anything-current-buffer'. -BODY is an anything call where we want to enable show completion. -If `anything-c-turn-on-show-completion' is nil just do nothing." +in `helm-current-buffer'. +BODY is an helm call where we want to enable show completion. +If `helm-c-turn-on-show-completion' is nil just do nothing." (declare (indent 2) (debug t)) - `(let ((anything-move-selection-after-hook - (and anything-c-turn-on-show-completion - (append (list 'anything-c-show-completion) - anything-move-selection-after-hook)))) + `(let ((helm-move-selection-after-hook + (and helm-c-turn-on-show-completion + (append (list 'helm-c-show-completion) + helm-move-selection-after-hook)))) (unwind-protect (progn - (anything-c-show-completion-init-overlay ,beg ,end) - (let ((anything-display-function - (if anything-c-show-completion-use-special-display - 'anything-c-show-completion-display-function - 'anything-default-display-buffer))) + (helm-c-show-completion-init-overlay ,beg ,end) + (let ((helm-display-function + (if helm-c-show-completion-use-special-display + 'helm-c-show-completion-display-function + 'helm-default-display-buffer))) ,@body)) - (and anything-c-turn-on-show-completion - (delete-overlay anything-c-show-completion-overlay))))) + (and helm-c-turn-on-show-completion + (delete-overlay helm-c-show-completion-overlay))))) ;;; Lisp symbol completion. ;; ;; ;;;###autoload -(defun anything-lisp-completion-at-point () - "Anything lisp symbol completion at point." +(defun helm-lisp-completion-at-point () + "Helm lisp symbol completion at point." (interactive) (let* ((data (lisp-completion-at-point)) (beg (car data)) @@ -10273,45 +10208,45 @@ If `anything-c-turn-on-show-completion' is nil just do nothing." (lgst-len 0) (target (and beg end (buffer-substring-no-properties beg end))) (candidates (all-completions target (nth 2 data) pred)) - (anything-quit-if-no-candidate t) + (helm-quit-if-no-candidate t) - (anything-execute-action-at-once-if-one t) - (anything-match-plugin-enabled - (member 'anything-compile-source--match-plugin - anything-compile-source-functions))) + (helm-execute-action-at-once-if-one t) + (helm-match-plugin-enabled + (member 'helm-compile-source--match-plugin + helm-compile-source-functions))) (if candidates - (with-anything-show-completion beg end - ;; Overlay is initialized now in anything-current-buffer. - (anything + (with-helm-show-completion beg end + ;; Overlay is initialized now in helm-current-buffer. + (helm :sources '((name . "Lisp completion") (init . (lambda () - (with-current-buffer (anything-candidate-buffer 'global) + (with-current-buffer (helm-candidate-buffer 'global) (loop for sym in candidates for len = (length sym) when (> len lgst-len) do (setq lgst-len len) do (insert (concat sym "\n")))))) (candidates-in-buffer) - (persistent-action . anything-lisp-completion-persistent-action) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") - (filtered-candidate-transformer anything-lisp-completion-transformer) + (filtered-candidate-transformer helm-lisp-completion-transformer) (action . (lambda (candidate) (delete-region beg end) (insert candidate)))) - :input (if anything-match-plugin-enabled (concat target " ") target))) + :input (if helm-match-plugin-enabled (concat target " ") target))) (message "[No Match]")))) -(defun anything-lisp-completion-persistent-action (candidate) +(defun helm-lisp-completion-persistent-action (candidate) (let ((cursor-in-echo-area t) mode-line-in-non-selected-windows) - (anything-c-show-info-in-mode-line + (helm-c-show-info-in-mode-line (propertize - (anything-c-get-first-line-documentation + (helm-c-get-first-line-documentation (intern candidate)) - 'face 'anything-lisp-completion-info)))) + 'face 'helm-lisp-completion-info)))) -(defun anything-lisp-completion-transformer (candidates source) - "Anything candidates transformer for lisp completion." +(defun helm-lisp-completion-transformer (candidates source) + "Helm candidates transformer for lisp completion." (declare (special lgst-len)) (loop for c in candidates for sym = (intern c) @@ -10322,7 +10257,7 @@ If `anything-c-turn-on-show-completion' is nil just do nothing." for spaces = (make-string (- lgst-len (length c)) ? ) collect (cons (concat c spaces annot) c))) -(defun anything-c-get-first-line-documentation (sym) +(defun helm-c-get-first-line-documentation (sym) "Return first line documentation of symbol SYM. If SYM is not documented, return \"Not documented\"." (let ((doc (cond ((fboundp sym) @@ -10342,9 +10277,9 @@ If SYM is not documented, return \"Not documented\"." ;;; File completion. ;; ;; Complete file name at point. -(defun anything-c-thing-before-point () +(defun helm-c-thing-before-point () "Get symbol name before point. -Borrowed from anything-complete.el, inlined here for compatibility." +Borrowed from helm-complete.el, inlined here for compatibility." (save-excursion (let ((beg (point))) ;; older regexp "\(\\|\\s-\\|^\\|\\_<\\|\r\\|'\\|#'" @@ -10353,26 +10288,26 @@ Borrowed from anything-complete.el, inlined here for compatibility." (buffer-substring-no-properties beg (match-end 0)))))) ;;;###autoload -(defun anything-c-complete-file-name-at-point () +(defun helm-c-complete-file-name-at-point () "Complete file name at point." (interactive) (let* ((init (substring-no-properties (thing-at-point 'filename))) (end (point)) (beg (- (point) (length init))) - (anything-quit-if-no-candidate t) - (anything-execute-action-at-once-if-one t) + (helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) completion) - (with-anything-show-completion beg end - (setq completion (anything-c-read-file-name "FileName: " + (with-helm-show-completion beg end + (setq completion (helm-c-read-file-name "FileName: " :initial-input init))) - (anything-c-insert-file-name-completion-at-point completion))) + (helm-c-insert-file-name-completion-at-point completion))) ;; Internal -(defvar anything-lisp-completion-counter 0) +(defvar helm-lisp-completion-counter 0) ;;;###autoload -(defun anything-lisp-completion-at-point-or-indent (arg) +(defun helm-lisp-completion-at-point-or-indent (arg) "First call indent and second call complete lisp symbol. -The second call should happen before `anything-lisp-completion-or-indent-delay', +The second call should happen before `helm-lisp-completion-or-indent-delay', after this delay, next call will indent again. After completion, next call is always indent. See that like click and double mouse click. @@ -10382,22 +10317,22 @@ One hit indent, two quick hits maybe indent and complete." ;; to use `completion-at-point'. (let ((tab-always-indent (if (eq tab-always-indent 'complete) t tab-always-indent))) - (incf anything-lisp-completion-counter) + (incf helm-lisp-completion-counter) (unwind-protect - (if (> anything-lisp-completion-counter 1) - (anything-lisp-completion-or-file-name-at-point) + (if (> helm-lisp-completion-counter 1) + (helm-lisp-completion-or-file-name-at-point) (indent-for-tab-command arg)) - ;; After `anything-lisp-completion-or-indent-delay' seconds + ;; After `helm-lisp-completion-or-indent-delay' seconds ;; reset to 0. - (run-with-timer anything-lisp-completion-or-indent-delay nil + (run-with-timer helm-lisp-completion-or-indent-delay nil #'(lambda () - (setq anything-lisp-completion-counter 0))) + (setq helm-lisp-completion-counter 0))) ;; Always reset to 0 at second hit. - (when (eq anything-lisp-completion-counter 2) - (setq anything-lisp-completion-counter 0))))) + (when (eq helm-lisp-completion-counter 2) + (setq helm-lisp-completion-counter 0))))) ;;;###autoload -(defun anything-lisp-completion-or-file-name-at-point () +(defun helm-lisp-completion-or-file-name-at-point () "Complete lisp symbol or filename at point. Filename completion happen if filename is started in or between double quotes." @@ -10405,12 +10340,12 @@ or between double quotes." (let ((tap (substring-no-properties (thing-at-point 'filename)))) (if (and tap (string-match "^\\(~/\\|/\\|[a-zA-Z]\:/\\).*" tap) (save-excursion (search-backward "\"" (point-at-bol) t))) - (anything-c-complete-file-name-at-point) - (anything-lisp-completion-at-point)))) + (helm-c-complete-file-name-at-point) + (helm-lisp-completion-at-point)))) -(defun anything-c-apropos-init (test default) - "Init candidates buffer for `anything-c-apropos' sources." - (with-current-buffer (anything-candidate-buffer 'global) +(defun helm-c-apropos-init (test default) + "Init candidates buffer for `helm-c-apropos' sources." + (with-current-buffer (helm-candidate-buffer 'global) (goto-char (point-min)) (when (and default (stringp default) ;; Some defaults args result as @@ -10425,19 +10360,19 @@ or between double quotes." do (insert (concat sym "\n"))))) -;;; Run Externals commands within Emacs with anything completion +;;; Run Externals commands within Emacs with helm completion ;; ;; -(defvar anything-external-command-history nil) +(defvar helm-external-command-history nil) -(defun anything-c-external-commands-list-1 (&optional sort) +(defun helm-c-external-commands-list-1 (&optional sort) "Returns a list of all external commands the user can execute. -If `anything-c-external-commands-list' is non-nil it will +If `helm-c-external-commands-list' is non-nil it will return its contents. Else it calculates all external commands -and sets `anything-c-external-commands-list'." - (if anything-c-external-commands-list - anything-c-external-commands-list - (setq anything-c-external-commands-list +and sets `helm-c-external-commands-list'." + (if helm-c-external-commands-list + helm-c-external-commands-list + (setq helm-c-external-commands-list (loop with paths = (split-string (getenv "PATH") path-separator) with completions = () @@ -10452,9 +10387,9 @@ and sets `anything-c-external-commands-list'." append lsdir into completions finally return (if sort (sort completions 'string-lessp) completions))))) -(defun anything-run-or-raise (exe &optional file) +(defun helm-run-or-raise (exe &optional file) "Generic command that run asynchronously EXE. -If EXE is already running just jump to his window if `anything-raise-command' +If EXE is already running just jump to his window if `helm-raise-command' is non--nil. When FILE argument is provided run EXE with FILE. In this case EXE must be provided as \"EXE %s\"." @@ -10462,36 +10397,36 @@ In this case EXE must be provided as \"EXE %s\"." "%s" "" exe)))) (proc (if file (concat real-com " " file) real-com))) (if (get-process proc) - (if anything-raise-command - (shell-command (format anything-raise-command real-com)) + (if helm-raise-command + (shell-command (format helm-raise-command real-com)) (error "Error: %s is already running" real-com)) - (when (loop for i in anything-c-external-commands-list thereis real-com) + (when (loop for i in helm-c-external-commands-list thereis real-com) (message "Starting %s..." real-com) (if file (start-process-shell-command proc nil (format exe (shell-quote-argument (if (eq system-type 'windows-nt) - (anything-w32-prepare-filename file) + (helm-w32-prepare-filename file) file)))) (start-process-shell-command proc nil real-com)) (set-process-sentinel (get-process proc) #'(lambda (process event) (when (and (string= event "finished\n") - anything-raise-command - (not (anything-c-get-pid-from-process-name real-com))) - (shell-command (format anything-raise-command "emacs"))) + helm-raise-command + (not (helm-c-get-pid-from-process-name real-com))) + (shell-command (format helm-raise-command "emacs"))) (message "%s process...Finished." process)))) - (setq anything-c-external-commands-list + (setq helm-c-external-commands-list (cons real-com - (delete real-com anything-c-external-commands-list)))))) + (delete real-com helm-c-external-commands-list)))))) ;;; Generic action functions ;; ;; -(defun anything-c-file-buffers (filename) +(defun helm-c-file-buffers (filename) "Returns a list of buffer names corresponding to FILENAME." (let ((name (expand-file-name filename)) (buf-list ())) @@ -10500,26 +10435,26 @@ In this case EXE must be provided as \"EXE %s\"." (when (and bfn (string= name bfn)) (push (buffer-name buf) buf-list)))))) -(defun anything-revert-buffer (candidate) +(defun helm-revert-buffer (candidate) (with-current-buffer candidate (when (or (buffer-modified-p) (not (verify-visited-file-modtime (get-buffer candidate)))) (revert-buffer t t)))) -(defun anything-revert-marked-buffers (ignore) - (mapc 'anything-revert-buffer (anything-marked-candidates))) +(defun helm-revert-marked-buffers (ignore) + (mapc 'helm-revert-buffer (helm-marked-candidates))) -(defun anything-kill-marked-buffers (ignore) - (mapc 'kill-buffer (anything-marked-candidates))) +(defun helm-kill-marked-buffers (ignore) + (mapc 'kill-buffer (helm-marked-candidates))) -(defun anything-c-delete-file (file &optional error-if-dot-file-p) +(defun helm-c-delete-file (file &optional error-if-dot-file-p) "Delete the given file after querying the user. Ask to kill buffers associated with that file, too." (when (and error-if-dot-file-p - (anything-ff-dot-file-p file)) + (helm-ff-dot-file-p file)) (error "Error: Cannot operate on `.' or `..'")) - (let ((buffers (anything-c-file-buffers file))) + (let ((buffers (helm-c-file-buffers file))) (if (< emacs-major-version 24) ;; `dired-delete-file' in Emacs versions < 24 ;; doesn't support delete-by-moving-to-trash @@ -10541,7 +10476,7 @@ Ask to kill buffers associated with that file, too." (when (y-or-n-p (format "Kill buffer %s, too? " buf)) (kill-buffer buf)))))) -(defun anything-get-mailcap-for-file (filename) +(defun helm-get-mailcap-for-file (filename) "Get the command to use for FILENAME from mailcap files. The command is like and is meant to use with `format'." (mailcap-parse-mailcaps) @@ -10552,34 +10487,34 @@ The command is like and is meant to use with `format'." ;; `mailcap-maybe-eval' is returned, in this case just return nil. (when (stringp result) result))) -(defun anything-get-default-program-for-file (filename) +(defun helm-get-default-program-for-file (filename) "Try to find a default program to open FILENAME. -Try first in `anything-c-external-programs-associations' and then in mailcap file +Try first in `helm-c-external-programs-associations' and then in mailcap file if nothing found return nil." (let* ((ext (file-name-extension filename)) - (def-prog (assoc-default ext anything-c-external-programs-associations))) + (def-prog (assoc-default ext helm-c-external-programs-associations))) (cond ((and def-prog (not (string= def-prog ""))) (concat def-prog " %s")) - ((and anything-c-default-external-file-browser + ((and helm-c-default-external-file-browser (file-directory-p filename)) - (concat anything-c-default-external-file-browser " %s")) - (t (anything-get-mailcap-for-file filename))))) + (concat helm-c-default-external-file-browser " %s")) + (t (helm-get-mailcap-for-file filename))))) -(defun anything-c-open-file-externally (file) +(defun helm-c-open-file-externally (file) "Open FILE with an external program. -Try to guess which program to use with `anything-get-default-program-for-file'. +Try to guess which program to use with `helm-get-default-program-for-file'. If not found or a prefix arg is given query the user which tool to use." (let* ((fname (expand-file-name file)) - (collection (anything-c-external-commands-list-1 'sort)) - (def-prog (anything-get-default-program-for-file fname)) - (real-prog-name (if (or anything-current-prefix-arg (not def-prog)) + (collection (helm-c-external-commands-list-1 'sort)) + (def-prog (helm-get-default-program-for-file fname)) + (real-prog-name (if (or helm-current-prefix-arg (not def-prog)) ;; Prefix arg or no default program. (prog1 - (anything-comp-read + (helm-comp-read "Program: " collection :must-match t :name "Open file Externally" - :history anything-external-command-history) + :history helm-external-command-history) ;; Always prompt to set this program as default. (setq def-prog nil)) ;; No prefix arg or default program exists. @@ -10593,27 +10528,27 @@ If not found or a prefix arg is given query the user which tool to use." (format "Do you want to make `%s' the default program for this kind of files? " real-prog-name)) - (anything-aif (assoc (file-name-extension fname) - anything-c-external-programs-associations) - (setq anything-c-external-programs-associations - (delete it anything-c-external-programs-associations))) + (helm-aif (assoc (file-name-extension fname) + helm-c-external-programs-associations) + (setq helm-c-external-programs-associations + (delete it helm-c-external-programs-associations))) (push (cons (file-name-extension fname) (read-string "Program (Add args maybe and confirm): " real-prog-name)) - anything-c-external-programs-associations) - (customize-save-variable 'anything-c-external-programs-associations - anything-c-external-programs-associations))) - (anything-run-or-raise program file) - (setq anything-external-command-history + helm-c-external-programs-associations) + (customize-save-variable 'helm-c-external-programs-associations + helm-c-external-programs-associations))) + (helm-run-or-raise program file) + (setq helm-external-command-history (cons real-prog-name (delete real-prog-name - (loop for i in anything-external-command-history + (loop for i in helm-external-command-history when (executable-find i) collect i)))))) -(defun anything-c-find-file-or-marked (candidate) - "Open file CANDIDATE or open anything marked files in background." - (let ((marked (anything-marked-candidates)) - (ffap-newfile-prompt anything-ff-newfile-prompt-p) +(defun helm-c-find-file-or-marked (candidate) + "Open file CANDIDATE or open helm marked files in background." + (let ((marked (helm-marked-candidates)) + (ffap-newfile-prompt helm-ff-newfile-prompt-p) (find-file-wildcards nil)) (if (> (length marked) 1) ;; Open all marked files in background and display @@ -10630,15 +10565,15 @@ If not found or a prefix arg is given query the user which tool to use." (let ((dirfname (directory-file-name candidate))) (if (file-exists-p dirfname) (error "Mkdir: Unable to create directory `%s': file exists." - (anything-c-basename dirfname)) + (helm-c-basename dirfname)) (make-directory candidate 'parent))) - (anything-find-files-1 candidate)) + (helm-find-files-1 candidate)) ;; A non--existing filename NOT ending with / or ;; an existing filename, create or jump to it. (find-file-at-point (car marked)))))) -(defun anything-delete-marked-files (ignore) - (let* ((files (anything-marked-candidates)) +(defun helm-delete-marked-files (ignore) + (let* ((files (helm-marked-candidates)) (len (length files))) (if (not (y-or-n-p (format "Delete *%s File(s):\n%s" @@ -10647,35 +10582,35 @@ If not found or a prefix arg is given query the user which tool to use." (message "(No deletions performed)") (dolist (i files) (set-text-properties 0 (length i) nil i) - (anything-c-delete-file i anything-ff-signal-error-on-dot-files)) + (helm-c-delete-file i helm-ff-signal-error-on-dot-files)) (message "%s File(s) deleted" len)))) -(defun anything-ediff-marked-buffers (candidate &optional merge) - "Ediff 2 marked buffers or CANDIDATE and `anything-current-buffer'. +(defun helm-ediff-marked-buffers (candidate &optional merge) + "Ediff 2 marked buffers or CANDIDATE and `helm-current-buffer'. With optional arg MERGE call `ediff-merge-buffers'." - (let ((lg-lst (length (anything-marked-candidates))) + (let ((lg-lst (length (helm-marked-candidates))) buf1 buf2) (case lg-lst (0 (error "Error:You have to mark at least 1 buffer")) (1 - (setq buf1 anything-current-buffer - buf2 (first (anything-marked-candidates)))) + (setq buf1 helm-current-buffer + buf2 (first (helm-marked-candidates)))) (2 - (setq buf1 (first (anything-marked-candidates)) - buf2 (second (anything-marked-candidates)))) + (setq buf1 (first (helm-marked-candidates)) + buf2 (second (helm-marked-candidates)))) (t (error "Error:To much buffers marked!"))) (if merge (ediff-merge-buffers buf1 buf2) (ediff-buffers buf1 buf2)))) -(defun anything-ediff-marked-buffers-merge (candidate) - "Ediff merge `anything-current-buffer' with CANDIDATE. -See `anything-ediff-marked-buffers'." - (anything-ediff-marked-buffers candidate t)) +(defun helm-ediff-marked-buffers-merge (candidate) + "Ediff merge `helm-current-buffer' with CANDIDATE. +See `helm-ediff-marked-buffers'." + (helm-ediff-marked-buffers candidate t)) -(defun anything-bookmark-get-bookmark-from-name (bmk) +(defun helm-bookmark-get-bookmark-from-name (bmk) "Return bookmark name even if it is a bookmark with annotation. e.g prepended with *. Return nil if bmk is not a valid bookmark." @@ -10685,20 +10620,20 @@ Return nil if bmk is not a valid bookmark." (when (assoc bmk bookmark-alist) bmk)))) -(defun anything-delete-marked-bookmarks (ignore) +(defun helm-delete-marked-bookmarks (ignore) "Delete this bookmark or all marked bookmarks." - (dolist (i (anything-marked-candidates)) - (bookmark-delete (anything-bookmark-get-bookmark-from-name i) + (dolist (i (helm-marked-candidates)) + (bookmark-delete (helm-bookmark-get-bookmark-from-name i) 'batch))) -(defun anything-require-or-error (feature function) +(defun helm-require-or-error (feature function) (or (require feature nil t) (error "Need %s to use `%s'." feature function))) -(defun anything-find-buffer-on-elscreen (candidate) +(defun helm-find-buffer-on-elscreen (candidate) "Open buffer in new screen, if marked buffers open all in elscreens." - (anything-require-or-error 'elscreen 'anything-find-buffer-on-elscreen) - (anything-aif (anything-marked-candidates) + (helm-require-or-error 'elscreen 'helm-find-buffer-on-elscreen) + (helm-aif (helm-marked-candidates) (dolist (i it) (let ((target-screen (elscreen-find-screen-by-buffer (get-buffer i) 'create))) @@ -10707,11 +10642,11 @@ Return nil if bmk is not a valid bookmark." (get-buffer candidate) 'create))) (elscreen-goto target-screen)))) -(defun anything-elscreen-find-file (file) - (anything-require-or-error 'elscreen 'anything-elscreen-find-file) +(defun helm-elscreen-find-file (file) + (helm-require-or-error 'elscreen 'helm-elscreen-find-file) (elscreen-find-file file)) -(defun anything-w32-prepare-filename (file) +(defun helm-w32-prepare-filename (file) "Convert filename FILE to something usable by external w32 executables." (replace-regexp-in-string ; For UNC paths "/" "\\" @@ -10720,16 +10655,16 @@ Return nil if bmk is not a valid bookmark." file nil nil) nil t)) ;;;###autoload -(defun anything-w32-shell-execute-open-file (file) +(defun helm-w32-shell-execute-open-file (file) (interactive "fOpen file:") (with-no-warnings - (w32-shell-execute "open" (anything-w32-prepare-filename file)))) + (w32-shell-execute "open" (helm-w32-prepare-filename file)))) -(defun anything-c-open-file-with-default-tool (file) +(defun helm-c-open-file-with-default-tool (file) "Open FILE with the default tool on this platform." (if (eq system-type 'windows-nt) - (anything-w32-shell-execute-open-file file) - (start-process "anything-c-open-file-with-default-tool" + (helm-w32-shell-execute-open-file file) + (start-process "helm-c-open-file-with-default-tool" nil (cond ((eq system-type 'gnu/linux) "xdg-open") @@ -10738,7 +10673,7 @@ Return nil if bmk is not a valid bookmark." "open")) file))) -(defun anything-c-open-dired (file) +(defun helm-c-open-dired (file) "Opens a dired buffer in FILE's directory. If FILE is a directory, open this directory." (if (file-directory-p file) @@ -10746,31 +10681,31 @@ directory, open this directory." (dired (file-name-directory file)) (dired-goto-file file))) -(defun anything-c-display-to-real-line (candidate) +(defun helm-c-display-to-real-line (candidate) (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate) (list (string-to-number (match-string 1 candidate)) (match-string 2 candidate)) (error "Line number not found"))) -(defun anything-c-action-line-goto (lineno-and-content) - (apply #'anything-goto-file-line (anything-interpret-value (anything-attr 'target-file)) +(defun helm-c-action-line-goto (lineno-and-content) + (apply #'helm-goto-file-line (helm-interpret-value (helm-attr 'target-file)) (append lineno-and-content - (list (if (and (anything-attr-defined 'target-file) - (not anything-in-persistent-action)) + (list (if (and (helm-attr-defined 'target-file) + (not helm-in-persistent-action)) 'find-file-other-window 'find-file))))) -(defun* anything-c-action-file-line-goto (file-line-content &optional (find-file-function #'find-file)) - (apply #'anything-goto-file-line +(defun* helm-c-action-file-line-goto (file-line-content &optional (find-file-function #'find-file)) + (apply #'helm-goto-file-line (if (stringp file-line-content) ;; Case: filtered-candidate-transformer is skipped - (cdr (anything-c-filtered-candidate-transformer-file-line-1 file-line-content)) + (cdr (helm-c-filtered-candidate-transformer-file-line-1 file-line-content)) file-line-content))) (require 'compile) -(defun anything-c-filtered-candidate-transformer-file-line (candidates source) - (delq nil (mapcar 'anything-c-filtered-candidate-transformer-file-line-1 candidates))) +(defun helm-c-filtered-candidate-transformer-file-line (candidates source) + (delq nil (mapcar 'helm-c-filtered-candidate-transformer-file-line-1 candidates))) -(defun anything-c-filtered-candidate-transformer-file-line-1 (candidate) +(defun helm-c-filtered-candidate-transformer-file-line-1 (candidate) (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate) (let ((filename (match-string 1 candidate)) (lineno (match-string 2 candidate)) @@ -10781,35 +10716,35 @@ directory, open this directory." content) (list (expand-file-name filename - (or (anything-interpret-value (anything-attr 'default-directory)) - (and (anything-candidate-buffer) + (or (helm-interpret-value (helm-attr 'default-directory)) + (and (helm-candidate-buffer) (buffer-local-value - 'default-directory (anything-candidate-buffer))))) + 'default-directory (helm-candidate-buffer))))) (string-to-number lineno) content))))) -(defun* anything-goto-file-line (file lineno content &optional (find-file-function #'find-file)) - (anything-aif (anything-attr 'before-jump-hook) +(defun* helm-goto-file-line (file lineno content &optional (find-file-function #'find-file)) + (helm-aif (helm-attr 'before-jump-hook) (funcall it)) (when file (funcall find-file-function file)) - (if (anything-attr-defined 'adjust) - (anything-c-goto-line-with-adjustment lineno content) - (anything-goto-line lineno)) - (unless (anything-attr-defined 'recenter) - (set-window-start (get-buffer-window anything-current-buffer) (point))) - (anything-aif (anything-attr 'after-jump-hook) + (if (helm-attr-defined 'adjust) + (helm-c-goto-line-with-adjustment lineno content) + (helm-goto-line lineno)) + (unless (helm-attr-defined 'recenter) + (set-window-start (get-buffer-window helm-current-buffer) (point))) + (helm-aif (helm-attr 'after-jump-hook) (funcall it)) - (when anything-in-persistent-action - (anything-match-line-color-current-line))) + (when helm-in-persistent-action + (helm-match-line-color-current-line))) -(defun anything-find-file-as-root (candidate) - (find-file (concat "/" anything-su-or-sudo "::" (expand-file-name candidate)))) +(defun helm-find-file-as-root (candidate) + (find-file (concat "/" helm-su-or-sudo "::" (expand-file-name candidate)))) -(defun anything-find-many-files (ignore) - (mapc 'find-file (anything-marked-candidates))) +(defun helm-find-many-files (ignore) + (mapc 'find-file (helm-marked-candidates))) ;; borrowed from etags.el -;; (anything-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el") -(defun anything-c-goto-line-with-adjustment (line line-content) +;; (helm-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el") +(defun helm-c-goto-line-with-adjustment (line line-content) (let ((startpos) offset found pat) ;; This constant is 1/2 the initial search window. @@ -10822,7 +10757,7 @@ directory, open this directory." "\\(^\\|\^m\\) *" "^ *") ;allow indent (regexp-quote line-content))) ;; If no char pos was given, try the given line number. - (setq startpos (progn (anything-goto-line line) (point))) + (setq startpos (progn (helm-goto-line line) (point))) (or startpos (setq startpos (point-min))) ;; First see if the tag is right at the specified location. (goto-char startpos) @@ -10844,97 +10779,97 @@ directory, open this directory." (forward-char 1)) (beginning-of-line)) -(anything-document-attribute 'default-directory "type . file-line" +(helm-document-attribute 'default-directory "type . file-line" "`default-directory' to interpret file.") -(anything-document-attribute 'before-jump-hook "type . file-line / line" +(helm-document-attribute 'before-jump-hook "type . file-line / line" "Function to call before jumping to the target location.") -(anything-document-attribute 'after-jump-hook "type . file-line / line" +(helm-document-attribute 'after-jump-hook "type . file-line / line" "Function to call after jumping to the target location.") -(anything-document-attribute 'adjust "type . file-line" +(helm-document-attribute 'adjust "type . file-line" "Search around line matching line contents.") -(anything-document-attribute 'recenter "type . file-line / line" +(helm-document-attribute 'recenter "type . file-line / line" "`recenter' after jumping.") -(anything-document-attribute 'target-file "type . line" +(helm-document-attribute 'target-file "type . line" "Goto line of target-file.") ;;;###autoload -(defun anything-c-call-interactively (cmd-or-name) +(defun helm-c-call-interactively (cmd-or-name) "Execute CMD-OR-NAME as Emacs command. It is added to `extended-command-history'. -`anything-current-prefix-arg' is used as the command's prefix argument." +`helm-current-prefix-arg' is used as the command's prefix argument." (setq extended-command-history - (cons (anything-c-stringify cmd-or-name) - (delete (anything-c-stringify cmd-or-name) extended-command-history))) - (let ((current-prefix-arg anything-current-prefix-arg) - (cmd (anything-c-symbolify cmd-or-name))) + (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 anything-c-set-variable (var) +(defun helm-c-set-variable (var) "Set value to VAR interactively." (interactive) - (let ((sym (anything-c-symbolify var))) + (let ((sym (helm-c-symbolify var))) (set sym (eval-minibuffer (format "Set %s: " var) (prin1-to-string (symbol-value sym)))))) ;; (setq hh 12) -;; (anything-c-set-variable 'hh) +;; (helm-c-set-variable 'hh) ;;; Persistent Action Helpers ;; ;; -(defvar anything-match-line-overlay-face nil) -(defvar anything-match-line-overlay nil) +(defvar helm-match-line-overlay-face nil) +(defvar helm-match-line-overlay nil) -(defun anything-match-line-color-current-line (&optional start end buf face rec) +(defun helm-match-line-color-current-line (&optional start end buf face rec) "Highlight and underline current position" (let ((args (list (or start (line-beginning-position)) (or end (1+ (line-end-position))) buf))) - (if (not anything-match-line-overlay) - (setq anything-match-line-overlay (apply 'make-overlay args)) - (apply 'move-overlay anything-match-line-overlay args))) - (overlay-put anything-match-line-overlay - 'face (or face anything-match-line-overlay-face)) + (if (not helm-match-line-overlay) + (setq helm-match-line-overlay (apply 'make-overlay args)) + (apply 'move-overlay helm-match-line-overlay args))) + (overlay-put helm-match-line-overlay + 'face (or face helm-match-line-overlay-face)) (when rec (goto-char start) (recenter))) -(defalias 'anything-persistent-highlight-point 'anything-match-line-color-current-line) +(defalias 'helm-persistent-highlight-point 'helm-match-line-color-current-line) -(setq anything-match-line-overlay-face 'anything-overlay-line-face) +(setq helm-match-line-overlay-face 'helm-overlay-line-face) -(defun anything-match-line-cleanup () - (when anything-match-line-overlay - (delete-overlay anything-match-line-overlay) - (setq anything-match-line-overlay nil))) +(defun helm-match-line-cleanup () + (when helm-match-line-overlay + (delete-overlay helm-match-line-overlay) + (setq helm-match-line-overlay nil))) -(defun anything-match-line-update () - (when anything-match-line-overlay - (delete-overlay anything-match-line-overlay) - (anything-match-line-color-current-line))) +(defun helm-match-line-update () + (when helm-match-line-overlay + (delete-overlay helm-match-line-overlay) + (helm-match-line-color-current-line))) -(add-hook 'anything-cleanup-hook 'anything-match-line-cleanup) -(add-hook 'anything-after-persistent-action-hook 'anything-match-line-update) +(add-hook 'helm-cleanup-hook 'helm-match-line-cleanup) +(add-hook 'helm-after-persistent-action-hook 'helm-match-line-update) ;;; Actions Transformers ;; ;; ;;; Files -(defun anything-c-transform-file-load-el (actions candidate) +(defun helm-c-transform-file-load-el (actions candidate) "Add action to load the file CANDIDATE if it is an emacs lisp file. Else return ACTIONS unmodified." (if (member (file-name-extension candidate) '("el" "elc")) (append actions '(("Load Emacs Lisp File" . load-file))) actions)) -(defun anything-c-transform-file-browse-url (actions candidate) +(defun helm-c-transform-file-browse-url (actions candidate) "Add an action to browse the file CANDIDATE if it in a html file or URL. Else return ACTIONS unmodified." (let ((browse-action '("Browse with Browser" . browse-url))) @@ -10945,17 +10880,17 @@ file or URL. Else return ACTIONS unmodified." (t actions)))) ;;; Function -(defun anything-c-transform-function-call-interactively (actions candidate) +(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" . - anything-c-call-interactively))) + helm-c-call-interactively))) actions)) ;;;; S-Expressions -(defun anything-c-transform-sexp-eval-command-sexp (actions candidate) +(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))) @@ -10974,82 +10909,82 @@ evaluate it and put it onto the `command-history'." ;; ;; ;;; Buffers -(defun anything-c-skip-boring-buffers (buffers) - (anything-c-skip-entries buffers anything-c-boring-buffer-regexp)) +(defun helm-c-skip-boring-buffers (buffers) + (helm-c-skip-entries buffers helm-c-boring-buffer-regexp)) -(defun anything-c-skip-current-buffer (buffers) +(defun helm-c-skip-current-buffer (buffers) "[DEPRECATED] Skip current buffer in buffer lists. This transformer should not be used as this is now handled directly -in `anything-c-buffer-list' and `anything-c-highlight-buffers'." - (if anything-allow-skipping-current-buffer - (remove (buffer-name anything-current-buffer) buffers) +in `helm-c-buffer-list' and `helm-c-highlight-buffers'." + (if helm-allow-skipping-current-buffer + (remove (buffer-name helm-current-buffer) buffers) buffers)) -(defun anything-c-shadow-boring-buffers (buffers) - "Buffers matching `anything-c-boring-buffer-regexp' will be +(defun helm-c-shadow-boring-buffers (buffers) + "Buffers matching `helm-c-boring-buffer-regexp' will be displayed with the `file-name-shadow' face if available." - (anything-c-shadow-entries buffers anything-c-boring-buffer-regexp)) + (helm-c-shadow-entries buffers helm-c-boring-buffer-regexp)) -(defvar anything-c-buffer-display-string-functions - '(anything-c-buffer-display-string--compilation - anything-c-buffer-display-string--shell - anything-c-buffer-display-string--eshell) +(defvar helm-c-buffer-display-string-functions + '(helm-c-buffer-display-string--compilation + helm-c-buffer-display-string--shell + helm-c-buffer-display-string--eshell) "Functions to setup display string for buffer. Function has one argument, buffer name. If it returns string, use it. If it returns nil, display buffer name. -See `anything-c-buffer-display-string--compilation' for example.") +See `helm-c-buffer-display-string--compilation' for example.") -(defun anything-c-transform-buffer-display-string (buffers) +(defun helm-c-transform-buffer-display-string (buffers) "Setup display string for buffer candidates -using `anything-c-buffer-display-string-functions'." +using `helm-c-buffer-display-string-functions'." (loop for buf in buffers if (consp buf) collect buf else for disp = (progn (set-buffer buf) (run-hook-with-args-until-success - 'anything-c-buffer-display-string-functions buf)) + 'helm-c-buffer-display-string-functions buf)) collect (if disp (cons disp buf) buf))) -(defun anything-c-buffer-display-string--compilation (buf) - (anything-aif (car compilation-arguments) +(defun helm-c-buffer-display-string--compilation (buf) + (helm-aif (car compilation-arguments) (format "%s: %s [%s]" buf it default-directory))) -(defun anything-c-buffer-display-string--eshell (buf) +(defun helm-c-buffer-display-string--eshell (buf) (declare (special eshell-history-ring)) (when (eq major-mode 'eshell-mode) (format "%s: %s [%s]" buf (ignore-errors (ring-ref eshell-history-ring 0)) default-directory))) -(defun anything-c-buffer-display-string--shell (buf) +(defun helm-c-buffer-display-string--shell (buf) (when (eq major-mode 'shell-mode) (format "%s: %s [%s]" buf (ignore-errors (ring-ref comint-input-ring 0)) default-directory))) ;;; Files -(defun anything-c-shadow-boring-files (files) - "Files matching `anything-c-boring-file-regexp' will be +(defun helm-c-shadow-boring-files (files) + "Files matching `helm-c-boring-file-regexp' will be displayed with the `file-name-shadow' face if available." - (anything-c-shadow-entries files anything-c-boring-file-regexp)) + (helm-c-shadow-entries files helm-c-boring-file-regexp)) -(defun anything-c-skip-boring-files (files) - "Files matching `anything-c-boring-file-regexp' will be skipped." - (anything-c-skip-entries files anything-c-boring-file-regexp)) -;; (anything-c-skip-boring-files '("README" "/src/.svn/hoge")) +(defun helm-c-skip-boring-files (files) + "Files matching `helm-c-boring-file-regexp' will be skipped." + (helm-c-skip-entries files helm-c-boring-file-regexp)) +;; (helm-c-skip-boring-files '("README" "/src/.svn/hoge")) -(defun anything-c-skip-current-file (files) +(defun helm-c-skip-current-file (files) "Current file will be skipped." - (remove (buffer-file-name anything-current-buffer) files)) + (remove (buffer-file-name helm-current-buffer) files)) -(defun anything-c-w32-pathname-transformer (args) +(defun helm-c-w32-pathname-transformer (args) "Change undesirable features of windows pathnames to ones more acceptable to other candidate transformers." (if (eq system-type 'windows-nt) - (anything-transform-mapcar + (helm-transform-mapcar (lambda (x) (replace-regexp-in-string "/cygdrive/\\(.\\)" "\\1:" @@ -11057,11 +10992,11 @@ other candidate transformers." args) args)) -(defun anything-c-shorten-home-path (files) +(defun helm-c-shorten-home-path (files) "Replaces /home/user with ~." (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows... (getenv "HOME")))) - (anything-transform-mapcar + (helm-transform-mapcar (lambda (file) (if (and (stringp file) (string-match home file)) (cons (replace-match "~" nil nil file) file) @@ -11069,7 +11004,7 @@ other candidate transformers." files))) ;;; Functions -(defun anything-c-mark-interactive-functions (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 @@ -11084,58 +11019,58 @@ other candidate transformers." ;; ;; ;; Internal -(defvar anything-c-adaptive-done nil +(defvar helm-c-adaptive-done nil "nil if history information is not yet stored for the current selection.") -(defvar anything-c-adaptive-history nil +(defvar helm-c-adaptive-history nil "Contains the stored history information. Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)") -;; Should run at beginning of `anything-initial-setup'. -(add-hook 'anything-before-initialize-hook #'(lambda () - (when anything-c-use-adaptative-sorting - (setq anything-c-adaptive-done nil)))) +;; Should run at beginning of `helm-initial-setup'. +(add-hook 'helm-before-initialize-hook #'(lambda () + (when helm-c-use-adaptative-sorting + (setq helm-c-adaptive-done nil)))) -;; Should run at beginning of `anything-exit-minibuffer'. -(add-hook 'anything-before-action-hook #'(lambda () - (when anything-c-use-adaptative-sorting - (anything-c-adaptive-store-selection)))) +;; Should run at beginning of `helm-exit-minibuffer'. +(add-hook 'helm-before-action-hook #'(lambda () + (when helm-c-use-adaptative-sorting + (helm-c-adaptive-store-selection)))) -;; Should run at beginning of `anything-select-action'. -(add-hook 'anything-select-action-hook #'(lambda () - (when anything-c-use-adaptative-sorting - (anything-c-adaptive-store-selection)))) +;; Should run at beginning of `helm-select-action'. +(add-hook 'helm-select-action-hook #'(lambda () + (when helm-c-use-adaptative-sorting + (helm-c-adaptive-store-selection)))) -(defun anything-c-source-use-adaptative-p (&optional source-name) +(defun helm-c-source-use-adaptative-p (&optional source-name) "Return current source only if it use adaptative history, nil otherwise." - (when anything-c-use-adaptative-sorting - (let* ((source (or source-name (anything-get-current-source))) + (when helm-c-use-adaptative-sorting + (let* ((source (or source-name (helm-get-current-source))) (adapt-source (or (assoc-default 'filtered-candidate-transformer (assoc (assoc-default 'type source) - anything-type-attributes)) + helm-type-attributes)) (assoc-default 'candidate-transformer (assoc (assoc-default 'type source) - anything-type-attributes)) + helm-type-attributes)) (assoc-default 'filtered-candidate-transformer source) (assoc-default 'candidate-transformer source)))) (if (listp adapt-source) - (when (member 'anything-c-adaptive-sort adapt-source) source) - (when (eq adapt-source 'anything-c-adaptive-sort) source))))) + (when (member 'helm-c-adaptive-sort adapt-source) source) + (when (eq adapt-source 'helm-c-adaptive-sort) source))))) -(defun anything-c-adaptive-store-selection () +(defun helm-c-adaptive-store-selection () "Store history information for the selected candidate." - (unless anything-c-adaptive-done - (setq anything-c-adaptive-done t) - (let ((source (anything-c-source-use-adaptative-p))) + (unless helm-c-adaptive-done + (setq helm-c-adaptive-done t) + (let ((source (helm-c-source-use-adaptative-p))) (when source (let* ((source-name (or (assoc-default 'type source) (assoc-default 'name source))) - (source-info (or (assoc source-name anything-c-adaptive-history) + (source-info (or (assoc source-name helm-c-adaptive-history) (progn - (push (list source-name) anything-c-adaptive-history) - (car anything-c-adaptive-history)))) - (selection (anything-get-selection)) + (push (list source-name) helm-c-adaptive-history) + (car helm-c-adaptive-history)))) + (selection (helm-get-selection)) (selection-info (progn (setcdr source-info (cons @@ -11156,10 +11091,10 @@ Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) .. (pattern-info (progn (setcdr selection-info (cons - (let ((found (assoc anything-pattern (cdr selection-info)))) + (let ((found (assoc helm-pattern (cdr selection-info)))) (if (not found) ;; new entry - (cons anything-pattern 0) + (cons helm-pattern 0) ;; move entry to the beginning of the ;; list, so if two patterns used the @@ -11175,40 +11110,40 @@ Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) .. (setcdr pattern-info (1+ (cdr pattern-info))) ;; truncate history if needed - (if (> (length (cdr selection-info)) anything-c-adaptive-history-length) + (if (> (length (cdr selection-info)) helm-c-adaptive-history-length) (setcdr selection-info - (subseq (cdr selection-info) 0 anything-c-adaptive-history-length)))))))) + (subseq (cdr selection-info) 0 helm-c-adaptive-history-length)))))))) -(defun anything-c-adaptative-maybe-load-history () - (when (and anything-c-use-adaptative-sorting - (file-readable-p anything-c-adaptive-history-file)) - (load-file anything-c-adaptive-history-file))) +(defun helm-c-adaptative-maybe-load-history () + (when (and helm-c-use-adaptative-sorting + (file-readable-p helm-c-adaptive-history-file)) + (load-file helm-c-adaptive-history-file))) -(add-hook 'emacs-startup-hook 'anything-c-adaptative-maybe-load-history) -(add-hook 'kill-emacs-hook 'anything-c-adaptive-save-history) +(add-hook 'emacs-startup-hook 'helm-c-adaptative-maybe-load-history) +(add-hook 'kill-emacs-hook 'helm-c-adaptive-save-history) -(defun anything-c-adaptive-save-history (&optional arg) - "Save history information to file given by `anything-c-adaptive-history-file'." +(defun helm-c-adaptive-save-history (&optional arg) + "Save history information to file given by `helm-c-adaptive-history-file'." (interactive "p") - (when anything-c-use-adaptative-sorting + (when helm-c-use-adaptative-sorting (with-temp-buffer (insert ";; -*- mode: emacs-lisp -*-\n" - ";; History entries used for anything adaptive display.\n") - (prin1 `(setq anything-c-adaptive-history ',anything-c-adaptive-history) + ";; History entries used for helm adaptive display.\n") + (prin1 `(setq helm-c-adaptive-history ',helm-c-adaptive-history) (current-buffer)) (insert ?\n) - (write-region (point-min) (point-max) anything-c-adaptive-history-file nil + (write-region (point-min) (point-max) helm-c-adaptive-history-file nil (unless arg 'quiet))))) -(defun anything-c-adaptive-sort (candidates source) +(defun helm-c-adaptive-sort (candidates source) "Sort the CANDIDATES for SOURCE by usage frequency. This is a filtered candidate transformer you can use for the attribute `filtered-candidate-transformer' of a source in -`anything-sources' or a type in `anything-type-attributes'." +`helm-sources' or a type in `helm-type-attributes'." (let* ((source-name (or (assoc-default 'type source) (assoc-default 'name source))) - (source-info (assoc source-name anything-c-adaptive-history))) + (source-info (assoc source-name helm-c-adaptive-history))) (if source-info (let ((usage ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT) @@ -11217,7 +11152,7 @@ attribute `filtered-candidate-transformer' of a source in (let ((count 0)) (dolist (pattern-info (cdr candidate-info)) (if (not (equal (car pattern-info) - anything-pattern)) + helm-pattern)) (incf count (cdr pattern-info)) ;; if current pattern is equal to the previously @@ -11240,31 +11175,31 @@ attribute `filtered-candidate-transformer' of a source in ;; put those candidates first which have the highest usage count (dolist (info usage) (when (member* (car info) candidates - :test 'anything-c-adaptive-compare) + :test 'helm-c-adaptive-compare) (push (car info) sorted) (setq candidates (remove* (car info) candidates - :test 'anything-c-adaptive-compare)))) + :test 'helm-c-adaptive-compare)))) ;; and append the rest (append (reverse sorted) candidates nil)) (message "Your `%s' is maybe corrupted or too old, \ -you should reinitialize it with `anything-c-reset-adaptative-history'" - anything-c-adaptive-history-file) +you should reinitialize it with `helm-c-reset-adaptative-history'" + helm-c-adaptive-history-file) (sit-for 1) candidates)) ;; if there is no information stored for this source then do nothing candidates))) ;;;###autoload -(defun anything-c-reset-adaptative-history () - "Delete all `anything-c-adaptive-history' and his file. -Useful when you have a old or corrupted `anything-c-adaptive-history-file'." +(defun helm-c-reset-adaptative-history () + "Delete all `helm-c-adaptive-history' and his file. +Useful when you have a old or corrupted `helm-c-adaptive-history-file'." (interactive) - (when (y-or-n-p "Really delete all your `anything-c-adaptive-history'? ") - (setq anything-c-adaptive-history nil) - (delete-file anything-c-adaptive-history-file))) + (when (y-or-n-p "Really delete all your `helm-c-adaptive-history'? ") + (setq helm-c-adaptive-history nil) + (delete-file helm-c-adaptive-history-file))) -(defun anything-c-adaptive-compare (x y) +(defun helm-c-adaptive-compare (x y) "Compare candidates X and Y taking into account that the candidate can be in (DISPLAY . REAL) format." (equal (if (listp x) @@ -11279,21 +11214,21 @@ candidate can be in (DISPLAY . REAL) format." ;;; Outliner ;; ;; -(defvar anything-outline-goto-near-line-flag t) -(defvar anything-outline-using nil) -(defun anything-after-update-hook--outline () - (if (and (eq anything-outline-using t) - (eq anything-outline-goto-near-line-flag t)) - (anything-outline-goto-near-line))) -(add-hook 'anything-after-update-hook 'anything-after-update-hook--outline) +(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 anything-outline-goto-near-line () - (with-anything-window +(defun helm-outline-goto-near-line () + (with-helm-window ;; TODO need consideration whether to update position by every input. - (when t ; (equal anything-pattern "") - (anything-goto-line 2) - (let ((lineno (with-anything-current-buffer - (line-number-at-pos (car anything-current-position))))) + (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)) @@ -11304,8 +11239,8 @@ candidate can be in (DISPLAY . REAL) format." (return-from exit)))) (forward-line -1) (and (bobp) (forward-line 1)) - (and (anything-pos-header-line-p) (forward-line -2)) - (anything-mark-current-line))))) + (and (helm-pos-header-line-p) (forward-line -2)) + (helm-mark-current-line))))) @@ -11313,16 +11248,16 @@ candidate can be in (DISPLAY . REAL) format." ;; ;; ;; Plug-in: info-index -(defun* anything-c-info-init (&optional (file (anything-attr 'info-file))) +(defun* helm-c-info-init (&optional (file (helm-attr 'info-file))) (let (result) - (unless (anything-candidate-buffer) + (unless (helm-candidate-buffer) (save-window-excursion (info file) (let (Info-history - (tobuf (anything-candidate-buffer 'global)) + (tobuf (helm-candidate-buffer 'global)) (infobuf (current-buffer)) s e) - (dolist (node (or (anything-attr 'index-nodes) (Info-index-nodes))) + (dolist (node (or (helm-attr 'index-nodes) (Info-index-nodes))) (Info-goto-node node) (goto-char (point-min)) (while (search-forward "\n* " nil t) @@ -11334,50 +11269,50 @@ candidate can be in (DISPLAY . REAL) format." (insert-buffer-substring infobuf s e) (insert "\n")))))))))) -(defun anything-c-info-goto (node-line) +(defun helm-c-info-goto (node-line) (Info-goto-node (car node-line)) - (anything-goto-line (cdr node-line))) + (helm-goto-line (cdr node-line))) -(defun anything-c-info-display-to-real (line) +(defun helm-c-info-display-to-real (line) (and (string-match ;; This regexp is stolen from Info-apropos-matches "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line) - (cons (format "(%s)%s" (anything-attr 'info-file) (match-string 2 line)) + (cons (format "(%s)%s" (helm-attr 'info-file) (match-string 2 line)) (string-to-number (or (match-string 3 line) "1"))))) -(defun anything-c-make-info-source (source file) +(defun helm-c-make-info-source (source file) `(,@source (name . ,(concat "Info Index: " file)) (info-file . ,file) - (init . anything-c-info-init) - (display-to-real . anything-c-info-display-to-real) + (init . helm-c-info-init) + (display-to-real . helm-c-info-display-to-real) (get-line . buffer-substring) (candidates-in-buffer) - (action ("Goto node" . anything-c-info-goto)))) + (action ("Goto node" . helm-c-info-goto)))) -(defun anything-compile-source--info-index (source) - (anything-aif (anything-interpret-value (assoc-default 'info-index source)) - (anything-c-make-info-source source it) +(defun helm-compile-source--info-index (source) + (helm-aif (helm-interpret-value (assoc-default 'info-index source)) + (helm-c-make-info-source source it) source)) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--info-index) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--info-index) -(anything-document-attribute 'info-index "info-index plugin" +(helm-document-attribute 'info-index "info-index plugin" "Create a source of info index very easily. -ex. (defvar anything-c-source-info-wget '((info-index . \"wget\"))") +ex. (defvar helm-c-source-info-wget '((info-index . \"wget\"))") -(anything-document-attribute 'index-nodes "info-index plugin (optional)" +(helm-document-attribute 'index-nodes "info-index plugin (optional)" "Index nodes of info file. If it is omitted, `Info-index-nodes' is used to collect index nodes. Some info files are missing index specification. -ex. See `anything-c-source-info-screen'.") +ex. See `helm-c-source-info-screen'.") ;; Plug-in: candidates-file -(defun anything-compile-source--candidates-file (source) +(defun helm-compile-source--candidates-file (source) (if (assoc-default 'candidates-file source) - `((init anything-p-candidats-file-init + `((init helm-p-candidats-file-init ,@(let ((orig-init (assoc-default 'init source))) (cond ((null orig-init) nil) ((functionp orig-init) (list orig-init)) @@ -11385,52 +11320,52 @@ ex. See `anything-c-source-info-screen'.") (candidates-in-buffer) ,@source) source)) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--candidates-file) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--candidates-file) -(defun anything-p-candidats-file-init () +(defun helm-p-candidats-file-init () (destructuring-bind (file &optional updating) - (anything-mklist (anything-attr 'candidates-file)) - (setq file (anything-interpret-value file)) - (with-current-buffer (anything-candidate-buffer (find-file-noselect file)) + (helm-mklist (helm-attr 'candidates-file)) + (setq file (helm-interpret-value file)) + (with-current-buffer (helm-candidate-buffer (find-file-noselect file)) (when updating (buffer-disable-undo) (font-lock-mode -1) (auto-revert-mode 1))))) -(anything-document-attribute 'candidates-file "candidates-file plugin" +(helm-document-attribute 'candidates-file "candidates-file plugin" "Use a file as the candidates buffer. 1st argument is a filename, string or function name or variable name. If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.") ;; Plug-in: headline -(defun anything-compile-source--anything-headline (source) +(defun helm-compile-source--helm-headline (source) (if (assoc-default 'headline source) - (append '((init . anything-headline-init) + (append '((init . helm-headline-init) (get-line . buffer-substring) (type . line)) source '((candidates-in-buffer) (persistent-help . "Show this line"))) source)) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--anything-headline) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--helm-headline) -(defun anything-headline-init () - (when (and (anything-current-buffer-is-modified) - (with-anything-current-buffer - (eval (or (anything-attr 'condition) t)))) - (anything-headline-make-candidate-buffer - (anything-interpret-value (anything-attr 'headline)) - (anything-interpret-value (anything-attr 'subexp))))) +(defun helm-headline-init () + (when (and (helm-current-buffer-is-modified) + (with-helm-current-buffer + (eval (or (helm-attr 'condition) t)))) + (helm-headline-make-candidate-buffer + (helm-interpret-value (helm-attr 'headline)) + (helm-interpret-value (helm-attr 'subexp))))) -(anything-document-attribute 'headline "Headline plug-in" - "Regexp string for anything-headline to scan.") -(anything-document-attribute 'condition "Headline plug-in" - "A sexp representing the condition to use anything-headline.") -(anything-document-attribute 'subexp "Headline plug-in" +(helm-document-attribute 'headline "Headline plug-in" + "Regexp string for helm-headline to scan.") +(helm-document-attribute 'condition "Headline plug-in" + "A sexp representing the condition to use helm-headline.") +(helm-document-attribute 'subexp "Headline plug-in" "Display (match-string-no-properties subexp).") -;; Le Wang: Note on how `anything-head-line-get-candidates' works with a list +;; Le Wang: Note on how `helm-head-line-get-candidates' works with a list ;; of regexps. ;; ;; 1. Create list of ((title . start-of-match) . hiearchy) @@ -11441,8 +11376,8 @@ If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.") ;; -(defun anything-headline-get-candidates (regexp subexp) - (with-anything-current-buffer +(defun helm-headline-get-candidates (regexp subexp) + (with-helm-current-buffer (save-excursion (goto-char (point-min)) (if (functionp regexp) (setq regexp (funcall regexp))) @@ -11483,69 +11418,69 @@ If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.") collect (matched)))))))) -(defun anything-headline-make-candidate-buffer (regexp subexp) - (with-current-buffer (anything-candidate-buffer 'local) - (loop for (content . pos) in (anything-headline-get-candidates regexp subexp) +(defun helm-headline-make-candidate-buffer (regexp subexp) + (with-current-buffer (helm-candidate-buffer 'local) + (loop for (content . pos) in (helm-headline-get-candidates regexp subexp) do (insert (format "%5d:%s\n" - (with-anything-current-buffer + (with-helm-current-buffer (line-number-at-pos pos)) content))))) -(defun anything-headline-goto-position (pos recenter) +(defun helm-headline-goto-position (pos recenter) (goto-char pos) (unless recenter - (set-window-start (get-buffer-window anything-current-buffer) (point)))) + (set-window-start (get-buffer-window helm-current-buffer) (point)))) ;; Plug-in: persistent-help -(defun anything-compile-source--persistent-help (source) - (append source '((header-line . anything-persistent-help-string)))) -(add-to-list 'anything-compile-source-functions 'anything-compile-source--persistent-help) +(defun helm-compile-source--persistent-help (source) + (append source '((header-line . helm-persistent-help-string)))) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--persistent-help) -(defun anything-persistent-help-string () +(defun helm-persistent-help-string () (substitute-command-keys - (concat "\\\\[anything-execute-persistent-action]: " - (or (anything-interpret-value (anything-attr 'persistent-help)) - (anything-aif (or (assoc-default 'persistent-action - (anything-get-current-source)) + (concat "\\\\[helm-execute-persistent-action]: " + (or (helm-interpret-value (helm-attr 'persistent-help)) + (helm-aif (or (assoc-default 'persistent-action + (helm-get-current-source)) (assoc-default 'action - (anything-get-current-source))) + (helm-get-current-source))) (cond ((symbolp it) (symbol-name it)) ((listp it) (or (ignore-errors (caar it)) "")))) "") " (keeping session)"))) -(anything-document-attribute 'persistent-help "persistent-help plug-in" +(helm-document-attribute 'persistent-help "persistent-help plug-in" "A string to explain persistent-action of this source. It also accepts a function or a variable name.") -;;; (anything '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST")))) +;;; (helm '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST")))) ;; Plug-in: Type customize -(defun anything-c-uniq-list (lst) +(defun helm-c-uniq-list (lst) "Like `remove-duplicates' in CL. But cut deeper duplicates and test by `equal'. " (reverse (remove-duplicates (reverse lst) :test 'equal))) -(defvar anything-additional-type-attributes nil) -(defun anything-c-arrange-type-attribute (type spec) - "Override type attributes by `define-anything-type-attribute'. +(defvar helm-additional-type-attributes nil) +(defun helm-c-arrange-type-attribute (type spec) + "Override type attributes by `define-helm-type-attribute'. The SPEC is like source. The symbol `REST' is replaced with original attribute value. Example: Set `play-sound-file' as default action - (anything-c-arrange-type-attribute 'file + (helm-c-arrange-type-attribute 'file '((action (\"Play sound\" . play-sound-file) REST ;; Rest of actions (find-file, find-file-other-window, etc...)." - (add-to-list 'anything-additional-type-attributes + (add-to-list 'helm-additional-type-attributes (cons type (loop with typeattr = (assoc-default - type anything-type-attributes) + type helm-type-attributes) for (attr . value) in spec if (listp value) collect (cons attr - (anything-c-uniq-list + (helm-c-uniq-list (loop for v in value if (eq v 'REST) append @@ -11554,139 +11489,139 @@ with original attribute value. collect v))) else collect (cons attr value))))) -(put 'anything-c-arrange-type-attribute 'lisp-indent-function 1) +(put 'helm-c-arrange-type-attribute 'lisp-indent-function 1) -(defun anything-compile-source--type-customize (source) - (anything-aif (assoc-default (assoc-default 'type source) - anything-additional-type-attributes) +(defun helm-compile-source--type-customize (source) + (helm-aif (assoc-default (assoc-default 'type source) + helm-additional-type-attributes) (append it source) source)) -(add-to-list 'anything-compile-source-functions - 'anything-compile-source--type-customize t) +(add-to-list 'helm-compile-source-functions + 'helm-compile-source--type-customize t) ;; Plug-in: default-action -(defun anything-compile-source--default-action (source) - (anything-aif (assoc-default 'default-action source) +(defun helm-compile-source--default-action (source) + (helm-aif (assoc-default 'default-action source) (append `((action ,it ,@(remove it (assoc-default 'action source)))) source) source)) -(add-to-list 'anything-compile-source-functions - 'anything-compile-source--default-action t) -(anything-document-attribute 'default-action "default-action plug-in" +(add-to-list 'helm-compile-source-functions + 'helm-compile-source--default-action t) +(helm-document-attribute 'default-action "default-action plug-in" "Default action.") ;;; Type Attributes ;; ;; -(define-anything-type-attribute 'buffer +(define-helm-type-attribute 'buffer `((action - ("Switch to buffer" . anything-c-switch-to-buffer) + ("Switch to buffer" . helm-c-switch-to-buffer) ,(and (locate-library "popwin") '("Switch to buffer in popup window" . popwin:popup-buffer)) ("Switch to buffer other window" . switch-to-buffer-other-window) ("Switch to buffer other frame" . switch-to-buffer-other-frame) - ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . anything-find-buffer-on-elscreen)) - ("Query replace regexp" . anything-c-buffer-query-replace-regexp) - ("Query replace" . anything-c-buffer-query-replace) + ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . helm-find-buffer-on-elscreen)) + ("Query replace regexp" . helm-c-buffer-query-replace-regexp) + ("Query replace" . helm-c-buffer-query-replace) ("View buffer" . view-buffer) ("Display buffer" . display-buffer) - ("Grep buffers (C-u grep all buffers)" . anything-c-zgrep-buffers) - ("Revert buffer(s)" . anything-revert-marked-buffers) + ("Grep buffers (C-u grep all buffers)" . helm-c-zgrep-buffers) + ("Revert buffer(s)" . helm-revert-marked-buffers) ("Insert buffer" . insert-buffer) - ("Kill buffer(s)" . anything-kill-marked-buffers) + ("Kill buffer(s)" . helm-kill-marked-buffers) ("Diff with file" . diff-buffer-with-file) - ("Ediff Marked buffers" . anything-ediff-marked-buffers) + ("Ediff Marked buffers" . helm-ediff-marked-buffers) ("Ediff Merge marked buffers" . (lambda (candidate) - (anything-ediff-marked-buffers candidate t)))) + (helm-ediff-marked-buffers candidate t)))) (persistent-help . "Show this buffer") - (candidate-transformer anything-c-skip-boring-buffers - anything-c-transform-buffer-display-string)) + (candidate-transformer helm-c-skip-boring-buffers + helm-c-transform-buffer-display-string)) "Buffer or buffer name.") -(define-anything-type-attribute 'file +(define-helm-type-attribute 'file `((action - ("Find file" . anything-find-many-files) + ("Find file" . helm-find-many-files) ,(and (locate-library "popwin") '("Find file in popup window" . popwin:find-file)) - ("Find file as root" . anything-find-file-as-root) + ("Find file as root" . helm-find-file-as-root) ("Find file other window" . find-file-other-window) ("Find file other frame" . find-file-other-frame) - ("Open dired in file's directory" . anything-c-open-dired) - ("Grep File(s) `C-u recurse'" . anything-find-files-grep) - ("Zgrep File(s) `C-u Recurse'" . anything-ff-zgrep) - ("Pdfgrep File(s)" . anything-ff-pdfgrep) - ("Checksum File" . anything-ff-checksum) - ("Ediff File" . anything-find-files-ediff-files) - ("Ediff Merge File" . anything-find-files-ediff-merge-files) + ("Open dired in file's directory" . helm-c-open-dired) + ("Grep File(s) `C-u recurse'" . helm-find-files-grep) + ("Zgrep File(s) `C-u Recurse'" . helm-ff-zgrep) + ("Pdfgrep File(s)" . helm-ff-pdfgrep) + ("Checksum File" . helm-ff-checksum) + ("Ediff File" . helm-find-files-ediff-files) + ("Ediff Merge File" . helm-find-files-ediff-merge-files) ("View file" . view-file) ("Insert file" . insert-file) - ("Delete file(s)" . anything-delete-marked-files) - ("Open file externally (C-u to choose)" . anything-c-open-file-externally) - ("Open file with default tool" . anything-c-open-file-with-default-tool) + ("Delete file(s)" . helm-delete-marked-files) + ("Open file externally (C-u to choose)" . helm-c-open-file-externally) + ("Open file with default tool" . helm-c-open-file-with-default-tool) ("Find file in hex dump" . hexl-find-file)) (persistent-help . "Show this file") - (action-transformer anything-c-transform-file-load-el - anything-c-transform-file-browse-url) - (candidate-transformer anything-c-w32-pathname-transformer - anything-c-skip-current-file - anything-c-skip-boring-files - anything-c-shorten-home-path)) + (action-transformer helm-c-transform-file-load-el + helm-c-transform-file-browse-url) + (candidate-transformer helm-c-w32-pathname-transformer + helm-c-skip-current-file + helm-c-skip-boring-files + helm-c-shorten-home-path)) "File name.") (let ((actions '(("Describe command" . describe-function) - ("Add command to kill ring" . anything-c-kill-new) + ("Add command to kill ring" . helm-c-kill-new) ("Go to command's definition" . find-function) ("Debug on entry" . debug-on-entry) ("Cancel debug on entry" . cancel-debug-on-entry) ("Trace function" . trace-function) ("Trace function (background)" . trace-function-background) ("Untrace function" . untrace-function)))) - (define-anything-type-attribute 'command - `((action ("Call interactively" . anything-c-call-interactively) + (define-helm-type-attribute 'command + `((action ("Call interactively" . helm-c-call-interactively) ,@actions) - (coerce . anything-c-symbolify) + (coerce . helm-c-symbolify) (persistent-action . describe-function)) "Command. (string or symbol)") - (define-anything-type-attribute 'function + (define-helm-type-attribute 'function `((action . ,actions) - (action-transformer anything-c-transform-function-call-interactively) - (candidate-transformer anything-c-mark-interactive-functions) - (coerce . anything-c-symbolify)) + (action-transformer helm-c-transform-function-call-interactively) + (candidate-transformer helm-c-mark-interactive-functions) + (coerce . helm-c-symbolify)) "Function. (string or symbol)")) -(define-anything-type-attribute 'variable +(define-helm-type-attribute 'variable '((action ("Describe variable" . describe-variable) - ("Add variable to kill ring" . anything-c-kill-new) + ("Add variable to kill ring" . helm-c-kill-new) ("Go to variable's definition" . find-variable) - ("Set variable" . anything-c-set-variable)) - (coerce . anything-c-symbolify)) + ("Set variable" . helm-c-set-variable)) + (coerce . helm-c-symbolify)) "Variable.") -(define-anything-type-attribute 'sexp +(define-helm-type-attribute 'sexp '((action ("Eval s-expression" . (lambda (c) (eval (read c)))) ("Add s-expression to kill ring" . kill-new)) - (action-transformer anything-c-transform-sexp-eval-command-sexp)) + (action-transformer helm-c-transform-sexp-eval-command-sexp)) "String representing S-Expressions.") -(define-anything-type-attribute 'bookmark - `((coerce . anything-bookmark-get-bookmark-from-name) +(define-helm-type-attribute 'bookmark + `((coerce . helm-bookmark-get-bookmark-from-name) (action - ("Jump to bookmark" . anything-c-bookmark-jump) + ("Jump to bookmark" . helm-c-bookmark-jump) ("Jump to BM other window" . bookmark-jump-other-window) ("Bookmark edit annotation" . bookmark-edit-annotation) ("Bookmark show annotation" . bookmark-show-annotation) - ("Delete bookmark(s)" . anything-delete-marked-bookmarks) + ("Delete bookmark(s)" . helm-delete-marked-bookmarks) ,@(and (locate-library "bookmark-extensions") `(("Edit Bookmark" . bmkext-edit-bookmark))) ("Rename bookmark" . bookmark-rename) ("Relocate bookmark" . bookmark-relocate)) - (keymap . ,anything-c-bookmark-map) - (mode-line . anything-bookmark-mode-line-string)) + (keymap . ,helm-c-bookmark-map) + (mode-line . helm-bookmark-mode-line-string)) "Bookmark name.") -(define-anything-type-attribute 'line - '((display-to-real . anything-c-display-to-real-line) - (action ("Go to Line" . anything-c-action-line-goto))) +(define-helm-type-attribute 'line + '((display-to-real . helm-c-display-to-real-line) + (action ("Go to Line" . helm-c-action-line-goto))) "LINENO:CONTENT string, eg. \" 16:foo\". Optional `target-file' attribute is a name of target file. @@ -11704,10 +11639,10 @@ If `recenter' attribute is specified, the line is displayed at the center of window, otherwise at the top of window. ") -(define-anything-type-attribute 'file-line - `((filtered-candidate-transformer anything-c-filtered-candidate-transformer-file-line) +(define-helm-type-attribute 'file-line + `((filtered-candidate-transformer helm-c-filtered-candidate-transformer-file-line) (multiline) - (action ("Go to" . anything-c-action-file-line-goto))) + (action ("Go to" . helm-c-action-file-line-goto))) "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\". Optional `default-directory' attribute is a default-directory @@ -11726,8 +11661,8 @@ If `recenter' attribute is specified, the line is displayed at the center of window, otherwise at the top of window. ") -(define-anything-type-attribute 'timer - '((real-to-display . anything-c-timer-real-to-display) +(define-helm-type-attribute 'timer + '((real-to-display . helm-c-timer-real-to-display) (action ("Cancel Timer" . cancel-timer) ("Describe Function" . (lambda (tm) (describe-function (timer--function tm)))) ("Find Function" . (lambda (tm) (find-function (timer--function tm))))) @@ -11736,161 +11671,161 @@ the center of window, otherwise at the top of window. "Timer.") -;;; Default `anything-sources' -;; Setting `anything-sources' is DEPRECATED, but it seems that newbies -;; tend to invoke M-x anything directly. So I offer default setting. -(setq anything-sources - '(anything-c-source-buffers-list - anything-c-source-recentf - anything-c-source-files-in-current-dir+)) +;;; Default `helm-sources' +;; Setting `helm-sources' is DEPRECATED, but it seems that newbies +;; tend to invoke M-x helm directly. So I offer default setting. +(setq helm-sources + '(helm-c-source-buffers-list + helm-c-source-recentf + helm-c-source-files-in-current-dir+)) -;;; Preconfigured Anything +;;; Preconfigured Helm ;; ;; ;;;###autoload -(defun anything-mini () - "Preconfigured `anything' lightweight version \(buffer -> recentf\)." +(defun helm-mini () + "Preconfigured `helm' lightweight version \(buffer -> recentf\)." (interactive) - (anything-other-buffer '(anything-c-source-buffers-list - anything-c-source-recentf - anything-c-source-buffer-not-found) - "*anything mini*")) + (helm-other-buffer '(helm-c-source-buffers-list + helm-c-source-recentf + helm-c-source-buffer-not-found) + "*helm mini*")) ;;;###autoload -(defun anything-for-files () - "Preconfigured `anything' for opening files. +(defun helm-for-files () + "Preconfigured `helm' for opening files. ffap -> recentf -> buffer -> bookmark -> file-cache -> files-in-current-dir -> locate." (interactive) - (anything-other-buffer anything-for-files-prefered-list "*anything for files*")) + (helm-other-buffer helm-for-files-prefered-list "*helm for files*")) ;;;###autoload -(defun anything-recentf () - "Preconfigured `anything' for `recentf'." +(defun helm-recentf () + "Preconfigured `helm' for `recentf'." (interactive) - (anything-other-buffer 'anything-c-source-recentf "*anything recentf*")) + (helm-other-buffer 'helm-c-source-recentf "*helm recentf*")) ;;;###autoload -(defun anything-info-at-point (arg) - "Preconfigured `anything' for searching info at point. +(defun helm-info-at-point (arg) + "Preconfigured `helm' for searching info at point. With a prefix-arg insert symbol at point." (interactive "P") - (let ((anything-c-google-suggest-default-function - 'anything-c-google-suggest-emacs-lisp)) - (anything :sources '(anything-c-source-info-elisp - anything-c-source-info-cl - anything-c-source-info-pages - anything-c-source-google-suggest) + (let ((helm-c-google-suggest-default-function + 'helm-c-google-suggest-emacs-lisp)) + (helm :sources '(helm-c-source-info-elisp + helm-c-source-info-cl + helm-c-source-info-pages + helm-c-source-google-suggest) :input (and arg (thing-at-point 'symbol)) - :buffer "*anything info*"))) + :buffer "*helm info*"))) ;;;###autoload -(defun anything-show-kill-ring () - "Preconfigured `anything' for `kill-ring'. +(defun helm-show-kill-ring () + "Preconfigured `helm' for `kill-ring'. It is drop-in replacement of `yank-pop'. You may bind this command to M-y. First call open the kill-ring browser, next calls move to next line." (interactive) - (anything :sources 'anything-c-source-kill-ring - :buffer "*anything kill-ring*")) + (helm :sources 'helm-c-source-kill-ring + :buffer "*helm kill-ring*")) ;;;###autoload -(defun anything-minibuffer-history () - "Preconfigured `anything' for `minibuffer-history'." +(defun helm-minibuffer-history () + "Preconfigured `helm' for `minibuffer-history'." (interactive) (let ((enable-recursive-minibuffers t)) - (anything-other-buffer 'anything-c-source-minibuffer-history - "*anything minibuffer-history*"))) + (helm-other-buffer 'helm-c-source-minibuffer-history + "*helm minibuffer-history*"))) ;;;###autoload -(defun anything-gentoo () - "Preconfigured `anything' for gentoo linux." +(defun helm-gentoo () + "Preconfigured `helm' for gentoo linux." (interactive) - (anything-other-buffer '(anything-c-source-gentoo - anything-c-source-use-flags) - "*anything gentoo*")) + (helm-other-buffer '(helm-c-source-gentoo + helm-c-source-use-flags) + "*helm gentoo*")) ;;;###autoload -(defun anything-imenu () - "Preconfigured `anything' for `imenu'." +(defun helm-imenu () + "Preconfigured `helm' for `imenu'." (interactive) - (anything :sources 'anything-c-source-imenu - :buffer "*anything imenu*")) + (helm :sources 'helm-c-source-imenu + :buffer "*helm imenu*")) ;;;###autoload -(defun anything-google-suggest () - "Preconfigured `anything' for google search with google suggest." +(defun helm-google-suggest () + "Preconfigured `helm' for google search with google suggest." (interactive) - (anything-other-buffer 'anything-c-source-google-suggest "*anything google*")) + (helm-other-buffer 'helm-c-source-google-suggest "*helm google*")) ;;;###autoload -(defun anything-yahoo-suggest () - "Preconfigured `anything' for Yahoo searching with Yahoo suggest." +(defun helm-yahoo-suggest () + "Preconfigured `helm' for Yahoo searching with Yahoo suggest." (interactive) - (anything-other-buffer 'anything-c-source-yahoo-suggest "*anything yahoo*")) + (helm-other-buffer 'helm-c-source-yahoo-suggest "*helm yahoo*")) -;;; Converted from anything-show-*-only +;;; Converted from helm-show-*-only ;;;###autoload -(defun anything-for-buffers () - "Preconfigured `anything' for buffers." +(defun helm-for-buffers () + "Preconfigured `helm' for buffers." (interactive) - (anything-other-buffer 'anything-c-source-buffers "*anything for buffers*")) + (helm-other-buffer 'helm-c-source-buffers "*helm for buffers*")) ;;;###autoload -(defun anything-buffers-list () - "Preconfigured `anything' to list buffers. -It is an enhanced version of `anything-for-buffers'." +(defun helm-buffers-list () + "Preconfigured `helm' to list buffers. +It is an enhanced version of `helm-for-buffers'." (interactive) - (anything :sources '(anything-c-source-buffers-list - anything-c-source-buffer-not-found) - :buffer "*anything buffers*" :keymap anything-c-buffer-map)) + (helm :sources '(helm-c-source-buffers-list + helm-c-source-buffer-not-found) + :buffer "*helm buffers*" :keymap helm-c-buffer-map)) -(defalias 'anything-buffers+ 'anything-buffers-list - "Preconfigured `anything' to list buffers. -It is an alias of `anything-buffers-list'.") +(defalias 'helm-buffers+ 'helm-buffers-list + "Preconfigured `helm' to list buffers. +It is an alias of `helm-buffers-list'.") ;;;###autoload -(defun anything-bbdb () - "Preconfigured `anything' for BBDB. +(defun helm-bbdb () + "Preconfigured `helm' for BBDB. Needs BBDB. http://bbdb.sourceforge.net/" (interactive) - (anything-other-buffer 'anything-c-source-bbdb "*anything bbdb*")) + (helm-other-buffer 'helm-c-source-bbdb "*helm bbdb*")) ;;;###autoload -(defun anything-locate (arg) - "Preconfigured `anything' for Locate. +(defun helm-locate (arg) + "Preconfigured `helm' for Locate. Note: you can add locate options after entering pattern. See 'man locate' for valid options. You can specify a specific database with prefix argument ARG \(C-u\). Many databases can be used: navigate and mark them. -See also `anything-locate-with-db'. +See also `helm-locate-with-db'. To create a user specific db, use \"updatedb -l 0 -o db_path -U directory\". Where db_path is a filename matched by -`anything-locate-db-file-regexp'." +`helm-locate-db-file-regexp'." (interactive "P") - (setq anything-ff-default-directory default-directory) - (anything-locate-1 arg)) + (setq helm-ff-default-directory default-directory) + (helm-locate-1 arg)) ;;;###autoload -(defun anything-w3m-bookmarks () - "Preconfigured `anything' for w3m bookmark. +(defun helm-w3m-bookmarks () + "Preconfigured `helm' for w3m bookmark. Needs w3m and emacs-w3m. http://w3m.sourceforge.net/ http://emacs-w3m.namazu.org/" (interactive) - (anything-other-buffer 'anything-c-source-w3m-bookmarks - "*anything w3m bookmarks*")) + (helm-other-buffer 'helm-c-source-w3m-bookmarks + "*helm w3m bookmarks*")) ;;;###autoload -(defun anything-firefox-bookmarks () - "Preconfigured `anything' for firefox bookmark. +(defun helm-firefox-bookmarks () + "Preconfigured `helm' for firefox bookmark. You will have to enable html bookmarks in firefox: open about:config in firefox and double click on this line to enable value \ to true: @@ -11904,167 +11839,167 @@ user_pref(\"browser.bookmarks.autoExportHTML\", true); After closing firefox, you will be able to browse you bookmarks. " (interactive) - (anything-other-buffer 'anything-c-source-firefox-bookmarks - "*Anything Firefox*")) + (helm-other-buffer 'helm-c-source-firefox-bookmarks + "*Helm Firefox*")) ;;;###autoload -(defun anything-colors () - "Preconfigured `anything' for color." +(defun helm-colors () + "Preconfigured `helm' for color." (interactive) - (anything-other-buffer - '(anything-c-source-colors anything-c-source-customize-face) - "*anything colors*")) + (helm-other-buffer + '(helm-c-source-colors helm-c-source-customize-face) + "*helm colors*")) ;;;###autoload -(defun anything-bookmarks () - "Preconfigured `anything' for bookmarks." +(defun helm-bookmarks () + "Preconfigured `helm' for bookmarks." (interactive) - (anything-other-buffer 'anything-c-source-bookmarks "*anything bookmarks*")) + (helm-other-buffer 'helm-c-source-bookmarks "*helm bookmarks*")) ;;;###autoload -(defun anything-c-pp-bookmarks () - "Preconfigured `anything' for bookmarks (pretty-printed)." +(defun helm-c-pp-bookmarks () + "Preconfigured `helm' for bookmarks (pretty-printed)." (interactive) - (anything-other-buffer '(anything-c-source-bookmarks-local - anything-c-source-bookmarks-su - anything-c-source-bookmarks-ssh) - "*anything pp bookmarks*")) + (helm-other-buffer '(helm-c-source-bookmarks-local + helm-c-source-bookmarks-su + helm-c-source-bookmarks-ssh) + "*helm pp bookmarks*")) ;;;###autoload -(defun anything-c-insert-latex-math () - "Preconfigured anything for latex math symbols completion." +(defun helm-c-insert-latex-math () + "Preconfigured helm for latex math symbols completion." (interactive) - (anything-other-buffer 'anything-c-source-latex-math "*anything latex*")) + (helm-other-buffer 'helm-c-source-latex-math "*helm latex*")) ;;;###autoload -(defun anything-register () - "Preconfigured `anything' for Emacs registers." +(defun helm-register () + "Preconfigured `helm' for Emacs registers." (interactive) - (anything-other-buffer 'anything-c-source-register "*anything register*")) + (helm-other-buffer 'helm-c-source-register "*helm register*")) ;;;###autoload -(defun anything-man-woman () - "Preconfigured `anything' for Man and Woman pages." +(defun helm-man-woman () + "Preconfigured `helm' for Man and Woman pages." (interactive) - (anything-other-buffer 'anything-c-source-man-pages "*Anything man woman*")) + (helm-other-buffer 'helm-c-source-man-pages "*Helm man woman*")) ;;;###autoload -(defun anything-org-keywords () - "Preconfigured `anything' for org keywords." +(defun helm-org-keywords () + "Preconfigured `helm' for org keywords." (interactive) - (anything-other-buffer 'anything-c-source-org-keywords "*org keywords*")) + (helm-other-buffer 'helm-c-source-org-keywords "*org keywords*")) ;;;###autoload -(defun anything-emms () - "Preconfigured `anything' for emms sources." +(defun helm-emms () + "Preconfigured `helm' for emms sources." (interactive) - (anything :sources '(anything-c-source-emms-streams - anything-c-source-emms-files - anything-c-source-emms-dired) - :buffer "*Anything Emms*")) + (helm :sources '(helm-c-source-emms-streams + helm-c-source-emms-files + helm-c-source-emms-dired) + :buffer "*Helm Emms*")) ;;;###autoload -(defun anything-eev-anchors () - "Preconfigured `anything' for eev anchors." +(defun helm-eev-anchors () + "Preconfigured `helm' for eev anchors." (interactive) - (anything-other-buffer 'anything-c-source-eev-anchor "*Anything eev anchors*")) + (helm-other-buffer 'helm-c-source-eev-anchor "*Helm eev anchors*")) ;;;###autoload -(defun anything-bm-list () - "Preconfigured `anything' for visible bookmarks. +(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 ((anything-outline-using t)) - (anything-other-buffer 'anything-c-source-bm "*anything bm list*"))) + (let ((helm-outline-using t)) + (helm-other-buffer 'helm-c-source-bm "*helm bm list*"))) ;;;###autoload -(defun anything-timers () - "Preconfigured `anything' for timers." +(defun helm-timers () + "Preconfigured `helm' for timers." (interactive) - (anything-other-buffer '(anything-c-source-absolute-time-timers - anything-c-source-idle-time-timers) - "*anything timers*")) + (helm-other-buffer '(helm-c-source-absolute-time-timers + helm-c-source-idle-time-timers) + "*helm timers*")) ;;;###autoload -(defun anything-list-emacs-process () - "Preconfigured `anything' for emacs process." +(defun helm-list-emacs-process () + "Preconfigured `helm' for emacs process." (interactive) - (anything-other-buffer 'anything-c-source-emacs-process "*anything process*")) + (helm-other-buffer 'helm-c-source-emacs-process "*helm process*")) ;;;###autoload -(defun anything-occur () - "Preconfigured Anything for Occur source. +(defun helm-occur () + "Preconfigured Helm for Occur source. If region is active, search only in region, otherwise search in whole buffer." (interactive) - (let ((anything-compile-source-functions - ;; rule out anything-match-plugin because the input is one regexp. - (delq 'anything-compile-source--match-plugin - (copy-sequence anything-compile-source-functions)))) - (anything :sources 'anything-c-source-occur - :buffer "*Anything Occur*" - :history 'anything-c-grep-history))) + (let ((helm-compile-source-functions + ;; rule out helm-match-plugin because the input is one regexp. + (delq 'helm-compile-source--match-plugin + (copy-sequence helm-compile-source-functions)))) + (helm :sources 'helm-c-source-occur + :buffer "*Helm Occur*" + :history 'helm-c-grep-history))) ;;;###autoload -(defun anything-browse-code () - "Preconfigured anything to browse code." +(defun helm-browse-code () + "Preconfigured helm to browse code." (interactive) - (anything :sources 'anything-c-source-browse-code - :buffer "*anything browse code*" + (helm :sources 'helm-c-source-browse-code + :buffer "*helm browse code*" :default (thing-at-point 'symbol))) ;;;###autoload -(defun anything-org-headlines () - "Preconfigured anything to show org headlines." +(defun helm-org-headlines () + "Preconfigured helm to show org headlines." (interactive) - (anything-other-buffer 'anything-c-source-org-headline "*org headlines*")) + (helm-other-buffer 'helm-c-source-org-headline "*org headlines*")) ;;;###autoload -(defun anything-regexp () - "Preconfigured anything to build regexps. +(defun helm-regexp () + "Preconfigured helm to build regexps. `query-replace-regexp' can be run from there against found regexp." (interactive) (save-restriction - (let ((anything-compile-source-functions - ;; rule out anything-match-plugin because the input is one regexp. - (delq 'anything-compile-source--match-plugin - (copy-sequence anything-compile-source-functions)))) - (when (and (anything-region-active-p) + (let ((helm-compile-source-functions + ;; rule out helm-match-plugin because the input is one regexp. + (delq 'helm-compile-source--match-plugin + (copy-sequence helm-compile-source-functions)))) + (when (and (helm-region-active-p) ;; Don't narrow to region if buffer is already narrowed. - (not (anything-current-buffer-narrowed-p))) + (not (helm-current-buffer-narrowed-p))) (narrow-to-region (region-beginning) (region-end))) - (anything :sources anything-c-source-regexp - :buffer "*anything regexp*" + (helm :sources helm-c-source-regexp + :buffer "*helm regexp*" :prompt "Regexp: " - :history 'anything-build-regexp-history)))) + :history 'helm-build-regexp-history)))) ;;;###autoload -(defun anything-c-copy-files-async () - "Preconfigured anything to copy file list FLIST to DEST asynchronously." +(defun helm-c-copy-files-async () + "Preconfigured helm to copy file list FLIST to DEST asynchronously." (interactive) - (let* ((flist (anything-c-read-file-name + (let* ((flist (helm-c-read-file-name "Copy File async: " :marked-candidates t)) - (dest (anything-c-read-file-name + (dest (helm-c-read-file-name "Copy File async To: " :preselect (car flist) - :initial-input (car anything-ff-history) - :history (anything-find-files-history :comp-read nil)))) - (anything-c-copy-async-with-log flist dest))) + :initial-input (car helm-ff-history) + :history (helm-find-files-history :comp-read nil)))) + (helm-c-copy-async-with-log flist dest))) ;;;###autoload -(defun anything-find-files (arg) - "Preconfigured `anything' for anything implementation of `find-file'. +(defun helm-find-files (arg) + "Preconfigured `helm' for helm implementation of `find-file'. Called with a prefix arg show history if some. -Don't call it from programs, use `anything-find-files-1' instead. +Don't call it from programs, use `helm-find-files-1' instead. This is the starting point for nearly all actions you can do on files." (interactive "P") - (let ((any-input (if (and arg anything-ff-history) - (anything-find-files-history) - (anything-find-files-initial-input))) + (let ((any-input (if (and arg helm-ff-history) + (helm-find-files-history) + (helm-find-files-initial-input))) (presel (buffer-file-name (current-buffer)))) (when (and (eq major-mode 'org-agenda-mode) org-directory @@ -12072,60 +12007,60 @@ This is the starting point for nearly all actions you can do on files." (setq any-input (expand-file-name org-directory))) (set-text-properties 0 (length any-input) nil any-input) (if any-input - (anything-find-files-1 any-input) - (setq any-input (expand-file-name (anything-c-current-directory))) - (anything-find-files-1 - any-input (if anything-ff-transformer-show-only-basename - (and presel (anything-c-basename presel)) + (helm-find-files-1 any-input) + (setq any-input (expand-file-name (helm-c-current-directory))) + (helm-find-files-1 + any-input (if helm-ff-transformer-show-only-basename + (and presel (helm-c-basename presel)) presel))))) ;;;###autoload -(defun anything-write-file () - "Preconfigured `anything' providing completion for `write-file'." +(defun helm-write-file () + "Preconfigured `helm' providing completion for `write-file'." (interactive) - (let ((anything-mp-highlight-delay nil)) - (anything :sources 'anything-c-source-write-file + (let ((helm-mp-highlight-delay nil)) + (helm :sources 'helm-c-source-write-file :input (expand-file-name default-directory) :prompt "Write buffer to file: " - :buffer "*Anything write file*"))) + :buffer "*Helm write file*"))) ;;;###autoload -(defun anything-insert-file () - "Preconfigured `anything' providing completion for `insert-file'." +(defun helm-insert-file () + "Preconfigured `helm' providing completion for `insert-file'." (interactive) - (let ((anything-mp-highlight-delay nil)) - (anything :sources 'anything-c-source-insert-file + (let ((helm-mp-highlight-delay nil)) + (helm :sources 'helm-c-source-insert-file :input (expand-file-name default-directory) :prompt "Insert file: " - :buffer "*Anything insert file*"))) + :buffer "*Helm insert file*"))) ;;;###autoload -(defun anything-dired-rename-file () - "Preconfigured `anything' to rename files from dired." +(defun helm-dired-rename-file () + "Preconfigured `helm' to rename files from dired." (interactive) - (anything-dired-do-action-on-file :action 'rename)) + (helm-dired-do-action-on-file :action 'rename)) ;;;###autoload -(defun anything-dired-copy-file () - "Preconfigured `anything' to copy files from dired." +(defun helm-dired-copy-file () + "Preconfigured `helm' to copy files from dired." (interactive) - (anything-dired-do-action-on-file :action 'copy)) + (helm-dired-do-action-on-file :action 'copy)) ;;;###autoload -(defun anything-dired-symlink-file () - "Preconfigured `anything' to symlink files from dired." +(defun helm-dired-symlink-file () + "Preconfigured `helm' to symlink files from dired." (interactive) - (anything-dired-do-action-on-file :action 'symlink)) + (helm-dired-do-action-on-file :action 'symlink)) ;;;###autoload -(defun anything-dired-hardlink-file () - "Preconfigured `anything' to hardlink files from dired." +(defun helm-dired-hardlink-file () + "Preconfigured `helm' to hardlink files from dired." (interactive) - (anything-dired-do-action-on-file :action 'hardlink)) + (helm-dired-do-action-on-file :action 'hardlink)) ;;;###autoload -(defun anything-do-grep () - "Preconfigured anything for grep. +(defun helm-do-grep () + "Preconfigured helm for grep. Contrarily to Emacs `grep' no default directory is given, but the full path of candidates in ONLY. That allow to grep different files not only in `default-directory' but anywhere @@ -12134,33 +12069,33 @@ grep will search in all files of these directories. You can use also wildcard in the base name of candidate. If a prefix arg is given use the -r option of grep. The prefix arg can be passed before or after start. -See also `anything-do-grep-1'." +See also `helm-do-grep-1'." (interactive) - (let ((only (anything-c-read-file-name + (let ((only (helm-c-read-file-name "Search in file(s): " :marked-candidates t :preselect (or (dired-get-filename nil t) (buffer-file-name (current-buffer))))) - (prefarg (or current-prefix-arg anything-current-prefix-arg))) - (anything-do-grep-1 only prefarg))) + (prefarg (or current-prefix-arg helm-current-prefix-arg))) + (helm-do-grep-1 only prefarg))) ;;;###autoload -(defun anything-do-zgrep () - "Preconfigured anything for zgrep." +(defun helm-do-zgrep () + "Preconfigured helm for zgrep." (interactive) - (let ((prefarg (or current-prefix-arg anything-current-prefix-arg)) - (ls (anything-c-read-file-name + (let ((prefarg (or current-prefix-arg helm-current-prefix-arg)) + (ls (helm-c-read-file-name "Search in file(s): " :marked-candidates t :preselect (or (dired-get-filename nil t) (buffer-file-name (current-buffer)))))) - (anything-ff-zgrep-1 ls prefarg))) + (helm-ff-zgrep-1 ls prefarg))) ;;;###autoload -(defun anything-do-pdfgrep () - "Preconfigured anything for pdfgrep." +(defun helm-do-pdfgrep () + "Preconfigured helm for pdfgrep." (interactive) - (let ((only (anything-c-read-file-name + (let ((only (helm-c-read-file-name "Search in file(s): " :marked-candidates t :test #'(lambda (file) @@ -12169,72 +12104,48 @@ See also `anything-do-grep-1'." (file-directory-p file))) :preselect (or (dired-get-filename nil t) (buffer-file-name (current-buffer))))) - (anything-c-grep-default-function 'anything-c-pdfgrep-init)) - (anything-do-pdfgrep-1 only))) + (helm-c-grep-default-function 'helm-c-pdfgrep-init)) + (helm-do-pdfgrep-1 only))) ;;;###autoload -(defun anything-c-etags-select (arg) - "Preconfigured anything for etags. +(defun helm-c-etags-select (arg) + "Preconfigured helm for etags. Called with one prefix arg use symbol at point as initial input. Called with two prefix arg reinitialize cache. If tag file have been modified reinitialize cache." (interactive "P") - (let ((tag (anything-c-etags-get-tag-file)) + (let ((tag (helm-c-etags-get-tag-file)) (init (and (equal arg '(4)) (thing-at-point 'symbol))) - (anything-quit-if-no-candidate t) - (anything-execute-action-at-once-if-one t) - (anything-compile-source-functions - (if anything-c-etags-use-regexp-search - ;; rule out anything-match-plugin because the input is one regexp. - (delq 'anything-compile-source--match-plugin - (copy-sequence anything-compile-source-functions)) - anything-compile-source-functions))) + (helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) + (helm-compile-source-functions + (if helm-c-etags-use-regexp-search + ;; rule out helm-match-plugin because the input is one regexp. + (delq 'helm-compile-source--match-plugin + (copy-sequence helm-compile-source-functions)) + helm-compile-source-functions))) (when (or (equal arg '(16)) - (and anything-c-etags-mtime-alist - (anything-c-etags-file-modified-p tag))) - (remhash tag anything-c-etags-cache)) + (and helm-c-etags-mtime-alist + (helm-c-etags-file-modified-p tag))) + (remhash tag helm-c-etags-cache)) (if (and tag (file-exists-p tag)) - (anything :sources 'anything-c-source-etags-select - :keymap anything-c-etags-map + (helm :sources 'helm-c-source-etags-select + :keymap helm-c-etags-map :input init - :buffer "*anything etags*") + :buffer "*helm etags*") (message "Error: No tag file found, please create one with etags shell command.")))) -;;;###autoload -(defun anything-filelist () - "Preconfigured `anything' to open files instantly. - -See `anything-c-filelist-file-name' docstring for usage." - (interactive) - (anything-other-buffer 'anything-c-source-filelist "*anything file list*")) ;;;###autoload -(defun anything-filelist+ () - "Preconfigured `anything' to open files/buffers/bookmarks instantly. - -This is a replacement for `anything-for-files'. -See `anything-c-filelist-file-name' docstring for usage." - (interactive) - (anything-other-buffer - '(anything-c-source-ffap-line - anything-c-source-ffap-guesser - anything-c-source-buffers-list - anything-c-source-recentf - anything-c-source-bookmarks - anything-c-source-file-cache - anything-c-source-filelist) - "*anything file list*")) - -;;;###autoload -(defun anything-M-x () - "Preconfigured `anything' for Emacs commands. -It is `anything' replacement of regular `M-x' `execute-extended-command'." +(defun helm-M-x () + "Preconfigured `helm' for Emacs commands. +It is `helm' replacement of regular `M-x' `execute-extended-command'." (interactive) (let* (in-help help-cand special-display-buffer-names special-display-regexps - anything-persistent-action-use-special-display + helm-persistent-action-use-special-display (history (loop with hist for i in extended-command-history for com = (intern i) @@ -12245,33 +12156,33 @@ It is `anything' replacement of regular `M-x' `execute-extended-command'." (if (and in-help (string= candidate help-cand)) (progn ;; When M-x is started from a help buffer, - ;; Don't kill it as it is anything-current-buffer. - (unless (equal hbuf anything-current-buffer) + ;; Don't kill it as it is helm-current-buffer. + (unless (equal hbuf helm-current-buffer) (kill-buffer hbuf)) (setq in-help nil)) - ;; Be sure anything-current-buffer + ;; Be sure helm-current-buffer ;; have not a dedicated window. (set-window-dedicated-p - (get-buffer-window anything-current-buffer) nil) + (get-buffer-window helm-current-buffer) nil) (describe-function (intern candidate)) (message nil) ; Erase the new stupid message Type "q"[...] (setq in-help t)) (setq help-cand candidate)))) - (let* ((command (anything-comp-read + (let* ((command (helm-comp-read "M-x " obarray :test 'commandp - :requires-pattern anything-M-x-requires-pattern + :requires-pattern helm-M-x-requires-pattern :name "Emacs Commands" - :buffer "*anything M-x*" + :buffer "*helm M-x*" :persistent-action 'pers-help :persistent-help "Describe this command" :history history :must-match t :candidates-in-buffer t - :fc-transformer 'anything-M-x-transformer)) + :fc-transformer 'helm-M-x-transformer)) (sym-com (intern command))) (unless current-prefix-arg - (setq current-prefix-arg anything-current-prefix-arg)) + (setq current-prefix-arg helm-current-prefix-arg)) ;; Avoid having `this-command' set to *exit-minibuffer. (setq this-command sym-com) (call-interactively sym-com) @@ -12279,129 +12190,129 @@ It is `anything' replacement of regular `M-x' `execute-extended-command'." (cons command (delete command history))))))) ;;;###autoload -(defun anything-manage-advice () - "Preconfigured `anything' to disable/enable function advices." +(defun helm-manage-advice () + "Preconfigured `helm' to disable/enable function advices." (interactive) - (anything-other-buffer 'anything-c-source-advice "*anything advice*")) + (helm-other-buffer 'helm-c-source-advice "*helm advice*")) ;;;###autoload -(defun anything-bookmark-ext () - "Preconfigured `anything' for bookmark-extensions sources. +(defun helm-bookmark-ext () + "Preconfigured `helm' for bookmark-extensions sources. Needs bookmark-ext.el: . -Contain also `anything-c-source-google-suggest'." +Contain also `helm-c-source-google-suggest'." (interactive) - (anything + (helm :sources - '(anything-c-source-bookmark-files&dirs - anything-c-source-bookmark-w3m - anything-c-source-google-suggest - anything-c-source-bmkext-addressbook - anything-c-source-bookmark-gnus - anything-c-source-bookmark-info - anything-c-source-bookmark-man - anything-c-source-bookmark-images - anything-c-source-bookmark-su-files&dirs - anything-c-source-bookmark-ssh-files&dirs) + '(helm-c-source-bookmark-files&dirs + helm-c-source-bookmark-w3m + helm-c-source-google-suggest + helm-c-source-bmkext-addressbook + helm-c-source-bookmark-gnus + helm-c-source-bookmark-info + helm-c-source-bookmark-man + helm-c-source-bookmark-images + helm-c-source-bookmark-su-files&dirs + helm-c-source-bookmark-ssh-files&dirs) :prompt "SearchBookmark: " - :buffer "*anything bmkext*")) + :buffer "*helm bmkext*")) ;;;###autoload -(defun anything-simple-call-tree () - "Preconfigured `anything' for simple-call-tree. List function relationships. +(defun helm-simple-call-tree () + "Preconfigured `helm' for simple-call-tree. List function relationships. Needs simple-call-tree.el. http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el" (interactive) - (anything-other-buffer - '(anything-c-source-simple-call-tree-functions-callers - anything-c-source-simple-call-tree-callers-functions) - "*anything simple-call-tree*")) + (helm-other-buffer + '(helm-c-source-simple-call-tree-functions-callers + helm-c-source-simple-call-tree-callers-functions) + "*helm simple-call-tree*")) ;;;###autoload -(defun anything-mark-ring () - "Preconfigured `anything' for `anything-c-source-mark-ring'." +(defun helm-mark-ring () + "Preconfigured `helm' for `helm-c-source-mark-ring'." (interactive) - (anything :sources 'anything-c-source-mark-ring)) + (helm :sources 'helm-c-source-mark-ring)) ;;;###autoload -(defun anything-global-mark-ring () - "Preconfigured `anything' for `anything-c-source-global-mark-ring'." +(defun helm-global-mark-ring () + "Preconfigured `helm' for `helm-c-source-global-mark-ring'." (interactive) - (anything :sources 'anything-c-source-global-mark-ring)) + (helm :sources 'helm-c-source-global-mark-ring)) ;;;###autoload -(defun anything-all-mark-rings () - "Preconfigured `anything' for `anything-c-source-global-mark-ring' and \ -`anything-c-source-mark-ring'." +(defun helm-all-mark-rings () + "Preconfigured `helm' for `helm-c-source-global-mark-ring' and \ +`helm-c-source-mark-ring'." (interactive) - (anything :sources '(anything-c-source-mark-ring - anything-c-source-global-mark-ring))) + (helm :sources '(helm-c-source-mark-ring + helm-c-source-global-mark-ring))) ;;;###autoload -(defun anything-yaoddmuse-emacswiki-edit-or-view () - "Preconfigured `anything' to edit or view EmacsWiki page. +(defun helm-yaoddmuse-emacswiki-edit-or-view () + "Preconfigured `helm' to edit or view EmacsWiki page. Needs yaoddmuse.el. http://www.emacswiki.org/emacs/download/yaoddmuse.el" (interactive) - (anything :sources 'anything-c-source-yaoddmuse-emacswiki-edit-or-view)) + (helm :sources 'helm-c-source-yaoddmuse-emacswiki-edit-or-view)) ;;;###autoload -(defun anything-yaoddmuse-emacswiki-post-library () - "Preconfigured `anything' to post library to EmacsWiki. +(defun helm-yaoddmuse-emacswiki-post-library () + "Preconfigured `helm' to post library to EmacsWiki. Needs yaoddmuse.el. http://www.emacswiki.org/emacs/download/yaoddmuse.el" (interactive) - (anything :sources 'anything-c-source-yaoddmuse-emacswiki-post-library)) + (helm :sources 'helm-c-source-yaoddmuse-emacswiki-post-library)) ;;;###autoload -(defun anything-eval-expression (arg) - "Preconfigured anything for `anything-c-source-evaluation-result'." +(defun helm-eval-expression (arg) + "Preconfigured helm for `helm-c-source-evaluation-result'." (interactive "P") - (anything :sources 'anything-c-source-evaluation-result + (helm :sources 'helm-c-source-evaluation-result :input (when arg (thing-at-point 'sexp)) - :buffer "*anything eval*" - :history 'anything-eval-expression-input-history - :keymap anything-eval-expression-map)) + :buffer "*helm eval*" + :history 'helm-eval-expression-input-history + :keymap helm-eval-expression-map)) ;;;###autoload -(defun anything-eval-expression-with-eldoc () - "Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. " +(defun helm-eval-expression-with-eldoc () + "Preconfigured helm for `helm-c-source-evaluation-result' with `eldoc' support. " (interactive) (declare (special eldoc-idle-delay)) (let ((timer (run-with-idle-timer eldoc-idle-delay - 'repeat 'anything-eldoc-show-in-eval)) + 'repeat 'helm-eldoc-show-in-eval)) (minibuffer-completing-symbol t) ; Enable lisp completion. (completion-cycle-threshold t)) ; Always cycle, no pesty completion buffer (emacs24 only). (unwind-protect (minibuffer-with-setup-hook - 'anything-eldoc-store-minibuffer - (call-interactively 'anything-eval-expression)) + 'helm-eldoc-store-minibuffer + (call-interactively 'helm-eval-expression)) (and timer (cancel-timer timer)) - (setq anything-eldoc-active-minibuffers-list - (cdr anything-eldoc-active-minibuffers-list))))) + (setq helm-eldoc-active-minibuffers-list + (cdr helm-eldoc-active-minibuffers-list))))) ;;;###autoload -(defun anything-calcul-expression () - "Preconfigured anything for `anything-c-source-calculation-result'." +(defun helm-calcul-expression () + "Preconfigured helm for `helm-c-source-calculation-result'." (interactive) - (anything-other-buffer 'anything-c-source-calculation-result "*anything calcul*")) + (helm-other-buffer 'helm-c-source-calculation-result "*helm calcul*")) ;;;###autoload -(defun anything-surfraw (pattern engine) - "Preconfigured `anything' to search PATTERN with search ENGINE." +(defun helm-surfraw (pattern engine) + "Preconfigured `helm' to search PATTERN with search ENGINE." (interactive (list (read-string "SearchFor: " - nil 'anything-surfraw-input-history) - (anything-comp-read + nil 'helm-surfraw-input-history) + (helm-comp-read "Engine: " - (anything-c-build-elvi-list) + (helm-c-build-elvi-list) :must-match t :name "Surfraw Search Engines" - :history anything-surfraw-engines-history))) + :history helm-surfraw-engines-history))) (let* ((engine-nodesc (car (split-string engine))) (url (with-temp-buffer (apply 'call-process "surfraw" nil t nil @@ -12409,98 +12320,98 @@ http://www.emacswiki.org/emacs/download/yaoddmuse.el" (append (list engine-nodesc "-p") (split-string pattern))) (replace-regexp-in-string "\n" "" (buffer-string)))) - (browse-url-browser-function (or anything-surfraw-default-browser-function + (browse-url-browser-function (or helm-surfraw-default-browser-function browse-url-browser-function))) (if (string= engine-nodesc "W") - (anything-c-browse-url anything-c-home-url) - (anything-c-browse-url url) - (setq anything-surfraw-engines-history - (cons engine (delete engine anything-surfraw-engines-history)))))) + (helm-c-browse-url helm-c-home-url) + (helm-c-browse-url url) + (setq helm-surfraw-engines-history + (cons engine (delete engine helm-surfraw-engines-history)))))) ;;;###autoload -(defun anything-call-source () - "Preconfigured `anything' to call anything source." +(defun helm-call-source () + "Preconfigured `helm' to call helm source." (interactive) - (anything :sources 'anything-c-source-call-source - :buffer anything-source-select-buffer)) + (helm :sources 'helm-c-source-call-source + :buffer helm-source-select-buffer)) ;;;###autoload -(defun anything-execute-anything-command () - "Preconfigured `anything' to execute preconfigured `anything'." +(defun helm-execute-helm-command () + "Preconfigured `helm' to execute preconfigured `helm'." (interactive) - (anything-other-buffer 'anything-c-source-anything-commands - "*anything commands*")) + (helm-other-buffer 'helm-c-source-helm-commands + "*helm commands*")) ;;;###autoload -(defun anything-create (&optional string initial-input) - "Preconfigured `anything' to do many create actions from STRING. -See also `anything-create--actions'." +(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 Anything: " initial-input))) - (anything :sources '(((name . "Anything Create") + (setq string (or string (read-string "Create Helm: " initial-input))) + (helm :sources '(((name . "Helm Create") (header-name . (lambda (_) (format "Action for \"%s\"" string))) - (candidates . anything-create--actions) + (candidates . helm-create--actions) (candidate-number-limit) (action . (lambda (func) (funcall func string))))))) ;;;###autoload -(defun anything-top () - "Preconfigured `anything' for top command." +(defun helm-top () + "Preconfigured `helm' for top command." (interactive) - (let ((anything-samewindow t) - (anything-enable-shortcuts) - (anything-display-function 'anything-default-display-buffer) - (anything-candidate-number-limit 9999)) + (let ((helm-samewindow t) + (helm-enable-shortcuts) + (helm-display-function 'helm-default-display-buffer) + (helm-candidate-number-limit 9999)) (save-window-excursion (delete-other-windows) - (anything-other-buffer 'anything-c-source-top "*anything top*")))) + (helm-other-buffer 'helm-c-source-top "*helm top*")))) ;;;###autoload -(defun anything-select-xfont () - "Preconfigured `anything' to select Xfont." +(defun helm-select-xfont () + "Preconfigured `helm' to select Xfont." (interactive) - (anything-other-buffer 'anything-c-source-xfonts "*anything select* xfont")) + (helm-other-buffer 'helm-c-source-xfonts "*helm select* xfont")) ;;;###autoload -(defun anything-world-time () - "Preconfigured `anything' to show world time." +(defun helm-world-time () + "Preconfigured `helm' to show world time." (interactive) - (anything-other-buffer 'anything-c-source-time-world "*anything world time*")) + (helm-other-buffer 'helm-c-source-time-world "*helm world time*")) ;;;###autoload -(defun anything-apt (arg) - "Preconfigured `anything' : frontend of APT package manager. +(defun helm-apt (arg) + "Preconfigured `helm' : frontend of APT package manager. With a prefix arg reload cache." (interactive "P") - (let ((query (read-string "Search Package: " nil 'anything-c-apt-input-history))) - (when arg (anything-c-apt-refresh)) - (anything :sources 'anything-c-source-apt + (let ((query (read-string "Search Package: " nil 'helm-c-apt-input-history))) + (when arg (helm-c-apt-refresh)) + (helm :sources 'helm-c-source-apt :prompt "Search Package: " :input query - :history 'anything-c-apt-input-history))) + :history 'helm-c-apt-input-history))) ;;;###autoload -(defun anything-esh-pcomplete () - "Preconfigured anything to provide anything completion in eshell." +(defun helm-esh-pcomplete () + "Preconfigured helm to provide helm completion in eshell." (interactive) - (let* ((anything-quit-if-no-candidate t) - (anything-execute-action-at-once-if-one t) + (let* ((helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) (target (thing-at-point 'symbol)) (end (point)) (beg (or (and target (- end (length target))) ;; Nothing at point. (progn (insert " ") (point))))) - (setq anything-ec-target (or target " ")) - (with-anything-show-completion beg end - (anything :sources 'anything-c-source-esh - :buffer "*anything pcomplete*" - :input (anything-ff-set-pattern ; Handle tramp filenames. + (setq helm-ec-target (or target " ")) + (with-helm-show-completion beg end + (helm :sources 'helm-c-source-esh + :buffer "*helm pcomplete*" + :input (helm-ff-set-pattern ; Handle tramp filenames. (car (last (ignore-errors ; Needed in lisp symbols completion. (pcomplete-parse-arguments))))))))) ;;;###autoload -(defun anything-eshell-history () - "Preconfigured anything for eshell history." +(defun helm-eshell-history () + "Preconfigured helm for eshell history." (interactive) (let* ((end (point)) (beg (save-excursion (eshell-bol) (point))) @@ -12511,8 +12422,8 @@ With a prefix arg reload cache." (setq flag-empty t) (setq end (point))) (unwind-protect - (with-anything-show-completion beg end - (anything :sources 'anything-c-source-eshell-history + (with-helm-show-completion beg end + (helm :sources 'helm-c-source-eshell-history :buffer "*Eshell history*" :input input)) (when (and flag-empty @@ -12520,74 +12431,74 @@ With a prefix arg reload cache." (delete-char -1))))) ;;;###autoload -(defun anything-c-run-external-command (program) - "Preconfigured `anything' to run External PROGRAM asyncronously from Emacs. +(defun helm-c-run-external-command (program) + "Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. If program is already running exit with error. You can set your own list of commands with -`anything-c-external-commands-list'." +`helm-c-external-commands-list'." (interactive (list - (anything-comp-read + (helm-comp-read "RunProgram: " - (anything-c-external-commands-list-1 'sort) + (helm-c-external-commands-list-1 'sort) :must-match t :name "External Commands" - :history anything-external-command-history))) - (anything-run-or-raise program) - (setq anything-external-command-history + :history helm-external-command-history))) + (helm-run-or-raise program) + (setq helm-external-command-history (cons program (delete program - (loop for i in anything-external-command-history + (loop for i in helm-external-command-history when (executable-find i) collect i))))) ;;;###autoload -(defun anything-ratpoison-commands () - "Preconfigured `anything' to execute ratpoison commands." +(defun helm-ratpoison-commands () + "Preconfigured `helm' to execute ratpoison commands." (interactive) - (anything-other-buffer 'anything-c-source-ratpoison-commands - "*anything ratpoison commands*")) + (helm-other-buffer 'helm-c-source-ratpoison-commands + "*helm ratpoison commands*")) ;;;###autoload -(defun anything-ucs () - "Preconfigured anything for `ucs-names' math symbols." +(defun helm-ucs () + "Preconfigured helm for `ucs-names' math symbols." (interactive) - (anything :sources 'anything-c-source-ucs - :keymap anything-c-ucs-map)) + (helm :sources 'helm-c-source-ucs + :keymap helm-c-ucs-map)) ;;;###autoload -(defun anything-c-apropos () - "Preconfigured anything to describe commands, functions, variables and faces." +(defun helm-c-apropos () + "Preconfigured helm to describe commands, functions, variables and faces." (interactive) (let ((default (thing-at-point 'symbol))) - (anything :sources + (helm :sources `(((name . "Commands") (init . (lambda () - (anything-c-apropos-init 'commandp ,default))) - (persistent-action . anything-lisp-completion-persistent-action) + (helm-c-apropos-init 'commandp ,default))) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (lambda (candidate) (describe-function (intern candidate))))) ((name . "Functions") (init . (lambda () - (anything-c-apropos-init #'(lambda (x) (and (fboundp x) + (helm-c-apropos-init #'(lambda (x) (and (fboundp x) (not (commandp x)))) ,default))) - (persistent-action . anything-lisp-completion-persistent-action) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (lambda (candidate) (describe-function (intern candidate))))) ((name . "Variables") (init . (lambda () - (anything-c-apropos-init 'boundp ,default))) - (persistent-action . anything-lisp-completion-persistent-action) + (helm-c-apropos-init 'boundp ,default))) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (lambda (candidate) (describe-variable (intern candidate))))) ((name . "Faces") (init . (lambda () - (anything-c-apropos-init 'facep ,default))) - (persistent-action . anything-lisp-completion-persistent-action) + (helm-c-apropos-init 'facep ,default))) + (persistent-action . helm-lisp-completion-persistent-action) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (filtered-candidate-transformer . (lambda (candidates source) @@ -12595,26 +12506,26 @@ You can set your own list of commands with collect (propertize c 'face (intern c))))) (action . (lambda (candidate) (describe-face (intern candidate))))) - ((name . "Anything attributes") + ((name . "Helm attributes") (candidates . (lambda () - (mapcar 'symbol-name anything-additional-attributes))) + (mapcar 'symbol-name helm-additional-attributes))) (action . (lambda (candidate) (with-output-to-temp-buffer "*Help*" - (princ (get (intern candidate) 'anything-attrdoc)))))))))) + (princ (get (intern candidate) 'helm-attrdoc)))))))))) ;;;###autoload -(defun anything-xrandr-set () +(defun helm-xrandr-set () (interactive) - (anything :sources 'anything-c-source-xrandr-change-resolution - :buffer "*anything xrandr*")) + (helm :sources 'helm-c-source-xrandr-change-resolution + :buffer "*helm xrandr*")) -;;; Unit tests are now in ../developer-tools/unit-test-anything-config.el. +;;; Unit tests are now in ../developer-tools/unit-test-helm-config.el. -(provide 'anything-config) +(provide 'helm-config) ;; Local Variables: ;; coding: utf-8 ;; End: -;;; anything-config.el ends here +;;; helm-config.el ends here diff --git a/vendor/helm/helm-match-plugin.el b/vendor/helm/helm-match-plugin.el new file mode 100644 index 0000000..0571c59 --- /dev/null +++ b/vendor/helm/helm-match-plugin.el @@ -0,0 +1,550 @@ +;;; helm-match-plugin.el --- Multiple regexp matching methods for helm + +;; Original Author: rubikitch + +;; This is a fork of `anything-match-plugin.el' created by +;; rubikitch + +;; Maintainers: Thierry Volpiatto +;; Le Wang + +;; Copyright (C) 2008~2012, rubikitch, all rights reserved. +;; Copyright (C) 2011~2012, Thierry Volpiatto, all rights reserved. + +;; Keywords: helm, matching + +;; X-URL: + +;; Created: 2012-03-15 12:29:23 + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Auto documentation +;; ------------------ +;; +;; * User variables +;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "helm-mp" :var-value t) +;; `helm-mp-matching-method' +;; Default Value: multi3 +;; `helm-mp-highlight-delay' +;; Default Value: 0.7 +;; `helm-mp-highlight-threshold' +;; Default Value: 2 +;; +;; * Internal variables +;; [EVAL] (autodoc-document-lisp-buffer :type 'internal-variable :prefix "helm-mp" :var-value t) +;; `helm-mp-default-match-functions' +;; Default Value: (helm-mp-exact-match helm-mp-3-match) +;; `helm-mp-default-search-functions' +;; Default Value: (helm-mp-exact-search helm-mp-3-search) +;; `helm-mp-default-search-backward-functions' +;; Default Value: (helm-mp-exact-search-backward helm-mp-3-search-backward) +;; `helm-mp-space-regexp' +;; Default Value: "[\\ ] " +;; `helm-mp-exact-pattern-str' +;; Default Value: "autod" +;; `helm-mp-exact-pattern-real' +;; Default Value: "\nautod\n" +;; `helm-mp-prefix-pattern-str' +;; Default Value: nil +;; `helm-mp-prefix-pattern-real' +;; Default Value: nil +;; `helm-mp-1-pattern-str' +;; Default Value: nil +;; `helm-mp-1-pattern-real' +;; Default Value: nil +;; `helm-mp-2-pattern-str' +;; Default Value: nil +;; `helm-mp-2-pattern-real' +;; Default Value: nil +;; `helm-mp-3-pattern-str' +;; Default Value: "autod" +;; `helm-mp-3-pattern-list' +;; Default Value: ((identity . "autod")) +;; `helm-mp-initial-highlight-delay' +;; Default Value: nil +;; +;; * Helm match plugin Functions +;; [EVAL] (autodoc-document-lisp-buffer :type 'function :prefix "helm-mp") +;; `helm-mp-set-matching-method' +;; `helm-mp-make-regexps' +;; `helm-mp-1-make-regexp' +;; `helm-mp-exact-get-pattern' +;; `helm-mp-exact-match' +;; `helm-mp-exact-search' +;; `helm-mp-exact-search-backward' +;; `helm-mp-prefix-get-pattern' +;; `helm-mp-prefix-match' +;; `helm-mp-prefix-search' +;; `helm-mp-prefix-search-backward' +;; `helm-mp-1-get-pattern' +;; `helm-mp-1-match' +;; `helm-mp-1-search' +;; `helm-mp-1-search-backward' +;; `helm-mp-2-get-pattern' +;; `helm-mp-2-match' +;; `helm-mp-2-search' +;; `helm-mp-2-search-backward' +;; `helm-mp-3-get-patterns' +;; `helm-mp-3-get-patterns-internal' +;; `helm-mp-3-match' +;; `helm-mp-3-search-base' +;; `helm-mp-3-search' +;; `helm-mp-3-search-backward' +;; `helm-mp-3p-match' +;; `helm-mp-3p-search' +;; `helm-mp-3p-search-backward' +;; `helm-mp-highlight-match' +;; `helm-mp-highlight-region' +;; `helm-mp-highlight-match-internal' + +;; *** END auto-documentation + +;;; Commentary: + +;; Change helm.el matching algorithm humanely. +;; It gives helm.el search refinement functionality. +;; exact match -> prefix match -> multiple regexp match + +;; A query of multiple regexp match is space-delimited string. +;; Helm displays candidates which matches all the regexps. +;; A regexp with "!" prefix means not matching the regexp. +;; To include spaces to a regexp, prefix "\" before space, +;; it is controlled by `helm-mp-space-regexp' variable. + +;; This file highlights patterns like `occur'. Note that patterns +;; longer than `helm-mp-highlight-threshold' are highlighted. And +;; region out of screen is highlighted after +;; `helm-mp-highlight-delay' seconds. + +;; Highlight in Emacs is time-consuming process for slow computers. To +;; disable it is to set nil to `helm-mp-highlight-delay'. + +;; helm-match-plugin is enable by default in helm. +;; To disable/enable it use M-x helm-c-toggle-match-plugin. + +;;; Code: + +(require 'helm) +(require 'cl) + + +;;;; Match-plugin + +;; Internal +(defvar helm-mp-default-match-functions nil) +(defvar helm-mp-default-search-functions nil) +(defvar helm-mp-default-search-backward-functions nil) + +(defun helm-mp-set-matching-method (var key) + "Default function to set matching methods in helm match plugin." + (set-default var key) + (case (symbol-value var) + (multi1 (setq helm-mp-default-match-functions + '(helm-mp-exact-match helm-mp-1-match) + helm-mp-default-search-functions + '(helm-mp-exact-search helm-mp-1-search) + helm-mp-default-search-backward-functions + '(helm-mp-exact-search-backward + helm-mp-1-search-backward))) + (multi2 (setq helm-mp-default-match-functions + '(helm-mp-exact-match helm-mp-2-match) + helm-mp-default-search-functions + '(helm-mp-exact-search helm-mp-2-search) + helm-mp-default-search-backward-functions + '(helm-mp-exact-search-backward + helm-mp-2-search-backward))) + (multi3 (setq helm-mp-default-match-functions + '(helm-mp-exact-match helm-mp-3-match) + helm-mp-default-search-functions + '(helm-mp-exact-search helm-mp-3-search) + helm-mp-default-search-backward-functions + '(helm-mp-exact-search-backward + helm-mp-3-search-backward))) + (multi3p (setq helm-mp-default-match-functions + '(helm-mp-exact-match helm-mp-3p-match) + helm-mp-default-search-functions + '(helm-mp-exact-search helm-mp-3p-search) + helm-mp-default-search-backward-functions + '(helm-mp-exact-search-backward + helm-mp-3p-search-backward))) + (t (error "Unknow value: %s" helm-mp-matching-method)))) + +(defgroup helm-match-plugin nil + "Helm match plugin." + :group 'helm) + +(defcustom helm-mp-matching-method 'multi3 + "Matching method for helm match plugin. +You can set here different methods to match candidates in helm. +Here are the possible value of this symbol and their meaning: +- multi1: Respect order, prefix of pattern must match. +- multi2: Same but with partial match. +- multi3: The best, multiple regexp match, allow negation. +- multi3p: Same but prefix must match. +Default is multi3." + :type '(radio :tag "Matching methods for helm" + (const :tag "Multiple regexp 1 ordered with prefix match" multi1) + (const :tag "Multiple regexp 2 ordered with partial match" multi2) + (const :tag "Multiple regexp 3 matching no order, partial, best." multi3) + (const :tag "Multiple regexp 3p matching with prefix match" multi3p)) + :set 'helm-mp-set-matching-method + :group 'helm-match-plugin) + +(defface helm-match + '((t (:inherit match))) + "Face used to highlight matches." + :group 'helm-match-plugin) + +(defcustom helm-mp-highlight-delay 0.7 + "Highlight matches with `helm-match' face after this many seconds. + If nil, no highlight. " + :type 'integer + :group 'helm-match-plugin) + +(defcustom helm-mp-highlight-threshold 2 + "Minimum length of pattern to highlight. +The smaller this value is, the slower highlight is." + :type 'integer + :group 'helm-match-plugin) + + + +;;; Build regexps +;; +;; +(defvar helm-mp-space-regexp "[\\ ] " + "Regexp to represent space itself in multiple regexp match.") + +(defun helm-mp-make-regexps (pattern) + "Split PATTERN if it contain spaces and return resulting list. +If spaces in PATTERN are escaped, don't split at this place. +i.e \"foo bar\"=> (\"foo\" \"bar\") +but \"foo\ bar\"=> (\"foobar\")." + (if (string= pattern "") + '("") + (loop for s in (split-string + (replace-regexp-in-string helm-mp-space-regexp + "\000\000" pattern) + " " t) + collect (replace-regexp-in-string "\000\000" " " s)))) + +(defun helm-mp-1-make-regexp (pattern) + "Replace spaces in PATTERN with \"\.*\"." + (mapconcat 'identity (helm-mp-make-regexps pattern) ".*")) + + +;;; Exact match. +;; +;; +;; Internal. +(defvar helm-mp-exact-pattern-str nil) +(defvar helm-mp-exact-pattern-real nil) + +(defun helm-mp-exact-get-pattern (pattern) + (unless (equal pattern helm-mp-exact-pattern-str) + (setq helm-mp-exact-pattern-str pattern + helm-mp-exact-pattern-real (concat "\n" pattern "\n"))) + helm-mp-exact-pattern-real) + + +(defun helm-mp-exact-match (str &optional pattern) + (string= str (or pattern helm-pattern))) + +(defun helm-mp-exact-search (pattern &rest ignore) + (and (search-forward (helm-mp-exact-get-pattern pattern) nil t) + (forward-line -1))) + +(defun helm-mp-exact-search-backward (pattern &rest ignore) + (and (search-backward (helm-mp-exact-get-pattern pattern) nil t) + (forward-line 1))) + + +;;; Prefix match +;; +;; +;; Internal +(defvar helm-mp-prefix-pattern-str nil) +(defvar helm-mp-prefix-pattern-real nil) + +(defun helm-mp-prefix-get-pattern (pattern) + (unless (equal pattern helm-mp-prefix-pattern-str) + (setq helm-mp-prefix-pattern-str pattern + helm-mp-prefix-pattern-real (concat "\n" pattern))) + helm-mp-prefix-pattern-real) + +(defun helm-mp-prefix-match (str &optional pattern) + (setq pattern (or pattern helm-pattern)) + (let ((len (length pattern))) + (and (<= len (length str)) + (string= (substring str 0 len) pattern )))) + +(defun helm-mp-prefix-search (pattern &rest ignore) + (search-forward (helm-mp-prefix-get-pattern pattern) nil t)) + +(defun helm-mp-prefix-search-backward (pattern &rest ignore) + (and (search-backward (helm-mp-prefix-get-pattern pattern) nil t) + (forward-line 1))) + + +;;; Multiple regexp patterns 1 (order is preserved / prefix). +;; +;; +;; Internal +(defvar helm-mp-1-pattern-str nil) +(defvar helm-mp-1-pattern-real nil) + +(defun helm-mp-1-get-pattern (pattern) + (unless (equal pattern helm-mp-1-pattern-str) + (setq helm-mp-1-pattern-str pattern + helm-mp-1-pattern-real + (concat "^" (helm-mp-1-make-regexp pattern)))) + helm-mp-1-pattern-real) + +(defun* helm-mp-1-match (str &optional (pattern helm-pattern)) + (string-match (helm-mp-1-get-pattern pattern) str)) + +(defun helm-mp-1-search (pattern &rest ignore) + (re-search-forward (helm-mp-1-get-pattern pattern) nil t)) + +(defun helm-mp-1-search-backward (pattern &rest ignore) + (re-search-backward (helm-mp-1-get-pattern pattern) nil t)) + + +;;; Multiple regexp patterns 2 (order is preserved / partial). +;; +;; +;; Internal +(defvar helm-mp-2-pattern-str nil) +(defvar helm-mp-2-pattern-real nil) + +(defun helm-mp-2-get-pattern (pattern) + (unless (equal pattern helm-mp-2-pattern-str) + (setq helm-mp-2-pattern-str pattern + helm-mp-2-pattern-real + (concat "^.*" (helm-mp-1-make-regexp pattern)))) + helm-mp-2-pattern-real) + +(defun* helm-mp-2-match (str &optional (pattern helm-pattern)) + (string-match (helm-mp-2-get-pattern pattern) str)) + +(defun helm-mp-2-search (pattern &rest ignore) + (re-search-forward (helm-mp-2-get-pattern pattern) nil t)) + +(defun helm-mp-2-search-backward (pattern &rest ignore) + (re-search-backward (helm-mp-2-get-pattern pattern) nil t)) + + +;;; Multiple regexp patterns 3 (permutation). +;; +;; +;; Internal +(defvar helm-mp-3-pattern-str nil) +(defvar helm-mp-3-pattern-list nil) + +(defun helm-mp-3-get-patterns (pattern) + "Return `helm-mp-3-pattern-list', a list of predicate/regexp cons cells. +e.g ((identity . \"foo\") (identity . \"bar\")). +This is done only if `helm-mp-3-pattern-str' is same as PATTERN." + (unless (equal pattern helm-mp-3-pattern-str) + (setq helm-mp-3-pattern-str pattern + helm-mp-3-pattern-list + (helm-mp-3-get-patterns-internal pattern))) + helm-mp-3-pattern-list) + +(defun helm-mp-3-get-patterns-internal (pattern) + "Return a list of predicate/regexp cons cells. +e.g ((identity . \"foo\") (identity . \"bar\"))." + (unless (string= pattern "") + (loop for pat in (helm-mp-make-regexps pattern) + collect (if (string= "!" (substring pat 0 1)) + (cons 'not (substring pat 1)) + (cons 'identity pat))))) + +(defun helm-mp-3-match (str &optional pattern) + "Check if PATTERN match STR. +When PATTERN contain a space, it is splitted and matching is done +with the several resulting regexps against STR. +e.g \"bar foo\" will match \"foobar\" and \"barfoo\". +Argument PATTERN, a string, is transformed in a list of +cons cell with `helm-mp-3-get-patterns' if it contain a space. +e.g \"foo bar\"=>((identity . \"foo\") (identity . \"bar\")). +Then each predicate of cons cell(s) is called with regexp of same +cons cell against STR (a candidate). +i.e (identity (string-match \"foo\" \"foo bar\")) => t." + (let ((pat (helm-mp-3-get-patterns (or pattern helm-pattern)))) + (loop for (predicate . regexp) in pat + always (funcall predicate (string-match regexp str))))) + +(defun helm-mp-3-search-base (pattern searchfn1 searchfn2) + (loop with pat = (if (stringp pattern) + (helm-mp-3-get-patterns pattern) + pattern) + while (funcall searchfn1 (or (cdar pat) "") nil t) + for bol = (point-at-bol) + for eol = (point-at-eol) + if (loop for (pred . str) in (cdr pat) always + (progn (goto-char bol) + (funcall pred (funcall searchfn2 str eol t)))) + do (goto-char eol) and return t + else do (goto-char eol) + finally return nil)) + +(defun helm-mp-3-search (pattern &rest ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 're-search-forward 're-search-forward)) + +(defun helm-mp-3-search-backward (pattern &rest ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 're-search-backward 're-search-backward)) + + +;;; mp-3p- (multiple regexp pattern 3 with prefix search) +;; +;; +(defun helm-mp-3p-match (str &optional pattern) + "Check if PATTERN match STR. +Same as `helm-mp-3-match' but more strict, matching against prefix also. +e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to +`helm-mp-3-match'." + (let* ((pat (helm-mp-3-get-patterns (or pattern helm-pattern))) + (first (car pat))) + (and (funcall (car first) (helm-mp-prefix-match str (cdr first))) + (loop for (predicate . regexp) in (cdr pat) + always (funcall predicate (string-match regexp str)))))) + +(defun helm-mp-3p-search (pattern &rest ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 'helm-mp-prefix-search 're-search-forward)) + +(defun helm-mp-3p-search-backward (pattern &rest ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 'helm-mp-prefix-search-backward 're-search-backward)) + + +;;; source compiler +;; +;; +(defun helm-compile-source--match-plugin (source) + (let ((searchers (if (assoc 'search-from-end source) + helm-mp-default-search-backward-functions + helm-mp-default-search-functions))) + `(,(if (or (assoc 'candidates-in-buffer source) + (equal '(identity) (assoc-default 'match source))) + '(match identity) + `(match ,@helm-mp-default-match-functions + ,@(assoc-default 'match source))) + (search ,@searchers + ,@(assoc-default 'search source)) + ,@source))) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--match-plugin t) + + +;;; Highlight matches. +;; +;; +(defun helm-mp-highlight-match () + "Highlight matches after `helm-mp-highlight-delay' seconds." + (when (and helm-mp-highlight-delay + (not (string= helm-pattern ""))) + (helm-mp-highlight-match-internal (window-end (helm-window))) + (run-with-idle-timer helm-mp-highlight-delay nil + 'helm-mp-highlight-match-internal + (with-current-buffer helm-buffer (point-max))))) +(add-hook 'helm-update-hook 'helm-mp-highlight-match) + +(defun helm-mp-highlight-region (start end regexp face) + (save-excursion + (goto-char start) + (let (me) + (while (and (setq me (re-search-forward regexp nil t)) + (< (point) end) + (< 0 (- (match-end 0) (match-beginning 0)))) + (unless (helm-pos-header-line-p) + (put-text-property (match-beginning 0) me 'face face)))))) + +(defun helm-mp-highlight-match-internal (end) + (when (helm-window) + (set-buffer helm-buffer) + (let ((requote (loop for (pred . re) in + (helm-mp-3-get-patterns helm-pattern) + when (and (eq pred 'identity) + (>= (length re) + helm-mp-highlight-threshold)) + collect re into re-list + finally return + (if (and re-list (>= (length re-list) 1)) + (mapconcat 'identity re-list "\\|") + (regexp-quote helm-pattern))))) + (when (>= (length requote) helm-mp-highlight-threshold) + (helm-mp-highlight-region + (point-min) end requote 'helm-match))))) + + +;;; Toggle helm-match-plugin +;; +;; +(defvar helm-mp-initial-highlight-delay nil) + +;;;###autoload +(defun helm-mp-toggle-match-plugin () + "Turn on/off multiple regexp matching in helm. +i.e helm-match-plugin." + (interactive) + (let ((helm-match-plugin-enabled + (member 'helm-compile-source--match-plugin + helm-compile-source-functions))) + (flet ((disable-match-plugin () + (setq helm-compile-source-functions + (delq 'helm-compile-source--match-plugin + helm-compile-source-functions)) + (setq helm-mp-initial-highlight-delay + helm-mp-highlight-delay) + (setq helm-mp-highlight-delay nil)) + (enable-match-plugin () + (unless helm-mp-initial-highlight-delay + (setq helm-mp-initial-highlight-delay + helm-mp-highlight-delay)) + (setq helm-compile-source-functions + (cons 'helm-compile-source--match-plugin + helm-compile-source-functions)) + (unless helm-mp-highlight-delay + (setq helm-mp-highlight-delay + helm-mp-initial-highlight-delay)))) + (if helm-match-plugin-enabled + (when (y-or-n-p "Really disable match-plugin? ") + (disable-match-plugin) + (message "Helm-match-plugin disabled")) + (when (y-or-n-p "Really enable match-plugin? ") + (enable-match-plugin) + (message "Helm-match-plugin enabled")))))) + + +;;;; Unit test +;; +;; unit test for match plugin are now in developper-tools/unit-test-match-plugin.el + +(provide 'helm-match-plugin) + +;;; helm-match-plugin.el ends here diff --git a/vendor/helm/helm.el b/vendor/helm/helm.el new file mode 100644 index 0000000..f2075d8 --- /dev/null +++ b/vendor/helm/helm.el @@ -0,0 +1,4427 @@ +;;; helm.el --- Emacs incremental and narrowing framework + +;; Copyright (C) 2007 Tamas Patrovics +;; 2008 ~ 2012 rubikitch +;; 2011 ~ 2012 Thierry Volpiatto + +;; Original Authors: Tamas Patrovics +;; rubikitch + +;; This is a fork of `anything.el' created by Tamas Patrovics. + +;; Maintainers: Thierry Volpiatto +;; Le Wang + +;; Keywords: files, frames, help, matching, outlines, +;; processes, tools, convenience, helm + +;; X-URL: + +;; MailingList: + + +;;; This file is NOT part of GNU Emacs + +;;; License +;; +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Autodoc documentation: +;; --------------------- + +;; * Commands defined here are: +;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "helm" :docstring t) +;; `helm-open-last-log' +;; Open helm log file of last helm session. +;; `helm' +;; Main function to execute helm sources. +;; `helm-resume' +;; Resurrect previously invoked `helm'. +;; `helm-resume-window-only' +;; +;; `helm-at-point' +;; Call helm with symbol at point as initial input. +;; `helm-force-update' +;; Force recalculation and update of candidates. +;; `helm-select-action' +;; Select an action for the currently selected candidate. +;; `helm-previous-line' +;; Move selection to the previous line. +;; `helm-next-line' +;; Move selection to the next line. +;; `helm-previous-page' +;; Move selection back with a pageful. +;; `helm-next-page' +;; Move selection forward with a pageful. +;; `helm-beginning-of-buffer' +;; Move selection at the top. +;; `helm-end-of-buffer' +;; Move selection at the bottom. +;; `helm-previous-source' +;; Move selection to the previous source. +;; `helm-next-source' +;; Move selection to the next source. +;; `helm-select-with-prefix-shortcut' +;; Invoke default action with prefix shortcut. +;; `helm-select-with-digit-shortcut' +;; Invoke default action with digit/alphabet shortcut. +;; `helm-confirm-and-exit-minibuffer' +;; Maybe ask for confirmation when exiting helm. +;; `helm-exit-minibuffer' +;; Select the current candidate by exiting the minibuffer. +;; `helm-keyboard-quit' +;; Quit minibuffer in helm. +;; `helm-help' +;; Help of `helm'. +;; `helm-debug-output' +;; Show all helm-related variables at this time. +;; `helm-delete-current-selection' +;; Delete the currently selected item. +;; `helm-delete-minibuffer-contents' +;; Same as `delete-minibuffer-contents' but this is a command. +;; `helm-toggle-resplit-window' +;; Toggle resplit helm window, vertically or horizontally. +;; `helm-narrow-window' +;; Narrow helm window. +;; `helm-enlarge-window' +;; Enlarge helm window. +;; `helm-select-2nd-action' +;; Select the 2nd action for the currently selected candidate. +;; `helm-select-3rd-action' +;; Select the 3rd action for the currently selected candidate. +;; `helm-select-4th-action' +;; Select the 4th action for the currently selected candidate. +;; `helm-select-2nd-action-or-end-of-line' +;; Select the 2nd action for the currently selected candidate. +;; `helm-execute-persistent-action' +;; Perform the associated action ATTR without quitting helm. +;; `helm-scroll-other-window' +;; Scroll other window (not *Helm* window) upward. +;; `helm-scroll-other-window-down' +;; Scroll other window (not *Helm* window) downward. +;; `helm-toggle-visible-mark' +;; Toggle helm visible mark at point. +;; `helm-display-all-visible-marks' +;; Show all `helm' visible marks strings. +;; `helm-next-visible-mark' +;; Move next helm visible mark. +;; `helm-prev-visible-mark' +;; Move previous helm visible mark. +;; `helm-yank-selection' +;; Set minibuffer contents to current selection. +;; `helm-kill-selection-and-quit' +;; Store current selection to kill ring. +;; `helm-follow-mode' +;; If this mode is on, persistent action is executed everytime the cursor is moved. +;; `helm-migrate-sources' +;; Help to migrate to new `helm' way. +;; `helm-describe-helm-attribute' +;; Display the full documentation of HELM-ATTRIBUTE. +;; `helm-send-bug-report' +;; Send a bug report of helm.el. +;; `helm-send-bug-report-from-helm' +;; Send a bug report of helm.el in helm session. + +;; * Variables defined here are: +;; [EVAL] (autodoc-document-lisp-buffer :type 'internal-variable :prefix "helm-" :docstring t) +;; `helm-version' +;; Not documented. +;; `helm-sources' +;; A list of sources to use with `helm'. +;; `helm-type-attributes' +;; It's a list of (TYPE ATTRIBUTES ...). +;; `helm-enable-shortcuts' +;; *Whether to use digit/alphabet shortcut to select the first nine matches. +;; `helm-shortcut-keys-alist' +;; Not documented. +;; `helm-display-source-at-screen-top' +;; *Display candidates at the top of screen. +;; `helm-candidate-number-limit' +;; Apply candidate-number-limit attribute value. +;; `helm-idle-delay' +;; *Be idle for this many seconds, before updating in delayed sources. +;; `helm-input-idle-delay' +;; Be idle for this many seconds, before updating. +;; `helm-samewindow' +;; Use current window to show the candidates. +;; `helm-source-filter' +;; A list of source names to be displayed. +;; `helm-map' +;; Keymap for helm. +;; `helm-header-face' +;; *Face for header lines in the helm buffer. +;; `helm-selection-face' +;; *Face for currently selected item. +;; `helm-buffer' +;; Buffer showing completions. +;; `helm-action-buffer' +;; Buffer showing actions. +;; `helm-selection-overlay' +;; Overlay used to highlight the currently selected item. +;; `helm-digit-overlays' +;; Overlays for digit shortcuts. See `helm-enable-shortcuts'. +;; `helm-candidate-cache' +;; Holds the available candidate withing a single helm invocation. +;; `helm-pattern' +;; Not documented. +;; `helm-input' +;; Not documented. +;; `helm-async-processes' +;; List of information about asynchronous processes managed by helm. +;; `helm-digit-shortcut-count' +;; Number of digit shortcuts shown in the helm buffer. +;; `helm-before-initialize-hook' +;; Run before helm initialization. +;; `helm-after-initialize-hook' +;; Run after helm initialization. +;; `helm-update-hook' +;; Run after the helm buffer was updated according the new input pattern. +;; `helm-after-update-hook' +;; Run after the helm buffer was updated according the new input pattern. +;; `helm-cleanup-hook' +;; Run after helm minibuffer is closed. +;; `helm-select-action-hook' +;; Run when opening the action buffer. +;; `helm-before-action-hook' +;; Run before executing action. +;; `helm-after-action-hook' +;; Run after executing action. +;; `helm-after-persistent-action-hook' +;; Run after executing persistent action. +;; `helm-move-selection-before-hook' +;; Run before moving selection in `helm-buffer'. +;; `helm-move-selection-after-hook' +;; Run after moving selection in `helm-buffer'. +;; `helm-restored-variables' +;; Variables which are restored after `helm' invocation. +;; `helm-saved-selection' +;; Value of the currently selected object when the action list is shown. +;; `helm-current-prefix-arg' +;; Record `current-prefix-arg' when exiting minibuffer. +;; `helm-candidate-separator' +;; Candidates separator of `multiline' source. +;; `helm-current-buffer' +;; Current buffer when `helm' is invoked. +;; `helm-buffer-file-name' +;; Variable `buffer-file-name' when `helm' is invoked. +;; `helm-saved-action' +;; Saved value of the currently selected action by key. +;; `helm-last-sources' +;; OBSOLETE!! Sources of previously invoked `helm'. +;; `helm-saved-current-source' +;; Value of the current source when the action list is shown. +;; `helm-compiled-sources' +;; Compiled version of `helm-sources'. +;; `helm-in-persistent-action' +;; Flag whether in persistent-action or not. +;; `helm-quick-update' +;; If non-nil, suppress displaying sources which are out of screen at first. +;; `helm-last-sources-local' +;; Buffer local value of `helm-sources'. +;; `helm-last-buffer' +;; `helm-buffer' of previously `helm' session. +;; `helm-save-configuration-functions' +;; The functions used to restore/save window or frame configurations. +;; `helm-persistent-action-use-special-display' +;; If non-nil, use `special-display-function' in persistent action. +;; `helm-execute-action-at-once-if-one' +;; Execute default action and exit when only one candidate is remaining. +;; `helm-quit-if-no-candidate' +;; Quit when there is no candidates when non--nil. +;; `helm-scroll-amount' +;; Scroll amount when scrolling other window in an helm session. +;; `helm-display-function' +;; Function to display *helm* buffer. +;; `helm-delayed-init-executed' +;; Not documented. +;; `helm-mode-line-string' +;; Help string displayed in mode-line in `helm'. +;; `helm-help-message' +;; Detailed help message string for `helm'. +;; `helm-source-in-each-line-flag' +;; Non-nil means add helm-source text-property in each candidate. +;; `helm-debug-forms' +;; Forms to show in `helm-debug-output'. +;; `helm-debug' +;; If non-nil, write log message into *Helm Log* buffer. +;; `helm-test-candidate-list' +;; Not documented. +;; `helm-test-mode' +;; Not documented. +;; `helm-source-name' +;; Not documented. +;; `helm-candidate-buffer-alist' +;; Not documented. +;; `helm-check-minibuffer-input-timer' +;; Not documented. +;; `helm-match-hash' +;; Not documented. +;; `helm-cib-hash' +;; Not documented. +;; `helm-tick-hash' +;; Not documented. +;; `helm-issued-errors' +;; Not documented. +;; `helm-shortcut-keys' +;; Not documented. +;; `helm-once-called-functions' +;; Not documented. +;; `helm-follow-mode' +;; If this mode is on, persistent action is executed everytime the cursor is moved. +;; `helm-let-variables' +;; Not documented. +;; `helm-split-window-state' +;; Not documented. +;; `helm-selection-point' +;; Not documented. +;; `helm-last-log-file' +;; Not documented. +;; `helm-compile-source-functions' +;; Functions to compile elements of `helm-sources' (plug-in). +;; `helm-quit' +;; Not documented. +;; `helm-additional-attributes' +;; List of all `helm' attributes. +;; `helm-buffers' +;; All of `helm-buffer' in most recently used order. +;; `helm-current-position' +;; Restore or save current position in `helm-current-buffer'. +;; `helm-last-frame-or-window-configuration' +;; Used to store window or frame configuration when helm start. +;; `helm-reading-pattern' +;; Whether in `read-string' in helm or not. +;; `helm-compile-source-functions-default' +;; Plug-ins this file provides. +;; `helm-input-local' +;; Not documented. +;; `helm-process-delayed-sources-timer' +;; Not documented. +;; `helm-mode-line-string-real' +;; Not documented. +;; `helm-exit-status' +;; Flag to inform whether helm have exited or quitted. +;; `helm-minibuffer-confirm-state' +;; Not documented. +;; `helm-types' +;; Not documented. +;; `helm-orig-enable-shortcuts' +;; Not documented. +;; `helm-persistent-action-display-window' +;; Return the window that will be used for presistent action. +;; `helm-visible-mark-face' +;; Not documented. +;; `helm-visible-mark-overlays' +;; Not documented. +;; `helm-marked-candidates' +;; Return marked candidates of current source if any. +;; `helm-maintainer-mail-address' +;; Not documented. +;; `helm-bug-report-salutation' +;; Not documented. +;; `helm-no-dump-variables' +;; Variables not to dump in bug report. + +;; *** END auto-documentation + +;; [EVAL] (autodoc-update-all) + + +;;; Commentary: + +;; +;; Start with M-x helm, narrow the list by typing some pattern, +;; select with up/down/pgup/pgdown/C-p/C-n/C-v/M-v, choose with enter, +;; left/right moves between sources. With TAB actions can be selected +;; if the selected candidate has more than one possible action. +;; +;; Note that helm.el provides only the framework and some example +;; configurations for demonstration purposes. See helm-config.el +;; for practical, polished, easy to use configurations which can be +;; used to assemble a custom personalized configuration. +;; +;; NOTE: What you find on Emacswiki is mostly deprecated and not maintained, +;; don't complain if you use such code or configuration and something +;; doesn't work. +;; +;; Here is Japanese translation of `helm-sources' attributes. Thanks. +;; http://d.hatena.ne.jp/sirocco634/20091012/1255336649 + + +;;; Bug Report: +;; +;; If you have problems, send a bug report via C-c C-x C-b in helm session (best) +;; or M-x helm-send-bug-report outside helm session. +;; I implemented bug report feature because I want to know your current state. +;; It helps me to solve problems easily. +;; The step is: +;; 0) Setup mail in Emacs, the easiest way is: +;; (setq user-mail-address "your@mail.address") +;; (setq user-full-name "Your Full Name") +;; (setq smtpmail-smtp-server "your.smtp.server.jp") +;; (setq mail-user-agent 'message-user-agent) +;; (setq message-send-mail-function 'message-smtpmail-send-it) +;; 1) Be sure to use the LATEST version of helm.el. +;; 2) Enable debugger. M-x toggle-debug-on-error or (setq debug-on-error t) +;; 3) Use Lisp version instead of compiled one: (load "helm.el") +;; 4) Do it! +;; 5) If you got an error, please do not close *Backtrace* buffer. +;; 6) Type C-c C-x C-b (helm session, best!) +;; or M-x helm-send-bug-report (outside) +;; then M-x insert-buffer *Backtrace* (if you got error) +;; 7) Describe the bug using a precise recipe. +;; 8) Type C-c C-c to send. +;; +;; You can also just report bug to: +;; https://groups.google.com/group/emacs-helm?hl=en + + +;; You can extend `helm' by writing plug-ins. As soon as +;; `helm' is invoked, `helm-sources' is compiled into basic +;; attributes, then compiled one is used during invocation. +;; +;; The oldest built-in plug-in is `type' attribute: appends +;; appropriate element of `helm-type-attributes'. Second built-in +;; plug-in is `candidates-in-buffer': selecting a line from candidates +;; buffer. +;; +;; To write a plug-in: +;; 1. Define a compiler: helm-compile-source--* +;; 2. Add compier function to `helm-compile-source-functions'. +;; 3. (optional) Write helper functions. +; +;; Tested on Emacs 22/23/24. +;; +;; +;; Thanks to Vagn Johansen for ideas. +;; Thanks to Stefan Kamphausen for fixes and XEmacs support. +;; Thanks to Tassilo Horn for fixes. +;; Thanks to Drew Adams for various fixes +;; Thanks to IMAKADO for candidates-in-buffer idea. +;; Thanks to Tomohiro MATSUYAMA for multiline patch. +;; + +;;; (@* "Index") + +;; If you have library `linkd.el', load +;; `linkd.el' and turn on `linkd-mode' now. It lets you easily +;; navigate around the sections Linkd mode will +;; highlight this Index. You can get `linkd.el' here: +;; http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el +;; + + +;;; (@* "Tips") + +;; +;; `helm' accepts keyword arguments. See docstring. +;; [EVAL IT] (describe-function 'helm) + +;; +;; `helm-enable-shortcuts' enables us to select candidate easily. +;; If 'prefix then they can be selected using . +;; The prefix key is `helm-select-with-prefix-shortcut'. +;; If the is a letter, pressing twice inputs the letter itself. +;; e.g. +;; (setq helm-enable-shortcuts 'prefix) +;; (define-key helm-map \"@\" 'helm-select-with-prefix-shortcut) + +;; +;; You can edit current selection using `helm-edit-current-selection'. +;; It is useful after persistent-action. + +;; +;; For `helm' users, setting `helm-sources' directly and +;; invoke M-x helm is obsolete way for now. Try M-x +;; `helm-migrate-sources'! + +;; +;; If you want to create helm sources, yasnippet would help you. +;; http://yasnippet.googlecode.com/ +;; +;; Then get the snippet from +;; http://www.emacswiki.org/cgi-bin/wiki/download/helm-source.yasnippet +;; +;; Put it in ~/.emacs.d/plugins/yasnippet/snippets/text-mode/emacs-lisp-mode/ + + +;; +;; `helm-interpret-value' is useful function to interpret value +;; like `candidates' attribute. +;; +;; (helm-interpret-value "literal") ; => "literal" +;; (helm-interpret-value (lambda () "lambda")) ; => "lambda" +;; (let ((source '((name . "lambda with source name")))) +;; (helm-interpret-value +;; (lambda () helm-source-name) +;; source)) ; => "lambda with source name" +;; (flet ((f () "function symbol")) +;; (helm-interpret-value 'f)) ; => "function symbol" +;; (let ((v "variable symbol")) +;; (helm-interpret-value 'v)) ; => "variable symbol" +;; (helm-interpret-value 'unbounded-1) ; error + +;; +;; Now symbols are acceptable as candidates. So you do not have to use +;; `symbol-name' function. The source is much simpler. For example, +;; `apropos-internal' returns a list of symbols. +;; +;; (helm +;; '(((name . "Commands") +;; (candidates . (lambda () (apropos-internal helm-pattern 'commandp))) +;; (volatile) +;; (action . describe-function)))) + +;; +;; To mark a candidate, press C-SPC as normal Emacs marking. To go to +;; marked candidate, press M-[ or M-]. + +;; +;; `helm-map' is now Emacs-standard key bindings by default. +;; +;; There are many `helm' applications, using `helm' for +;; selecting candidate. In this case, if there is one candidate or no +;; candidate, popping up *helm* buffer is irritating. If one +;; candidate, you want to select it at once. If no candidate, you want +;; to quit `helm'. Set `helm-execute-action-at-once-if-one' +;; and `helm-quit-if-no-candidate' to non-nil to remedy it. Note +;; that setting these variables GLOBALLY is bad idea because of +;; delayed sources. These are meant to be let-binded. +;; +;; ex. +;; (let ((helm-execute-action-at-once-if-one t) +;; (helm-quit-if-no-candidate (lambda () (message "No candidate")))) +;; (helm temporary-sources input)) + +;; +;; `set-frame-configuration' arises flickering. If you hate +;; flickering, eval: +;; (setq helm-save-configuration-functions +;; '(set-window-configuration . current-window-configuration)) +;; at the cost of restoring frame configuration (only window configuration). + +;; +;; `helm-delete-current-selection' deletes the current line. +;; It is useful when deleting a candidate in persistent action. +;; eg. `kill-buffer'. +;; +;; [EVAL IT] (describe-function 'helm-delete-current-selection) + +;; +;; `helm-attr' gets the attribute. `helm-attrset' sets the +;; attribute. `helm-attr-defined' tests whether the attribute is +;; defined. They handles source-local variables. +;; +;; [EVAL IT] (describe-function 'helm-attr) +;; [EVAL IT] (describe-function 'helm-attrset) +;; [EVAL IT] (describe-function 'helm-attr-defined) + +;; +;; `helm-sources' accepts many attributes to make your life easier. +;; Now `helm-sources' accepts a list of symbols. +;; +;; [EVAL IT] (describe-variable 'helm-sources) + +;; +;; `helm' has optional arguments. Now you do not have to let-bind +;; `helm-sources'. +;; +;; [EVAL IT] (describe-function 'helm) + +;; +;; `helm-resume' resumes last `helm' session. Now you do not +;; have to retype pattern. +;; +;; [EVAL IT] (describe-function 'helm-resume) + +;; +;; `helm-execute-persistent-action' executes action without +;; quitting `helm'. When popping up a buffer in other window by +;; persistent action, you can scroll with `helm-scroll-other-window' and +;; `helm-scroll-other-window-down'. See also `helm-sources' docstring. +;; +;; [EVAL IT] (describe-function 'helm-execute-persistent-action) +;; [EVAL IT] (describe-variable 'helm-sources) + +;; +;; `helm-select-2nd-action', `helm-select-3rd-action' and +;; `helm-select-4th-action' select other than default action +;; without pressing Tab. + +;; +;; Using `helm-candidate-buffer' and the candidates-in-buffer +;; attribute is much faster than traditional "candidates and match" +;; way. And `helm-current-buffer-is-modified' avoids to +;; recalculate candidates for unmodified buffer. See docstring of +;; them. +;; +;; [EVAL IT] (describe-function 'helm-candidate-buffer) +;; [EVAL IT] (describe-function 'helm-candidates-in-buffer) +;; [EVAL IT] (describe-function 'helm-current-buffer-is-modified) + +;; +;; `helm-current-buffer' and `helm-buffer-file-name' stores +;; `(current-buffer)' and `buffer-file-name' in the buffer `helm' +;; is invoked. Use them freely. +;; +;; [EVAL IT] (describe-variable 'helm-current-buffer) +;; [EVAL IT] (describe-variable 'helm-buffer-file-name) + +;; +;; `helm-completing-read' and `helm-read-file-name' are +;; experimental implementation. If you are curious, type M-x +;; helm-read-string-mode. It is a minor mode and toggles on/off. + +;; +;; Use `helm-test-candidates' to test your handmade helm +;; sources. It simulates contents of *helm* buffer with pseudo +;; `helm-sources' and `helm-pattern', without side-effect. So +;; you can unit-test your helm sources! Let's TDD! +;; +;; [EVAL IT] (describe-function 'helm-test-candidates) +;; +;; For helm developpers: +;; +;; There are many unit-testing framework in Emacs Lisp. See the EmacsWiki. +;; http://www.emacswiki.org/cgi-bin/emacs/UnitTesting +;; There is an unit-test by Emacs Lisp Expectations in developper-tools directory. +;; http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el +;; http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el + +;; +;; If you want to create helm sources, see helm-config.el. +;; It is huge collection of sources. You can learn from examples. + + +;; (@* "TODO") +;; +;; - process status indication +;; +;; - async sources doesn't honor digit-shortcut-count +;; +;; - helm-candidate-number-limit can't be nil everywhere + +;; (@* "HISTORY") +;; +;; Change log of this file is found at +;; http://repo.or.cz/w/helm-config.git/history/master:/helm.el +;; +;; Change log of this project is found at +;; http://repo.or.cz/w/helm-config.git?a=shortlog +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;; Code: + +(require 'cl) + +(defvar helm-version "1.3.9") + +;; (@* "User Configuration") + + +;;; Variables +;; +;; +;; [DEPRECATED] +;; A default value is provided in helm-config.el +(defvar helm-sources nil + "A list of sources to use with `helm'. +It is deprecated, you should not use this. +Use instead individual sources or list of sources of your choice.") + +;; Default values are provided in helm-config.el. +(defvar helm-type-attributes nil + "It's a list of \(TYPE ATTRIBUTES ...\). +ATTRIBUTES are the same as attributes for `helm-sources'. +TYPE connects the value to the appropriate sources. +Don't set this directly, use instead `define-helm-type-attribute'. + +This allows specifying common attributes for several sources. +For example, sources which provide files can specify +common attributes with a `file' type.") + +(defvaralias 'helm-enable-digit-shortcuts 'helm-enable-shortcuts + "Same as `helm-enable-shortcuts'. +Alphabet shortcuts are available now in `helm-enable-shortcuts'. +`helm-enable-digit-shortcuts' is retained for compatibility.") + +(defvar helm-enable-shortcuts nil + "*Whether to use digit/alphabet shortcut to select the first nine matches. +If t then they can be selected using Ctrl+. + +If 'prefix then they can be selected using . +The prefix key is `helm-select-with-prefix-shortcut'. +If the is a letter, pressing twice inputs the letter itself. +e.g. + (setq helm-enable-shortcuts 'prefix) + (define-key helm-map \"@\" 'helm-select-with-prefix-shortcut) + +If 'alphabet then they can be selected using Shift+ (deprecated). +It is not recommended because you cannot input capital letters in pattern. + +Keys (digit/alphabet) are listed in `helm-shortcut-keys-alist'.") + +(defvar helm-shortcut-keys-alist + '((alphabet . "asdfghjklzxcvbnmqwertyuiop") + (prefix . "asdfghjklzxcvbnmqwertyuiop1234567890") + (t . "123456789"))) + +(defvar helm-display-source-at-screen-top t + "*Display candidates at the top of screen. +This happen when using `helm-next-source' and `helm-previous-source'.") + +(defvar helm-candidate-number-limit 50 + "*Limit candidate number globally. +Do not show more candidates than this limit from individual sources. +It is usually pointless to show hundreds of matches +when the pattern is empty, because it is much simpler to type a +few characters to narrow down the list of potential candidates. + +Set it to nil if you don't want this limit.") + +(defvar helm-idle-delay 0.3 + "*Be idle for this many seconds, before updating in delayed sources. +This is useful for sources involving heavy operations +\(like launching external programs\), so that candidates +from the source are not retrieved unnecessarily if the user keeps typing. + +It also can be used to declutter the results helm displays, +so that results from certain sources are not shown with every +character typed, only if the user hesitates a bit.") + +(defvar helm-input-idle-delay 0.3 + "Be idle for this many seconds, before updating. + +Unlike `helm-idle-delay', it is also effective for non-delayed sources. +If nil, candidates are collected immediately. + +Note: If this value is too low compared to `helm-idle-delay', +you may have duplicated sources when using multiples sources. +Safe value is always >= `helm-idle-delay'. +Default settings are equal value for both.") + +(defvar helm-samewindow nil + "Use current window to show the candidates. +If t then Helm doesn't pop up a new window.") + +(defvar helm-source-filter nil + "A list of source names to be displayed. +Other sources won't appear in the search results. +If nil then there is no filtering. +See also `helm-set-source-filter'.") + + +(defvar helm-map + (let ((map (copy-keymap minibuffer-local-map))) + (define-key map (kbd "") 'helm-next-line) + (define-key map (kbd "") 'helm-previous-line) + (define-key map (kbd "C-n") 'helm-next-line) + (define-key map (kbd "C-p") 'helm-previous-line) + (define-key map (kbd "") 'helm-previous-page) + (define-key map (kbd "") 'helm-next-page) + (define-key map (kbd "M-v") 'helm-previous-page) + (define-key map (kbd "C-v") 'helm-next-page) + (define-key map (kbd "M-<") 'helm-beginning-of-buffer) + (define-key map (kbd "M->") 'helm-end-of-buffer) + (define-key map (kbd "C-g") 'helm-keyboard-quit) + (define-key map (kbd "") 'helm-next-source) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-exit-minibuffer) + (define-key map (kbd "C-1") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-2") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-3") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-4") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-5") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-6") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-7") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-8") 'helm-select-with-digit-shortcut) + (define-key map (kbd "C-9") 'helm-select-with-digit-shortcut) + (loop for c from ?A to ?Z do + (define-key map (make-string 1 c) 'helm-select-with-digit-shortcut)) + (define-key map (kbd "C-i") 'helm-select-action) + (define-key map (kbd "C-z") 'helm-execute-persistent-action) + (define-key map (kbd "C-e") 'helm-select-2nd-action-or-end-of-line) + (define-key map (kbd "C-j") 'helm-select-3rd-action) + (define-key map (kbd "C-o") 'helm-next-source) + (define-key map (kbd "C-M-v") 'helm-scroll-other-window) + (define-key map (kbd "M-") 'helm-scroll-other-window) + (define-key map (kbd "C-M-y") 'helm-scroll-other-window-down) + (define-key map (kbd "C-M-S-v") 'helm-scroll-other-window-down) + (define-key map (kbd "M-") 'helm-scroll-other-window-down) + (define-key map (kbd "") 'helm-scroll-other-window) + (define-key map (kbd "") 'helm-scroll-other-window-down) + (define-key map (kbd "C-SPC") 'helm-toggle-visible-mark) + (define-key map (kbd "M-SPC") 'helm-toggle-visible-mark) + (define-key map (kbd "M-[") 'helm-prev-visible-mark) + (define-key map (kbd "M-]") 'helm-next-visible-mark) + (define-key map (kbd "C-k") 'helm-delete-minibuffer-contents) + + (define-key map (kbd "C-r") 'undefined) + (define-key map (kbd "C-t") 'helm-toggle-resplit-window) + (define-key map (kbd "C-}") 'helm-narrow-window) + (define-key map (kbd "C-{") 'helm-enlarge-window) + + (define-key map (kbd "C-c C-d") 'helm-delete-current-selection) + (define-key map (kbd "C-c C-y") 'helm-yank-selection) + (define-key map (kbd "C-c C-k") 'helm-kill-selection-and-quit) + (define-key map (kbd "C-c C-f") 'helm-follow-mode) + (define-key map (kbd "C-c C-u") 'helm-force-update) + (define-key map (kbd "M-p") 'previous-history-element) + (define-key map (kbd "M-n") 'next-history-element) + ;; Debugging command + (define-key map "\C-c\C-x\C-d" 'helm-debug-output) + (define-key map "\C-c\C-x\C-m" 'helm-display-all-visible-marks) + (define-key map "\C-c\C-x\C-b" 'helm-send-bug-report-from-helm) + ;; Use `describe-mode' key in `global-map'. + (define-key map [f1] nil) ; Allow to eval keymap whithout errors. + (dolist (k (where-is-internal 'describe-mode global-map)) + (define-key map k 'helm-help)) + map) + "Keymap for helm.") + + +(defgroup helm nil + "Open helm." + :prefix "helm-" :group 'convenience) + +(defface helm-header + '((t (:inherit header-line))) + "Face for header lines in the helm buffer." + :group 'helm) + +(defvar helm-header-face 'helm-header + "*Face for header lines in the helm buffer.") + +(defface helm-candidate-number + '((t (:background "Yellow" :foreground "black"))) + "Face for candidate number in mode-line." :group 'helm) + +(defvar helm-selection-face 'highlight + "*Face for currently selected item.") + +(defvar helm-buffer "*helm*" + "Buffer showing completions.") + +(defvar helm-action-buffer "*helm action*" + "Buffer showing actions.") + +(defvar helm-selection-overlay nil + "Overlay used to highlight the currently selected item.") + +(defvar helm-digit-overlays nil + "Overlays for digit shortcuts. See `helm-enable-shortcuts'.") + +(defvar helm-candidate-cache nil + "Holds the available candidate withing a single helm invocation.") + +(defvar helm-pattern + "The input pattern used to update the helm buffer.") + +(defvar helm-input + "The input typed in the candidates panel.") + +(defvar helm-async-processes nil + "List of information about asynchronous processes managed by helm.") + +(defvar helm-digit-shortcut-count 0 + "Number of digit shortcuts shown in the helm buffer.") + +(defvar helm-before-initialize-hook nil + "Run before helm initialization. +This hook is run before init functions in `helm-sources'.") + +(defvar helm-after-initialize-hook nil + "Run after helm initialization. +Global variables are initialized and the helm buffer is created. +But the helm buffer has no contents.") + +(defvar helm-update-hook nil + "Run after the helm buffer was updated according the new input pattern. +This hook is run at the beginning of buffer. +The first candidate is selected after running this hook. +See also `helm-after-update-hook'.") + +(defvar helm-after-update-hook nil + "Run after the helm buffer was updated according the new input pattern. +This is very similar to `helm-update-hook' but selection is not moved. +It is useful to select a particular object instead of the first one.") + +(defvar helm-cleanup-hook nil + "Run after helm minibuffer is closed. +IOW this hook is executed BEFORE performing action.") + +(defvar helm-select-action-hook nil + "Run when opening the action buffer.") + +(defvar helm-before-action-hook nil + "Run before executing action. +Contrarily to `helm-cleanup-hook', +this hook run before helm minibuffer is closed +and before performing action.") + +(defvar helm-after-action-hook nil + "Run after executing action.") + +(defvar helm-after-persistent-action-hook nil + "Run after executing persistent action.") + +(defvar helm-move-selection-before-hook nil + "Run before moving selection in `helm-buffer'.") + +(defvar helm-move-selection-after-hook nil + "Run after moving selection in `helm-buffer'.") + +(defvar helm-restored-variables + '(helm-candidate-number-limit + helm-source-filter + helm-source-in-each-line-flag + helm-map + helm-sources) + "Variables which are restored after `helm' invocation.") + +(defvar helm-saved-selection nil + "Value of the currently selected object when the action list is shown.") + +(defvar helm-current-prefix-arg nil + "Record `current-prefix-arg' when exiting minibuffer.") + +(defvar helm-candidate-separator + "--------------------" + "Candidates separator of `multiline' source.") + +(defvar helm-current-buffer nil + "Current buffer when `helm' is invoked.") + +(defvar helm-buffer-file-name nil + "Variable `buffer-file-name' when `helm' is invoked.") + +(defvar helm-saved-action nil + "Saved value of the currently selected action by key.") + +(defvar helm-last-sources nil + "OBSOLETE!! Sources of previously invoked `helm'.") + +(defvar helm-saved-current-source nil + "Value of the current source when the action list is shown.") + +(defvar helm-compiled-sources nil + "Compiled version of `helm-sources'.") + +(defvar helm-in-persistent-action nil + "Flag whether in persistent-action or not.") + +(defvar helm-quick-update nil + "If non-nil, suppress displaying sources which are out of screen at first. +They are treated as delayed sources at this input. +This flag makes `helm' a bit faster with many sources.") + +(defvar helm-last-sources-local nil + "Buffer local value of `helm-sources'.") + +(defvar helm-last-buffer nil + "`helm-buffer' of previously `helm' session.") + +(defvar helm-save-configuration-functions + '(set-window-configuration . current-window-configuration) + "The functions used to restore/save window or frame configurations. +It is a pair where the car is the function to restore window or frame config, +and the cdr is the function to save the window or frame config. + +If you want to save and restore frame configuration, set this variable to + '\(set-frame-configuration . current-frame-configuration\) + +Older version saves/restores frame configuration, but the default is changed now +because flickering can occur in some environment. ") + +(defvar helm-persistent-action-use-special-display nil + "If non-nil, use `special-display-function' in persistent action.") + +(defvar helm-execute-action-at-once-if-one nil + "Execute default action and exit when only one candidate is remaining. +It is useful for `helm' applications.") + +(defvar helm-quit-if-no-candidate nil + "Quit when there is no candidates when non--nil. +This variable accepts a function, which is executed if no candidate. + +It is useful for `helm' applications.") + +(defvar helm-scroll-amount nil + "Scroll amount when scrolling other window in an helm session. +It is used by `helm-scroll-other-window' +and `helm-scroll-other-window-down'. + +If you prefer scrolling line by line, set this value to 1.") + +(defvar helm-display-function 'helm-default-display-buffer + "Function to display *helm* buffer. +It is `helm-default-display-buffer' by default, +which affects `helm-samewindow'.") + +(defvar helm-delayed-init-executed nil) + +(defvar helm-mode-line-string "\\\\[helm-help]:help \ +\\[helm-select-action]:Acts \ +\\[helm-exit-minibuffer]/\\[helm-select-2nd-action-or-end-of-line]/\ +\\[helm-select-3rd-action]:NthAct \ +\\[helm-send-bug-report-from-helm]:BugReport" + "Help string displayed in mode-line in `helm'. +It can be a string or a list of two args, in this case, +first arg is a string that will be used as name for candidates number, +second arg any string to display in mode line. +If nil, use default `mode-line-format'.") + +(defvar helm-help-message + "\\The keys that are defined for `helm' are: + \\{helm-map}" + "Detailed help message string for `helm'. +It also accepts function or variable symbol.") + +(defvar helm-source-in-each-line-flag nil + "Non-nil means add helm-source text-property in each candidate. +experimental feature.") + +(defvaralias 'helm-debug-variables 'helm-debug-forms) + +(defvar helm-debug-forms nil + "Forms to show in `helm-debug-output'. +Otherwise all variables started with `helm-' are shown. +It is useful for debug.") + +(defvar helm-debug nil + "If non-nil, write log message into *Helm Log* buffer. +If `debug-on-error' is non-nil, write log message regardless of this variable. +It is disabled by default because *Helm Log* grows quickly.") + + +;; (@* "Internal Variables") +(defvar helm-test-candidate-list nil) +(defvar helm-test-mode nil) +(defvar helm-source-name nil) +(defvar helm-candidate-buffer-alist nil) +(defvar helm-check-minibuffer-input-timer nil) +(defvar helm-match-hash (make-hash-table :test 'equal)) +(defvar helm-cib-hash (make-hash-table :test 'equal)) +(defvar helm-tick-hash (make-hash-table :test 'equal)) +(defvar helm-issued-errors nil) +(defvar helm-shortcut-keys nil) +(defvar helm-once-called-functions nil) +(defvar helm-follow-mode nil) +(defvar helm-let-variables nil) +(defvar helm-split-window-state nil) +(defvar helm-selection-point nil) +(defvar helm-alive-p nil) + + +;; (@* "Utility: logging") +(defun helm-log (format-string &rest args) + "Log message if `debug-on-error' or `helm-debug' is non-nil. +Messages are written to the *Helm Log* buffer. + +Argument FORMAT-STRING is a string to use with `format'. +Use optional arguments ARGS like in `format'." + (when (or debug-on-error helm-debug) + (with-current-buffer (get-buffer-create "*Helm Log*") + (buffer-disable-undo) + (set (make-local-variable 'inhibit-read-only) t) + (goto-char (point-max)) + (insert (let ((tm (current-time))) + (format "%s.%06d (%s) %s\n" + (format-time-string "%H:%M:%S" tm) + (nth 2 tm) + (helm-log-get-current-function) + (apply #'format (cons format-string args)))))))) + +(defmacro helm-log-eval (&rest exprs) + "Write each EXPRS evaluation result to the *Helm Log* buffer." + `(helm-log-eval-internal ',exprs)) + +(defun helm-log-run-hook (hook) + "Run HOOK like `run-hooks' but write these actions to helm log buffer." + (helm-log "executing %s" hook) + (when (boundp hook) + (helm-log-eval (symbol-value hook)) + (helm-log-eval (default-value hook))) + (run-hooks hook) + (helm-log "executed %s" hook)) + +(defun helm-log-eval-internal (exprs) + "Eval EXPRS and write results to helm log buffer." + (dolist (expr exprs) + (condition-case err + (helm-log "%S = %S" expr (eval expr)) + (error (helm-log "%S = ERROR!" expr))))) + +(defun helm-log-get-current-function () + "Get function name calling `helm-log'. +The original idea is from `tramp-debug-message'." + (loop with exclude-func-re = "^helm-\\(?:interpret\\|log\\|.*funcall\\)" + for btn from 1 to 40 ;avoid inf-loop + for btf = (second (backtrace-frame btn)) + for fn = (if (symbolp btf) (symbol-name btf) "") + if (and (string-match "^helm" fn) + (not (string-match exclude-func-re fn))) + return fn)) + +(defun helm-log-error (&rest args) + "Accumulate error messages into `helm-issued-errors'. +ARGS are args given to `format'." + (apply 'helm-log (concat "ERROR: " (car args)) (cdr args)) + (let ((msg (apply 'format args))) + (unless (member msg helm-issued-errors) + (add-to-list 'helm-issued-errors msg)))) + +(defvar helm-last-log-file nil) +(defun helm-log-save-maybe () + "May be save log buffer to `helm-last-log-file'." + (when (stringp helm-debug) + (let ((logdir (expand-file-name (format-time-string "%Y%m%d") + helm-debug))) + (make-directory logdir t) + (with-current-buffer (get-buffer-create "*Helm Log*") + (write-region (point-min) (point-max) + (setq helm-last-log-file + (expand-file-name (format-time-string "%Y%m%d-%H%M%S") + logdir)) + nil 'silent) + (erase-buffer))))) + +(defun helm-open-last-log () + "Open helm log file of last helm session." + (interactive) + (if helm-last-log-file + (view-file helm-last-log-file) + (switch-to-buffer "*Helm Log*"))) + +(defun helm-print-error-messages () + "Print error messages in `helm-issued-errors'." + (message "%s" (mapconcat 'identity (reverse helm-issued-errors) "\n"))) + +;; (helm-log "test") +;; (switch-to-buffer-other-window "*Helm Log*") + + +;; (@* "Programming Tools") +(defmacro helm-aif (test-form then-form &rest else-forms) + "Like `if' but set the result of TEST-FORM in a temprary variable called `it'. +THEN-FORM and ELSE-FORMS are then excuted just like in `if'." + (declare (indent 2) (debug t)) + `(let ((it ,test-form)) + (if it ,then-form ,@else-forms))) + +(defun helm-mklist (obj) + "If OBJ is a list \(but not lambda\), return itself. +Otherwise make a list with one element." + (if (and (listp obj) (not (functionp obj))) + obj + (list obj))) + + +;; (@* "Helm API") + +(defun helm-buffer-get () + "Return `helm-action-buffer' if shown otherwise `helm-buffer'." + (if (helm-action-window) + helm-action-buffer + helm-buffer)) + +(defun helm-window () + "Window of `helm-buffer'." + (get-buffer-window (helm-buffer-get) 'visible)) + +(defun helm-action-window () + "Window of `helm-action-buffer'." + (get-buffer-window helm-action-buffer 'visible)) + +(defmacro with-helm-window (&rest body) + "Be sure BODY is excuted in the helm window." + (declare (indent 0) (debug t)) + `(if helm-test-mode + (with-current-buffer (helm-buffer-get) + ,@body) + (with-selected-window (helm-window) + ,@body))) + +(defmacro with-helm-current-buffer (&rest body) + "Eval BODY inside `helm-current-buffer'." + (declare (indent 0) (debug t)) + `(with-current-buffer helm-current-buffer + ,@body)) + +(defmacro with-helm-restore-variables(&rest body) + "Restore `helm-restored-variables' after executing BODY. +`post-command-hook' is handled specially." + (declare (indent 0) (debug t)) + `(let ((--orig-vars (mapcar (lambda (v) + (cons v (symbol-value v))) + helm-restored-variables)) + (--post-command-hook-pair (cons post-command-hook + (default-value 'post-command-hook)))) + (setq post-command-hook '(t)) + (setq-default post-command-hook nil) + (unwind-protect (progn ,@body) + (loop for (var . value) in --orig-vars + do (set var value)) + (setq post-command-hook (car --post-command-hook-pair)) + (setq-default post-command-hook (cdr --post-command-hook-pair)) + (helm-log "restore variables")))) + +(defun* helm-attr (attribute-name &optional + (src (helm-get-current-source))) + "Get the value of ATTRIBUTE-NAME of SRC. +if SRC is omitted, use current source. +It is useful to write your sources." + (helm-aif (assq attribute-name src) + (cdr it))) + +(defun* helm-attr* (attribute-name + &optional (src (helm-get-current-source))) + "Pass the value of ATTRIBUTE-NAME of SRC to `helm-interpret-value'. +if SRC is omitted, use current source. +It is useful to write your sources." + (helm-interpret-value (helm-attr attribute-name src))) + +(defun* helm-attr-defined (attribute-name + &optional (src (helm-get-current-source))) + "Return non-nil if ATTRIBUTE-NAME of SRC is defined. +if SRC is omitted, use current source. +It is useful to write your sources." + (and (assq attribute-name src) t)) + +(defun* helm-attrset (attribute-name value + &optional + (src (helm-get-current-source))) + "Set the value of ATTRIBUTE-NAME of SRC to VALUE. +if SRC is omitted, use current source. +It is useful to write your sources." + (helm-aif (assq attribute-name src) + (setcdr it value) + (setcdr src (cons (cons attribute-name value) (cdr src)))) + value) + +(defun helm-set-source-filter (sources) + "Set the value of `helm-source-filter' to SOURCES and update. + +This function sets a filter for helm sources and it may be +called while helm is running. It can be used to toggle +displaying of sources dinamically. For example, additional keys +can be bound into `helm-map' to display only the file-related +results if there are too many matches from other sources and +you're after files only: + +Shift+F shows only file results from some sources: + +\(define-key helm-map \"F\" 'helm-my-show-files-only) + +\(defun helm-my-show-files-only () + (interactive) + (helm-set-source-filter '(\"File Name History\" + \"Files from Current Directory\"))) + +Shift+A shows all results: + +\(define-key helm-map \"A\" 'helm-my-show-all) + +\(defun helm-my-show-all () + (interactive) + (helm-set-source-filter nil)) + +Note that you have to prefix the functions with helm- prefix, +otherwise they won't be bound when Helm is used under +Iswitchb. The -my- part is added to avoid collisions with +existing Helm function names." + (unless (and (listp sources) + (loop for name in sources always (stringp name))) + (error "Invalid data in `helm-set-source-filter': %S" sources)) + (setq helm-source-filter sources) + (helm-log-eval helm-source-filter) + (helm-update)) + +(defun helm-set-sources (sources &optional no-init no-update) + "Set SOURCES during `helm' invocation. +If NO-INIT is non-nil, skip executing init functions of SOURCES. +If NO-UPDATE is non-nil, skip executing `helm-update'." + (with-current-buffer helm-buffer + (setq helm-compiled-sources nil + helm-sources sources + helm-last-sources-local sources) + (helm-log-eval helm-compiled-sources helm-sources)) + (unless no-init (helm-funcall-foreach 'init)) + (unless no-update (helm-update))) + +(defvar helm-compile-source-functions + '(helm-compile-source--type + helm-compile-source--dummy + helm-compile-source--disable-shortcuts + helm-compile-source--candidates-in-buffer) + "Functions to compile elements of `helm-sources' (plug-in).") + +(defun helm-get-sources () + "Return compiled `helm-sources', which is memoized. + +Attributes: + +- type + `helm-type-attributes' are merged in. +- candidates-buffer + candidates, volatile and match attribute are created." + (cond + ;; action + ((helm-action-window) + helm-sources) + ;; memoized + (helm-compiled-sources) + ;; first time + (t + (prog1 + (setq helm-compiled-sources + (helm-compile-sources + helm-sources helm-compile-source-functions)) + (helm-log-eval helm-compiled-sources))))) + +(defun* helm-get-selection (&optional (buffer nil buffer-s) + force-display-part) + "Return the currently selected item or nil. +if BUFFER is nil or unspecified, use helm-buffer as default value. +If FORCE-DISPLAY-PART is non-nil, return the display string. +If FORCE-DISPLAY-PART value is 'withprop the display string is returned +with its properties." + (setq buffer (if (and buffer buffer-s) buffer helm-buffer)) + (unless (helm-empty-buffer-p buffer) + (with-current-buffer buffer + (let* ((disp-fn (if (eq force-display-part 'withprop) + 'buffer-substring + 'buffer-substring-no-properties)) + (selection + (or (and (not force-display-part) + (get-text-property (overlay-start + helm-selection-overlay) + 'helm-realvalue)) + ;; It is needed to return properties of DISP in some case, + ;; e.g for `helm-confirm-and-exit-minibuffer', + ;; so use `buffer-substring' here when 'withprop is specified. + (let ((disp (funcall disp-fn + (overlay-start helm-selection-overlay) + (1- (overlay-end helm-selection-overlay)))) + (source (helm-get-current-source))) + (helm-aif (and (not force-display-part) + (assoc-default 'display-to-real source)) + (helm-funcall-with-source source it disp) + disp))))) + (unless (equal selection "") + (helm-log-eval selection) + selection))))) + +(defun helm-get-action () + "Return the associated action for the selected candidate. +It is a function symbol \(sole action\) or list +of \(action-display . function\)." + (unless (helm-empty-buffer-p (helm-buffer-get)) + (helm-aif (helm-attr 'action-transformer) + (helm-composed-funcall-with-source + (helm-get-current-source) it + (helm-attr 'action) (helm-get-selection)) + (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." + (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)) + source + (with-current-buffer (helm-buffer-get) + (or + ;; This happen only when `helm-source-in-each-line-flag' + ;; is non--nil and there is candidates in buffer. + (get-text-property (point) 'helm-source) + ;; Return nil when no--candidates. + (block exit + ;; This goto-char shouldn't be necessary, but point is moved to + ;; point-min somewhere else which shouldn't happen. + (goto-char (overlay-start helm-selection-overlay)) + (let* ((header-pos (or (helm-get-previous-header-pos) + (helm-get-next-header-pos))) + (source-name + (save-excursion + (unless header-pos + (return-from exit nil)) + (goto-char header-pos) + (helm-current-line-contents)))) + (loop for source in (helm-get-sources) thereis + (and (equal (assoc-default 'name source) source-name) + source)))))))) + +(defun helm-buffer-is-modified (buffer) + "Return non-nil when BUFFER is modified since `helm' was invoked." + (let* ((b (get-buffer buffer)) + (key (concat (buffer-name b) "/" (helm-attr 'name))) + (source-tick (or (gethash key helm-tick-hash) 0)) + (buffer-tick (buffer-chars-modified-tick b)) + (modifiedp (/= source-tick buffer-tick))) + (puthash key buffer-tick helm-tick-hash) + (helm-log-eval buffer modifiedp) + modifiedp)) + +(defun helm-current-buffer-is-modified () + "Check if `helm-current-buffer' is modified since `helm' was invoked." + (helm-buffer-is-modified helm-current-buffer)) + +(defvar helm-quit nil) +(defun helm-run-after-quit (function &rest args) + "Perform an action after quitting `helm'. +The action is to call FUNCTION with arguments ARGS." + (setq helm-quit t) + (helm-kill-async-processes) + (helm-log-eval function args) + (apply 'run-with-idle-timer 0 nil function args) + (helm-exit-minibuffer)) + + +(defun define-helm-type-attribute (type definition &optional doc) + "Register type attribute of TYPE as DEFINITION with DOC. +DOC is displayed in `helm-type-attributes' docstring. + +Use this function is better than setting `helm-type-attributes' directly." + (loop for i in definition do + ;; without `ignore-errors', error at emacs22 + (ignore-errors (setf i (delete nil i)))) + (helm-add-type-attribute type definition) + (and doc (helm-document-type-attribute type doc)) + nil) + +(defvaralias 'helm-attributes 'helm-additional-attributes) +(defvar helm-additional-attributes nil + "List of all `helm' attributes.") + +(defun helm-document-attribute (attribute short-doc &optional long-doc) + "Register ATTRIBUTE documentation introduced by plug-in. +SHORT-DOC is displayed beside attribute name. +LONG-DOC is displayed below attribute name and short documentation." + (if long-doc + (setq short-doc (concat "(" short-doc ")")) + (setq long-doc short-doc + short-doc "")) + (add-to-list 'helm-additional-attributes attribute t) + (put attribute 'helm-attrdoc + (concat "- " (symbol-name attribute) + " " short-doc "\n\n" long-doc "\n"))) + +(put 'helm-document-attribute 'lisp-indent-function 2) + +(defun helm-interpret-value (value &optional source) + "Interpret VALUE as variable, function or literal. +If VALUE is a function, call it with no arguments and return the value. +If SOURCE is `helm' source, `helm-source-name' is source name. + +If VALUE is a variable, return the value. + +If VALUE is a symbol, but it is not a function or a variable, cause an error. + +Otherwise, return VALUE itself." + (cond ((and source (functionp value)) + (helm-funcall-with-source source value)) + ((functionp value) + (funcall value)) + ((and (symbolp value) (boundp value)) + (symbol-value value)) + ((symbolp value) + (error "helm-interpret-value: Symbol must be a function or a variable")) + (t + value))) + +(defun helm-once (function &rest args) + "Ensure FUNCTION with ARGS to be called once in `helm' session." + (let ((spec (cons function args))) + (unless (member spec helm-once-called-functions) + (apply function args) + (push spec helm-once-called-functions)))) + + +;; (@* "Core: API helper") +(defun* helm-empty-buffer-p (&optional (buffer helm-buffer)) + "Check if BUFFER have candidates. +Default value for BUFFER is `helm-buffer'." + (zerop (buffer-size (and buffer (get-buffer buffer))))) + +(defun helm-let-eval-varlist (varlist) + "Return the list of pairs VARLIST with each cdr of pair evaluated. +If VARLIST contain single elements, those are returned +as a list of one element." + (mapcar (lambda (pair) + (if (listp pair) + (cons (car pair) (eval (cadr pair))) + (cons pair nil))) + varlist)) + +;; [NOT USED] +;; (defun helm-let*-eval-varlist (varlist) +;; (let ((vars (mapcar (lambda (pair) +;; (or (car-safe pair) pair)) +;; varlist))) +;; (eval `(let ,vars +;; ,@(mapcar (lambda (pair) +;; (if (listp pair) +;; `(setq ,(car pair) ,(cadr pair)) +;; `(setq ,pair nil))) +;; varlist) +;; (mapcar (lambda (v) +;; (cons v (symbol-value v))) +;; ',vars))))) + +(defun helm-let-internal (binding bodyfunc) + "Set BINDING to helm buffer-local variables and Evaluate BODYFUNC. +BINDING is a list of \(VARNAME . VALUE\) pair." + (setq helm-let-variables binding) + (unwind-protect + (funcall bodyfunc) + (setq helm-let-variables nil))) + + +;; (@* "Core: tools") +(defun helm-current-line-contents () + "Current line string without properties." + (buffer-substring-no-properties (point-at-bol) (point-at-eol))) + +(defun helm-funcall-with-source (source func &rest args) + "Call from SOURCE FUNC list or single function FUNC with ARGS. +FUNC can be a symbol or a list of functions. +Return the result of last function call." + (let ((helm-source-name (assoc-default 'name source)) + result) + (helm-log-eval helm-source-name func args) + (dolist (func (if (functionp func) (list func) func) result) + (setq result (apply func args))))) + +(defun helm-funcall-foreach (sym) + "Call the function SYM for each source if any." + (dolist (source (helm-get-sources)) + (helm-aif (assoc-default sym source) + (helm-funcall-with-source source it)))) + +(defun helm-normalize-sources (sources) + "If SOURCES is only one source, make a list of one element." + (cond ((or (and sources + (symbolp sources)) + (and (listp sources) (assq 'name sources))) + (list sources)) + (sources) + (t helm-sources))) + +(defun helm-approximate-candidate-number (&optional in-current-source) + "Return approximate number of candidates in `helm-buffer'. +If IN-CURRENT-SOURCE is provided return number of candidates +in the source where point is. +It is used to check if candidate number is 0, 1, or 2+." + (with-current-buffer helm-buffer + (save-excursion + (if in-current-source + (goto-char (helm-get-previous-header-pos)) + (goto-char (point-min))) + (forward-line 1) + (let ((count-multi 1)) + (if (helm-pos-multiline-p) + (save-excursion + (loop while (and (not (if in-current-source + (save-excursion + (forward-line 2) + (or (helm-pos-header-line-p) (eobp))) + (eobp))) + (search-forward helm-candidate-separator nil t)) + do (incf count-multi) + finally return count-multi)) + (save-excursion + (loop with ln = 0 + while (not (if in-current-source + (or (helm-pos-header-line-p) (eobp)) + (eobp))) + unless (helm-pos-header-line-p) + do (incf ln) + do (forward-line 1) finally return ln))))))) + +(defmacro with-helm-quittable (&rest body) + "If an error occur in execution of BODY, quit helm safely." + (declare (indent 0) (debug t)) + `(let (inhibit-quit) + (condition-case v + (progn ,@body) + (quit (setq helm-quit t) + (exit-minibuffer) + (keyboard-quit))))) + +(defun helm-compose (arg-lst func-lst) + "Apply arguments specified in ARG-LST with each function of FUNC-LST. +The result of each function will be the new `car' of ARG-LST. + +This function allows easy sequencing of transformer functions." + (dolist (func func-lst) + (setcar arg-lst (apply func arg-lst))) + (car arg-lst)) + +(defun helm-composed-funcall-with-source (source funcs &rest args) + "With SOURCE apply `helm-funcall-with-source' with each FUNCS and ARGS. +This is used in transformers to modify candidates list." + (if (functionp funcs) + (apply 'helm-funcall-with-source source funcs args) + (apply 'helm-funcall-with-source source + (lambda (&rest args) + (helm-compose args funcs)) + args))) + +(defun helm-new-timer (variable timer) + "Give VARIABLE value to TIMER and cancel old timer." + (helm-aif (symbol-value variable) + (cancel-timer it)) + (set variable timer)) + + +;; (@* "Core: entry point") +(defconst helm-argument-keys + '(:sources :input :prompt :resume :preselect :buffer :keymap :default :history)) + +;;;###autoload +(defun helm (&rest plist) + "Main function to execute helm sources. + +Keywords supported: +:sources :input :prompt :resume :preselect :buffer :keymap :default :history +Extra keywords are supported and can be added, see below. + +When call interactively with no arguments deprecated `helm-sources' +will be used if non--nil. + +PLIST is a list like \(:key1 val1 :key2 val2 ...\) or +\(&optional sources input prompt resume preselect buffer keymap default history\). + +Basic keywords are the following: + +\:sources + +Temporary value of `helm-sources'. It also accepts a +symbol, interpreted as a variable of an helm source. It +also accepts an alist representing an helm source, which is +detected by \(assq 'name ANY-SOURCES\) + +\:input + +Temporary value of `helm-pattern', ie. initial input of minibuffer. + +\:prompt + +Prompt other than \"pattern: \". + +\:resume + +If t, Resurrect previously instance of `helm'. Skip the initialization. +If 'noresume, this instance of `helm' cannot be resumed. + +\:preselect + +Initially selected candidate. Specified by exact candidate or a regexp. + +\:buffer + +`helm-buffer' instead of *helm*. + +\:keymap + +`helm-map' for current `helm' session. + +\:default + +A default argument that will be inserted in minibuffer \ +with \\\\[next-history-element]. +When nil of not present `thing-at-point' will be used instead. + +\:history + +By default all minibuffer input is pushed to `minibuffer-history', +if an argument HISTORY is provided, input will be pushed to HISTORY. +History element should be a symbol. + +Of course, conventional arguments are supported, the two are same. + +\(helm :sources sources :input input :prompt prompt :resume resume + :preselect preselect :buffer buffer :keymap keymap :default default + :history history\) +\(helm sources input prompt resume preselect buffer keymap default history\) + +Other keywords are interpreted as local variables of this helm session. +The `helm-' prefix can be omitted. For example, + +\(helm :sources 'helm-c-source-buffers + :buffer \"*buffers*\" :candidate-number-limit 10\) + +means starting helm session with `helm-c-source-buffers' +source in *buffers* buffer and set variable `helm-candidate-number-limit' +to 10 as session local variable." + (interactive) + (if (keywordp (car plist)) + (helm-let-internal + (helm-parse-keys plist) + (lambda () + (apply 'helm + (mapcar (lambda (key) (plist-get plist key)) + helm-argument-keys)))) + (apply 'helm-internal plist))) + +(defun helm-parse-keys (keys) + "Parse the KEYS arguments of `helm'. +Return only the keys that are not in `helm-argument-keys'. +It is used to set local variables via `helm-let-internal'. +This allow to add arguments that are not part of `helm-argument-keys', +but are valid helm attributes. +i.e :candidate-number-limit will be bound to `helm-candidate-number-limit' +in source." + ;; (helm-parse-keys '(:sources ((name . "test") + ;; (candidates . (a b c))) + ;; :buffer "toto" + ;; :candidate-number-limit 4)) + ;; ==> ((helm-candidate-number-limit . 4)) + (loop for (key value) on keys by #'cddr + for symname = (substring (symbol-name key) 1) + for sym = (intern (if (string-match "^helm-" symname) + symname + (concat "helm-" symname))) + unless (memq key helm-argument-keys) + collect (cons sym value))) + +;;; (@* "Core: entry point helper") +(defun helm-internal (&optional + any-sources any-input + any-prompt any-resume + any-preselect any-buffer + any-keymap any-default any-history) + "The internal helm function called by `helm'. +For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and +ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'." + (helm-log (concat "[Start session] " (make-string 41 ?+))) + (helm-log-eval any-prompt any-preselect + any-buffer any-keymap any-default) + (let ((old-overridding-local-map overriding-local-map)) + (unwind-protect + (condition-case v + (let ( ;; It is needed because `helm-source-name' is non-nil + ;; when `helm' is invoked by action. Awful global scope. + helm-source-name + helm-in-persistent-action + helm-quit + (case-fold-search t) + (helm-buffer (or any-buffer helm-buffer)) + ;; cua-mode ; avoid error when region is selected + ) + (with-helm-restore-variables + (helm-initialize any-resume any-input any-sources) + (helm-display-buffer helm-buffer) + (helm-log "show prompt") + (unwind-protect + (helm-read-pattern-maybe + any-prompt any-input any-preselect + any-resume any-keymap any-default + (when (and any-history (symbolp any-history)) any-history)) + (helm-cleanup))) + (prog1 (unless helm-quit + (helm-execute-selection-action-1)) + (helm-log (concat "[End session] " (make-string 41 ?-))))) + (quit + (helm-restore-position-on-quit) + (helm-log (concat "[End session (quit)] " (make-string 34 ?-))) + nil)) + (setq overriding-local-map old-overridding-local-map) + (helm-log-save-maybe)))) + + +;;; Helm resume +;; +;; +(defun* helm-resume (&optional + (any-buffer helm-last-buffer) + buffer-pattern (any-resume t)) + "Resurrect previously invoked `helm'. +Called with a prefix arg, allow choosing among all existing +helm buffers. i.e choose among various helm sessions." + (interactive) + (when (or current-prefix-arg buffer-pattern) + (setq any-buffer (helm-resume-select-buffer buffer-pattern))) + (setq helm-compiled-sources nil) + (helm + :sources (or (buffer-local-value 'helm-last-sources-local (get-buffer any-buffer)) + helm-last-sources helm-sources) + :input (buffer-local-value 'helm-input-local (get-buffer any-buffer)) + :resume any-resume + :buffer any-buffer)) + +;;; rubikitch: experimental +;;; I use this and check it whether I am convenient. +;;; I may introduce an option to control the behavior. +(defun* helm-resume-window-only (&optional + (any-buffer helm-last-buffer) + buffer-pattern) + (interactive) + (helm-resume any-buffer buffer-pattern 'window-only)) + +(defun helm-resume-p (any-resume) + "Whether current helm session is resumed or not. +Just check if ANY-RESUME value is t or window-only." + (memq any-resume '(t window-only))) + +(defun helm-resume-select-buffer (input) + "Resume precedent helm session with initial input INPUT." + (or (helm :sources '(((name . "Resume helm buffer") + (candidates . helm-buffers) + (action . identity))) + :input input + :resume 'noresume + :buffer "*helm resume*") + (keyboard-quit))) + + +;;;###autoload +(defun helm-at-point (&optional + any-sources any-input + any-prompt any-resume + any-preselect any-buffer) + "Call helm with symbol at point as initial input. +ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT and ANY-BUFFER +are same args as in `helm'." + (interactive) + (helm :sources any-sources + :input (if current-prefix-arg + (concat "\\b" (thing-at-point 'symbol) "\\b" + (if (featurep 'helm-match-plugin) " " "")) + any-input) + :prompt any-prompt + :resume any-resume + :preselect any-preselect + :buffer any-buffer)) + +;;;###autoload +(defun helm-other-buffer (any-sources any-buffer) + "Simplified interface of `helm' with other `helm-buffer'. +Call `helm' with only ANY-SOURCES and ANY-BUFFER as args." + (helm :sources any-sources :buffer any-buffer)) + +(defun helm-nest (&rest same-as-helm) + "Allow calling `helm' whithin a running helm session." + (with-helm-window + (let (helm-current-position + helm-current-buffer + (orig-helm-current-buffer helm-current-buffer) + (orig-helm-buffer helm-buffer) + (orig-helm-last-frame-or-window-configuration + helm-last-frame-or-window-configuration) + helm-pattern + (helm-buffer (or (getf same-as-helm :buffer) + (nth 5 same-as-helm) + "*Helm*")) + helm-sources + helm-compiled-sources + (helm-samewindow t) + (enable-recursive-minibuffers t)) + (unwind-protect + (apply #'helm same-as-helm) + (with-current-buffer orig-helm-buffer + (helm-initialize-overlays orig-helm-buffer) + (setq helm-buffer (current-buffer)) + (helm-mark-current-line) + (setq helm-last-frame-or-window-configuration + orig-helm-last-frame-or-window-configuration) + (setq cursor-type t) + (setq helm-current-buffer orig-helm-current-buffer)))))) + + +;;; Initialize +;; +;; +(defvar helm-buffers nil + "All of `helm-buffer' in most recently used order.") +(defun helm-initialize (any-resume any-input any-sources) + "Start initialization of `helm' session. +For ANY-RESUME ANY-INPUT and ANY-SOURCES See `helm'." + (helm-log "start initialization: any-resume=%S any-input=%S" any-resume any-input) + (helm-frame-or-window-configuration 'save) + (setq helm-sources (helm-normalize-sources any-sources)) + (helm-log "sources = %S" helm-sources) + (helm-hooks 'setup) + (helm-current-position 'save) + (if (helm-resume-p any-resume) + (helm-initialize-overlays (helm-buffer-get)) + (helm-initial-setup)) + (unless (eq any-resume 'noresume) + (helm-recent-push helm-buffer 'helm-buffers) + (setq helm-last-buffer helm-buffer)) + (when any-input (setq helm-input any-input helm-pattern any-input)) + (and (helm-resume-p any-resume) (helm-funcall-foreach 'resume)) + (helm-log "end initialization")) + +(defun helm-execute-selection-action-1 () + "Execute current action." + (helm-log-run-hook 'helm-before-action-hook) + (unwind-protect + (helm-execute-selection-action) + (helm-aif (get-buffer helm-action-buffer) + (kill-buffer it)) + (helm-log-run-hook 'helm-after-action-hook))) + +(defun helm-restore-position-on-quit () + "Restore position in `helm-current-buffer' when quitting." + (helm-current-position 'restore)) + +(defun helm-recent-push (elt list-var) + "Add ELT to the value of LIST-VAR as most recently used value." + (let ((m (member elt (symbol-value list-var)))) + (and m (set list-var (delq (car m) (symbol-value list-var)))) + (push elt (symbol-value list-var)))) + + +;;; (@* "Core: Accessors") +;;; rubikitch: I love to create functions to control variables. +(defvar helm-current-position nil + "Cons of \(point . window-start\) when `helm' is invoked. +It is needed to restore position in `helm-current-buffer' +when `helm' is keyboard-quitted.") +(defun helm-current-position (save-or-restore) + "Restore or save current position in `helm-current-buffer'. +Argument SAVE-OR-RESTORE is one of save or restore." + (case save-or-restore + (save + (helm-log "Save position at %S" (cons (point) (window-start))) + (setq helm-current-position (cons (point) (window-start)))) + (restore + (helm-log "Restore position at %S in buffer %s" + helm-current-position + (buffer-name (current-buffer))) + (goto-char (car helm-current-position)) + ;; Fix this position with the NOFORCE arg of `set-window-start' + ;; otherwise, if there is some other buffer than `helm-current-buffer' + ;; one, position will be lost. + (set-window-start (selected-window) (cdr helm-current-position) t)))) + + +;; Internal. +(defvar helm-last-frame-or-window-configuration nil + "Used to store window or frame configuration when helm start.") +(defun helm-frame-or-window-configuration (save-or-restore) + "Save or restore last frame or window configuration. +Possible value of SAVE-OR-RESTORE are 'save and 'restore. +window or frame configuration is saved/restored according to values of +`helm-save-configuration-functions'." + (helm-log-eval helm-save-configuration-functions) + (case save-or-restore + (save (setq helm-last-frame-or-window-configuration + (funcall (cdr helm-save-configuration-functions)))) + (restore (funcall (car helm-save-configuration-functions) + helm-last-frame-or-window-configuration) + ;; Restore frame focus. + (let ((frame (and (listp helm-last-frame-or-window-configuration) + (caadr helm-last-frame-or-window-configuration)))) + ;; If `helm-save-configuration-functions' are window functions + ;; frame should be nil, use current frame. + (unless (framep frame) + (setq frame (selected-frame))) + (select-frame-set-input-focus frame))))) + + +;; (@* "Core: Display *helm* buffer") +(defun helm-display-buffer (buf) + "Display *helm* buffer BUF." + (let (pop-up-frames) + (funcall (with-current-buffer buf helm-display-function) buf))) + +(defun helm-default-display-buffer (buf) + "Default function to display BUF. +Where BUF is generally `helm-buffer'. +It use `switch-to-buffer' or `pop-to-buffer' depending of value of +`helm-samewindow'." + (funcall (if helm-samewindow 'switch-to-buffer 'pop-to-buffer) buf)) + + +;; (@* "Core: initialize") +(defun helm-initial-setup () + "Initialize helm settings and set up the helm buffer." + (helm-log-run-hook 'helm-before-initialize-hook) + (setq helm-current-prefix-arg nil) + (setq helm-once-called-functions nil) + (setq helm-delayed-init-executed nil) + (setq helm-alive-p t) + (setq helm-current-buffer + (if (minibuffer-window-active-p (minibuffer-window)) + ;; If minibuffer is active be sure to use it's buffer + ;; as `helm-current-buffer'. + (window-buffer (active-minibuffer-window)) + (current-buffer))) + (setq helm-buffer-file-name buffer-file-name) + (setq helm-issued-errors nil) + (setq helm-compiled-sources nil) + (setq helm-saved-current-source nil) + (if (or (not split-width-threshold) + (and (integerp split-width-threshold) + (>= split-width-threshold (+ (frame-width) 4)))) + (setq helm-split-window-state 'vertical) + (setq helm-split-window-state 'horizontal)) + ;; Call the init function for sources where appropriate + (helm-funcall-foreach 'init) + (setq helm-pattern "") + (setq helm-input "") + (setq helm-candidate-cache nil) + (setq helm-last-sources helm-sources) + (helm-create-helm-buffer) + (helm-log-run-hook 'helm-after-initialize-hook)) + +(defvar helm-reading-pattern nil + "Whether in `read-string' in helm or not.") + +(defun helm-read-pattern-maybe (any-prompt any-input + any-preselect any-resume any-keymap + any-default any-history) + "Read pattern with prompt ANY-PROMPT and initial input ANY-INPUT. +For ANY-PRESELECT ANY-RESUME ANY-KEYMAP, See `helm'." + (if (helm-resume-p any-resume) + (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)))) + ;; 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'. + ;; Maybe it will be overriden when changing source + ;; by `helm-maybe-update-keymap'. + (set (make-local-variable 'helm-map) + (or src-keymap any-keymap helm-map)) + (helm-log-eval (helm-approximate-candidate-number) + helm-execute-action-at-once-if-one + helm-quit-if-no-candidate) + (cond ((and helm-execute-action-at-once-if-one + (= (helm-approximate-candidate-number) 1)) + (ignore)) + ((and helm-quit-if-no-candidate + (= (helm-approximate-candidate-number) 0)) + (setq helm-quit t) + (and (functionp helm-quit-if-no-candidate) + (funcall helm-quit-if-no-candidate))) + (t + (let ((helm-reading-pattern t) + (tap (or any-default + (with-helm-current-buffer + (thing-at-point 'symbol))))) + (read-from-minibuffer (or any-prompt "pattern: ") + any-input helm-map + nil any-history tap))))))) + +(defun helm-maybe-update-keymap () + "Handle differents keymaps in multiples sources. +This function is meant to be run in `helm-move-selection-after-hook'. +It will override `helm-map' with the keymap attribute of current source +if some when multiples sources are present." + (with-helm-window + (let ((kmap (assoc-default 'keymap (helm-get-current-source)))) + (when kmap (setq overriding-local-map kmap))))) +(add-hook 'helm-move-selection-after-hook 'helm-maybe-update-keymap) + +(defun helm-create-helm-buffer (&optional test-mode) + "Create newly created `helm-buffer'. +If TEST-MODE is non-nil, clear `helm-candidate-cache'." + (when test-mode + (setq helm-candidate-cache nil)) + (with-current-buffer (get-buffer-create helm-buffer) + (helm-log "kill local variables: %S" (buffer-local-variables)) + (kill-all-local-variables) + (set (make-local-variable 'inhibit-read-only) t) + (buffer-disable-undo) + (erase-buffer) + (set (make-local-variable 'inhibit-read-only) t) + (set (make-local-variable 'helm-last-sources-local) helm-sources) + (set (make-local-variable 'helm-follow-mode) nil) + (set (make-local-variable 'helm-display-function) helm-display-function) + (set (make-local-variable 'helm-selection-point) nil) + (helm-initialize-persistent-action) + (helm-log-eval helm-display-function helm-let-variables) + (loop for (var . val) in helm-let-variables + do (set (make-local-variable var) val)) + (setq cursor-type nil) + (setq mode-name "Helm")) + (helm-initialize-overlays helm-buffer) + (get-buffer helm-buffer)) + +(defun helm-initialize-overlays (buffer) + "Initialize helm overlays in BUFFER." + (helm-log "overlay setup") + (if helm-selection-overlay + ;; make sure the overlay belongs to the helm buffer if + ;; it's newly created + (move-overlay helm-selection-overlay (point-min) (point-min) + (get-buffer buffer)) + + (setq helm-selection-overlay + (make-overlay (point-min) (point-min) (get-buffer buffer))) + (overlay-put helm-selection-overlay 'face helm-selection-face)) + + (cond (helm-enable-shortcuts + (setq helm-shortcut-keys + (assoc-default helm-enable-shortcuts helm-shortcut-keys-alist)) + (unless helm-digit-overlays + (setq helm-digit-overlays + (loop for key across helm-shortcut-keys + for overlay = (make-overlay (point-min) (point-min) + (get-buffer buffer)) + do (overlay-put overlay 'before-string + (format "%s - " (upcase (make-string 1 key)))) + collect overlay)))) + (helm-digit-overlays + (mapc 'delete-overlay helm-digit-overlays) + (setq helm-digit-overlays nil)))) + +(defun helm-hooks (setup-or-cleanup) + "Add or remove hooks according to SETUP-OR-CLEANUP value. +if SETUP-OR-CLEANUP value is setup add hooks, any other value +will remove hooks. +hooks concerned are `post-command-hook' and `minibuffer-setup-hook'." + (let ((hooks '((post-command-hook helm-check-minibuffer-input) + (minibuffer-setup-hook helm-print-error-messages)))) + (if (eq setup-or-cleanup 'setup) + (dolist (args hooks) (apply 'add-hook args)) + (dolist (args (reverse hooks)) (apply 'remove-hook args))))) + + +;; (@* "Core: clean up") +;;; TODO move +(defun helm-cleanup () + "Clean up the mess when helm exit or quit." + (helm-log "start cleanup") + (with-current-buffer helm-buffer + ;; rubikitch: I think it is not needed. + ;; thierry: If you end up for any reasons (error etc...) + ;; with an helm-buffer staying around (visible), + ;; You will have no cursor in this buffer when switching to it, + ;; so I think this is needed. + (setq cursor-type t) + ;; Call burry-buffer whithout arg + ;; to be sure helm-buffer is removed from window. + (bury-buffer) + ;; Be sure we call this from helm-buffer. + (helm-funcall-foreach 'cleanup)) + (helm-new-timer 'helm-check-minibuffer-input-timer nil) + (helm-kill-async-processes) + (helm-log-run-hook 'helm-cleanup-hook) + (helm-hooks 'cleanup) + (helm-frame-or-window-configuration 'restore) + (setq helm-alive-p nil) + ;; This is needed in some cases where last input + ;; is yielded infinitely in minibuffer after helm session. + (helm-clean-up-minibuffer)) + +(defun helm-clean-up-minibuffer () + "Remove contents of minibuffer." + (let ((miniwin (minibuffer-window))) + ;; Clean only current minibuffer used by helm. + ;; i.e The precedent one is active. + (unless (minibuffer-window-active-p miniwin) + (with-current-buffer (window-buffer miniwin) + (delete-minibuffer-contents))))) + + +;; (@* "Core: input handling") +(defun helm-check-minibuffer-input () + "Extract input string from the minibuffer and check if it needs to be handled." + (let ((delay (with-current-buffer helm-buffer + (and helm-input-idle-delay + (max helm-input-idle-delay 0.1))))) + (if (or (not delay) (helm-action-window)) + (helm-check-minibuffer-input-1) + (helm-new-timer + 'helm-check-minibuffer-input-timer + (run-with-idle-timer delay nil 'helm-check-minibuffer-input-1))))) + +(defun helm-check-minibuffer-input-1 () + "Check minibuffer content." + (with-helm-quittable + (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) + (helm-check-new-input (minibuffer-contents))))) + +(defun helm-check-new-input (input) + "Check INPUT string and update the helm buffer if necessary." + (unless (equal input helm-pattern) + (setq helm-pattern input) + (unless (helm-action-window) + (setq helm-input helm-pattern)) + (helm-log-eval helm-pattern helm-input) + (helm-update))) + + +;; (@* "Core: source compiler") +(defvar helm-compile-source-functions-default helm-compile-source-functions + "Plug-ins this file provides.") +(defun helm-compile-sources (sources funcs) + "Compile SOURCES with FUNCS. +See `helm-compile-source-functions'. +Helm plug-ins are realized by this function." + (mapcar + (lambda (source) + (loop with source = (if (listp source) source (symbol-value source)) + for f in funcs + do (setq source (funcall f source)) + finally (return source))) + sources)) + + +;; (@* "Core: plug-in attribute documentation hack") + +;; `helm-document-attribute' is public API. +(defadvice documentation-property (after helm-document-attribute activate) + "Display plug-in attributes' documentation as `helm-sources' docstring." + (when (eq (ad-get-arg 0) 'helm-sources) + (setq ad-return-value + (concat ad-return-value "\n" + (mapconcat (lambda (sym) (get sym 'helm-attrdoc)) + helm-additional-attributes + "\n"))))) +;; (describe-variable 'helm-sources) +;; (documentation-property 'helm-sources 'variable-documentation) +;; (progn (ad-disable-advice 'documentation-property 'after 'helm-document-attribute) (ad-update 'documentation-property)) + + +;; (@* "Core: all candidates") +(defun helm-process-delayed-init (source) + "Initialize delayed SOURCE." + (let ((name (assoc-default 'name source))) + (unless (member name helm-delayed-init-executed) + (helm-aif (assoc-default 'delayed-init source) + (with-current-buffer helm-current-buffer + (helm-funcall-with-source source it) + (dolist (f (if (functionp it) (list it) it)) + (add-to-list 'helm-delayed-init-executed name))))))) + +(defun helm-get-candidates (source) + "Retrieve and return the list of candidates from SOURCE." + (helm-process-delayed-init source) + (let* ((candidate-source (assoc-default 'candidates source)) + (type-error (lambda () + (error (concat "Candidates must either be a function, " + " a variable or a list: %s") + candidate-source))) + (candidates (condition-case err + (helm-interpret-value candidate-source source) + (error (funcall type-error))))) + (cond ((processp candidates) candidates) + ((listp candidates) (helm-transform-candidates candidates source)) + (t (funcall type-error))))) + + +(defun helm-get-cached-candidates (source) + "Return the cached value of candidates for SOURCE. +Cache the candidates if there is not yet a cached value." + (let* ((name (assoc-default 'name source)) + (candidate-cache (assoc name helm-candidate-cache))) + (cond (candidate-cache + (helm-log "use cached candidates") + (cdr candidate-cache)) + (t + (helm-log "calculate candidates") + (let ((candidates (helm-get-candidates source))) + (cond ((processp candidates) + (push (cons candidates + (append source + (list (cons 'item-count 0) + (cons 'incomplete-line "")))) + helm-async-processes) + (set-process-filter candidates 'helm-output-filter) + (setq candidates nil)) + ((not (assoc 'volatile source)) + (setq candidate-cache (cons name candidates)) + (push candidate-cache helm-candidate-cache))) + candidates))))) + + +;;; (@* "Core: candidate transformers") +(defun helm-transform-mapcar (function args) + "`mapcar' for candidate-transformer. + +ARGS is (cand1 cand2 ...) or ((disp1 . real1) (disp2 . real2) ...) + +\(helm-transform-mapcar 'upcase '(\"foo\" \"bar\")) +=> (\"FOO\" \"BAR\") +\(helm-transform-mapcar 'upcase '((\"1st\" . \"foo\") (\"2nd\" . \"bar\"))) +=> ((\"1st\" . \"FOO\") (\"2nd\" . \"BAR\")) +" + (loop for arg in args + if (consp arg) + collect (cons (car arg) (funcall function (cdr arg))) + else + collect (funcall function arg))) + +(defun helm-process-candidate-transformer (candidates source) + "Execute candidate-transformer function on all CANDIDATES of SOURCE." + (helm-aif (assoc-default 'candidate-transformer source) + (helm-composed-funcall-with-source source it candidates) + candidates)) + +(defun helm-process-filtered-candidate-transformer (candidates source) + "Execute filtered-candidate-transformer function on all CANDIDATES of SOURCE." + (helm-aif (assoc-default 'filtered-candidate-transformer source) + (helm-composed-funcall-with-source source it candidates source) + candidates)) + +(defun helm-process-filtered-candidate-transformer-maybe (candidates source process-p) + "Execute filtered-candidate-transformer function on all CANDIDATES of SOURCE. +This happen if PROCESS-P is non-nil." + (if process-p + (helm-process-filtered-candidate-transformer candidates source) + candidates)) + +(defun helm-process-real-to-display (candidates source) + "Execute real-to-display function on all CANDIDATES of SOURCE." + (helm-aif (assoc-default 'real-to-display source) + (setq candidates (helm-funcall-with-source + source 'mapcar + (lambda (cand_) + (if (consp cand_) + ;; override DISPLAY from candidate-transformer + (cons (funcall it (cdr cand_)) (cdr cand_)) + (cons (funcall it cand_) cand_))) + candidates)) + candidates)) + +(defun helm-transform-candidates (candidates source &optional process-p) + "Transform CANDIDATES of SOURCE according to candidate transformers. +This happen if PROCESS-P is non-nil." + (helm-process-real-to-display + (helm-process-filtered-candidate-transformer-maybe + (helm-process-candidate-transformer candidates source) source process-p) + source)) + + +;; (@* "Core: narrowing candidates") +(defun helm-candidate-number-limit (source) + "Apply candidate-number-limit attribute value. +This overhide variable `helm-candidate-number-limit'. + +e.g: +If \(candidate-number-limit\) is in SOURCE, show all candidates in SOURCE. +If \(candidate-number-limit . 123\) is in SOURCE limit candidate to 123." + (helm-aif (assq 'candidate-number-limit source) + (or (cdr it) 99999999) + (or helm-candidate-number-limit 99999999))) + +;; FIXME: Why a defconst here +(defconst helm-default-match-functions + (list (lambda (candidate) + (string-match helm-pattern candidate))) + "Default functions to match candidates according to `helm-pattern'.") + +(defun helm-compute-matches (source) + "Compute matched results from SOURCE according to its settings." + (if debug-on-error + (helm-compute-matches-internal source) + (condition-case v + (helm-compute-matches-internal source) + (error (helm-log-error + "helm-compute-matches: error when processing source: %s" + (assoc-default 'name source)) + nil)))) + +(defun helm-candidate-get-display (candidate) + "Get searched display part from CANDIDATE. +CANDIDATE is a string, a symbol, or \(DISPLAY . REAL\) cons cell." + (format "%s" (or (car-safe candidate) candidate))) + +(defun helm-process-pattern-transformer (pattern source) + "Execute pattern-transformer attribute PATTERN function in SOURCE." + (helm-aif (assoc-default 'pattern-transformer source) + (helm-composed-funcall-with-source source it pattern) + pattern)) + +(defun helm-match-functions (source) + (or (assoc-default 'match source) + helm-default-match-functions)) + +(defmacro helm-accumulate-candidates-internal (cand newmatches + hash item-count limit) + "Internal, add CAND into NEWMATCHES. +Use HASH to uniq NEWMATCHES. +Argument ITEM-COUNT count the matches. +if ITEM-COUNT reaches LIMIT, exit from inner loop." + `(unless (gethash ,cand ,hash) + (puthash ,cand t ,hash) + (push ,cand ,newmatches) + (incf ,item-count) + (when (= ,item-count ,limit) + (setq exit t) + (return)))) + +(defun helm-take-first-elements (seq n) + (if (> (length seq) n) + (setq seq (subseq seq 0 n)) + seq)) + +(defun helm-match-from-candidates (cands matchfns limit) + (let (matches) + (condition-case nil + (let ((item-count 0) exit) + (clrhash helm-match-hash) + (dolist (match matchfns) + (let (newmatches) + (dolist (candidate cands) + (when (funcall match (helm-candidate-get-display candidate)) + (helm-accumulate-candidates-internal + candidate newmatches helm-match-hash item-count limit))) + (setq matches (append matches (reverse newmatches))) + (if exit (return))))) + (invalid-regexp (setq matches nil))) + matches)) + +(defun helm-compute-matches-internal (source) + (save-current-buffer + (let ((matchfns (helm-match-functions source)) + (helm-source-name (assoc-default 'name source)) + (limit (helm-candidate-number-limit source)) + (helm-pattern (helm-process-pattern-transformer + helm-pattern source))) + (helm-process-filtered-candidate-transformer + (if (or (equal helm-pattern "") (equal matchfns '(identity))) + (helm-take-first-elements + (helm-get-cached-candidates source) limit) + (helm-match-from-candidates + (helm-get-cached-candidates source) matchfns limit)) + source)))) + +;; (helm '(((name . "error")(candidates . (lambda () (hage))) (action . identity)))) + +(defun helm-process-source (source) + "Display matched results from SOURCE according to its settings." + (helm-log-eval (assoc-default 'name source)) + (if (assq 'direct-insert-match source) ;experimental + (helm-process-source--direct-insert-match source) + (let ((matches (helm-compute-matches source))) + (when matches + (when helm-test-mode + (setq helm-test-candidate-list + `(,@helm-test-candidate-list + (,(assoc-default 'name source) + ,matches)))) + (helm-insert-header-from-source source) + (if (not (assq 'multiline source)) + (mapc 'helm-insert-match-with-digit-overlay matches) + (let ((start (point)) separate) + (dolist (match matches) + (if separate + (helm-insert-candidate-separator) + (setq separate t)) + (helm-insert-match-with-digit-overlay match)) + (put-text-property start (point) 'helm-multiline t))))))) + +(defun helm-insert-match-with-digit-overlay (match) + (declare (special source)) + (helm-put-digit-overlay-maybe) + (helm-insert-match match 'insert source)) + +(defun helm-put-digit-overlay-maybe () + (when (and helm-enable-shortcuts + (not (eq helm-digit-shortcut-count + (length helm-digit-overlays)))) + (move-overlay (nth helm-digit-shortcut-count + helm-digit-overlays) + (point-at-bol) + (point-at-bol)) + (incf helm-digit-shortcut-count))) + +(defun helm-process-source--direct-insert-match (source) + "[EXPERIMENTAL] Insert candidates from `helm-candidate-buffer' in SOURCE." + (helm-log-eval (assoc-default 'name source)) + (let ((helm-source-name (assoc-default 'name source)) + content-buf) + (funcall (assoc-default 'candidates source)) + (setq content-buf (helm-candidate-buffer)) + (unless (helm-empty-buffer-p content-buf) + (helm-insert-header-from-source source) + (insert-buffer-substring content-buf) + ;; TODO call helm-put-digit-overlay-maybe with loop + ))) + +(defun helm-process-delayed-sources (delayed-sources &optional preselect) + "Process helm DELAYED-SOURCES. +Move selection to string or regexp PRESELECT if non--nil. +This function is called in `helm-process-delayed-sources-timer' +when emacs is idle for `helm-idle-delay'." + (with-helm-quittable + (helm-log-eval (mapcar (lambda (s) (assoc-default 'name s)) delayed-sources)) + (with-current-buffer helm-buffer + (save-excursion + (goto-char (point-max)) + (mapc 'helm-process-source delayed-sources) + (when (and (not (helm-empty-buffer-p)) + ;; No selection yet. + (= (overlay-start helm-selection-overlay) + (overlay-end helm-selection-overlay))) + (helm-update-move-first-line 'without-hook))) + (when preselect (helm-preselect preselect)) + (save-excursion + (goto-char (point-min)) + (helm-log-run-hook 'helm-update-hook)) + (helm-log-run-hook 'helm-after-update-hook)))) + + +;; (@* "Core: *helm* buffer contents") +(defvar helm-input-local nil) +(defvar helm-process-delayed-sources-timer nil) +(defun helm-update (&optional preselect) + "Update candidates list in `helm-buffer' according to `helm-pattern'. +Argument PRESELECT is a string or regexp used to move selection to a particular +place once updating is done. It should be used on single source because search +is done on whole `helm-buffer' and not on current source." + (helm-log "start update") + (setq helm-digit-shortcut-count 0) + (helm-kill-async-processes) + (with-current-buffer (helm-buffer-get) + (set (make-local-variable 'helm-input-local) helm-pattern) + (erase-buffer) + (when helm-enable-shortcuts + (mapc 'delete-overlay helm-digit-overlays)) + (let (delayed-sources + normal-sources) + (unwind-protect ; Process normal sources and store delayed one's. + (setq delayed-sources + (loop for source in (remove-if-not 'helm-update-source-p + (helm-get-sources)) + if (helm-delayed-source-p source) + collect source + else do (progn (push source normal-sources) + (helm-process-source source)))) + (helm-log-eval + (mapcar (lambda (s) (assoc-default 'name s)) delayed-sources)) + (if helm-test-mode ; Need only to process sources. + (mapc 'helm-process-source delayed-sources) + (cond ((and preselect delayed-sources normal-sources) + ;; Preselection run here when there is + ;; normal AND delayed sources. + (helm-log "Update preselect candidate %s" preselect) + (helm-preselect preselect)) + (delayed-sources ; Preselection and hooks will run later. + (helm-update-move-first-line 'without-hook)) + (t ; No delayed sources, run the hooks now. + (helm-update-move-first-line) + (helm-log-run-hook 'helm-after-update-hook) + (when preselect + (helm-log "Update preselect candidate %s" preselect) + (helm-preselect preselect)))) + (when delayed-sources + (helm-new-timer + 'helm-process-delayed-sources-timer + (run-with-idle-timer + ;; Be sure helm-idle-delay is > + ;; to helm-input-idle-delay + ;; otherwise use value of helm-input-idle-delay + ;; or 0.1 if == to 0. + (max helm-idle-delay helm-input-idle-delay 0.1) nil + 'helm-process-delayed-sources delayed-sources preselect)))) + (helm-log "end update"))))) + +(defun helm-update-source-p (source) + "Wheter SOURCE need updating or not." + (and (or (not helm-source-filter) + (member (assoc-default 'name source) helm-source-filter)) + (>= (length helm-pattern) + (helm-aif (assoc 'requires-pattern source) + (or (cdr it) 1) + 0)))) + +(defun helm-delayed-source-p (source) + "Wheter SOURCE is a delayed source or not." + (or (assoc 'delayed source) + (and helm-quick-update + (< (window-height (get-buffer-window (current-buffer))) + (line-number-at-pos (point-max)))))) + +(defun helm-update-move-first-line (&optional without-hook) + "Goto first line of `helm-buffer'." + (goto-char (point-min)) + (unless without-hook + (save-excursion (helm-log-run-hook 'helm-update-hook))) + (helm-next-line)) + +(defun helm-force-update (&optional preselect) + "Force recalculation and update of candidates. +If current source has `update' attribute, a function without argument, +call it before update." + (interactive) + (let ((source (helm-get-current-source)) + (selection (helm-get-selection nil t))) + (when source + (mapc 'helm-force-update--reinit + (helm-get-sources))) + (helm-update preselect) + ;; If preselect arg exists, `helm-update' should + ;; have moved to selection, otherwise do it now. + (unless preselect + (helm-keep-selection (assoc-default 'name source) selection)) + (with-helm-window (recenter)))) + +(defun helm-force-update--reinit (source) + "Reinit SOURCE by calling his update and/or init functions." + (helm-aif (helm-funcall-with-source + source 'helm-candidate-buffer) + (kill-buffer it)) + (dolist (attr '(update init)) + (helm-aif (assoc-default attr source) + (helm-funcall-with-source source it))) + (helm-remove-candidate-cache source)) + +(defun helm-keep-selection (source selection) + "Switch to SOURCE and goto SELECTION." + (when (and source selection) + (with-helm-window + (helm-goto-source source) + (forward-char -1) + (if (search-forward selection nil t) + (forward-line 0) + (goto-char (point-min)) + (forward-line 1)) + (helm-mark-current-line)))) + +(defun helm-remove-candidate-cache (source) + "Remove SOURCE from `helm-candidate-cache'." + (setq helm-candidate-cache + (delete (assoc (assoc-default 'name source) + helm-candidate-cache) + helm-candidate-cache))) + +(defun helm-insert-match (match insert-function source) + "Insert MATCH into `helm-buffer' with INSERT-FUNCTION for SOURCE. +If MATCH is a list then insert the string intended to appear on the display +and store the real value in a text property." + (let ((start (point-at-bol (point))) + (dispvalue (or (car-safe match) match)) + (realvalue (cdr-safe match))) + (setq dispvalue + (cond ((symbolp dispvalue) (symbol-name dispvalue)) + ((numberp dispvalue) (number-to-string dispvalue)) + (t dispvalue))) + (when (stringp dispvalue) + (funcall insert-function dispvalue) + ;; Some sources with candidates-in-buffer have already added + ;; 'helm-realvalue property when creating candidate buffer. + (unless (get-text-property start 'helm-realvalue) + (and realvalue + (put-text-property start (point-at-eol) + 'helm-realvalue realvalue))) + (when helm-source-in-each-line-flag + (put-text-property start (point-at-eol) 'helm-source source)) + (funcall insert-function "\n")))) + +(defun helm-insert-header-from-source (source) + "Insert SOURCE name in `helm-buffer' header. +Maybe insert by overlay additional info after source name if SOURCE have +header-name attribute." + (let ((name (assoc-default 'name source))) + (helm-insert-header + name + (helm-aif (assoc-default 'header-name source) + (helm-funcall-with-source source it name))))) + +(defun helm-insert-header (name &optional display-string) + "Insert header of source NAME into the helm buffer. +If DISPLAY-STRING is non--nil and a string, display this additional info +after the source name by overlay." + (unless (bobp) + (let ((start (point))) + (insert "\n") + (put-text-property start (point) 'helm-header-separator t))) + (let ((start (point))) + (insert name) + (put-text-property (point-at-bol) + (point-at-eol) 'helm-header t) + (when display-string + (overlay-put (make-overlay (point-at-bol) (point-at-eol)) + 'display display-string)) + (insert "\n") + (put-text-property start (point) 'face helm-header-face))) + +(defun helm-insert-candidate-separator () + "Insert separator of candidates into the helm buffer." + (insert helm-candidate-separator) + (put-text-property (point-at-bol) + (point-at-eol) 'helm-candidate-separator t) + (insert "\n")) + + +;; (@* "Core: async process") +(defun helm-output-filter (process string) + "From PROCESS process output STRING." + (helm-output-filter-1 (assoc process helm-async-processes) string)) + +(defun helm-output-filter-1 (process-assoc string) + (helm-log-eval string) + (with-current-buffer helm-buffer + (let ((source (cdr process-assoc))) + (save-excursion + (helm-aif (assoc-default 'insertion-marker source) + (goto-char it) + (goto-char (point-max)) + (helm-insert-header-from-source source) + (setcdr process-assoc + (append source `((insertion-marker . ,(point-marker)))))) + (helm-output-filter--process-source + (car process-assoc) string source + (helm-candidate-number-limit source)))) + (helm-output-filter--post-process))) + +(defun helm-output-filter--process-source (process string source limit) + (dolist (candidate (helm-transform-candidates + (helm-output-filter--collect-candidates + (split-string string "\n") + (assoc 'incomplete-line source)) + source t)) + (if (not (assq 'multiline source)) + (helm-insert-match candidate 'insert-before-markers source) + (let ((start (point))) + (helm-insert-candidate-separator) + (helm-insert-match candidate 'insert-before-markers source) + (put-text-property start (point) 'helm-multiline t))) + (incf (cdr (assoc 'item-count source))) + (when (>= (assoc-default 'item-count source) limit) + (helm-kill-async-process process) + (return)))) + +(defun helm-output-filter--collect-candidates (lines incomplete-line-info) + (helm-log-eval (cdr incomplete-line-info)) + (butlast + (loop for line in lines collect + (if (cdr incomplete-line-info) + (prog1 + (concat (cdr incomplete-line-info) line) + (setcdr incomplete-line-info nil)) + line) + finally (setcdr incomplete-line-info line)))) + +(defun helm-output-filter--post-process () + (helm-log-run-hook 'helm-update-hook) + (helm-aif (get-buffer-window helm-buffer 'visible) + (save-selected-window + (select-window it) + (helm-skip-noncandidate-line 'next) + (helm-mark-current-line)))) + +(defun helm-kill-async-processes () + "Kill all known asynchronous processes of `helm-async-processes'." + (mapc 'helm-kill-async-process (mapcar 'car helm-async-processes)) + (setq helm-async-processes nil)) + +(defun helm-kill-async-process (process) + "Kill PROCESS and detach the associated functions." + (set-process-filter process nil) + (delete-process process)) + + +;; (@* "Core: action") +(defun helm-execute-selection-action (&optional + selection action + preserve-saved-action) + "If a candidate SELECTION is present then perform the associated ACTION on it. +If PRESERVE-SAVED-ACTION is non-nil don't save action." + (helm-log "executing action") + (setq action (helm-get-default-action + (or action + helm-saved-action + (if (get-buffer helm-action-buffer) + (helm-get-selection helm-action-buffer) + (helm-get-action))))) + (let ((source (or helm-saved-current-source + (helm-get-current-source)))) + (setq selection (or selection + (helm-get-selection) + (and (assoc 'accept-empty source) ""))) + (unless preserve-saved-action (setq helm-saved-action nil)) + (if (and selection action) + (helm-funcall-with-source + source action + (helm-coerce-selection selection source))))) + +(defun helm-coerce-selection (selection source) + "Apply coerce attribute function to SELECTION in SOURCE. +Coerce source with coerce function." + (helm-aif (assoc-default 'coerce source) + (helm-funcall-with-source source it selection) + selection)) + +(defun helm-get-default-action (action) + "Get the first ACTION value of action list in source." + (if (and (listp action) (not (functionp action))) + (cdar action) + action)) + +(defun helm-select-action () + "Select an action for the currently selected candidate. +If action buffer is selected, back to the helm buffer." + (interactive) + (helm-log-run-hook 'helm-select-action-hook) + (cond ((get-buffer-window helm-action-buffer 'visible) + (set-window-buffer (get-buffer-window helm-action-buffer) + helm-buffer) + (kill-buffer helm-action-buffer) + (helm-set-pattern helm-input 'noupdate)) + (t + (setq helm-saved-selection (helm-get-selection)) + (unless helm-saved-selection + (error "Nothing is selected")) + (setq helm-saved-current-source (helm-get-current-source)) + (let ((actions (helm-get-action))) + (if (functionp actions) + (message "Sole action: %s" actions) + (helm-show-action-buffer actions) + (helm-delete-minibuffer-contents) + (setq helm-pattern 'dummy) ; so that it differs from the previous one + (helm-check-minibuffer-input)))))) + +(defun helm-show-action-buffer (actions) + (with-current-buffer (get-buffer-create helm-action-buffer) + (erase-buffer) + (buffer-disable-undo) + (set-window-buffer (get-buffer-window helm-buffer) helm-action-buffer) + (set (make-local-variable 'helm-sources) + `(((name . "Actions") + (volatile) + (candidates . ,actions) + (candidate-number-limit)))) + (set (make-local-variable 'helm-source-filter) nil) + (set (make-local-variable 'helm-selection-overlay) nil) + (set (make-local-variable 'helm-digit-overlays) nil) + (helm-initialize-overlays helm-action-buffer))) + + +;; (@* "Core: selection") +(defun helm-move-selection-common (move-func unit direction) + "Move the selection marker to a new position wit function MOVE-FUNC. +It is determined by UNIT and DIRECTION." + (unless (or (helm-empty-buffer-p (helm-buffer-get)) + (not (helm-window))) + (with-helm-window + (helm-log-run-hook 'helm-move-selection-before-hook) + (funcall move-func) + (helm-skip-noncandidate-line direction) + (helm-display-source-at-screen-top-maybe unit) + (when (helm-get-previous-header-pos) + (helm-mark-current-line)) + (helm-display-mode-line (helm-get-current-source)) + (helm-log-run-hook 'helm-move-selection-after-hook)))) + +(defun helm-display-source-at-screen-top-maybe (unit) + (when (and helm-display-source-at-screen-top (eq unit 'source)) + (set-window-start (selected-window) + (save-excursion (forward-line -1) (point))))) + +(defun helm-skip-noncandidate-line (direction) + (helm-skip-header-and-separator-line direction) + (and (bobp) (forward-line 1)) ;skip first header + (and (eobp) (forward-line -1))) ;avoid last empty line + + +(defun helm-skip-header-and-separator-line (direction) + (while (and (not (bobp)) + (or (helm-pos-header-line-p) + (helm-pos-candidate-separator-p))) + (forward-line (if (and (eq direction 'previous) + (not (eq (point-at-bol) (point-min)))) + -1 1)))) + +(defvar helm-mode-line-string-real nil) +(defun helm-display-mode-line (source) + (set (make-local-variable 'helm-mode-line-string) + (helm-interpret-value (or (assoc-default 'mode-line source) + (default-value 'helm-mode-line-string)) + source)) + (if helm-mode-line-string + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (line-number-mode "L%l") " " (helm-follow-mode "(F) ") + (:eval (helm-show-candidate-number + (when (listp helm-mode-line-string) + (car helm-mode-line-string)))) + " " helm-mode-line-string-real "-%-") + helm-mode-line-string-real + (substitute-command-keys (if (listp helm-mode-line-string) + (cadr helm-mode-line-string) + helm-mode-line-string))) + (setq mode-line-format + (default-value 'mode-line-format))) + (setq header-line-format + (helm-interpret-value (assoc-default 'header-line source) source))) + +(defun helm-show-candidate-number (&optional name) + "Used to display candidate number in mode-line. +You can specify NAME of candidates e.g \"Buffers\" otherwise +it is \"Candidate\(s\)\" by default." + (propertize + (format "[%s %s]" + (helm-approximate-candidate-number 'in-current-source) + (or name "Candidate(s)")) + 'face 'helm-candidate-number)) + +(defun helm-previous-line () + "Move selection to the previous line." + (interactive) + (helm-move-selection-common + (lambda () + (if (not (helm-pos-multiline-p)) + (forward-line -1) ;double forward-line is meaningful + (forward-line -1) ;because evaluation order is important + (helm-skip-header-and-separator-line 'previous) + (let ((header-pos (helm-get-previous-header-pos)) + (separator-pos (helm-get-previous-candidate-separator-pos))) + (when header-pos + (goto-char (if (or (null separator-pos) (< separator-pos header-pos)) + header-pos ; first candidate + separator-pos)) + (forward-line 1))))) + 'line 'previous)) + +(defun helm-next-line () + "Move selection to the next line." + (interactive) + (helm-move-selection-common + (lambda () + (if (not (helm-pos-multiline-p)) + (forward-line 1) + (let ((header-pos (helm-get-next-header-pos)) + (separator-pos (helm-get-next-candidate-separator-pos))) + (cond ((and separator-pos + (or (null header-pos) (< separator-pos header-pos))) + (goto-char separator-pos)) + (header-pos + (goto-char header-pos)))))) + 'line 'next)) + +(defun helm-previous-page () + "Move selection back with a pageful." + (interactive) + (helm-move-selection-common + (lambda () + (condition-case nil + (scroll-down) + (beginning-of-buffer (goto-char (point-min))))) + 'page 'previous)) + +(defun helm-next-page () + "Move selection forward with a pageful." + (interactive) + (helm-move-selection-common + (lambda () + (condition-case nil + (scroll-up) + (end-of-buffer (goto-char (point-max))))) + 'page 'next)) + +(defun helm-beginning-of-buffer () + "Move selection at the top." + (interactive) + (helm-move-selection-common + (lambda () (goto-char (point-min))) + 'edge 'previous)) + +(defun helm-end-of-buffer () + "Move selection at the bottom." + (interactive) + (helm-move-selection-common + (lambda () (goto-char (point-max))) + 'edge 'next)) + +(defun helm-previous-source () + "Move selection to the previous source." + (interactive) + (helm-move-selection-common + (lambda () + (forward-line -1) + (if (bobp) + (goto-char (point-max)) + (helm-skip-header-and-separator-line 'previous)) + (goto-char (helm-get-previous-header-pos)) + (forward-line 1)) + 'source 'previous)) + +(defun helm-next-source () + "Move selection to the next source." + (interactive) + (helm-move-selection-common + (lambda () + (goto-char (or (helm-get-next-header-pos) (point-min)))) + 'source 'next)) + +(defun helm-goto-source (source-or-name) + "Move the selection to the source SOURCE-OR-NAME." + (helm-move-selection-common + (lambda () + (goto-char (point-min)) + (let ((name (if (stringp source-or-name) source-or-name + (assoc-default 'name source-or-name)))) + (condition-case err + (while (not (string= name (helm-current-line-contents))) + (goto-char (helm-get-next-header-pos))) + (error (message ""))))) + 'source 'next)) + +(defun helm-mark-current-line (&optional resumep) + "Move `helm-selection-overlay' to current line. +Note that this is not related with visibles marks, which are used +to mark candidates." + (with-helm-window + (when resumep + (goto-char helm-selection-point)) + (move-overlay + helm-selection-overlay (point-at-bol) + (if (helm-pos-multiline-p) + (let ((header-pos (helm-get-next-header-pos)) + (separator-pos (helm-get-next-candidate-separator-pos))) + (or (and (null header-pos) separator-pos) + (and header-pos separator-pos (< separator-pos header-pos) + separator-pos) + header-pos + (point-max))) + (1+ (point-at-eol)))) + (setq helm-selection-point (overlay-start helm-selection-overlay))) + (helm-follow-execute-persistent-action-maybe)) + +(defun helm-this-command-key () + (event-basic-type (elt (this-command-keys-vector) 0))) +;; (progn (read-key-sequence "Key: ") (p (helm-this-command-key))) + +(defun helm-select-with-shortcut-internal (types get-key-func) + (if (memq helm-enable-shortcuts types) + (save-selected-window + (select-window (helm-window)) + (let* ((key (funcall get-key-func)) + (overlay (ignore-errors (nth (position key helm-shortcut-keys) + helm-digit-overlays)))) + (if (not (and overlay (overlay-buffer overlay))) + (when (numberp key) + (select-window (minibuffer-window)) + (self-insert-command 1)) + (goto-char (overlay-start overlay)) + (helm-mark-current-line) + (helm-exit-minibuffer)))) + (self-insert-command 1))) + +(defun helm-select-with-prefix-shortcut () + "Invoke default action with prefix shortcut." + (interactive) + (helm-select-with-shortcut-internal + '(prefix) + (lambda () (read-event "Select shortcut key: ")))) + +(defun helm-select-with-digit-shortcut () + "Invoke default action with digit/alphabet shortcut." + (interactive) + (helm-select-with-shortcut-internal + '(alphabet t) 'helm-this-command-key)) + +;; (setq helm-enable-shortcuts 'prefix) +;; (define-key helm-map "@" 'helm-select-with-prefix-shortcut) +;; (define-key helm-map (kbd "") 'helm-select-with-prefix-shortcut) + +(defvar helm-exit-status 0 + "Flag to inform whether helm have exited or quitted. +Exit with 0 mean helm have exited executing an action. +Exit with 1 mean helm have quitted with \\[keyboard-quit] +It is useful for example to restore a window config if helm abort +in special cases. +See `helm-exit-minibuffer' and `helm-keyboard-quit'.") + +(defvar helm-minibuffer-confirm-state nil) +(defun helm-confirm-and-exit-minibuffer () + "Maybe ask for confirmation when exiting helm. +It is similar to `minibuffer-complete-and-exit' adapted to helm. +If `minibuffer-completion-confirm' value is 'confirm, +send in minibuffer confirm message and exit on next hit. +If `minibuffer-completion-confirm' value is t, +don't exit and send message 'no match'." + (interactive) + (let* ((empty-buffer-p (with-current-buffer helm-buffer + (eq (point-min) (point-max)))) + (unknow (and (not empty-buffer-p) + (string= (get-text-property + 0 'display (helm-get-selection nil 'withprop)) + "[?]")))) + (cond ((and (or empty-buffer-p unknow) + (eq minibuffer-completion-confirm 'confirm)) + (setq helm-minibuffer-confirm-state + 'confirm) + (setq minibuffer-completion-confirm nil) + (minibuffer-message " [confirm]")) + ((and (or empty-buffer-p unknow) + (eq minibuffer-completion-confirm t)) + (minibuffer-message " [No match]")) + (t + (setq helm-minibuffer-confirm-state nil) + (helm-exit-minibuffer))))) +(add-hook 'helm-after-update-hook 'helm-confirm-and-exit-hook) + +(defun helm-confirm-and-exit-hook () + "Restore `minibuffer-completion-confirm' when helm update." + (unless (or (eq minibuffer-completion-confirm t) + (not helm-minibuffer-confirm-state)) + (setq minibuffer-completion-confirm + helm-minibuffer-confirm-state))) + +(defun helm-exit-minibuffer () + "Select the current candidate by exiting the minibuffer." + (interactive) + (unless helm-current-prefix-arg + (setq helm-current-prefix-arg current-prefix-arg)) + (setq helm-exit-status 0) + (exit-minibuffer)) + +(defun helm-keyboard-quit () + "Quit minibuffer in helm. +If action buffer is displayed, kill it." + (interactive) + (when (get-buffer-window helm-action-buffer 'visible) + (kill-buffer helm-action-buffer)) + (setq helm-exit-status 1) + (abort-recursive-edit)) + +(defun helm-get-next-header-pos () + "Return the position of the next header from point." + (next-single-property-change (point) 'helm-header)) + +(defun helm-get-previous-header-pos () + "Return the position of the previous header from point." + (previous-single-property-change (point) 'helm-header)) + +(defun helm-pos-multiline-p () + "Return non-nil if the current position is in the multiline source region." + (get-text-property (point) 'helm-multiline)) + +(defun helm-get-next-candidate-separator-pos () + "Return the position of the next candidate separator from point." + (next-single-property-change (point) 'helm-candidate-separator)) + +(defun helm-get-previous-candidate-separator-pos () + "Return the position of the previous candidate separator from point." + (previous-single-property-change (point) 'helm-candidate-separator)) + +(defun helm-pos-header-line-p () + "Return t if the current line is a header line." + (or (get-text-property (point-at-bol) 'helm-header) + (get-text-property (point-at-bol) 'helm-header-separator))) + +(defun helm-pos-candidate-separator-p () + "Return t if the current line is a candidate separator." + (get-text-property (point-at-bol) 'helm-candidate-separator)) + + +;; (@* "Core: help") +(defun helm-help-internal (bufname insert-content-fn) + "Show long message during `helm' session in BUFNAME. +INSERT-CONTENT-FN is the text to be displayed in BUFNAME." + (save-window-excursion + (select-window (helm-window)) + (delete-other-windows) + (switch-to-buffer (get-buffer-create bufname)) + (erase-buffer) + (funcall insert-content-fn) + (setq mode-line-format "%b (SPC,C-v:NextPage b,M-v:PrevPage other:Exit)") + (setq cursor-type nil) + (goto-char 1) + (helm-help-event-loop))) + +(defun helm-help-event-loop () + (ignore-errors + (loop for event = (read-event) do + (case event + ((?\C-v ? ) (scroll-up)) + ((?\M-v ?b) (scroll-down)) + (t (return)))))) + +(defun helm-help () + "Help of `helm'." + (interactive) + (helm-help-internal + " *Helm Help*" + (lambda () + (insert (substitute-command-keys + (helm-interpret-value (or (assoc-default + 'help-message + (helm-get-current-source)) + helm-help-message)))) + (org-mode)))) + +(defun helm-debug-output () + "Show all helm-related variables at this time." + (interactive) + (helm-help-internal " *Helm Debug*" 'helm-debug-output-function)) + +(defun helm-debug-output-function (&optional vars) + (message "Calculating all helm-related values...") + (insert "If you debug some variables or forms, set `helm-debug-forms' +to a list of forms.\n\n") + (dolist (v (or vars + helm-debug-forms + (apropos-internal "^helm-" 'boundp))) + (insert "** " + (pp-to-string v) "\n" + (pp-to-string (with-current-buffer helm-buffer (eval v))) "\n")) + (message "Calculating all helm-related values...Done")) + + +;; (@* "Core: misc") +(defun helm-kill-buffer-hook () + "Remove tick entry from `helm-tick-hash' when killing a buffer." + (loop for key being the hash-keys in helm-tick-hash + if (string-match (format "^%s/" (regexp-quote (buffer-name))) key) + do (remhash key helm-tick-hash))) +(add-hook 'kill-buffer-hook 'helm-kill-buffer-hook) + +(defun helm-preselect (candidate-or-regexp) + "Move `helm-selection-overlay' to CANDIDATE-OR-REGEXP on startup." + (with-helm-window + (when candidate-or-regexp + (goto-char (point-min)) + ;; go to first candidate of first source + (forward-line 1) + (let ((start (point))) + (or (re-search-forward + (concat "^" (regexp-quote candidate-or-regexp) "$") nil t) + (re-search-forward candidate-or-regexp nil t) + (search-forward candidate-or-regexp nil t) + (goto-char start)))) + (helm-mark-current-line))) + +(defun helm-delete-current-selection () + "Delete the currently selected item." + (interactive) + (with-helm-window + (cond ((helm-pos-multiline-p) + (helm-aif (helm-get-next-candidate-separator-pos) + (delete-region (point-at-bol) + (1+ (progn (goto-char it) (point-at-eol)))) + ;; last candidate + (goto-char (helm-get-previous-candidate-separator-pos)) + (delete-region (point-at-bol) (point-max))) + (when (helm-end-of-source-p) + (goto-char (or (helm-get-previous-candidate-separator-pos) + (point-min))) + (forward-line 1))) + (t + (delete-region (point-at-bol) (1+ (point-at-eol))) + (when (helm-end-of-source-p) (forward-line -1)))) + (helm-mark-current-line))) + +(defun helm-end-of-source-p () + "Return non--nil if we are at eob or end of source." + (save-excursion + (forward-line 1) + (or (eq (point-at-bol) (point-at-eol)) + (helm-pos-header-line-p) + (eobp)))) + +(defun helm-edit-current-selection-internal (func) + (with-helm-window + (beginning-of-line) + (let ((realvalue (get-text-property (point) 'helm-realvalue))) + (funcall func) + (beginning-of-line) + (and realvalue + (put-text-property (point) (point-at-eol) + 'helm-realvalue realvalue)) + (helm-mark-current-line)))) + +(defmacro helm-edit-current-selection (&rest forms) + "Evaluate FORMS at current selection in the helm buffer. +You can edit the line." + (declare (indent 0) (debug t)) + `(helm-edit-current-selection-internal + (lambda () ,@forms))) + +(defun helm-set-pattern (pattern &optional noupdate) + "Set minibuffer contents to PATTERN. +if optional NOUPDATE is non-nil, helm buffer is not changed." + (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) + (delete-minibuffer-contents) + (insert pattern)) + (when noupdate + (setq helm-pattern pattern) + (helm-hooks 'cleanup) + (run-with-idle-timer 0 nil 'helm-hooks 'setup))) + +(defun helm-delete-minibuffer-contents () + "Same as `delete-minibuffer-contents' but this is a command." + (interactive) + (helm-set-pattern "")) +(defalias 'helm-delete-minibuffer-content 'helm-delete-minibuffer-contents) + + +;;; Plugins +;; +;; (@* "Built-in plug-in: type") +(defun helm-compile-source--type (source) + (helm-aif (assoc-default 'type source) + (append source (assoc-default it helm-type-attributes) nil) + source)) + +;; `define-helm-type-attribute' is public API. + +(defun helm-add-type-attribute (type definition) + (helm-aif (assq type helm-type-attributes) + (setq helm-type-attributes (delete it helm-type-attributes))) + (push (cons type definition) helm-type-attributes)) + +(defvar helm-types nil) +(defun helm-document-type-attribute (type doc) + (add-to-list 'helm-types type t) + (put type 'helm-typeattrdoc + (concat "- " (symbol-name type) "\n\n" doc "\n"))) + +(defadvice documentation-property (after helm-document-type-attribute activate) + "Display type attributes' documentation as `helm-type-attributes' docstring." + (when (eq (ad-get-arg 0) 'helm-type-attributes) + (setq ad-return-value + (concat ad-return-value "\n\n++++ Types currently defined ++++\n" + (mapconcat (lambda (sym) (get sym 'helm-typeattrdoc)) + helm-types "\n"))))) + +;; (@* "Built-in plug-in: dummy") +(defun helm-dummy-candidate (candidate source) + "Use `helm-pattern' as CANDIDATE in SOURCE." + ;; `source' is defined in filtered-candidate-transformer + (list helm-pattern)) + +(defun helm-compile-source--dummy (source) + (if (assoc 'dummy source) + (append source + '((candidates "dummy") + (accept-empty) + (match identity) + (filtered-candidate-transformer . helm-dummy-candidate) + (disable-shortcuts) + (volatile))) + source)) + +;; (@* "Built-in plug-in: disable-shortcuts") +(defvar helm-orig-enable-shortcuts nil) +(defun helm-save-enable-shortcuts () + (helm-once + (lambda () + (setq helm-orig-enable-shortcuts helm-enable-shortcuts + helm-enable-shortcuts nil)))) + +(defun helm-compile-source--disable-shortcuts (source) + (if (assoc 'disable-shortcuts source) + (append `((init ,@(helm-mklist (assoc-default 'init source)) + helm-save-enable-shortcuts) + (resume ,@(helm-mklist (assoc-default 'resume source)) + helm-save-enable-shortcuts) + (cleanup ,@(helm-mklist (assoc-default 'cleanup source)) + (lambda () (setq helm-enable-shortcuts + helm-orig-enable-shortcuts)))) + source) + source)) + +;; (@* "Built-in plug-in: candidates-in-buffer") +(defun helm-candidates-in-buffer () + "Get candidates from the candidates buffer according to `helm-pattern'. + +BUFFER is `helm-candidate-buffer' by default. Each +candidate must be placed in one line. This function is meant to +be used in candidates-in-buffer or candidates attribute of an +helm source. Especially fast for many (1000+) candidates. + +eg. + '((name . \"many files\") + (init . (lambda () (with-current-buffer (helm-candidate-buffer 'local) + (insert-many-filenames)))) + (search re-search-forward) ; optional + (candidates-in-buffer) + (type . file)) + ++===============================================================+ +| The new way of making and narrowing candidates: Using buffers | ++===============================================================+ + +By default, `helm' makes candidates by evaluating the +candidates function, then narrows them by `string-match' for each +candidate. + +But this way is very slow for many candidates. The new way is +storing all candidates in a buffer and narrowing them by +`re-search-forward'. Search function is customizable by search +attribute. The important point is that buffer processing is MUCH +FASTER than string list processing and is the Emacs way. + +The init function writes all candidates to a newly-created +candidate buffer. The candidates buffer is created or specified +by `helm-candidate-buffer'. Candidates are stored in a line. + +The candidates function narrows all candidates, IOW creates a +subset of candidates dynamically. It is the task of +`helm-candidates-in-buffer'. As long as +`helm-candidate-buffer' is used,`(candidates-in-buffer)' is +sufficient in most cases. + +Note that `(candidates-in-buffer)' is shortcut of three attributes: + (candidates . helm-candidates-in-buffer) + (volatile) + (match identity) +And `(candidates-in-buffer . func)' is shortcut of three attributes: + (candidates . func) + (volatile) + (match identity) +The expansion is performed in `helm-get-sources'. + +The candidates-in-buffer attribute implies the volatile attribute. +The volatile attribute is needed because `helm-candidates-in-buffer' +creates candidates dynamically and need to be called everytime +`helm-pattern' changes. + +Because `helm-candidates-in-buffer' plays the role of `match' attribute +function, specifying `(match identity)' makes the source slightly faster. + +To customize `helm-candidates-in-buffer' behavior, use search, +get-line and search-from-end attributes. See also `helm-sources' docstring." + (declare (special source)) + (helm-candidates-in-buffer-1 + (helm-candidate-buffer) + helm-pattern + (or (assoc-default 'get-line source) + #'buffer-substring-no-properties) + ;; use external variable `source'. + (or (assoc-default 'search source) + (if (assoc 'search-from-end source) + '(helm-candidates-in-buffer-search-from-end) + '(helm-candidates-in-buffer-search-from-start))) + (helm-candidate-number-limit source) + (assoc 'search-from-end source))) + +(defun helm-candidates-in-buffer-search-from-start (pattern) + "Search PATTERN with `re-search-forward' with bound and noerror args." + (re-search-forward pattern nil t)) + +(defun helm-candidates-in-buffer-search-from-end (pattern) + "Search PATTERN with `re-search-backward' with bound and noerror args." + (re-search-backward pattern nil t)) + +(defun helm-candidates-in-buffer-1 (buffer pattern get-line-fn + search-fns limit search-from-end) + ;; buffer == nil when candidates buffer does not exist. + (when buffer + (with-current-buffer buffer + (let ((start-point (if search-from-end (point-max) (point-min))) + (endp (if search-from-end #'bobp #'eobp))) + (goto-char (1- start-point)) + (if (string= pattern "") + (helm-initial-candidates-from-candidate-buffer + endp get-line-fn limit search-from-end) + (helm-search-from-candidate-buffer + pattern get-line-fn search-fns limit search-from-end + start-point endp)))))) + +(defun helm-point-is-moved (proc) + "If point is moved after executing PROC, return t, otherwise nil." + (/= (point) (progn (funcall proc) (point)))) + +(defun helm-search-from-candidate-buffer (pattern get-line-fn search-fns + limit search-from-end + start-point endp) + (let (buffer-read-only + matches exit newmatches) + (helm-search-from-candidate-buffer-internal + (lambda () + (clrhash helm-cib-hash) + (dolist (searcher search-fns) + (goto-char start-point) + (setq newmatches nil) + (loop with item-count = 0 + while (funcall searcher pattern) + for cand = (funcall get-line-fn (point-at-bol) (point-at-eol)) + do (helm-accumulate-candidates-internal + cand newmatches helm-cib-hash item-count limit) + unless (helm-point-is-moved + (lambda () + (if search-from-end + (goto-char (1- (point-at-bol))) + (forward-line 1)))) + return nil) + (setq matches (append matches (nreverse newmatches))) + (if exit (return))) + (delq nil matches))))) + +(defun helm-initial-candidates-from-candidate-buffer (endp get-line-fn limit search-from-end) + (delq nil (loop with next-line-fn = + (if search-from-end + (lambda (x) (goto-char (max (1- (point-at-bol)) 1))) + #'forward-line) + until (funcall endp) + for i from 1 to limit + collect (funcall get-line-fn (point-at-bol) (point-at-eol)) + do (funcall next-line-fn 1)))) + +(defun helm-search-from-candidate-buffer-internal (search-fn) + (goto-char (point-min)) + (insert "\n") + (goto-char (point-max)) + (insert "\n") + (unwind-protect + (funcall search-fn) + (goto-char (point-min)) + (delete-char 1) + (goto-char (1- (point-max))) + (delete-char 1) + + (set-buffer-modified-p nil))) + +(defun helm-candidate-buffer (&optional create-or-buffer) + "Register and return a buffer containing candidates of current source. +`helm-candidate-buffer' searches buffer-local candidates buffer first, +then global candidates buffer. + +Acceptable values of CREATE-OR-BUFFER: + +- nil (omit) + Only return the candidates buffer. +- a buffer + Register a buffer as a candidates buffer. +- 'global + Create a new global candidates buffer, + named \" *helm candidates:SOURCE*\". +- other non-nil value + Create a new local candidates buffer, + named \" *helm candidates:SOURCE*HELM-CURRENT-BUFFER\"." + (let* ((global-bname (format " *helm candidates:%s*" + helm-source-name)) + (local-bname (format " *helm candidates:%s*%s" + helm-source-name + (buffer-name helm-current-buffer)))) + (flet ((register-func () + (setq helm-candidate-buffer-alist + (cons (cons helm-source-name create-or-buffer) + (delete (assoc helm-source-name + helm-candidate-buffer-alist) + helm-candidate-buffer-alist)))) + (kill-buffers-func () + (loop for b in (buffer-list) + if (string-match (format "^%s" (regexp-quote global-bname)) + (buffer-name b)) + do (kill-buffer b))) + (create-func () + (with-current-buffer + (get-buffer-create (if (eq create-or-buffer 'global) + global-bname + local-bname)) + (buffer-disable-undo) + (erase-buffer) + (font-lock-mode -1))) + (return-func () + (or (get-buffer local-bname) + (get-buffer global-bname) + (helm-aif (assoc-default helm-source-name + helm-candidate-buffer-alist) + (and (buffer-live-p it) it))))) + (when create-or-buffer + (register-func) + (unless (bufferp create-or-buffer) + (and (eq create-or-buffer 'global) (kill-buffers-func)) + (create-func))) + (return-func)))) + +(defun helm-compile-source--candidates-in-buffer (source) + (helm-aif (assoc 'candidates-in-buffer source) + (append source + `((candidates . ,(or (cdr it) 'helm-candidates-in-buffer)) + (volatile) (match identity))) + source)) + + +;; (@* "Utility: resplit helm window") +(defun helm-toggle-resplit-window () + "Toggle resplit helm window, vertically or horizontally." + (interactive) + (with-helm-window + (let ((before-height (window-height))) + (delete-window) + (set-window-buffer + (select-window (if (= (window-height) before-height) + (prog1 + (split-window-vertically) + (setq helm-split-window-state 'vertical)) + (setq helm-split-window-state 'horizontal) + (split-window-horizontally))) + helm-buffer)))) + +;; (@* "Utility: Resize helm window.") +(defun helm-enlarge-window-1 (n) + "Enlarge or narrow helm window. +If N is positive enlarge, if negative narrow." + (unless helm-samewindow + (let ((horizontal-p (eq helm-split-window-state 'horizontal))) + (with-helm-window + (enlarge-window n horizontal-p))))) + +(defun helm-narrow-window () + "Narrow helm window." + (interactive) + (helm-enlarge-window-1 -1)) + +(defun helm-enlarge-window () + "Enlarge helm window." + (interactive) + (helm-enlarge-window-1 1)) + +;; (@* "Utility: select another action by key") +(defun helm-select-nth-action (n) + "Select the N nth action for the currently selected candidate." + (setq helm-saved-selection (helm-get-selection)) + (unless helm-saved-selection + (error "Nothing is selected")) + (setq helm-saved-action (helm-get-nth-action n (helm-get-action))) + (helm-exit-minibuffer)) + +(defun helm-get-nth-action (n action) + (cond ((and (zerop n) (functionp action)) + action) + ((listp action) + (or (cdr (elt action n)) + (error "No such action"))) + ((and (functionp action) (< 0 n)) + (error "Sole action")) + (t + (error "Error in `helm-select-nth-action'")))) + +(defun helm-select-2nd-action () + "Select the 2nd action for the currently selected candidate." + (interactive) + (helm-select-nth-action 1)) + +(defun helm-select-3rd-action () + "Select the 3rd action for the currently selected candidate." + (interactive) + (helm-select-nth-action 2)) + +(defun helm-select-4th-action () + "Select the 4th action for the currently selected candidate." + (interactive) + (helm-select-nth-action 3)) + +(defun helm-select-2nd-action-or-end-of-line () + "Select the 2nd action for the currently selected candidate. +This happen when point is at the end of minibuffer. +Otherwise goto the end of minibuffer." + (interactive) + (if (eolp) + (helm-select-nth-action 1) + (end-of-line))) + +;; (@* "Utility: Persistent Action") +(defmacro with-helm-display-same-window (&rest body) + "Execute BODY in the window used for persistent action. +Make `pop-to-buffer' and `display-buffer' display in the same window." + (declare (indent 0) (debug t)) + `(let ((display-buffer-function 'helm-persistent-action-display-buffer)) + ,@body)) + +(defvar helm-persistent-action-display-window nil) +(defun helm-initialize-persistent-action () + (set (make-local-variable 'helm-persistent-action-display-window) nil)) + +(defun* helm-execute-persistent-action (&optional (attr 'persistent-action) onewindow) + "Perform the associated action ATTR without quitting helm. +ATTR default is 'persistent-action', but it can be helm else. +In this case you have to add this new attribute to your source. +When `helm-samewindow' and ONEWINDOW are non--nil, +the helm window is never split in persistent action." + (interactive) + (helm-log "executing persistent-action") + (with-helm-window + (save-selected-window + (helm-select-persistent-action-window onewindow) + (helm-log-eval (current-buffer)) + (let ((helm-in-persistent-action t)) + (with-helm-display-same-window + (helm-execute-selection-action + nil + (or (assoc-default attr (helm-get-current-source)) + (helm-get-action)) + t) + (helm-log-run-hook 'helm-after-persistent-action-hook)))))) + + +(defun helm-persistent-action-display-window (&optional onewindow) + "Return the window that will be used for presistent action. +If ONEWINDOW is non--nil window will not be splitted in persistent action +if `helm-samewindow' is non--nil also." + (with-helm-window + (setq helm-persistent-action-display-window + (cond ((window-live-p helm-persistent-action-display-window) + helm-persistent-action-display-window) + ((and helm-samewindow (one-window-p t) (not onewindow)) + (split-window)) + ((get-buffer-window helm-current-buffer)) + (t + (next-window (selected-window) 1)))))) + +(defun helm-select-persistent-action-window (&optional onewindow) + "Select the window that will be used for persistent action. +See `helm-persistent-action-display-window' for how to use ONEWINDOW." + (select-window (get-buffer-window (helm-buffer-get))) + (select-window + (setq minibuffer-scroll-window + (helm-persistent-action-display-window onewindow)))) + +(defun helm-persistent-action-display-buffer (buf &optional not-this-window) + "Make `pop-to-buffer' and `display-buffer' display in the same window. +If `helm-persistent-action-use-special-display' is non-nil and +BUF is to be displayed by `special-display-function', use it. +Otherwise ignores `special-display-buffer-names' and `special-display-regexps'. +Argument NOT-THIS-WINDOW if present will be used as +second argument of `display-buffer'." + (let* ((name (buffer-name buf)) + display-buffer-function pop-up-windows pop-up-frames + (same-window-regexps + (unless (and helm-persistent-action-use-special-display + (or (member name + (mapcar (lambda (x) (or (car-safe x) x)) + special-display-buffer-names)) + (remove-if-not + (lambda (x) (string-match (or (car-safe x) x) name)) + special-display-regexps))) + '(".")))) + (display-buffer buf not-this-window))) + +;; scroll-other-window(-down)? for persistent-action +(defun helm-scroll-other-window-base (command) + (with-selected-window (helm-persistent-action-display-window) + (funcall command helm-scroll-amount))) + +(defun helm-scroll-other-window () + "Scroll other window (not *Helm* window) upward." + (interactive) + (helm-scroll-other-window-base 'scroll-up)) + +(defun helm-scroll-other-window-down () + "Scroll other window (not *Helm* window) downward." + (interactive) + (helm-scroll-other-window-base 'scroll-down)) + + +;; (@* "Utility: Visible Mark") +(defface helm-visible-mark + '((((min-colors 88) (background dark)) + (:background "green1" :foreground "black")) + (((background dark)) (:background "green" :foreground "black")) + (((min-colors 88)) (:background "green1")) + (t (:background "green"))) + "Face for visible mark." + :group 'helm) + +(defvar helm-visible-mark-face 'helm-visible-mark) +(defvar helm-visible-mark-overlays nil) + +(defun helm-clear-visible-mark () + (with-current-buffer (helm-buffer-get) + (mapc 'delete-overlay helm-visible-mark-overlays) + (set (make-local-variable 'helm-visible-mark-overlays) nil))) +(add-hook 'helm-after-initialize-hook 'helm-clear-visible-mark) + +(defvar helm-marked-candidates nil + "Marked candadates. List of \(source . real\) pair.") + +(defun helm-this-visible-mark () + (loop for o in helm-visible-mark-overlays + when (equal (point-at-bol) (overlay-start o)) + return o)) + +(defun helm-delete-visible-mark (overlay) + (setq helm-marked-candidates + (remove + (cons (helm-get-current-source) (helm-get-selection)) + helm-marked-candidates)) + (delete-overlay overlay) + (setq helm-visible-mark-overlays + (delq overlay helm-visible-mark-overlays))) + +(defun helm-make-visible-mark () + (let ((o (make-overlay (point-at-bol) (1+ (point-at-eol))))) + (overlay-put o 'face helm-visible-mark-face) + (overlay-put o 'source (assoc-default 'name (helm-get-current-source))) + (overlay-put o 'string (buffer-substring (overlay-start o) (overlay-end o))) + (overlay-put o 'real (helm-get-selection)) + (add-to-list 'helm-visible-mark-overlays o)) + (push (cons (helm-get-current-source) (helm-get-selection)) + helm-marked-candidates)) + +(defun helm-toggle-visible-mark () + "Toggle helm visible mark at point." + (interactive) + (with-helm-window + (helm-aif (helm-this-visible-mark) + (helm-delete-visible-mark it) + (helm-make-visible-mark)) + (helm-next-line))) + +(defun helm-display-all-visible-marks () + "Show all `helm' visible marks strings." + (interactive) + (with-helm-window + (lexical-let ((overlays (reverse helm-visible-mark-overlays))) + (helm-run-after-quit + (lambda () + (with-output-to-temp-buffer "*helm visible marks*" + (dolist (o overlays) (princ (overlay-get o 'string))))))))) + +(defun helm-marked-candidates () + "Return marked candidates of current source if any. +Otherwise one element list of current selection. + +It is analogous to `dired-get-marked-files'." + (with-current-buffer (helm-buffer-get) + (let ((cands + (if helm-marked-candidates + (loop with current-src = (helm-get-current-source) + for (source . real) in (reverse helm-marked-candidates) + when (equal current-src source) + collect (helm-coerce-selection real source)) + (list (helm-get-selection))))) + (helm-log-eval cands) + cands))) + +(defun helm-reset-marked-candidates () + (with-current-buffer (helm-buffer-get) + (set (make-local-variable 'helm-marked-candidates) nil))) + +(add-hook 'helm-after-initialize-hook 'helm-reset-marked-candidates) +;; (add-hook 'helm-after-action-hook 'helm-reset-marked-candidates) + +(defun helm-current-source-name= (name) + (save-excursion + (goto-char (helm-get-previous-header-pos)) + (equal name (helm-current-line-contents)))) + +(defun helm-revive-visible-mark () + "Restore marked candidates when helm update display." + (with-current-buffer helm-buffer + (dolist (o helm-visible-mark-overlays) + (goto-char (point-min)) + (while (and (search-forward (overlay-get o 'string) nil t) + (helm-current-source-name= (overlay-get o 'source))) + ;; Calculate real value of candidate. + ;; It can be nil if candidate have only a display value. + (let ((real (get-text-property (point-at-bol 0) 'helm-realvalue))) + (if real + ;; Check if real value of current candidate is the same + ;; that the one stored in overlay. + (and (string= (overlay-get o 'real) real) + (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0)))) + (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0))))))))) +(add-hook 'helm-update-hook 'helm-revive-visible-mark) + +(defun helm-next-point-in-list (curpos points &optional prev) + (cond + ;; rule out special cases + ((null points) curpos) + ((and prev (< curpos (car points))) curpos) + ((< (car (last points)) curpos) + (if prev (car (last points)) curpos)) + (t + (nth (if prev + (loop for pt in points + for i from 0 + if (<= curpos pt) + return (1- i)) + (loop for pt in points + for i from 0 + if (< curpos pt) + return i)) + points)))) + +(defun helm-next-visible-mark (&optional prev) + "Move next helm visible mark. +If PREV is non-nil move to precedent." + (interactive) + (with-helm-window + (ignore-errors + (goto-char (helm-next-point-in-list + (point) + (sort (mapcar 'overlay-start helm-visible-mark-overlays) '<) + prev))) + (helm-mark-current-line))) + +(defun helm-prev-visible-mark () + "Move previous helm visible mark." + (interactive) + (helm-next-visible-mark t)) + +;; (@* "Utility: Selection Paste") +(defun helm-yank-selection () + "Set minibuffer contents to current selection." + (interactive) + (helm-set-pattern (helm-get-selection nil t))) + +(defun helm-kill-selection-and-quit () + "Store current selection to kill ring. +You can paste it by typing \\[yank]." + (interactive) + (helm-run-after-quit + (lambda (sel) + (kill-new sel) + (message "Killed: %s" sel)) + (helm-get-selection nil t))) + + +;; (@* "Utility: Automatical execution of persistent-action") +(add-to-list 'minor-mode-alist '(helm-follow-mode " AFollow")) +(defun helm-follow-mode () + "If this mode is on, persistent action is executed everytime the cursor is moved." + (interactive) + (with-current-buffer helm-buffer + (setq helm-follow-mode (not helm-follow-mode)) + (message "helm-follow-mode is %s" + (if helm-follow-mode "enabled" "disabled")))) + +(defun helm-follow-execute-persistent-action-maybe () + "Execute persistent action in mode `helm-follow-mode'. +This happen after `helm-input-idle-delay' secs." + (and (not (get-buffer-window helm-action-buffer 'visible)) + (buffer-local-value 'helm-follow-mode + (get-buffer-create helm-buffer)) + (sit-for (and helm-input-idle-delay + (max helm-input-idle-delay 0.1))) + (helm-window) + (helm-get-selection) + (save-excursion + (helm-execute-persistent-action)))) + + +;; (@* "Utility: Migrate `helm-sources' to my-helm command") +(defun helm-migrate-sources () + "Help to migrate to new `helm' way." + (interactive) + (with-current-buffer (get-buffer-create "*helm migrate*") + (erase-buffer) + (insert (format "\ +Setting `helm-sources' directly is not good because +`helm' is not for one command. For now, interactive use of +`helm' (M-x helm) is only for demonstration purpose. +So you should define commands calling `helm'. +I help you to migrate to the new way. + +The code below is automatically generated from current +`helm-sources' value. You can use the `my-helm' command +now! + +Copy and paste it to your .emacs. Then substitute `my-helm' +for `helm' bindings in all `define-key', `local-set-key' and +`global-set-key' calls. + +\(defun my-helm () + \"Helm command for you. + +It is automatically generated by `helm-migrate-sources'.\" + (interactive) + (helm-other-buffer + '%S + \"*my-helm*\")) +" helm-sources)) + (eval-last-sexp nil) + (substitute-key-definition 'helm 'my-helm global-map) + (pop-to-buffer (current-buffer)))) + + +;; (@* "Compatibility") + +;; Copied assoc-default from XEmacs version 21.5.12 +(unless (fboundp 'assoc-default) + (defun assoc-default (key alist &optional test default) + "Find object KEY in a pseudo-alist ALIST. +ALIST is a list of conses or objects. Each element (or the element's car, +if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). +If that is non-nil, the element matches; +then `assoc-default' returns the element's cdr, if it is a cons, +or DEFAULT if the element is not a cons. + +If no element matches, the value is nil. +If TEST is omitted or nil, `equal' is used." + (let (found (tail alist) value) + (while (and tail (not found)) + (let ((elt (car tail))) + (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) + (setq found t value (if (consp elt) (cdr elt) default)))) + (setq tail (cdr tail))) + value))) + +;; Function not available in XEmacs, +(unless (fboundp 'minibuffer-contents) + (defun minibuffer-contents () + "Return the user input in a minbuffer as a string. +The current buffer must be a minibuffer." + (field-string (point-max))) + + (defun delete-minibuffer-contents () + "Delete all user input in a minibuffer. +The current buffer must be a minibuffer." + (delete-field (point-max)))) + +;; Function not available in older Emacs (<= 22.1). +(unless (fboundp 'buffer-chars-modified-tick) + (defun buffer-chars-modified-tick (&optional buffer) + "Return BUFFER's character-change tick counter. +Each buffer has a character-change tick counter, which is set to the +value of the buffer's tick counter (see `buffer-modified-tick'), each +time text in that buffer is inserted or deleted. By comparing the +values returned by two individual calls of `buffer-chars-modified-tick', +you can tell whether a character change occurred in that buffer in +between these calls. No argument or nil as argument means use current +buffer as BUFFER." + (with-current-buffer (or buffer (current-buffer)) + (if (listp buffer-undo-list) + (length buffer-undo-list) + (buffer-modified-tick))))) + + +;; (@* "CUA workaround") +(defadvice cua-delete-region (around helm-avoid-cua activate) + (ignore-errors ad-do-it)) + +(defadvice copy-region-as-kill (around helm-avoid-cua activate) + (if cua-mode + (ignore-errors ad-do-it) + ad-do-it)) + +;;(@* "Attribute Documentation") +(defun helm-describe-helm-attribute (helm-attribute) + "Display the full documentation of HELM-ATTRIBUTE. +HELM-ATTRIBUTE should be a symbol." + (interactive (list (intern + (completing-read + "Describe helm attribute: " + (mapcar 'symbol-name helm-additional-attributes) + nil t)))) + (with-output-to-temp-buffer "*Help*" + (princ (get helm-attribute 'helm-attrdoc)))) + +(helm-document-attribute 'name "mandatory" + " The name of the source. It is also the heading which appears + above the list of matches from the source. Must be unique.") + +(helm-document-attribute 'header-name "optional" + " A function returning the display string of the header. Its + argument is the name of the source. This attribute is useful to + add an additional information with the source name.") + +(helm-document-attribute 'candidates "mandatory if candidates-in-buffer attribute is not provided" + " Specifies how to retrieve candidates from the source. It can + either be a variable name, a function called with no parameters + or the actual list of candidates. + + The list must be a list whose members are strings, symbols + or (DISPLAY . REAL) pairs. + + In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown + in the Helm buffer, but the REAL one is used as action + argument when the candidate is selected. This allows a more + readable presentation for candidates which would otherwise be, + for example, too long or have a common part shared with other + candidates which can be safely replaced with an abbreviated + string for display purposes. + + Note that if the (DISPLAY . REAL) form is used then pattern + matching is done on the displayed string, not on the real + value. + + If the candidates have to be retrieved asynchronously (for + example, by an external command which takes a while to run) + then the function should start the external command + asynchronously and return the associated process object. + Helm will take care of managing the process (receiving the + output from it, killing it if necessary, etc.). The process + should return candidates matching the current pattern (see + variable `helm-pattern'.) + + Note that currently results from asynchronous sources appear + last in the helm buffer regardless of their position in + `helm-sources'.") + +(helm-document-attribute 'action "mandatory if type attribute is not provided" + " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. + FUNCTION is called with one parameter: the selected candidate. + + An action other than the default can be chosen from this list + of actions for the currently selected candidate (by default + with TAB). The DISPLAY string is shown in the completions + buffer and the FUNCTION is invoked when an action is + selected. The first action of the list is the default.") + +(helm-document-attribute 'coerce "optional" + " It's a function called with one argument: the selected candidate. + + This function is intended for type convertion. + In normal case, the selected candidate (string) is passed to action function. + If coerce function is specified, it is called just before action function. + + Example: converting string to symbol + (coerce . intern)") + +(helm-document-attribute 'type "optional if action attribute is provided" + " Indicates the type of the items the source returns. + + Merge attributes not specified in the source itself from + `helm-type-attributes'. + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'init "optional" + " Function called with no parameters when helm is started. It + is useful for collecting current state information which can be + used to create the list of candidates later. + + For example, if a source needs to work with the current + directory then it can store its value here, because later + helm does its job in the minibuffer and in the + `helm-buffer' and the current directory can be different + there.") + +(helm-document-attribute 'delayed-init "optional" + " Function called with no parameters before candidate function is + called. It is similar with `init' attribute, but its + evaluation is deferred. It is useful to combine with ") + +(helm-document-attribute 'match "optional" + " List of functions called with one parameter: a candidate. The + function should return non-nil if the candidate matches the + current pattern (see variable `helm-pattern'). + + This attribute allows the source to override the default + pattern matching based on `string-match'. It can be used, for + example, to implement a source for file names and do the + pattern matching on the basename of files, since it's more + likely one is typing part of the basename when searching for a + file, instead of some string anywhere else in its path. + + If the list contains more than one function then the list of + matching candidates from the source is constructed by appending + the results after invoking the first function on all the + potential candidates, then the next function, and so on. The + matching candidates supplied by the first function appear first + in the list of results and then results from the other + functions, respectively. + + This attribute has no effect for asynchronous sources (see + attribute `candidates'), since they perform pattern matching + themselves.") + +(helm-document-attribute 'candidate-transformer "optional" + " It's a function or a list of functions called with one argument + when the completion list from the source is built. The argument + is the list of candidates retrieved from the source. The + function should return a transformed list of candidates which + will be used for the actual completion. If it is a list of + functions, it calls each function sequentially. + + This can be used to transform or remove items from the list of + candidates. + + Note that `candidates' is run already, so the given transformer + function should also be able to handle candidates with (DISPLAY + . REAL) format.") + +(helm-document-attribute 'filtered-candidate-transformer "optional" + " It has the same format as `candidate-transformer', except the + function is called with two parameters: the candidate list and + the source. + + This transformer is run on the candidate list which is already + filtered by the current pattern. While `candidate-transformer' + is run only once, it is run every time the input pattern is + changed. + + It can be used to transform the candidate list dynamically, for + example, based on the current pattern. + + In some cases it may also be more efficent to perform candidate + transformation here, instead of with `candidate-transformer' + even if this transformation is done every time the pattern is + changed. For example, if a candidate set is very large then + `candidate-transformer' transforms every candidate while only + some of them will actually be dislpayed due to the limit + imposed by `helm-candidate-number-limit'. + + Note that `candidates' and `candidate-transformer' is run + already, so the given transformer function should also be able + to handle candidates with (DISPLAY . REAL) format. + + This option has no effect for asynchronous sources. (Not yet, + at least.") + +(helm-document-attribute 'action-transformer "optional" + " It's a function or a list of functions called with two + arguments when the action list from the source is + assembled. The first argument is the list of actions, the + second is the current selection. If it is a list of functions, + it calls each function sequentially. + + The function should return a transformed action list. + + This can be used to customize the list of actions based on the + currently selected candidate.") + +(helm-document-attribute 'pattern-transformer "optional" + " It's a function or a list of functions called with one argument + before computing matches. Its argument is `helm-pattern'. + Functions should return transformed `helm-pattern'. + + It is useful to change interpretation of `helm-pattern'.") + +(helm-document-attribute 'delayed "optional" + " Candidates from the source are shown only if the user stops + typing and is idle for `helm-idle-delay' seconds.") + +(helm-document-attribute 'volatile "optional" + " Indicates the source assembles the candidate list dynamically, + so it shouldn't be cached within a single Helm + invocation. It is only applicable to synchronous sources, + because asynchronous sources are not cached.") + +(helm-document-attribute 'requires-pattern "optional" + " If present matches from the source are shown only if the + pattern is not empty. Optionally, it can have an integer + parameter specifying the required length of input which is + useful in case of sources with lots of candidates.") + +(helm-document-attribute 'persistent-action "optional" + " Function called with one parameter; the selected candidate. + + An action performed by `helm-execute-persistent-action'. + If none, use the default action.") + +(helm-document-attribute 'candidates-in-buffer "optional" + " Shortcut attribute for making and narrowing candidates using + buffers. This newly-introduced attribute prevents us from + forgetting to add volatile and match attributes. + + See docstring of `helm-candidates-in-buffer'. + + (candidates-in-buffer) is equivalent of three attributes: + (candidates . helm-candidates-in-buffer) + (volatile) + (match identity) + + (candidates-in-buffer . candidates-function) is equivalent of: + (candidates . candidates-function) + (volatile) + (match identity) + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'search "optional" + " List of functions like `re-search-forward' or `search-forward'. + Buffer search function used by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses `re-search-forward'. + This attribute is meant to be used with + (candidates . helm-candidates-in-buffer) or + (candidates-in-buffer) in short.") + +(helm-document-attribute 'search-from-end "optional" + " Make `helm-candidates-in-buffer' search from the end of buffer. + If this attribute is specified, `helm-candidates-in-buffer' uses + `re-search-backward' instead.") + +(helm-document-attribute 'get-line "optional" + " A function like `buffer-substring-no-properties' or `buffer-substring'. + This function converts point of line-beginning and point of line-end, + which represents a candidate computed by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses + `buffer-substring-no-properties'.") + +(helm-document-attribute 'display-to-real "optional" + " Function called with one parameter; the selected candidate. + + The function transforms the selected candidate, and the result + is passed to the action function. The display-to-real + attribute provides another way to pass other string than one + shown in Helm buffer. + + Traditionally, it is possible to make candidates, + candidate-transformer or filtered-candidate-transformer + function return a list with (DISPLAY . REAL) pairs. But if REAL + can be generated from DISPLAY, display-to-real is more + convenient and faster.") + +(helm-document-attribute 'real-to-display "optional" + " Function called with one parameter; the selected candidate. + + The inverse of display-to-real attribute. + + The function transforms the selected candidate, which is passed + to the action function, for display. The real-to-display + attribute provides the other way to pass other string than one + shown in Helm buffer. + + Traditionally, it is possible to make candidates, + candidate-transformer or filtered-candidate-transformer + function return a list with (DISPLAY . REAL) pairs. But if + DISPLAY can be generated from REAL, real-to-display is more + convenient. + + Note that DISPLAY parts returned from candidates / + candidate-transformer are IGNORED as the name `display-to-real' + says.") + +(helm-document-attribute 'cleanup "optional" + " Function called with no parameters when *helm* buffer is closed. It + is useful for killing unneeded candidates buffer. + + Note that the function is executed BEFORE performing action.") + +(helm-document-attribute 'candidate-number-limit "optional" + " Override `helm-candidate-number-limit' only for this source.") + +(helm-document-attribute 'accept-empty "optional" + " Pass empty string \"\" to action function.") + +(helm-document-attribute 'disable-shortcuts "optional" + " Disable `helm-enable-shortcuts' in current `helm' session. + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'dummy "optional" + " Set `helm-pattern' to candidate. If this attribute is + specified, The candidates attribute is ignored. + + This attribute is implemented by plug-in. + This plug-in implies disable-shortcuts plug-in.") + +(helm-document-attribute 'multiline "optional" + " Enable to selection multiline candidates.") + +(helm-document-attribute 'update "optional" + (substitute-command-keys + " Function called with no parameters when \ +\\\\[helm-force-update] is pressed.")) + +(helm-document-attribute 'mode-line "optional" + " source local `helm-mode-line-string'. (included in `mode-line-format') + It accepts also variable/function name.") + +(helm-document-attribute 'header-line "optional" + " source local `header-line-format'. + It accepts also variable/function name. ") + +(helm-document-attribute + 'resume "optional" + " Function called with no parameters when `helm-resume' is started.") + +(helm-document-attribute 'keymap "optional" + " Specific keymap for this source. + It is useful to have a keymap per source when using more than one source. + Otherwise, a keymap can be set per command with `helm' argument KEYMAP. + NOTE: when a source have `helm-map' as keymap attr, + the global value of `helm-map' will override the actual local one.") + +(helm-document-attribute 'help-message "optional" + " Help message for this source. + If not present, `helm-help-message' value will be used.") + + +;; (@* "Bug Report") +(defvar helm-maintainer-mail-address "emacs-helm@googlegroups.com") + +(defvar helm-bug-report-salutation + "Describe bug below, using a precise recipe. + +When I executed M-x ... + +How to send a bug report: + 1) Be sure to use the LATEST version of helm.el. + 2) Enable debugger. M-x toggle-debug-on-error or (setq debug-on-error t) + 3) Use Lisp version instead of compiled one: (load \"helm.el\") + 4) If you got an error, please paste *Backtrace* buffer. + 5) Type C-c C-c to send.") + +(defvar helm-no-dump-variables + '(helm-candidate-buffer-alist + helm-digit-overlays + helm-help-message + helm-candidate-cache + ) + "Variables not to dump in bug report.") + +(defun helm-dumped-variables-in-bug-report () + (let ((hash (make-hash-table))) + (loop for var in (apropos-internal "helm-" 'boundp) + for vname = (symbol-name var) + unless (or (string-match "-map$" vname) + (string-match "^helm-c-source-" vname) + (string-match "-hash$" vname) + (string-match "-face$" vname) + (memq var helm-no-dump-variables)) + collect var))) + +(defun helm-send-bug-report () + "Send a bug report of helm.el." + (interactive) + (with-current-buffer (or helm-last-buffer + (current-buffer)) + (reporter-submit-bug-report + helm-maintainer-mail-address + "helm.el" + (helm-dumped-variables-in-bug-report) + nil nil + helm-bug-report-salutation))) + +(defun helm-send-bug-report-from-helm () + "Send a bug report of helm.el in helm session." + (interactive) + (helm-run-after-quit 'helm-send-bug-report)) + +;; Debugging function. +(defun* helm-test-candidates + (sources &optional (input "") + (compile-source-functions + helm-compile-source-functions-default)) + "Test helper function for helm. +Given pseudo `helm-sources' and `helm-pattern', returns list like + ((\"source name1\" (\"candidate1\" \"candidate2\")) + (\"source name2\" (\"candidate3\" \"candidate4\")))" + (let ((helm-test-mode t) + helm-enable-shortcuts + helm-candidate-cache + (helm-compile-source-functions compile-source-functions) + helm-before-initialize-hook + helm-after-initialize-hook + helm-update-hook + helm-test-candidate-list) + (get-buffer-create helm-buffer) + (helm-initialize nil input sources) + (helm-update) + ;; test-mode spec: select 1st candidate! + (with-current-buffer helm-buffer + (forward-line 1) + (helm-mark-current-line)) + (prog1 + helm-test-candidate-list + (helm-cleanup)))) + + +;; (@* "Unit Tests") +;; See developer-tools/unit-test-helm.el + +(provide 'helm) + +;; Local Variables: +;; coding: utf-8 +;; End: + +;;; helm.el ends here