From 0e18516054961b3abae8716e4e7bc62140c87041 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 2 Feb 2021 14:50:21 +0100 Subject: [PATCH] update helm --- bba.org | 6 +- custom.el | 2 +- elpa/helm-20191101.641/helm-command.el | 308 -- elpa/helm-20191101.641/helm-dabbrev.el | 388 -- elpa/helm-20191101.641/helm-pkg.el | 9 - elpa/helm-20210131.1946/.dir-locals.el | 6 + .../emacs-helm.sh | 74 +- .../helm-adaptive.el | 22 +- .../helm-autoloads.el | 468 ++- .../helm-bookmark.el | 49 +- .../helm-buffers.el | 298 +- .../helm-color.el | 10 +- .../helm-comint.el | 43 +- elpa/helm-20210131.1946/helm-command.el | 360 ++ elpa/helm-20210131.1946/helm-config.el | 40 + elpa/helm-20210131.1946/helm-dabbrev.el | 402 +++ .../helm-easymenu.el | 5 +- .../helm-elisp-package.el | 50 +- .../helm-elisp.el | 151 +- elpa/helm-20210131.1946/helm-epa.el | 231 ++ .../helm-eshell.el | 141 +- .../helm-eval.el | 18 +- .../helm-external.el | 34 +- elpa/helm-20210131.1946/helm-fd.el | 127 + .../helm-files.el | 2056 +++++++---- .../helm-find.el | 7 +- .../helm-font.el | 26 +- .../helm-for-files.el | 15 +- .../helm-global-bindings.el} | 108 +- .../helm-grep.el | 347 +- .../helm-help.el | 663 +++- .../helm-id-utils.el | 16 +- .../helm-imenu.el | 87 +- .../helm-info.el | 32 +- .../helm-locate.el | 103 +- .../helm-man.el | 9 +- .../helm-misc.el | 16 +- .../helm-mode.el | 1094 ++++-- .../helm-net.el | 48 +- .../helm-occur.el | 163 +- elpa/helm-20210131.1946/helm-pkg.el | 13 + .../helm-regexp.el | 6 +- .../helm-ring.el | 52 +- .../helm-semantic.el | 8 +- .../helm-shell.el | 2 +- .../helm-sys.el | 49 +- .../helm-tags.el | 18 +- .../helm-types.el | 47 +- .../helm-utils.el | 222 +- .../helm-x-files.el | 13 +- elpa/helm-core-20191031.1931/helm-core-pkg.el | 7 - .../helm-core-autoloads.el | 60 +- elpa/helm-core-20210128.1814/helm-core-pkg.el | 7 + .../helm-lib.el | 667 +++- .../helm-multi-match.el | 102 +- .../helm-source.el | 72 +- .../helm.el | 3158 ++++++++++------- elpa/helm-org-20191101.715/helm-org-pkg.el | 2 - .../helm-org-autoloads.el | 10 +- elpa/helm-org-20200311.633/helm-org-pkg.el | 2 + .../helm-org.el | 368 +- .../helm-projectile-pkg.el | 2 - .../helm-projectile-autoloads.el | 28 +- .../helm-projectile-pkg.el | 2 + .../helm-projectile.el | 64 +- .../helm-swoop-pkg.el | 2 - .../helm-swoop-autoloads.el | 44 +- .../helm-swoop-20200814.448/helm-swoop-pkg.el | 2 + .../helm-swoop.el | 1223 +++---- 69 files changed, 8833 insertions(+), 5451 deletions(-) delete mode 100644 elpa/helm-20191101.641/helm-command.el delete mode 100644 elpa/helm-20191101.641/helm-dabbrev.el delete mode 100644 elpa/helm-20191101.641/helm-pkg.el create mode 100644 elpa/helm-20210131.1946/.dir-locals.el rename elpa/{helm-20191101.641 => helm-20210131.1946}/emacs-helm.sh (78%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-adaptive.el (95%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-autoloads.el (74%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-bookmark.el (95%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-buffers.el (84%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-color.el (95%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-comint.el (83%) create mode 100644 elpa/helm-20210131.1946/helm-command.el create mode 100644 elpa/helm-20210131.1946/helm-config.el create mode 100644 elpa/helm-20210131.1946/helm-dabbrev.el rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-easymenu.el (94%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-elisp-package.el (91%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-elisp.el (90%) create mode 100644 elpa/helm-20210131.1946/helm-epa.el rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-eshell.el (86%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-eval.el (91%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-external.el (91%) create mode 100644 elpa/helm-20210131.1946/helm-fd.el rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-files.el (73%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-find.el (97%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-font.el (93%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-for-files.el (97%) rename elpa/{helm-20191101.641/helm-config.el => helm-20210131.1946/helm-global-bindings.el} (65%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-grep.el (87%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-help.el (72%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-id-utils.el (92%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-imenu.el (82%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-info.el (90%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-locate.el (86%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-man.el (93%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-misc.el (96%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-mode.el (61%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-net.el (91%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-occur.el (81%) create mode 100644 elpa/helm-20210131.1946/helm-pkg.el rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-regexp.el (95%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-ring.el (93%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-semantic.el (97%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-shell.el (95%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-sys.el (92%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-tags.el (96%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-types.el (88%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-utils.el (85%) rename elpa/{helm-20191101.641 => helm-20210131.1946}/helm-x-files.el (93%) delete mode 100644 elpa/helm-core-20191031.1931/helm-core-pkg.el rename elpa/{helm-core-20191031.1931 => helm-core-20210128.1814}/helm-core-autoloads.el (82%) create mode 100644 elpa/helm-core-20210128.1814/helm-core-pkg.el rename elpa/{helm-core-20191031.1931 => helm-core-20210128.1814}/helm-lib.el (69%) rename elpa/{helm-core-20191031.1931 => helm-core-20210128.1814}/helm-multi-match.el (79%) rename elpa/{helm-core-20191031.1931 => helm-core-20210128.1814}/helm-source.el (94%) rename elpa/{helm-core-20191031.1931 => helm-core-20210128.1814}/helm.el (73%) delete mode 100644 elpa/helm-org-20191101.715/helm-org-pkg.el rename elpa/{helm-org-20191101.715 => helm-org-20200311.633}/helm-org-autoloads.el (92%) create mode 100644 elpa/helm-org-20200311.633/helm-org-pkg.el rename elpa/{helm-org-20191101.715 => helm-org-20200311.633}/helm-org.el (57%) delete mode 100644 elpa/helm-projectile-20190731.1538/helm-projectile-pkg.el rename elpa/{helm-projectile-20190731.1538 => helm-projectile-20201217.908}/helm-projectile-autoloads.el (79%) create mode 100644 elpa/helm-projectile-20201217.908/helm-projectile-pkg.el rename elpa/{helm-projectile-20190731.1538 => helm-projectile-20201217.908}/helm-projectile.el (96%) delete mode 100644 elpa/helm-swoop-20200121.1859/helm-swoop-pkg.el rename elpa/{helm-swoop-20200121.1859 => helm-swoop-20200814.448}/helm-swoop-autoloads.el (70%) create mode 100644 elpa/helm-swoop-20200814.448/helm-swoop-pkg.el rename elpa/{helm-swoop-20200121.1859 => helm-swoop-20200814.448}/helm-swoop.el (60%) diff --git a/bba.org b/bba.org index baf6f79a..e5fa63dd 100644 --- a/bba.org +++ b/bba.org @@ -3936,12 +3936,12 @@ Some links you might check out: (if (>= emacs-major-version 24) (progn (add-to-list 'load-path - "~/.emacs.d/elpa/helm-20191031.839") + "~/.emacs.d/elpa/helm-20210131.1946") (require 'helm) (helm-mode 1) (global-set-key (kbd "M-y") 'helm-show-kill-ring) (global-set-key (kbd "C-c w") 'helm-man-woman) - (global-set-key (kbd "M-x") 'helm-M-x) + (global-set-key (kbd "M-x") #'helm-M-x) (global-set-key "\C-cr" 'helm-recentf) (global-set-key (kbd "M-s o") 'helm-occur) (define-key global-map "\C-x\C-b" 'helm-buffers-list) @@ -4021,8 +4021,6 @@ combine key strokes to access commands even faster. (key-chord-define cfengine3-mode-map ",," "\C-e,") (key-chord-define prog-mode-map ";;" "\C-e;") (key-chord-define prog-mode-map ",," "\C-e,") - (key-chord-define-global "uu" 'undo) - (key-chord-define-global "xb" 'helm-mini) (key-chord-define-global "xf" 'ido-find-file) (key-chord-define-global "xx" 'helm-M-x) (key-chord-define org-mode-map "TT" 'org-set-tags-command) diff --git a/custom.el b/custom.el index 98135cf5..0110f4d3 100644 --- a/custom.el +++ b/custom.el @@ -18,7 +18,7 @@ ("8db4b03b9ae654d4a57804286eb3e332725c84d7cdab38463cb6b97d5762ad26" default))) '(gnuserv-program (concat exec-directory "/gnuserv")) '(grep-template "grep -i -nH -e ") - '(helm-comint-mode-list (quote (comint-mode slime-repl-mode sql-interactive-mode))) + '(helm-comint-mode-list '(comint-mode slime-repl-mode sql-interactive-mode)) '(history-length 1000) '(magit-commit-arguments (quote ("--signoff" "--gpg-sign=43BA01102D205F88"))) '(magit-commit-signoff t) diff --git a/elpa/helm-20191101.641/helm-command.el b/elpa/helm-20191101.641/helm-command.el deleted file mode 100644 index 54aae483..00000000 --- a/elpa/helm-20191101.641/helm-command.el +++ /dev/null @@ -1,308 +0,0 @@ -;;; helm-command.el --- Helm execute-exended-command. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto - -;; This program 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 3 of the License, or -;; (at your option) any later version. - -;; This program 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 this program. If not, see . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-help) -(require 'helm-mode) -(require 'helm-elisp) - - -(defgroup helm-command nil - "Emacs command related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-M-x-requires-pattern 0 - "Value of requires-pattern for `helm-M-x'. -Show all candidates on startup when 0 (default)." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-always-save-history nil - "`helm-M-x' Save command in `extended-command-history' even when it fail." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-reverse-history nil - "The history source of `helm-M-x' appear in second position when non--nil." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-fuzzy-match nil - "Enable fuzzy matching in `helm-M-x' when non--nil." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-default-sort-fn #'helm-M-x-fuzzy-sort-candidates - "Default sort function for `helm-M-x'. - -It should sort against REAL value of candidates. - -It is used only when `helm-M-x-fuzzy-match' is enabled." - :group 'helm-command - :type 'function) - -;;; Faces -;; -;; -(defgroup helm-command-faces nil - "Customize the appearance of helm-command." - :prefix "helm-" - :group 'helm-command - :group 'helm-faces) - -(defface helm-M-x-key '((t (:foreground "orange" :underline t))) - "Face used in helm-M-x to show keybinding." - :group 'helm-command-faces) - - -(defvar helm-M-x-input-history nil) -(defvar helm-M-x-prefix-argument nil - "Prefix argument before calling `helm-M-x'.") - - -(defun helm-M-x-get-major-mode-command-alist (mode-map) - "Return alist of MODE-MAP." - (when mode-map - (cl-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 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. -Return nil if no mode-map found." - (cl-loop ;; Start with a conventional mode-map name. - with mode-map = (intern-soft (format "%s-map" mode)) - with mode-string = (symbol-name mode) - with mode-name = (replace-regexp-in-string "-mode" "" mode-string) - while (not mode-map) - for count downfrom (length mode-name) - ;; Return when no result after parsing entire string. - when (eq count 0) return nil - for sub-name = (substring mode-name 0 count) - do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode")))) - finally return mode-map)) - -(defun helm-M-x-current-mode-map-alist () - "Return mode-map alist of current `major-mode'." - (let ((map-sym (helm-get-mode-map-from-mode major-mode))) - (when (and map-sym (boundp map-sym)) - (helm-M-x-get-major-mode-command-alist (symbol-value map-sym))))) - - -(defun helm-M-x-transformer-1 (candidates &optional sort) - "Transformer function to show bindings in emacs commands. -Show global bindings and local bindings according to current `major-mode'. -If SORT is non nil sort list with `helm-generic-sort-fn'. -Note that SORT should not be used when fuzzy matching because -fuzzy matching is running its own sort function with a different algorithm." - (with-helm-current-buffer - (cl-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)) - unless (get (intern (if (consp cand) (car cand) cand)) 'helm-only) - collect - (cons (cond ((and (string-match "^M-x" key) local-key) - (format "%s (%s)" - cand (propertize - local-key - 'face 'helm-M-x-key))) - ((string-match "^M-x" key) cand) - (t (format "%s (%s)" - cand (propertize - key - 'face 'helm-M-x-key)))) - cand) - into ls - finally return - (if sort (sort ls #'helm-generic-sort-fn) ls)))) - -(defun helm-M-x-transformer (candidates _source) - "Transformer function for `helm-M-x' candidates." - (helm-M-x-transformer-1 candidates (null helm--in-fuzzy))) - -(defun helm-M-x-transformer-hist (candidates _source) - "Transformer function for `helm-M-x' candidates." - (helm-M-x-transformer-1 candidates)) - -(defun helm-M-x--notify-prefix-arg () - ;; Notify a prefix-arg set AFTER calling M-x. - (when prefix-arg - (with-helm-window - (helm-display-mode-line (helm-get-current-source) 'force)))) - -(defun helm-cmd--get-current-function-name () - (save-excursion - (beginning-of-defun) - (cadr (split-string (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))))) - -(defun helm-cmd--get-preconfigured-commands (&optional dir) - (let* ((helm-dir (or dir (helm-basedir (locate-library "helm")))) - (helm-autoload-file (expand-file-name "helm-autoloads.el" helm-dir)) - results) - (when (file-exists-p helm-autoload-file) - (with-temp-buffer - (insert-file-contents helm-autoload-file) - (while (re-search-forward "Preconfigured" nil t) - (push (substring (helm-cmd--get-current-function-name) 1) results)))) - results)) - -(defvar helm-M-x-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-comp-read-map) - (define-key map (kbd "C-u") nil) - (define-key map (kbd "C-u") 'helm-M-x-universal-argument) - map)) - -(defun helm-M-x-universal-argument () - "Same as `universal-argument' but for `helm-M-x'." - (interactive) - (if helm-M-x-prefix-argument - (progn (setq helm-M-x-prefix-argument nil) - (let ((inhibit-read-only t)) - (with-selected-window (minibuffer-window) - (save-excursion - (goto-char (point-min)) - (delete-char (- (minibuffer-prompt-width) (length "M-x ")))))) - (message "Initial prefix arg disabled")) - (setq prefix-arg (list 4)) - (universal-argument--mode))) -(put 'helm-M-x-universal-argument 'helm-only t) - -(defun helm-M-x-fuzzy-sort-candidates (candidates _source) - (helm-fuzzy-matching-default-sort-fn-1 candidates t)) - -(defun helm-M-x-read-extended-command (&optional collection history) - "Read command name to invoke in `helm-M-x'. -Helm completion is not provided when executing or defining -kbd macros. -Optional arg COLLECTION is to allow using another COLLECTION -than the default which is OBARRAY." - (if (or defining-kbd-macro executing-kbd-macro) - (if helm-mode - (unwind-protect - (progn - (helm-mode -1) - (read-extended-command)) - (helm-mode 1)) - (read-extended-command)) - (let* ((helm-fuzzy-sort-fn helm-M-x-default-sort-fn) - (helm--mode-line-display-prefarg t) - (tm (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg)) - (helm-move-selection-after-hook - (cons (lambda () (setq current-prefix-arg nil)) - helm-move-selection-after-hook))) - (setq extended-command-history - (cl-loop for c in extended-command-history - when (and c (commandp (intern c))) - do (set-text-properties 0 (length c) nil c) - and collect c)) - (unwind-protect - (progn - (setq current-prefix-arg nil) - (helm-comp-read - (concat (cond - ((eq helm-M-x-prefix-argument '-) "- ") - ((and (consp helm-M-x-prefix-argument) - (eq (car helm-M-x-prefix-argument) 4)) "C-u ") - ((and (consp helm-M-x-prefix-argument) - (integerp (car helm-M-x-prefix-argument))) - (format "%d " (car helm-M-x-prefix-argument))) - ((integerp helm-M-x-prefix-argument) - (format "%d " helm-M-x-prefix-argument))) - "M-x ") - (or collection obarray) - :test 'commandp - :requires-pattern helm-M-x-requires-pattern - :name "Emacs Commands" - :buffer "*helm M-x*" - :persistent-action (lambda (candidate) - (helm-elisp--persistent-help - candidate 'helm-describe-function)) - :persistent-help "Describe this command" - :history (or history extended-command-history) - :reverse-history helm-M-x-reverse-history - :input-history 'helm-M-x-input-history - :del-input nil - :help-message 'helm-M-x-help-message - :group 'helm-command - :keymap helm-M-x-map - :must-match t - :match-part (lambda (c) (car (split-string c))) - :fuzzy helm-M-x-fuzzy-match - :nomark t - :candidates-in-buffer t - :fc-transformer 'helm-M-x-transformer - :hist-fc-transformer 'helm-M-x-transformer-hist)) - (cancel-timer tm) - (setq helm--mode-line-display-prefarg nil))))) - -;;;###autoload -(defun helm-M-x (_arg &optional command-name) - "Preconfigured `helm' for Emacs commands. -It is `helm' replacement of regular `M-x' `execute-extended-command'. - -Unlike regular `M-x' emacs vanilla `execute-extended-command' command, -the prefix args if needed, can be passed AFTER starting `helm-M-x'. -When a prefix arg is passed BEFORE starting `helm-M-x', the first `C-u' -while in `helm-M-x' session will disable it. - -You can get help on each command by persistent action." - (interactive - (progn - (setq helm-M-x-prefix-argument current-prefix-arg) - (list current-prefix-arg (helm-M-x-read-extended-command)))) - (when (stringp command-name) - (unless (string= command-name "") - (let ((sym-com (and (stringp command-name) (intern-soft command-name)))) - (when sym-com - ;; Avoid having `this-command' set to *exit-minibuffer. - (setq this-command sym-com - ;; Handle C-x z (repeat) Issue #322 - real-this-command sym-com) - ;; If helm-M-x is called with regular emacs completion (kmacro) - ;; use the value of arg otherwise use helm-current-prefix-arg. - (let ((prefix-arg (or helm-current-prefix-arg helm-M-x-prefix-argument))) - (cl-flet ((save-hist (command) - (setq extended-command-history - (cons command (delete command extended-command-history))))) - (condition-case-unless-debug err - (progn - (command-execute sym-com 'record) - (save-hist command-name)) - (error - (when helm-M-x-always-save-history - (save-hist command-name)) - (signal (car err) (cdr err))))))))))) -(put 'helm-M-x 'interactive-only 'command-execute) - -(provide 'helm-command) - -;; Local Variables: -;; byte-compile-warnings: (not obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-command.el ends here diff --git a/elpa/helm-20191101.641/helm-dabbrev.el b/elpa/helm-20191101.641/helm-dabbrev.el deleted file mode 100644 index 6adce190..00000000 --- a/elpa/helm-20191101.641/helm-dabbrev.el +++ /dev/null @@ -1,388 +0,0 @@ -;;; helm-dabbrev.el --- Helm implementation of dabbrev. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto - -;; This program 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 3 of the License, or -;; (at your option) any later version. - -;; This program 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 this program. If not, see . - -;;; Code: - -(require 'helm) -(require 'helm-lib) -(require 'helm-help) -(require 'helm-elisp) ; For show-completion. - -(defgroup helm-dabbrev nil - "Dabbrev related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-dabbrev-always-search-all t - "Always search in all buffers when non--nil. -Note that even if nil, a search in all buffers -will occur if the length of candidates is <= than -`helm-dabbrev-max-length-result'." - :group 'helm-dabbrev - :type 'boolean) - -(defcustom helm-dabbrev-candidates-number-limit 1000 - "Maximum number of candidates to collect. - -Higher this number is, slower the computation of candidates will be. -You can use safely a higher value with emacs-26+. -Note that this have nothing to do with `helm-candidate-number-limit'." - :group 'helm-dabbrev - :type 'integer) - -(defcustom helm-dabbrev-ignored-buffers-regexps - '("\\*helm" "\\*Messages" "\\*Echo Area" "\\*Buffer List") - "List of regexps matching names of buffers that helm-dabbrev should not check." - :group 'helm-dabbrev - :type '(repeat regexp)) - -(defcustom helm-dabbrev-related-buffer-fn #'helm-dabbrev--same-major-mode-p - "A function that decide if a buffer to search in is related to `current-buffer'. -This is actually determined by comparing `major-mode' of the buffer to search -and the `current-buffer'. -The function take one arg, the buffer which is current, look at -`helm-dabbrev--same-major-mode-p' for example. - -When nil all buffers are considered related to `current-buffer'." - :group 'helm-dabbrev - :type 'function) - -(defcustom helm-dabbrev-major-mode-assoc nil - "Major mode association alist. -This allow helm-dabbrev searching in buffers with the associated `major-mode'. -e.g \(emacs-lisp-mode . lisp-interaction-mode\) -will allow searching in the lisp-interaction-mode buffer when `current-buffer' -is an `emacs-lisp-mode' buffer and vice versa i.e -no need to provide \(lisp-interaction-mode . emacs-lisp-mode\) association. - -When nil check is the searched buffer have same `major-mode' -than the `current-buffer'. -This have no effect when `helm-dabbrev-related-buffer-fn' is nil or of course -bound to a function that doesn't handle this var." - :type '(alist :key-type symbol :value-type symbol) - :group 'helm-dabbrev) - -(defcustom helm-dabbrev-lineno-around 30 - "Search first in this number of lines before an after point." - :group 'helm-dabbrev - :type 'integer) - -(defcustom helm-dabbrev-cycle-threshold 5 - "Number of time helm-dabbrev cycle before displaying helm completion. -When nil or 0 disable cycling." - :group 'helm-dabbrev - :type '(choice (const :tag "Cycling disabled" nil) integer)) - -(defcustom helm-dabbrev-case-fold-search 'smart - "Set `case-fold-search' in `helm-dabbrev'. -Same as `helm-case-fold-search' but for `helm-dabbrev'. -Note that this is not affecting searching in helm buffer, -but the initial search for all candidates in buffer(s)." - :group 'helm-dabbrev - :type '(choice (const :tag "Ignore case" t) - (const :tag "Respect case" nil) - (other :tag "Smart" 'smart))) - -(defcustom helm-dabbrev-use-thread nil - "[EXPERIMENTAL] Compute candidates asynchronously (partially) when non nil. - -The idea is to compute candidates while cycling the first ones, so -this is available only if `helm-dabbrev-cycle-threshold' is not 0 or -nil, also it is available only on emacs-26+ (needs threads). - -This is reasonably working when you don't have to complete a huge list -of candidates, otherwise you will have a small delay after the first cycle -because thread is released unexpectedly when helm-dabbrev exit after -first insertion. - -IOW keep `helm-dabbrev-candidates-number-limit' to a reasonable -value (I don't!) and give enough prefix before completing e.g. for -completing \"helm-dabbrev\" use \"helm-d\" and not \"he\" if you want -to use this." - :group 'helm-dabbrev - :type 'boolean) - -(defvaralias 'helm-dabbrev--regexp 'helm-dabbrev-separator-regexp) -(make-obsolete-variable 'helm-dabbrev--regexp - 'helm-dabbrev-separator-regexp "2.8.3") -;; Check for beginning of line should happen last (^\n\\|^). -(defvar helm-dabbrev-separator-regexp - "\\s-\\|\t\\|[(\\[\\{\"'`=<$;,@.#+]\\|\\s\\\\|^\n\\|^" - "Regexp matching the start of a dabbrev candidate.") - - -(defvar helm-dabbrev-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-/") 'helm-next-line) - (define-key map (kbd "M-:") 'helm-previous-line) - map)) - -;; Internal -(defvar helm-dabbrev--cache nil) -(defvar helm-dabbrev--data nil) -(cl-defstruct helm-dabbrev-info dabbrev limits iterator) -(defvar helm-dabbrev--already-tried nil) -(defvar helm-dabbrev--current-thread nil) - - -(defun helm-dabbrev--buffer-list () - (cl-loop for buf in (buffer-list) - unless (cl-loop for r in helm-dabbrev-ignored-buffers-regexps - thereis (string-match r (buffer-name buf))) - collect buf)) - -(defun helm-dabbrev--same-major-mode-p (start-buffer) - "Decide if current-buffer is related to START-BUFFER." - (helm-same-major-mode-p start-buffer helm-dabbrev-major-mode-assoc)) - -(defun helm-dabbrev--collect (str limit ignore-case all) - (let* ((case-fold-search ignore-case) - (buffer1 (current-buffer)) ; start buffer. - (minibuf (minibufferp buffer1)) - result pos-before pos-after - (search-and-store - (lambda (pattern direction) - (while (and (<= (length result) limit) - (cl-case direction - (1 (search-forward pattern nil t)) - (-1 (search-backward pattern nil t)) - (2 (let ((pos - (save-excursion - (forward-line - helm-dabbrev-lineno-around) - (point)))) - (setq pos-after pos) - (search-forward pattern pos t))) - (-2 (let ((pos - (save-excursion - (forward-line - (- helm-dabbrev-lineno-around)) - (point)))) - (setq pos-before pos) - (search-backward pattern pos t))))) - (let* ((pbeg (match-beginning 0)) - (replace-regexp (concat "\\(" helm-dabbrev-separator-regexp - "\\)\\'")) - (match-word (helm-dabbrev--search - pattern pbeg replace-regexp))) - (when (and match-word (not (member match-word result))) - (push match-word result))))))) - (catch 'break - (dolist (buf (if all (helm-dabbrev--buffer-list) - (list (current-buffer)))) - (with-current-buffer buf - (when (or minibuf ; check against all buffers when in minibuffer. - (if helm-dabbrev-related-buffer-fn - (funcall helm-dabbrev-related-buffer-fn buffer1) - t)) - (save-excursion - ;; Start searching before thing before point. - (goto-char (- (point) (length str))) - ;; Search the last 30 lines before point. - (funcall search-and-store str -2)) ; store pos [1] - (save-excursion - ;; Search the next 30 lines after point. - (funcall search-and-store str 2)) ; store pos [2] - (save-excursion - ;; Search all before point. - ;; If limit is reached in previous call of - ;; search-and-store pos-before is never set and - ;; goto-char will fail, so check it. - (when pos-before - (goto-char pos-before) ; start from [1] - (funcall search-and-store str -1))) - (save-excursion - ;; Search all after point. - ;; Same comment as above for pos-after. - (when pos-after - (goto-char pos-after) ; start from [2] - (funcall search-and-store str 1))))) - (when (>= (length result) limit) (throw 'break nil)))) - (nreverse result))) - -(defun helm-dabbrev--search (pattern beg sep-regexp) - "Search word or symbol at point matching PATTERN. -Argument BEG is corresponding to the previous match-beginning search. -The search starts at (1- BEG) with a regexp starting with -`helm-dabbrev-separator-regexp' followed by PATTERN followed by a -regexp matching syntactically any word or symbol. -The possible false positives matching SEP-REGEXP at end are finally -removed." - (let ((eol (point-at-eol))) - (save-excursion - (goto-char (1- beg)) - (when (re-search-forward - (concat "\\(" - helm-dabbrev-separator-regexp - "\\)" - "\\(?99:\\(" - (regexp-quote pattern) - "\\(\\sw\\|\\s_\\)+\\)\\)") - eol t) - (replace-regexp-in-string - sep-regexp "" - (match-string-no-properties 99)))))) - -(defun helm-dabbrev--get-candidates (dabbrev &optional limit) - (cl-assert dabbrev nil "[No Match]") - (helm-dabbrev--collect - dabbrev (or limit helm-dabbrev-candidates-number-limit) - (cl-case helm-dabbrev-case-fold-search - (smart (helm-set-case-fold-search-1 dabbrev)) - (t helm-dabbrev-case-fold-search)) - helm-dabbrev-always-search-all)) - -(defun helm-dabbrev-default-action (candidate) - (with-helm-current-buffer - (let* ((limits (helm-bounds-of-thing-before-point - helm-dabbrev-separator-regexp)) - (beg (car limits)) - (end (point))) - (run-with-timer - 0.01 nil - 'helm-insert-completion-at-point - beg end candidate)))) - -;;;###autoload -(cl-defun helm-dabbrev () - "Preconfigured helm for dynamic abbreviations." - (interactive) - (let ((dabbrev (helm-thing-before-point - nil helm-dabbrev-separator-regexp)) - (limits (helm-bounds-of-thing-before-point - helm-dabbrev-separator-regexp)) - (enable-recursive-minibuffers t) - (cycling-disabled-p (or (null helm-dabbrev-cycle-threshold) - (zerop helm-dabbrev-cycle-threshold))) - (helm-execute-action-at-once-if-one t) - (helm-quit-if-no-candidate - (lambda () - (message "[Helm-dabbrev: No expansion found]")))) - (cl-assert (and (stringp dabbrev) (not (string= dabbrev ""))) - nil "[Helm-dabbrev: Nothing found before point]") - (when (and - ;; have been called at least once. - (helm-dabbrev-info-p helm-dabbrev--data) - ;; But user have moved with some other command - ;; in the meaning time. - (not (eq last-command 'helm-dabbrev))) - (setq helm-dabbrev--data nil)) - ;; When candidates are requested in helm directly without cycling, - ;; we need them right now before running helm, so no need to use a - ;; thread here. - (when cycling-disabled-p - (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev))) - (unless (or cycling-disabled-p - (helm-dabbrev-info-p helm-dabbrev--data)) - (setq helm-dabbrev--data - (make-helm-dabbrev-info - :dabbrev dabbrev - :limits limits - :iterator - (helm-iter-list - (cl-loop for i in (helm-dabbrev--get-candidates - dabbrev helm-dabbrev-cycle-threshold) - when (string-match-p - (concat "^" (regexp-quote dabbrev)) i) - collect i)))) - ;; Thread is released as soon as helm-dabbrev exits after first - ;; insertion so this is unusable for now, keep it like this for - ;; now hooping the situation with threads will be improved in - ;; emacs. The idea is to compute whole list of candidates in - ;; background while cycling with the first - ;; helm-dabbrev-cycle-threshold ones. - (when (and (fboundp 'make-thread) helm-dabbrev-use-thread) - (setq helm-dabbrev--current-thread - (make-thread - (lambda () - (setq helm-dabbrev--cache - (helm-dabbrev--get-candidates dabbrev))))))) - (let ((iter (and (helm-dabbrev-info-p helm-dabbrev--data) - (helm-dabbrev-info-iterator helm-dabbrev--data))) - deactivate-mark) - ;; Cycle until iterator is consumed. - (helm-aif (and iter (helm-iter-next iter)) - (progn - (helm-insert-completion-at-point - (car (helm-dabbrev-info-limits helm-dabbrev--data)) - ;; END is the end of the previous inserted string, not - ;; the end (apart for first insertion) of the initial string. - (cdr limits) it) - ;; Move already tried candidates to end of list. - (push it helm-dabbrev--already-tried)) - ;; Iterator is now empty, reset dabbrev to initial value - ;; and start helm completion. - (let* ((old-dabbrev (if (helm-dabbrev-info-p helm-dabbrev--data) - (helm-dabbrev-info-dabbrev helm-dabbrev--data) - dabbrev)) - (only-one (null (cdr (all-completions - old-dabbrev - helm-dabbrev--already-tried))))) - (unless helm-dabbrev-use-thread - (message "Waiting for helm-dabbrev candidates...") - (setq helm-dabbrev--cache - (helm-dabbrev--get-candidates old-dabbrev))) - ;; If the length of candidates is only one when computed - ;; that's mean the unique matched item have already been - ;; inserted by the iterator, so no need to reinsert the old dabbrev, - ;; just let helm exiting with "No expansion found". - (unless (or only-one cycling-disabled-p) - (setq dabbrev old-dabbrev - limits (helm-dabbrev-info-limits helm-dabbrev--data)) - (setq helm-dabbrev--data nil) - (delete-region (car limits) (point)) - (insert dabbrev)) - ;; Cycling is finished, block until helm-dabbrev--cache have - ;; finished to complete. - (when (and (fboundp 'thread-join) - helm-dabbrev-use-thread - (thread-alive-p helm-dabbrev--current-thread)) - (thread-join helm-dabbrev--current-thread)) - (when (and (null cycling-disabled-p) only-one) - (cl-return-from helm-dabbrev - (message "[Helm-dabbrev: No expansion found]"))) - (with-helm-show-completion (car limits) (cdr limits) - (unwind-protect - (helm :sources - (helm-build-in-buffer-source "Dabbrev Expand" - :data - (cl-loop for cand in helm-dabbrev--cache - unless - (member cand helm-dabbrev--already-tried) - collect cand into lst - finally return - (append lst helm-dabbrev--already-tried)) - :persistent-action 'ignore - :persistent-help "DoNothing" - :keymap helm-dabbrev-map - :action 'helm-dabbrev-default-action - :group 'helm-dabbrev) - :buffer "*helm dabbrev*" - :input (concat "^" dabbrev " ") - :resume 'noresume - :allow-nest t) - (setq helm-dabbrev--already-tried nil)))))))) - -(provide 'helm-dabbrev) - -;; Local Variables: -;; byte-compile-warnings: (not obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-dabbrev.el ends here diff --git a/elpa/helm-20191101.641/helm-pkg.el b/elpa/helm-20191101.641/helm-pkg.el deleted file mode 100644 index d9a664cc..00000000 --- a/elpa/helm-20191101.641/helm-pkg.el +++ /dev/null @@ -1,9 +0,0 @@ -(define-package "helm" "20191101.641" "Helm is an Emacs incremental and narrowing framework" - '((emacs "24.4") - (async "1.9.3") - (popup "0.5.3") - (helm-core "3.0")) - :url "https://emacs-helm.github.io/helm/") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/helm-20210131.1946/.dir-locals.el b/elpa/helm-20210131.1946/.dir-locals.el new file mode 100644 index 00000000..204ad156 --- /dev/null +++ b/elpa/helm-20210131.1946/.dir-locals.el @@ -0,0 +1,6 @@ +;;; Directory Local Variables +;;; For more information see (info "(emacs) Directory Variables") + +((nil . ((bug-reference-bug-regexp . "\\([Ii]ssue ?#?\\|[Bb]ug ?#?\\|[Pp]atch ?#\\|RFE ?#\\|PR [a-z+-]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)") + (bug-reference-url-format . "https://github.com/emacs-helm/helm/issues/%s"))) + (emacs-lisp-mode . ((mode . bug-reference-prog)))) diff --git a/elpa/helm-20191101.641/emacs-helm.sh b/elpa/helm-20210131.1946/emacs-helm.sh similarity index 78% rename from elpa/helm-20191101.641/emacs-helm.sh rename to elpa/helm-20210131.1946/emacs-helm.sh index 848a72c6..9c41716d 100755 --- a/elpa/helm-20191101.641/emacs-helm.sh +++ b/elpa/helm-20210131.1946/emacs-helm.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh -## Copyright (C) 2012 ~ 2019 Thierry Volpiatto +## Copyright (C) 2012 ~ 2020 Thierry Volpiatto ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -139,7 +139,7 @@ cd "${0%/*}" || exit 1 # Check if autoload file exists. # It may be in a different directory if emacs-helm.sh is a symlink. -TRUENAME=$(find . -samefile "$0" -printf "%l") +TRUENAME=$(ls -l "$0" | awk '{print $11}') if [ ! -z "$TRUENAME" ]; then AUTO_FILE="${TRUENAME%/*}/helm-autoloads.el" else @@ -175,27 +175,57 @@ cat > $CONF_FILE < $TOOLBARS 0) (setq default-frame-alist '((vertical-scroll-bars . nil) (tool-bar-lines . 0) diff --git a/elpa/helm-20191101.641/helm-adaptive.el b/elpa/helm-20210131.1946/helm-adaptive.el similarity index 95% rename from elpa/helm-20191101.641/helm-adaptive.el rename to elpa/helm-20210131.1946/helm-adaptive.el index 13b6f638..83b1da55 100644 --- a/elpa/helm-20191101.641/helm-adaptive.el +++ b/elpa/helm-20210131.1946/helm-adaptive.el @@ -3,7 +3,7 @@ ;; Original Author: Tamas Patrovics ;; Copyright (C) 2007 Tamas Patrovics -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -29,11 +29,11 @@ :group 'helm) (defcustom helm-adaptive-history-file - "~/.emacs.d/helm-adaptive-history" + (locate-user-emacs-file "helm-adaptive-history") "Path of file where history information is stored. -When nil history is not saved nor restored after emacs restart unless -you save/restore `helm-adaptive-history' with something else like -psession or desktop." +When nil history is not saved nor restored after Emacs restart +unless you save/restore `helm-adaptive-history' with something +else like psession or desktop." :type 'string :group 'helm-adapt) @@ -48,8 +48,8 @@ psession or desktop." When nil sort on frequency usage only. Only frequency: -When candidate have low frequency, you have to hit on it many times to -make it going up on top. +When candidate have low frequency, you have to hit on it many +times to make it going up on top. Frequency+recent: Even with a low frequency, candidate go up on top. If a candidate @@ -172,7 +172,7 @@ Returns nil if `helm-adaptive-history-file' doesn't exist." (load-file helm-adaptive-history-file))) (defun helm-adaptive-save-history (&optional arg) - "Save history information to file given by `helm-adaptive-history-file'." + "Save history information to the file given by `helm-adaptive-history-file'." (interactive "p") (when helm-adaptive-history-file (with-temp-buffer @@ -253,7 +253,8 @@ you should reinitialize it with `helm-reset-adaptive-history'" ;;;###autoload (defun helm-reset-adaptive-history () "Delete all `helm-adaptive-history' and his file. -Useful when you have a old or corrupted `helm-adaptive-history-file'." +Useful when you have a old or corrupted +`helm-adaptive-history-file'." (interactive) (when (y-or-n-p "Really delete all your `helm-adaptive-history'? ") (setq helm-adaptive-history nil) @@ -262,7 +263,8 @@ Useful when you have a old or corrupted `helm-adaptive-history-file'." (defun helm-adaptive-compare (x y) "Compare display parts if some of candidates X and Y. -Arguments X and Y are cons cell in (DISPLAY . REAL) format or atoms." +Arguments X and Y are cons cell in (DISPLAY . REAL) format or +atoms." (equal (if (listp x) (car x) x) (if (listp y) (car y) y))) diff --git a/elpa/helm-20191101.641/helm-autoloads.el b/elpa/helm-20210131.1946/helm-autoloads.el similarity index 74% rename from elpa/helm-20191101.641/helm-autoloads.el rename to elpa/helm-20210131.1946/helm-autoloads.el index 200a923b..91513aab 100644 --- a/elpa/helm-20191101.641/helm-autoloads.el +++ b/elpa/helm-20210131.1946/helm-autoloads.el @@ -22,13 +22,17 @@ or call the function `helm-adaptive-mode'.") (autoload 'helm-adaptive-mode "helm-adaptive" "\ Toggle adaptive sorting in all sources. +If called interactively, enable Helm-Adaptive mode if ARG is +positive, and disable it if ARG is zero or negative. If called +from Lisp, also enable the mode if ARG is omitted or nil, and +toggle it if ARG is `toggle'; disable the mode otherwise. + \(fn &optional ARG)" t nil) (autoload 'helm-reset-adaptive-history "helm-adaptive" "\ Delete all `helm-adaptive-history' and his file. -Useful when you have a old or corrupted `helm-adaptive-history-file'. - -\(fn)" t nil) +Useful when you have a old or corrupted +`helm-adaptive-history-file'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-adaptive" '("helm-adapt"))) @@ -38,18 +42,14 @@ Useful when you have a old or corrupted `helm-adaptive-history-file'. ;;; Generated autoloads from helm-bookmark.el (autoload 'helm-bookmarks "helm-bookmark" "\ -Preconfigured `helm' for bookmarks. - -\(fn)" t nil) +Preconfigured `helm' for bookmarks." t nil) (autoload 'helm-filtered-bookmarks "helm-bookmark" "\ -Preconfigured helm for bookmarks (filtered by category). -Optional source `helm-source-bookmark-addressbook' is loaded -only if external addressbook-bookmark package is installed. - -\(fn)" t nil) +Preconfigured `helm' for bookmarks (filtered by category). +Optional source `helm-source-bookmark-addressbook' is loaded only +if external addressbook-bookmark package is installed." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-bookmark" '("helm-" "bmkext-jump-" "bookmark"))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-bookmark" '("bmkext-jump-" "bookmark" "helm-"))) ;;;*** @@ -57,14 +57,10 @@ only if external addressbook-bookmark package is installed. ;;; Generated autoloads from helm-buffers.el (autoload 'helm-buffers-list "helm-buffers" "\ -Preconfigured `helm' to list buffers. - -\(fn)" t nil) +Preconfigured `helm' to list buffers." t nil) (autoload 'helm-mini "helm-buffers" "\ -Preconfigured `helm' displaying `helm-mini-default-sources'. - -\(fn)" t nil) +Preconfigured `helm' displaying `helm-mini-default-sources'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-buffers" '("helm-"))) @@ -74,9 +70,7 @@ Preconfigured `helm' displaying `helm-mini-default-sources'. ;;; Generated autoloads from helm-color.el (autoload 'helm-colors "helm-color" "\ -Preconfigured `helm' for color. - -\(fn)" t nil) +Preconfigured `helm' for color." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-color" '("helm-"))) @@ -86,19 +80,13 @@ Preconfigured `helm' for color. ;;; Generated autoloads from helm-comint.el (autoload 'helm-comint-prompts "helm-comint" "\ -Pre-configured `helm' to browse the prompts of the current comint buffer. - -\(fn)" t nil) +Pre-configured `helm' to browse the prompts of the current comint buffer." t nil) (autoload 'helm-comint-prompts-all "helm-comint" "\ -Pre-configured `helm' to browse the prompts of all comint sessions. - -\(fn)" t nil) +Pre-configured `helm' to browse the prompts of all comint sessions." t nil) (autoload 'helm-comint-input-ring "helm-comint" "\ -Preconfigured `helm' that provide completion of `comint' history. - -\(fn)" t nil) +Preconfigured `helm' that provide completion of `comint' history." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-comint" '("helm-"))) @@ -109,40 +97,28 @@ Preconfigured `helm' that provide completion of `comint' history. (autoload 'helm-M-x "helm-command" "\ Preconfigured `helm' for Emacs commands. -It is `helm' replacement of regular `M-x' `execute-extended-command'. +It is `helm' replacement of regular `M-x' +`execute-extended-command'. -Unlike regular `M-x' emacs vanilla `execute-extended-command' command, -the prefix args if needed, can be passed AFTER starting `helm-M-x'. -When a prefix arg is passed BEFORE starting `helm-M-x', the first `C-u' -while in `helm-M-x' session will disable it. +Unlike regular `M-x' Emacs vanilla `execute-extended-command' +command, the prefix args if needed, can be passed AFTER starting +`helm-M-x'. When a prefix arg is passed BEFORE starting +`helm-M-x', the first `C-u' while in `helm-M-x' session will +disable it. You can get help on each command by persistent action. -\(fn ARG &optional COMMAND-NAME)" t nil) +\(fn ARG)" t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-command" '("helm-"))) -;;;*** - -;;;### (autoloads nil "helm-config" "helm-config.el" (0 0 0 0)) -;;; Generated autoloads from helm-config.el - -(autoload 'helm-configuration "helm-config" "\ -Customize `helm'. - -\(fn)" t nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-config" '("helm-"))) - ;;;*** ;;;### (autoloads nil "helm-dabbrev" "helm-dabbrev.el" (0 0 0 0)) ;;; Generated autoloads from helm-dabbrev.el (autoload 'helm-dabbrev "helm-dabbrev" "\ -Preconfigured helm for dynamic abbreviations. - -\(fn)" t nil) +Preconfigured helm for dynamic abbreviations." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-dabbrev" '("helm-dabbrev-"))) @@ -152,52 +128,38 @@ Preconfigured helm for dynamic abbreviations. ;;; Generated autoloads from helm-elisp.el (autoload 'helm-lisp-completion-at-point "helm-elisp" "\ -Preconfigured helm for lisp symbol completion at point. - -\(fn)" t nil) +Preconfigured Helm for Lisp symbol completion at point." t nil) (autoload 'helm-complete-file-name-at-point "helm-elisp" "\ -Preconfigured helm to complete file name at point. +Preconfigured Helm to complete file name at point. \(fn &optional FORCE)" t nil) -(autoload 'helm-lisp-indent "helm-elisp" "\ - - -\(fn)" t nil) +(autoload 'helm-lisp-indent "helm-elisp" nil t nil) (autoload 'helm-lisp-completion-or-file-name-at-point "helm-elisp" "\ -Preconfigured helm to complete lisp symbol or filename at point. -Filename completion happen if string start after or between a double quote. - -\(fn)" t nil) +Preconfigured Helm to complete Lisp symbol or filename at point. +Filename completion happens if string start after or between a +double quote." t nil) (autoload 'helm-apropos "helm-elisp" "\ -Preconfigured helm to describe commands, functions, variables and faces. -In non interactives calls DEFAULT argument should be provided as a string, -i.e the `symbol-name' of any existing symbol. +Preconfigured Helm to describe commands, functions, variables and faces. +In non interactives calls DEFAULT argument should be provided as +a string, i.e. the `symbol-name' of any existing symbol. \(fn DEFAULT)" t nil) (autoload 'helm-manage-advice "helm-elisp" "\ -Preconfigured `helm' to disable/enable function advices. - -\(fn)" t nil) +Preconfigured `helm' to disable/enable function advices." t nil) (autoload 'helm-locate-library "helm-elisp" "\ -Preconfigured helm to locate elisp libraries. - -\(fn)" t nil) +Preconfigured helm to locate elisp libraries." t nil) (autoload 'helm-timers "helm-elisp" "\ -Preconfigured `helm' for timers. - -\(fn)" t nil) +Preconfigured `helm' for timers." t nil) (autoload 'helm-complex-command-history "helm-elisp" "\ -Preconfigured helm for complex command history. - -\(fn)" t nil) +Preconfigured `helm' for complex command history." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-elisp" '("helm-" "with-helm-show-completion"))) @@ -208,44 +170,68 @@ Preconfigured helm for complex command history. ;;; Generated autoloads from helm-elisp-package.el (autoload 'helm-list-elisp-packages "helm-elisp-package" "\ -Preconfigured helm for listing and handling emacs packages. +Preconfigured `helm' for listing and handling Emacs packages. \(fn ARG)" t nil) (autoload 'helm-list-elisp-packages-no-fetch "helm-elisp-package" "\ -Preconfigured helm for emacs packages. +Preconfigured Helm for Emacs packages. -Same as `helm-list-elisp-packages' but don't fetch packages on remote. -Called with a prefix ARG always fetch packages on remote. +Same as `helm-list-elisp-packages' but don't fetch packages on +remote. Called with a prefix ARG always fetch packages on +remote. \(fn ARG)" t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-elisp-package" '("helm-"))) +;;;*** + +;;;### (autoloads nil "helm-epa" "helm-epa.el" (0 0 0 0)) +;;; Generated autoloads from helm-epa.el + +(defvar helm-epa-mode nil "\ +Non-nil if Helm-Epa mode is enabled. +See the `helm-epa-mode' command +for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `helm-epa-mode'.") + +(custom-autoload 'helm-epa-mode "helm-epa" nil) + +(autoload 'helm-epa-mode "helm-epa" "\ +Enable helm completion on gpg keys in epa functions. + +If called interactively, enable Helm-Epa mode if ARG is positive, +and disable it if ARG is zero or negative. If called from Lisp, +also enable the mode if ARG is omitted or nil, and toggle it if +ARG is `toggle'; disable the mode otherwise. + +\(fn &optional ARG)" t nil) + +(autoload 'helm-epa-list-keys "helm-epa" "\ +List all gpg keys. +This is the helm interface for `epa-list-keys'." t nil) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-epa" '("helm-epa"))) + ;;;*** ;;;### (autoloads nil "helm-eshell" "helm-eshell.el" (0 0 0 0)) ;;; Generated autoloads from helm-eshell.el (autoload 'helm-esh-pcomplete "helm-eshell" "\ -Preconfigured helm to provide helm completion in eshell. - -\(fn)" t nil) +Preconfigured `helm' to provide Helm completion in Eshell." t nil) (autoload 'helm-eshell-history "helm-eshell" "\ -Preconfigured helm for eshell history. - -\(fn)" t nil) +Preconfigured Helm for Eshell history." t nil) (autoload 'helm-eshell-prompts "helm-eshell" "\ -Pre-configured `helm' to browse the prompts of the current Eshell. - -\(fn)" t nil) +Pre-configured `helm' to browse the prompts of the current Eshell." t nil) (autoload 'helm-eshell-prompts-all "helm-eshell" "\ -Pre-configured `helm' to browse the prompts of all Eshell sessions. - -\(fn)" t nil) +Pre-configured `helm' to browse the prompts of all Eshell sessions." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-eshell" '("helm-e"))) @@ -255,19 +241,15 @@ Pre-configured `helm' to browse the prompts of all Eshell sessions. ;;; Generated autoloads from helm-eval.el (autoload 'helm-eval-expression "helm-eval" "\ -Preconfigured helm for `helm-source-evaluation-result'. +Preconfigured `helm' for `helm-source-evaluation-result'. \(fn ARG)" t nil) (autoload 'helm-eval-expression-with-eldoc "helm-eval" "\ -Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support. - -\(fn)" t nil) +Preconfigured `helm' for `helm-source-evaluation-result' with `eldoc' support." t nil) (autoload 'helm-calcul-expression "helm-eval" "\ -Preconfigured helm for `helm-source-calculation-result'. - -\(fn)" t nil) +Preconfigured `helm' for `helm-source-calculation-result'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-eval" '("helm-"))) @@ -286,6 +268,13 @@ You can set your own list of commands with (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-external" '("helm-"))) +;;;*** + +;;;### (autoloads nil "helm-fd" "helm-fd.el" (0 0 0 0)) +;;; Generated autoloads from helm-fd.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-fd" '("helm-fd-"))) + ;;;*** ;;;### (autoloads nil "helm-files" "helm-files.el" (0 0 0 0)) @@ -298,15 +287,16 @@ You can set your own list of commands with (autoload 'helm-browse-project "helm-files" "\ Preconfigured helm to browse projects. -Browse files and see status of project with its vcs. +Browse files and see status of project with its VCS. Only HG and GIT are supported for now. -Fall back to `helm-browse-project-find-files' -if current directory is not under control of one of those vcs. +Fall back to `helm-browse-project-find-files' if current +directory is not under control of one of those VCS. With a prefix ARG browse files recursively, with two prefix ARG rebuild the cache. If the current directory is found in the cache, start `helm-browse-project-find-files' even with no prefix ARG. -NOTE: The prefix ARG have no effect on the VCS controlled directories. +NOTE: The prefix ARG have no effect on the VCS controlled +directories. Needed dependencies for VCS: @@ -319,21 +309,21 @@ and Preconfigured `helm' for helm implementation of `find-file'. Called with a prefix arg show history if some. 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. +This is the starting point for nearly all actions you can do on +files. \(fn ARG)" t nil) (autoload 'helm-delete-tramp-connection "helm-files" "\ Allow deleting tramp connection or marked tramp connections at once. -This replace `tramp-cleanup-connection' which is partially broken in -emacs < to 25.1.50.1 (See Emacs Bug#24432). - -It allows additionally to delete more than one connection at once. +This replace `tramp-cleanup-connection' which is partially broken +in Emacs < to 25.1.50.1 (See Emacs Bug#24432). -\(fn)" t nil) +It allows additionally to delete more than one connection at +once." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-files" '("helm-" "eshell-command-aliases-list"))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-files" '("eshell-command-aliases-list" "helm-"))) ;;;*** @@ -368,12 +358,10 @@ are passed to \"find\" literally. ;;; Generated autoloads from helm-font.el (autoload 'helm-select-xfont "helm-font" "\ -Preconfigured `helm' to select Xfont. - -\(fn)" t nil) +Preconfigured `helm' to select Xfont." t nil) (autoload 'helm-ucs "helm-font" "\ -Preconfigured helm for `ucs-names'. +Preconfigured `helm' for `ucs-names'. Called with a prefix arg force reloading cache. @@ -389,50 +377,49 @@ Called with a prefix arg force reloading cache. (autoload 'helm-for-files "helm-for-files" "\ Preconfigured `helm' for opening files. -Run all sources defined in `helm-for-files-preferred-list'. - -\(fn)" t nil) +Run all sources defined in `helm-for-files-preferred-list'." t nil) (autoload 'helm-multi-files "helm-for-files" "\ Preconfigured helm like `helm-for-files' but running locate only on demand. Allow toggling back and forth from locate to others sources with `helm-multi-files-toggle-locate-binding' key. -This avoid launching needlessly locate when what you search is already -found. - -\(fn)" t nil) +This avoids launching locate needlessly when what you are +searching for is already found." t nil) (autoload 'helm-recentf "helm-for-files" "\ -Preconfigured `helm' for `recentf'. - -\(fn)" t nil) +Preconfigured `helm' for `recentf'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-for-files" '("helm-"))) +;;;*** + +;;;### (autoloads nil "helm-global-bindings" "helm-global-bindings.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from helm-global-bindings.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-global-bindings" '("helm-"))) + ;;;*** ;;;### (autoloads nil "helm-grep" "helm-grep.el" (0 0 0 0)) ;;; Generated autoloads from helm-grep.el (autoload 'helm-goto-precedent-file "helm-grep" "\ -Go to precedent file in helm grep/etags buffers. - -\(fn)" t nil) +Go to previous file in Helm grep/etags buffers." t nil) (autoload 'helm-goto-next-file "helm-grep" "\ -Go to precedent file in helm grep/etags buffers. - -\(fn)" t nil) +Go to previous file in Helm grep/etags buffers." t nil) (autoload 'helm-do-grep-ag "helm-grep" "\ -Preconfigured helm for grepping with AG in `default-directory'. -With prefix-arg prompt for type if available with your AG version. +Preconfigured `helm' for grepping with AG in `default-directory'. +With prefix arg prompt for type if available with your AG +version. \(fn ARG)" t nil) (autoload 'helm-grep-do-git-grep "helm-grep" "\ -Preconfigured helm for git-grepping `default-directory'. +Preconfigured `helm' for git-grepping `default-directory'. With a prefix arg ARG git-grep the whole repository. \(fn ARG)" t nil) @@ -445,12 +432,10 @@ With a prefix arg ARG git-grep the whole repository. ;;; Generated autoloads from helm-help.el (autoload 'helm-documentation "helm-help" "\ -Preconfigured Helm for Helm documentation. +Preconfigured `helm' for Helm documentation. With a prefix arg refresh the documentation. -Find here the documentation of all documented sources. - -\(fn)" t nil) +Find here the documentation of all documented sources." t nil) (defvar helm-comp-read-mode-line "\\C/\\[helm-cr-empty-string]:Empty \\\\[helm-help]:Help \\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend \\[helm-customize-group]:Conf") @@ -467,13 +452,11 @@ String displayed in mode-line in `helm-source-find-files'.") ;;; Generated autoloads from helm-id-utils.el (autoload 'helm-gid "helm-id-utils" "\ -Preconfigured helm for `gid' command line of `ID-Utils'. -Need A database created with the command `mkid' -above `default-directory'. -Need id-utils as dependency which provide `mkid', `gid' etc... -See . - -\(fn)" t nil) +Preconfigured `helm' for `gid' command line of `ID-Utils'. +Need A database created with the command `mkid' above +`default-directory'. +Need id-utils as dependency which provide `mkid', `gid' etc.. +See ." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-id-utils" '("helm-gid-"))) @@ -483,16 +466,13 @@ See . ;;; Generated autoloads from helm-imenu.el (autoload 'helm-imenu "helm-imenu" "\ -Preconfigured `helm' for `imenu'. - -\(fn)" t nil) +Preconfigured `helm' for `imenu'." t nil) (autoload 'helm-imenu-in-all-buffers "helm-imenu" "\ -Preconfigured helm for fetching imenu entries in all buffers with similar mode as current. -A mode is similar as current if it is the same, it is derived i.e `derived-mode-p' -or it have an association in `helm-imenu-all-buffer-assoc'. - -\(fn)" t nil) +Preconfigured `helm' for fetching imenu entries in all buffers with similar mode as current. +A mode is similar as current if it is the same, it is derived +i.e. `derived-mode-p' or it have an association in +`helm-imenu-all-buffer-assoc'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-imenu" '("helm-"))) @@ -504,12 +484,13 @@ or it have an association in `helm-imenu-all-buffer-assoc'. (autoload 'helm-info "helm-info" "\ Preconfigured `helm' for searching Info files' indices. -With a prefix argument \\[universal-argument], set REFRESH to non-nil. +With a prefix argument \\[universal-argument], set REFRESH to +non-nil. -Optional parameter REFRESH, when non-nil, reevaluates +Optional parameter REFRESH, when non-nil, re-evaluates `helm-default-info-index-list'. If the variable has been customized, set it to its saved value. If not, set it to its -standard value. See `custom-reevaluate-setting' for more. +standard value. See `custom-reevaluate-setting' for more. REFRESH is useful when new Info files are installed. If `helm-default-info-index-list' has not been customized, the new @@ -518,9 +499,7 @@ Info files are made available. \(fn &optional REFRESH)" t nil) (autoload 'helm-info-at-point "helm-info" "\ -Preconfigured `helm' for searching info at point. - -\(fn)" t nil) +Preconfigured `helm' for searching info at point." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-info" '("helm-"))) @@ -541,8 +520,8 @@ Note: you can add locate options after entering pattern. See 'man locate' for valid options and also `helm-locate-command'. You can specify a local database with prefix argument ARG. -With two prefix arg, refresh the current local db or create it -if it doesn't exists. +With two prefix arg, refresh the current local db or create it if +it doesn't exists. To create a user specific db, use \"updatedb -l 0 -o db_path -U directory\". @@ -573,29 +552,19 @@ With a prefix arg reinitialize the cache. (autoload 'helm-world-time "helm-misc" "\ Preconfigured `helm' to show world time. -Default action change TZ environment variable locally to emacs. - -\(fn)" t nil) +Default action change TZ environment variable locally to emacs." t nil) (autoload 'helm-insert-latex-math "helm-misc" "\ -Preconfigured helm for latex math symbols completion. - -\(fn)" t nil) +Preconfigured helm for latex math symbols completion." t nil) (autoload 'helm-ratpoison-commands "helm-misc" "\ -Preconfigured `helm' to execute ratpoison commands. - -\(fn)" t nil) +Preconfigured `helm' to execute ratpoison commands." t nil) (autoload 'helm-stumpwm-commands "helm-misc" "\ -Preconfigured helm for stumpwm commands. - -\(fn)" t nil) +Preconfigured helm for stumpwm commands." t nil) (autoload 'helm-minibuffer-history "helm-misc" "\ -Preconfigured `helm' for `minibuffer-history'. - -\(fn)" t nil) +Preconfigured `helm' for `minibuffer-history'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-misc" '("helm-"))) @@ -641,7 +610,7 @@ Keys description: When it is non--nil, all elements of HISTORY are displayed in a special source before COLLECTION. -- INPUT-HISTORY: A symbol. the minibuffer input history will be +- INPUT-HISTORY: A symbol. The minibuffer input history will be stored there, if nil or not provided, `minibuffer-history' will be used instead. @@ -670,7 +639,7 @@ Keys description: - VOLATILE: Use volatile attribute. - SORT: A predicate to give to `sort' e.g `string-lessp' - Use this only on small data as it is ineficient. + Use this only on small data as it is inefficient. If you want to sort faster add a sort function to FC-TRANSFORMER. Note that FUZZY when enabled is already providing a sort function. @@ -695,22 +664,24 @@ Keys description: See match-part documentation in `helm-source'. - MATCH-DYNAMIC: See match-dynamic in `helm-source-sync' - It have no effect when used with CANDIDATES-IN-BUFFER. + It has no effect when used with CANDIDATES-IN-BUFFER. - ALLOW-NEST: Allow nesting this `helm-comp-read' in a helm session. See `helm'. - MULTILINE: See multiline in `helm-source'. +- COERCE: See coerce in `helm-source'. + - GROUP: See group in `helm-source'. 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 `helm-comp-read' See `helm-M-x' for example. +That means you can pass prefix args before or after calling a command +that use `helm-comp-read'. See `helm-M-x' for example. -\(fn PROMPT COLLECTION &key TEST INITIAL-INPUT DEFAULT PRESELECT (BUFFER \"*Helm Completions*\") MUST-MATCH FUZZY REVERSE-HISTORY (REQUIRES-PATTERN 0) HISTORY INPUT-HISTORY (CASE-FOLD helm-comp-read-case-fold-search) (DEL-INPUT t) (PERSISTENT-ACTION nil) (PERSISTENT-HELP \"DoNothing\") (MODE-LINE helm-comp-read-mode-line) HELP-MESSAGE (KEYMAP helm-comp-read-map) (NAME \"Helm Completions\") HEADER-NAME CANDIDATES-IN-BUFFER MATCH-PART MATCH-DYNAMIC EXEC-WHEN-ONLY-ONE QUIT-WHEN-NO-CAND (VOLATILE t) SORT FC-TRANSFORMER HIST-FC-TRANSFORMER MARKED-CANDIDATES NOMARK (ALISTP t) (CANDIDATE-NUMBER-LIMIT helm-candidate-number-limit) MULTILINE ALLOW-NEST (GROUP \\='helm))" nil nil) +\(fn PROMPT COLLECTION &key TEST INITIAL-INPUT DEFAULT PRESELECT (BUFFER \"*Helm Completions*\") MUST-MATCH FUZZY REVERSE-HISTORY (REQUIRES-PATTERN 0) HISTORY INPUT-HISTORY (CASE-FOLD helm-comp-read-case-fold-search) (DEL-INPUT t) (PERSISTENT-ACTION nil) (PERSISTENT-HELP \"DoNothing\") (MODE-LINE helm-comp-read-mode-line) HELP-MESSAGE (KEYMAP helm-comp-read-map) (NAME \"Helm Completions\") HEADER-NAME CANDIDATES-IN-BUFFER MATCH-PART MATCH-DYNAMIC EXEC-WHEN-ONLY-ONE QUIT-WHEN-NO-CAND (VOLATILE t) SORT FC-TRANSFORMER HIST-FC-TRANSFORMER (MARKED-CANDIDATES helm-comp-read-use-marked) NOMARK (ALISTP t) (CANDIDATE-NUMBER-LIMIT helm-candidate-number-limit) MULTILINE ALLOW-NEST COERCE (GROUP \\='helm))" nil nil) (autoload 'helm-read-file-name "helm-mode" "\ Read a file name with helm completion. @@ -722,9 +693,9 @@ Keys description: - NAME: Source name, default to \"Read File Name\". -- INITIAL-INPUT: Where to start read file name, default to `default-directory'. +- INITIAL-INPUT: Where to start reading file name, default to `default-directory'. -- BUFFER: `helm-buffer' name default to \"*Helm Completions*\". +- BUFFER: `helm-buffer' name, defaults to \"*Helm Completions*\". - TEST: A predicate called with one arg 'candidate'. @@ -768,29 +739,20 @@ or call the function `helm-mode'.") (autoload 'helm-mode "helm-mode" "\ Toggle generic helm completion. -All functions in Emacs that use `completing-read' -or `read-file-name' and friends will use helm interface -when this mode is turned on. +All functions in Emacs that use `completing-read', +`read-file-name', `completion-in-region' and friends will use helm +interface when this mode is turned on. However you can modify this behavior for functions of your choice with `helm-completing-read-handlers-alist'. -Also commands using `completion-in-region' will be helmized when -`helm-mode-handle-completion-in-region' is non nil, you can modify -this behavior with `helm-mode-no-completion-in-region-in-modes'. - Called with a positive arg, turn on unconditionally, with a negative arg turn off. -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 `helm-completing-read-handlers-alist' -with a nil value. +You can toggle it with M-x `helm-mode'. About `ido-mode': -When you are using `helm-mode', DO NOT use `ido-mode', instead if you -want some commands use `ido', add these commands to +DO NOT enable `ido-everywhere' when using `helm-mode'. Instead of +using `ido-mode', add the commands where you want to use ido to `helm-completing-read-handlers-alist' with `ido' as value. Note: This mode is incompatible with Emacs23. @@ -805,27 +767,27 @@ Note: This mode is incompatible with Emacs23. ;;; Generated autoloads from helm-net.el (autoload 'helm-browse-url-firefox "helm-net" "\ -Same as `browse-url-firefox' but detach from emacs. +Same as `browse-url-firefox' but detach from Emacs. -So when you quit emacs you can keep your firefox session open -and not be prompted to kill firefox process. +So when you quit Emacs you can keep your Firefox session open and +not be prompted to kill the Firefox process. -NOTE: Probably not supported on some systems (e.g Windows). +NOTE: Probably not supported on some systems (e.g., Windows). \(fn URL &optional IGNORE)" t nil) (autoload 'helm-browse-url-opera "helm-net" "\ -Browse URL with opera browser and detach from emacs. +Browse URL with Opera browser and detach from Emacs. -So when you quit emacs you can keep your opera session open -and not be prompted to kill opera process. +So when you quit Emacs you can keep your Opera session open and +not be prompted to kill the Opera process. -NOTE: Probably not supported on some systems (e.g Windows). +NOTE: Probably not supported on some systems (e.g., Windows). \(fn URL &optional IGNORE)" t nil) (autoload 'helm-browse-url-chromium "helm-net" "\ -Browse URL with google chrome browser. +Browse URL with Google Chrome browser. \(fn URL &optional IGNORE)" t nil) @@ -839,15 +801,18 @@ Browse URL with conkeror browser. \(fn URL &optional IGNORE)" t nil) +(autoload 'helm-browse-url-next "helm-net" "\ +Browse URL with next browser. + +\(fn URL &optional IGNORE)" t nil) + (autoload 'helm-surfraw "helm-net" "\ Preconfigured `helm' to search PATTERN with search ENGINE. \(fn PATTERN ENGINE)" t nil) (autoload 'helm-google-suggest "helm-net" "\ -Preconfigured `helm' for google search with google suggest. - -\(fn)" t nil) +Preconfigured `helm' for Google search with Google suggest." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-net" '("helm-"))) @@ -870,25 +835,16 @@ buffers (i.e. a helm command using `helm-source-buffers-list' like `helm-mini') and use the multi occur buffers action. This is the helm implementation that collect lines matching pattern -like vanilla emacs `occur' but have nothing to do with it, the search -engine beeing completely different and also much faster. - -\(fn)" t nil) +like vanilla Emacs `occur' but have nothing to do with it, the search +engine beeing completely different and also much faster." t nil) -(autoload 'helm-occur-mode "helm-occur" "\ -Major mode to provide actions in helm moccur saved buffer. - -Special commands: -\\{helm-occur-mode-map} - -\(fn)" t nil) +(autoload 'helm-occur-visible-buffers "helm-occur" "\ +Run helm-occur on all visible buffers in frame." t nil) (autoload 'helm-occur-from-isearch "helm-occur" "\ Invoke `helm-occur' from isearch. -To use this bind it to a key in `isearch-mode-map'. - -\(fn)" t nil) +To use this bind it to a key in `isearch-mode-map'." t nil) (autoload 'helm-multi-occur-from-isearch "helm-occur" "\ Invoke `helm-multi-occur' from isearch. @@ -898,9 +854,7 @@ With a prefix arg, reverse the behavior of The prefix arg can be set before calling `helm-multi-occur-from-isearch' or during the buffer selection. -To use this bind it to a key in `isearch-mode-map'. - -\(fn)" t nil) +To use this bind it to a key in `isearch-mode-map'." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-occur" '("helm-"))) @@ -911,9 +865,7 @@ To use this bind it to a key in `isearch-mode-map'. (autoload 'helm-regexp "helm-regexp" "\ Preconfigured helm to build regexps. -`query-replace-regexp' can be run from there against found regexp. - -\(fn)" t nil) +`query-replace-regexp' can be run from there against found regexp." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-regexp" '("helm-"))) @@ -923,40 +875,28 @@ Preconfigured helm to build regexps. ;;; Generated autoloads from helm-ring.el (autoload 'helm-mark-ring "helm-ring" "\ -Preconfigured `helm' for `helm-source-mark-ring'. - -\(fn)" t nil) +Preconfigured `helm' for `helm-source-mark-ring'." t nil) (autoload 'helm-global-mark-ring "helm-ring" "\ -Preconfigured `helm' for `helm-source-global-mark-ring'. - -\(fn)" t nil) +Preconfigured `helm' for `helm-source-global-mark-ring'." t nil) (autoload 'helm-all-mark-rings "helm-ring" "\ -Preconfigured `helm' for `helm-source-global-mark-ring' and `helm-source-mark-ring'. - -\(fn)" t nil) +Preconfigured `helm' for `helm-source-global-mark-ring' and `helm-source-mark-ring'." t nil) (autoload 'helm-register "helm-ring" "\ -Preconfigured `helm' for Emacs registers. - -\(fn)" t nil) +Preconfigured `helm' for Emacs registers." t nil) (autoload 'helm-show-kill-ring "helm-ring" "\ Preconfigured `helm' for `kill-ring'. It is drop-in replacement of `yank-pop'. -First call open the kill-ring browser, next calls move to next line. - -\(fn)" t nil) +First call open the kill-ring browser, next calls move to next line." t nil) (autoload 'helm-execute-kmacro "helm-ring" "\ Preconfigured helm for keyboard macros. Define your macros with `f3' and `f4'. See (info \"(emacs) Keyboard Macros\") for detailed infos. -This command is useful when used with persistent action. - -\(fn)" t nil) +This command is useful when used with persistent action." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-ring" '("helm-"))) @@ -967,7 +907,7 @@ This command is useful when used with persistent action. (autoload 'helm-semantic "helm-semantic" "\ Preconfigured `helm' for `semantic'. -If ARG is supplied, pre-select symbol at point instead of current +If ARG is supplied, pre-select symbol at point instead of current. \(fn ARG)" t nil) @@ -1011,22 +951,21 @@ or call the function `helm-top-poll-mode'.") (autoload 'helm-top-poll-mode "helm-sys" "\ Refresh automatically helm top buffer once enabled. +If called interactively, enable Helm-Top-Poll mode if ARG is +positive, and disable it if ARG is zero or negative. If called +from Lisp, also enable the mode if ARG is omitted or nil, and +toggle it if ARG is `toggle'; disable the mode otherwise. + \(fn &optional ARG)" t nil) (autoload 'helm-top "helm-sys" "\ -Preconfigured `helm' for top command. - -\(fn)" t nil) +Preconfigured `helm' for top command." t nil) (autoload 'helm-list-emacs-process "helm-sys" "\ -Preconfigured `helm' for emacs process. - -\(fn)" t nil) +Preconfigured `helm' for Emacs process." t nil) (autoload 'helm-xrandr-set "helm-sys" "\ -Preconfigured helm for xrandr. - -\(fn)" t nil) +Preconfigured helm for xrandr." t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-sys" '("helm-"))) @@ -1076,6 +1015,11 @@ or call the function `helm-popup-tip-mode'.") (autoload 'helm-popup-tip-mode "helm-utils" "\ Show help-echo informations in a popup tip at end of line. +If called interactively, enable Helm-Popup-Tip mode if ARG is +positive, and disable it if ARG is zero or negative. If called +from Lisp, also enable the mode if ARG is omitted or nil, and +toggle it if ARG is `toggle'; disable the mode otherwise. + \(fn &optional ARG)" t nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-utils" '("helm-" "with-helm-display-marked-candidates"))) @@ -1089,8 +1033,8 @@ Show help-echo informations in a popup tip at end of line. ;;;*** -;;;### (autoloads nil nil ("helm-easymenu.el" "helm-pkg.el") (0 0 -;;;;;; 0 0)) +;;;### (autoloads nil nil ("helm-config.el" "helm-easymenu.el" "helm-pkg.el") +;;;;;; (0 0 0 0)) ;;;*** diff --git a/elpa/helm-20191101.641/helm-bookmark.el b/elpa/helm-20210131.1946/helm-bookmark.el similarity index 95% rename from elpa/helm-20191101.641/helm-bookmark.el rename to elpa/helm-20210131.1946/helm-bookmark.el index 66f49cbb..5d0d4ba9 100644 --- a/elpa/helm-20191101.641/helm-bookmark.el +++ b/elpa/helm-20210131.1946/helm-bookmark.el @@ -1,6 +1,6 @@ ;;; helm-bookmark.el --- Helm for Emacs regular Bookmarks. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -56,42 +56,50 @@ (defface helm-bookmark-info - '((t (:foreground "green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "green")) "Face used for W3m Emacs bookmarks (not w3m bookmarks)." :group 'helm-bookmark) (defface helm-bookmark-w3m - '((t (:foreground "yellow"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "yellow")) "Face used for W3m Emacs bookmarks (not w3m bookmarks)." :group 'helm-bookmark) (defface helm-bookmark-gnus - '((t (:foreground "magenta"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "magenta")) "Face used for Gnus bookmarks." :group 'helm-bookmark) (defface helm-bookmark-man - '((t (:foreground "Orange4"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Orange4")) "Face used for Woman/man bookmarks." :group 'helm-bookmark) (defface helm-bookmark-file - '((t (:foreground "Deepskyblue2"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Deepskyblue2")) "Face used for file bookmarks." :group 'helm-bookmark) (defface helm-bookmark-file-not-found - '((t (:foreground "Slategray4"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Slategray4")) "Face used for file bookmarks." :group 'helm-bookmark) (defface helm-bookmark-directory - '((t (:inherit helm-ff-directory))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit helm-ff-directory)) "Face used for file bookmarks." :group 'helm-bookmark) (defface helm-bookmark-addressbook - '((t (:foreground "tomato"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "tomato")) "Face used for addressbook bookmarks." :group 'helm-bookmark) @@ -105,7 +113,7 @@ (define-key map (kbd "C-]") 'helm-bookmark-toggle-filename) (define-key map (kbd "M-e") 'helm-bookmark-run-edit) map) - "Generic Keymap for emacs bookmark sources.") + "Generic Keymap for Emacs bookmark sources.") (defclass helm-source-basic-bookmarks (helm-source-in-buffer helm-type-bookmark) ((init :initform (lambda () @@ -151,7 +159,7 @@ "Toggle bookmark location visibility." (interactive) (with-helm-alive-p - (helm-attrset 'toggle-filename + (helm-set-attr 'toggle-filename '(helm-bookmark-toggle-filename-1 . never-split)) (helm-execute-persistent-action 'toggle-filename))) (put 'helm-bookmark-toggle-filename 'helm-only t) @@ -292,8 +300,8 @@ BOOKMARK is a bookmark name or a bookmark record." (defvar w3m-async-exec) (defun helm-bookmark-jump-w3m (bookmark) "Jump to W3m bookmark BOOKMARK, setting a new tab. -If `browse-url-browser-function' is set to something else -than `w3m-browse-url' use it." +If `browse-url-browser-function' is set to something else than +`w3m-browse-url' use it." (require 'helm-net) (let* ((file (or (bookmark-prop-get bookmark 'filename) (bookmark-prop-get bookmark 'url))) @@ -596,7 +604,8 @@ than `w3m-browse-url' use it." ;; (defun helm-bookmark-edit-bookmark (bookmark-name) "Edit bookmark's name and file name, and maybe save them. -BOOKMARK-NAME is the current (old) name of the bookmark to be renamed." +BOOKMARK-NAME is the current (old) name of the bookmark to be +renamed." (let ((bmk (helm-bookmark-get-bookmark-from-name bookmark-name)) (handler (bookmark-prop-get bookmark-name 'handler))) (if (eq handler 'addressbook-bookmark-jump) @@ -644,8 +653,8 @@ If NEW is nil, then prompt for its string value. If BATCH is non-nil, then do not rebuild the menu list. -While the user enters the new name, repeated `C-w' inserts consecutive -words from the buffer into the new bookmark name." +While the user enters the new name, repeated `C-w' inserts +consecutive words from the buffer into the new bookmark name." (interactive (list (bookmark-completing-read "Old bookmark name"))) (bookmark-maybe-historicize-string old) (bookmark-maybe-load-default-file) @@ -694,7 +703,7 @@ words from the buffer into the new bookmark name." (defun helm-bookmark-get-bookmark-from-name (bmk) "Return bookmark name even if it is a bookmark with annotation. -e.g prepended with *." +E.g. prepended with *." (let ((bookmark (replace-regexp-in-string "\\`\\*" "" bmk))) (if (assoc bookmark bookmark-alist) bookmark bmk))) @@ -716,9 +725,9 @@ e.g prepended with *." ;;;###autoload (defun helm-filtered-bookmarks () - "Preconfigured helm for bookmarks (filtered by category). -Optional source `helm-source-bookmark-addressbook' is loaded -only if external addressbook-bookmark package is installed." + "Preconfigured `helm' for bookmarks (filtered by category). +Optional source `helm-source-bookmark-addressbook' is loaded only +if external addressbook-bookmark package is installed." (interactive) (helm :sources helm-bookmark-default-filtered-sources :prompt "Search Bookmark: " diff --git a/elpa/helm-20191101.641/helm-buffers.el b/elpa/helm-20210131.1946/helm-buffers.el similarity index 84% rename from elpa/helm-20191101.641/helm-buffers.el rename to elpa/helm-20210131.1946/helm-buffers.el index 1fa450e1..313fa87c 100644 --- a/elpa/helm-20191101.641/helm-buffers.el +++ b/elpa/helm-20210131.1946/helm-buffers.el @@ -1,6 +1,6 @@ ;;; helm-buffers.el --- helm support for buffers. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,11 +26,11 @@ (require 'helm-help) (require 'helm-occur) -(declare-function ido-make-buffer-list "ido" (default)) -(declare-function ido-add-virtual-buffers-to-list "ido") (declare-function helm-comp-read "helm-mode") (declare-function helm-browse-project "helm-files") +(defvar dired-buffers) + (defgroup helm-buffers nil "Buffers related Applications and libraries for Helm." @@ -62,18 +62,18 @@ These buffers will be displayed even if they match one of (defcustom helm-buffer-max-length 20 "Max length of buffer names before truncate. -When disabled (nil) use the longest buffer-name length found." +When disabled (nil) use the longest `buffer-name' length found." :group 'helm-buffers :type '(choice (const :tag "Disabled" nil) (integer :tag "Length before truncate"))) (defcustom helm-buffer-details-flag t - "Always show details in buffer list when non--nil." + "Always show details in buffer list when non-nil." :group 'helm-buffers :type 'boolean) (defcustom helm-buffers-fuzzy-matching nil - "Fuzzy matching buffer names when non--nil. + "Fuzzy matching buffer names when non-nil. Only buffer names are fuzzy matched when this is enabled, `major-mode' matching is not affected by this." :group 'helm-buffers @@ -85,7 +85,7 @@ Only buffer names are fuzzy matched when this is enabled, :type 'boolean) (defcustom helm-buffers-truncate-lines t - "Truncate lines in `helm-buffers-list' when non--nil." + "Truncate lines in `helm-buffers-list' when non-nil." :group 'helm-buffers :type 'boolean) @@ -99,8 +99,8 @@ Only buffer names are fuzzy matched when this is enabled, helm-source-buffer-not-found) "Default sources list used in `helm-mini'. -When adding a source here it is up to you to ensure the library of -this source is accessible and properly loaded." +When adding a source here it is up to you to ensure the library +of this source is accessible and properly loaded." :group 'helm-buffers :type '(repeat (choice symbol))) @@ -117,21 +117,41 @@ this source is accessible and properly loaded." (defcustom helm-buffer--pretty-names '((dired-mode . "Dired") (lisp-interaction-mode . "Lisp Inter")) "An alist specifying pretty names for modes. -Most of the time buffer's `mode-name' is a string so no need to add it -here as there is no need to compute it, but sometimes it may be a -mode-line specification which may be costly to compute, in this case -add here the pretty name as a string to avoid this costly computation. -Also if some pretty names are too long you can add your own -abbreviation here." +Most of the time buffer's `mode-name' is a string so no need to +add it here as there is no need to compute it, but sometimes it +may be a mode-line specification which may be costly to compute, +in this case add here the pretty name as a string to avoid this +costly computation. Also if some pretty names are too long you +can add your own abbreviation here." :type '(alist :key-type symbol :value-type string) :group 'helm-buffers) (defcustom helm-buffers-maybe-switch-to-tab nil "Switch to buffer in its tab when non nil. -This have no effect when `tab-bar-mode' is not available." +This has no effect when `tab-bar-mode' is not available." :group 'helm-buffers :type 'boolean) +(defcustom helm-buffer-list-reorder-fn #'helm-buffers-reorder-buffer-list + "A function in charge of ordering the initial buffer list. +It takes two arguments VISIBLES buffers and OTHERS buffers. +Arg VISIBLES handles the buffers visibles in this frame. +Arg OTHERS handles all the other buffers. +You can write a function that reorder VISIBLES and OTHERS as you +want. +Default function returns OTHERS buffers on top and VISIBLES +buffer at the end. See `helm-buffers-reorder-buffer-list'." + :group 'helm-buffers + :type 'function) + +(defcustom helm-buffers-sort-fn helm-fuzzy-sort-fn + "The sort function to use in `helm-buffers-list'. + +Default to `helm-fuzzy-sort-fn' you can use +`helm-fuzzy-matching-sort-fn-preserve-ties-order' as alternative if +you want to keep the recentest order when narrowing candidates." + :type 'function + :group 'helm-buffers) ;;; Faces ;; @@ -143,57 +163,69 @@ This have no effect when `tab-bar-mode' is not available." :group 'helm-faces) (defface helm-buffer-saved-out - '((t (:foreground "red" :background "black"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red" :background "black")) "Face used for buffer files modified outside of emacs." :group 'helm-buffers-faces) (defface helm-buffer-not-saved - '((t (:foreground "Indianred2"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Indianred2")) "Face used for buffer files not already saved on disk." :group 'helm-buffers-faces) (defface helm-buffer-modified - '((t :inherit font-lock-comment-face)) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-comment-face)) "Face used for modified buffers." :group 'helm-buffers-faces) (defface helm-buffer-size - '((((background dark)) :foreground "RosyBrown") - (((background light)) :foreground "SlateGray")) + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "RosyBrown") + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "SlateGray")) "Face used for buffer size." :group 'helm-buffers-faces) (defface helm-buffer-process - '((t (:foreground "Sienna3"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Sienna3")) "Face used for process status in buffer." :group 'helm-buffers-faces) (defface helm-buffer-directory - '((t (:foreground "DarkRed" :background "LightGray"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DarkRed" :background "LightGray")) "Face used for directories in `helm-buffers-list'." :group 'helm-buffers-faces) (defface helm-buffer-file - '((t :inherit font-lock-builtin-face)) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-builtin-face)) "Face for buffer file names in `helm-buffers-list'." :group 'helm-buffers-faces) (defface helm-buffer-archive - '((t (:foreground "Gold"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Gold")) "Face for archive file names in `helm-buffers-list'." :group 'helm-buffers-faces) (defface helm-non-file-buffer - '((t (:inherit italic))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit italic)) "Face used for non-file buffers in `helm-buffers-list'." :group 'helm-buffers-faces) (defvar helm-buffers-tick-counter nil "Allows recording local changes to a non-file buffer. -Typical usage of this var is for modes that want to see if -their buffers have changed since last visit. -Such programs may want to record tick counter after visiting their -buffers like this: +Typical usage of this var is for modes that want to see if their +buffers have changed since last visit. +Such programs may want to record tick counter after visiting +their buffers like this: (setq helm-buffers-tick-counter (buffer-modified-tick)) @@ -214,6 +246,7 @@ Note that this variable is buffer-local.") (define-key map (kbd "C-x C-d") 'helm-buffers-run-browse-project) (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 "M-g M-g") 'helm-buffer-run-goto-line) (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) @@ -235,17 +268,6 @@ Note that this variable is buffer-local.") map) "Keymap for buffer sources in helm.") -(defvar helm-buffers-ido-virtual-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (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 "M-g s") 'helm-ff-run-grep) - (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) - (define-key map (kbd "M-D") 'helm-ff-run-delete-file) - (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) - map)) - (defvar helm-buffer-max-len-mode nil) (defvar helm-buffers-in-project-p nil) @@ -259,15 +281,15 @@ Note that this variable is buffer-local.") ;; source with a different 'buffer-list fn as the same cache was ;; reused in each source (issue #1907), now 'candidates attr is set ;; directly so that each list of candidates is local to source. - (helm-attrset 'candidates (funcall (helm-attr 'buffer-list))) + (helm-set-attr 'candidates (funcall (helm-get-attr 'buffer-list))) (let ((result (cl-loop with allbufs = (memq 'helm-shadow-boring-buffers (helm-attr 'filtered-candidate-transformer helm-source-buffers-list)) for b in (if allbufs - (helm-attr 'candidates) + (helm-get-attr 'candidates) (helm-skip-boring-buffers - (helm-attr 'candidates) + (helm-get-attr 'candidates) helm-source-buffers-list)) maximize (length b) into len-buf maximize (length (helm-buffer--format-mode-name b)) @@ -353,48 +375,36 @@ Note that this variable is buffer-local.") #'helm-buffers-create-new-buffer-of) :keymap helm-buffer-not-found-map)) -(defvar ido-temp-list) -(defvar ido-ignored-list) -(defvar ido-process-ignore-lists) -(defvar ido-use-virtual-buffers) -(defvar ido-virtual-buffers) - -(defvar helm-source-ido-virtual-buffers - (helm-build-sync-source "Ido virtual buffers" - :candidates (lambda () - (let (ido-temp-list - ido-ignored-list - (ido-process-ignore-lists t)) - (when ido-use-virtual-buffers - (ido-add-virtual-buffers-to-list) - ido-virtual-buffers))) - :fuzzy-match helm-buffers-fuzzy-matching - :keymap helm-buffers-ido-virtual-map - :help-message 'helm-buffers-ido-virtual-help-message - :action '(("Find file" . helm-find-many-files) - ("Find file other window" . find-file-other-window) - ("Find file other frame" . find-file-other-frame) - ("Find file as root" . helm-find-file-as-root) - ("Grep File(s) `C-u recurse'" . helm-find-files-grep) - ("Zgrep File(s) `C-u Recurse'" . helm-ff-zgrep) - ("View file" . view-file) - ("Delete file(s)" . helm-delete-marked-files) - ("Open file externally (C-u to choose)" - . helm-open-file-externally)))) - -(defvar ido-use-virtual-buffers) -(defvar ido-ignore-buffers) +(defun helm-buffers-get-visible-buffers () + "Returns buffers visibles on current frame." + (let (result) + (walk-windows + (lambda (x) + (push (buffer-name (window-buffer x)) result)) + nil 'visible) + result)) + +(defun helm-buffer-list-1 (&optional visibles) + (cl-loop for b in (buffer-list) + for bn = (buffer-name b) + unless (member bn visibles) + collect bn)) + +(defun helm-buffers-reorder-buffer-list (visibles others) + "Default function to reorder buffer-list. +Arg VISIBLES handles the buffers visibles in this frame. +Arg OTHERS handles all the other buffers. +This function returns OTHERS buffers on top and VISIBLES buffer +at the end." + (nconc others visibles)) + (defun helm-buffer-list () "Return the current list of buffers. -Currently visible buffers are put at the end of the list. -See `ido-make-buffer-list' for more infos." - (require 'ido) - (let ((ido-process-ignore-lists t) - ido-ignored-list - ido-ignore-buffers - ido-use-virtual-buffers) - (ido-make-buffer-list nil))) +The list is reordered with `helm-buffer-list-reorder-fn'." + (let* ((visibles (helm-buffers-get-visible-buffers)) + (others (helm-buffer-list-1 visibles))) + (funcall helm-buffer-list-reorder-fn visibles others))) (defun helm-buffer-size (buffer) "Return size of BUFFER." @@ -504,7 +514,9 @@ See `ido-make-buffer-list' for more infos." (defun helm-highlight-buffers (buffers _source) "Transformer function to highlight BUFFERS list. -Should be called after others transformers i.e (boring buffers)." +Should be called after others transformers i.e. (boring +buffers)." + (cl-assert helm-fuzzy-matching-highlight-fn nil "Wrong type argument functionp: nil") (cl-loop for i in buffers for (name size mode meta) = (if helm-buffer-details-flag (helm-buffer--details i 'details) @@ -569,11 +581,11 @@ Should be called after others transformers i.e (boring buffers)." (let* ((buf (helm-get-selection)) (preselect (helm-buffer--get-preselection buf))) (setq helm-buffer-details-flag (not helm-buffer-details-flag)) - (helm-update (lambda () - (helm-awhile (re-search-forward preselect nil t) - (helm-mark-current-line) - (when (equal buf (helm-get-selection)) - (cl-return t)))))))) + (helm-force-update (lambda () + (helm-awhile (re-search-forward preselect nil t) + (helm-mark-current-line) + (when (equal buf (helm-get-selection)) + (cl-return t)))))))) (put 'helm-toggle-buffers-details 'helm-only t) (defun helm-buffers--pattern-sans-filters (&optional separator) @@ -583,14 +595,11 @@ Should be called after others transformers i.e (boring buffers)." finally return (mapconcat 'identity lst (or separator " ")))) (defun helm-buffers-sort-transformer (candidates source) + (cl-assert helm-buffers-sort-fn nil "Wrong type argument functionp: nil") (if (string= helm-pattern "") candidates - (if helm-buffers-fuzzy-matching - (let ((helm-pattern (helm-buffers--pattern-sans-filters))) - (funcall helm-fuzzy-sort-fn candidates source)) - (sort candidates - (lambda (s1 s2) - (< (string-width s1) (string-width s2))))))) + (let ((helm-pattern (helm-buffers--pattern-sans-filters))) + (funcall helm-buffers-sort-fn candidates source)))) (defun helm-buffers-mark-similar-buffers-1 (&optional type) (with-helm-window @@ -622,7 +631,7 @@ Should be called after others transformers i.e (boring buffers)." (defun helm-buffers-mark-similar-buffers () "Mark All buffers that have same property `type' than current. -i.e same color." +I.e. same color." (interactive) (with-helm-alive-p (let ((marked (helm-marked-candidates))) @@ -699,18 +708,25 @@ i.e same color." (defun helm-buffers--match-from-inside (candidate) (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) (buf (get-buffer cand)) - (regexp (cl-loop with pattern = helm-pattern - for p in (helm-mm-split-pattern pattern) - when (string-match "\\`@\\(.*\\)" p) - return (match-string 1 p)))) - (if (and buf regexp) + (pattern (cl-loop with pat = helm-pattern + for p in (helm-mm-split-pattern pat) + when (string-match "\\`@\\(.*\\)" p) + collect (match-string 1 p) into lst + finally return (mapconcat 'identity lst " "))) + (patterns (helm-mm-3-get-patterns pattern))) + (if (and buf patterns) (with-current-buffer buf (save-excursion (goto-char (point-min)) - (if helm-migemo-mode - (helm-mm-migemo-forward regexp nil t) - (re-search-forward regexp nil t)))) - t))) + (cl-loop for (pred . regexp) in patterns + always + (save-excursion + (funcall + pred + (if helm-migemo-mode + (helm-mm-migemo-forward regexp nil t) + (re-search-forward regexp nil t))))))) + t))) (defun helm-buffers--match-from-directory (candidate) (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) @@ -777,7 +793,7 @@ If REGEXP-FLAG is given use `query-replace-regexp'." "Toggle diff buffer without quitting helm." (interactive) (with-helm-alive-p - (helm-attrset 'diff-action 'helm-buffer-toggle-diff) + (helm-set-attr 'diff-action 'helm-buffer-toggle-diff) (helm-execute-persistent-action 'diff-action))) (put 'helm-buffer-diff-persistent 'helm-only t) @@ -796,13 +812,13 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (helm-get-selection)))) (cl-loop for buf in marked do (helm-revert-buffer buf)) (when helm-marked-candidates (helm-unmark-all)) - (helm-update preselect)))) + (helm-force-update preselect)))) (defun helm-buffer-revert-persistent () "Revert buffer without quitting helm." (interactive) (with-helm-alive-p - (helm-attrset 'revert-action '(helm-buffer-revert-and-update . never-split)) + (helm-set-attr 'revert-action '(helm-buffer-revert-and-update . never-split)) (helm-execute-persistent-action 'revert-action))) (put 'helm-buffer-revert-persistent 'helm-only t) @@ -816,25 +832,25 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (with-current-buffer (get-buffer buf) (when (buffer-file-name) (save-buffer)))) (when helm-marked-candidates (helm-unmark-all)) - (helm-update (regexp-quote preselect))))) + (helm-force-update (regexp-quote preselect))))) (defun helm-buffer-save-some-buffers (_candidate) (helm-buffers-mark-similar-buffers-1 'mod) (helm-buffer-save-and-update nil)) (defun helm-buffer-run-save-some-buffers () - "Save unsaved file buffers without quitting helm." + "Save unsaved file buffers without quitting Helm." (interactive) (with-helm-alive-p - (helm-attrset 'save-some-action '(helm-buffer-save-some-buffers . never-split)) + (helm-set-attr 'save-some-action '(helm-buffer-save-some-buffers . never-split)) (helm-execute-persistent-action 'save-some-action))) (put 'helm-buffer-run-save-some-buffers 'helm-only t) (defun helm-buffer-save-persistent () - "Save buffer without quitting helm." + "Save buffer without quitting Helm." (interactive) (with-helm-alive-p - (helm-attrset 'save-action '(helm-buffer-save-and-update . never-split)) + (helm-set-attr 'save-action '(helm-buffer-save-and-update . never-split)) (helm-execute-persistent-action 'save-action))) (put 'helm-buffer-save-persistent 'helm-only t) @@ -849,11 +865,27 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (helm-exit-and-execute-action 'helm-buffers-rename-buffer))) (put 'helm-buffer-run-rename-buffer 'helm-only t) +(defun helm-switch-to-buffer-at-linum (candidate) + (let ((linum (read-number + "Line number: " + (with-current-buffer candidate + (line-number-at-pos))))) + (switch-to-buffer candidate) + (goto-char (point-min)) + (forward-line (1- linum)))) + +(defun helm-buffer-run-goto-line () + "Switch to buffer at line number." + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-switch-to-buffer-at-linum))) +(put 'helm-buffer-run-goto-line 'helm-only t) + (defun helm-buffer-run-kill-persistent () - "Kill buffer without quitting helm." + "Kill buffer without quitting Helm." (interactive) (with-helm-alive-p - (helm-attrset 'kill-action '(helm-buffers-persistent-kill . never-split)) + (helm-set-attr 'kill-action '(helm-buffers-persistent-kill . never-split)) (helm-execute-persistent-action 'kill-action))) (put 'helm-buffer-run-kill-persistent 'helm-only t) @@ -915,19 +947,25 @@ If REGEXP-FLAG is given use `query-replace-regexp'." (helm-exit-and-execute-action 'switch-to-buffer-other-frame))) (put 'helm-buffer-switch-other-frame 'helm-only t) +(defun helm-buffers-switch-to-buffer-other-tab (_candidate) + (let ((bufs (helm-marked-candidates))) + (cl-loop for buf in bufs + do (switch-to-buffer-other-tab buf)))) + (defun helm-buffers-switch-to-buffer-new-tab () "Run switch to buffer in other tab action from `helm-source-buffers-list'." (interactive) (cl-assert (fboundp 'tab-bar-mode) nil "Tab-bar-mode not available") (with-helm-alive-p - (helm-exit-and-execute-action 'switch-to-buffer-other-tab))) + (helm-exit-and-execute-action 'helm-buffers-switch-to-buffer-other-tab))) (put 'helm-buffers-switch-to-buffer-new-tab 'helm-only t) (defun helm-buffer-switch-buffers (_candidate) "Switch to buffer candidates and replace current buffer. -If more than one buffer marked switch to these buffers in separate windows. -If a prefix arg is given split windows vertically." +If more than one buffer marked switch to these buffers in +separate windows. If a prefix arg is given split windows +vertically." (let ((buffers (helm-marked-candidates))) (helm-window-show-buffers buffers))) @@ -1014,17 +1052,18 @@ If a prefix arg is given split windows vertically." (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 (helm-marked-candidates))) - buf1 buf2) + (let* ((mkd (helm-marked-candidates)) + (lg-lst (length mkd)) + buf1 buf2) (cl-case lg-lst (0 (error "Error:You have to mark at least 1 buffer")) (1 (setq buf1 helm-current-buffer - buf2 (cl-first (helm-marked-candidates)))) + buf2 (cl-first mkd))) (2 - (setq buf1 (cl-first (helm-marked-candidates)) - buf2 (cl-second (helm-marked-candidates)))) + (setq buf1 (cl-first mkd) + buf2 (cl-second mkd))) (t (error "Error:Too many buffers marked!"))) (if merge @@ -1049,7 +1088,7 @@ Can be used by any source that list buffers." (get-buffer helm-buffer)) helm-pattern) " " t) - thereis (and (string-match "\\`@\\(.*\\)" i) + thereis (and (string-match "\\`@\\([^!]*\\)" i) (match-string 1 i))))) (helm-multi-occur-1 buffers input))) @@ -1063,15 +1102,15 @@ Can be used by any source that list buffers." (defun helm-buffers-toggle-show-hidden-buffers () (interactive) (with-helm-alive-p - (let ((filter-attrs (helm-attr 'filtered-candidate-transformer + (let ((filter-attrs (helm-get-attr 'filtered-candidate-transformer helm-source-buffers-list))) (if (memq 'helm-shadow-boring-buffers filter-attrs) - (helm-attrset 'filtered-candidate-transformer + (helm-set-attr 'filtered-candidate-transformer (cons 'helm-skip-boring-buffers (remove 'helm-shadow-boring-buffers filter-attrs)) helm-source-buffers-list) - (helm-attrset 'filtered-candidate-transformer + (helm-set-attr 'filtered-candidate-transformer (cons 'helm-shadow-boring-buffers (remove 'helm-skip-boring-buffers filter-attrs)) @@ -1080,7 +1119,7 @@ Can be used by any source that list buffers." (put 'helm-buffers-toggle-show-hidden-buffers 'helm-only t) (defun helm-buffers-browse-project (buf) - "Browse project from buffer." + "Browse project from buffer BUF." (with-current-buffer buf (helm-browse-project helm-current-prefix-arg))) @@ -1096,6 +1135,8 @@ Can be used by any source that list buffers." ;; ;; (defun helm-skip-boring-buffers (buffers _source) + "Remove buffers matching `helm-boring-buffer-regexp-list' in BUFFERS. +Where BUFFERS is a list of buffer names." (helm-skip-entries buffers helm-boring-buffer-regexp-list helm-white-buffer-regexp-list)) @@ -1114,7 +1155,6 @@ displayed with the `file-name-shadow' face if available." (setq helm-source-buffers-list (helm-make-source "Buffers" 'helm-source-buffers))) (helm :sources '(helm-source-buffers-list - helm-source-ido-virtual-buffers helm-source-buffer-not-found) :buffer "*helm buffers*" :keymap helm-buffer-map diff --git a/elpa/helm-20191101.641/helm-color.el b/elpa/helm-20210131.1946/helm-color.el similarity index 95% rename from elpa/helm-20191101.641/helm-color.el rename to elpa/helm-20210131.1946/helm-color.el index a962796a..476f45a4 100644 --- a/elpa/helm-20191101.641/helm-color.el +++ b/elpa/helm-20210131.1946/helm-color.el @@ -1,6 +1,6 @@ ;;; helm-color.el --- colors and faces -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -84,25 +84,25 @@ (kill-new (helm-colors-get-rgb candidate))) (defun helm-color-run-insert-name () - "Insert name of color from `helm-source-colors'" + "Insert name of color from `helm-source-colors'." (interactive) (with-helm-alive-p (helm-exit-and-execute-action 'helm-color-insert-name))) (put 'helm-color-run-insert-name 'helm-only t) (defun helm-color-run-kill-name () - "Kill name of color from `helm-source-colors'" + "Kill name of color from `helm-source-colors'." (interactive) (with-helm-alive-p (helm-exit-and-execute-action 'helm-color-kill-name))) (put 'helm-color-run-kill-name 'helm-only t) (defun helm-color-run-insert-rgb () - "Insert RGB of color from `helm-source-colors'" + "Insert RGB of color from `helm-source-colors'." (interactive) (with-helm-alive-p (helm-exit-and-execute-action 'helm-color-insert-rgb))) (put 'helm-color-run-insert-rgb 'helm-only t) (defun helm-color-run-kill-rgb () - "Kill RGB of color from `helm-source-colors'" + "Kill RGB of color from `helm-source-colors'." (interactive) (with-helm-alive-p (helm-exit-and-execute-action 'helm-color-kill-rgb))) (put 'helm-color-run-kill-rgb 'helm-only t) diff --git a/elpa/helm-20191101.641/helm-comint.el b/elpa/helm-20210131.1946/helm-comint.el similarity index 83% rename from elpa/helm-20191101.641/helm-comint.el rename to elpa/helm-20210131.1946/helm-comint.el index 953d8a76..b8842a89 100644 --- a/elpa/helm-20191101.641/helm-comint.el +++ b/elpa/helm-20210131.1946/helm-comint.el @@ -1,6 +1,6 @@ ;;; helm-comint.el --- Comint prompt navigation for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2019 Pierre Neidhardt +;; Copyright (C) 2020 Pierre Neidhardt ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -33,12 +33,14 @@ ;;; Comint prompts ;; (defface helm-comint-prompts-promptidx - '((t (:foreground "cyan"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + (:foreground "cyan"))) "Face used to highlight comint prompt index." :group 'helm-comint-faces) (defface helm-comint-prompts-buffer-name - '((t (:foreground "green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + (:foreground "green"))) "Face used to highlight comint buffer name." :group 'helm-comint-faces) @@ -47,19 +49,30 @@ :group 'helm-comint :type 'boolean) -(defcustom helm-comint-mode-list '(comint-mode slime-repl-mode) +(defcustom helm-comint-mode-list '(comint-mode slime-repl-mode sly-mrepl-mode sql-interactive-mode) "Supported modes for prompt navigation. -Derived modes (e.g. Geiser's REPL) are automatically supported." +Derived modes (e.g., Geiser's REPL) are automatically supported." :group 'helm-comint :type '(repeat (choice symbol))) +(defcustom helm-comint-next-prompt-function '((sly-mrepl-mode . (lambda () + (sly-mrepl-next-prompt) + (point)))) + "Alist of (MODE . NEXT-PROMPT-FUNCTION) to use. + If the current major mode is a key in this list, the associated + function will be used to navigate the prompts. + The function must return the point after the prompt. + Otherwise (comint-next-prompt 1) will be used." + :group 'helm-comint + :type '(alist :key-type symbol :value-type function)) + (defcustom helm-comint-max-offset 400 "Max number of chars displayed per candidate in comint-input-ring browser. -When `t', don't truncate candidate, show all. -By default it is approximatively the number of bits contained in five lines -of 80 chars each i.e 80*5. -Note that if you set this to nil multiline will be disabled, i.e you -will not have anymore separators between candidates." +When t, don't truncate candidate, show all. +By default it is approximatively the number of bits contained in +five lines of 80 chars each i.e 80*5. +Note that if you set this to nil multiline will be disabled, i.e +you will not have anymore separators between candidates." :type '(choice (const :tag "Disabled" t) (integer :tag "Max candidate offset")) :group 'helm-misc) @@ -76,7 +89,7 @@ will not have anymore separators between candidates." "List the prompts in BUFFER in mode MODE. Return a list of (\"prompt\" (point) (buffer-name) prompt-index)) -e.g. (\"ls\" 162 \"*shell*\" 3). +E.g. (\"ls\" 162 \"*shell*\" 3). If BUFFER is nil, use current buffer." (with-current-buffer (or buffer (current-buffer)) (when (derived-mode-p mode) @@ -84,7 +97,10 @@ If BUFFER is nil, use current buffer." (goto-char (point-min)) (let (result (count 1)) (save-mark-and-excursion - (helm-awhile (and (not (eobp)) (comint-next-prompt 1)) + (helm-awhile (and (not (eobp)) + (helm-aif (alist-get major-mode helm-comint-next-prompt-function) + (funcall it) + (comint-next-prompt 1))) (push (list (buffer-substring-no-properties it (point-at-eol)) it (buffer-name) count) @@ -202,7 +218,8 @@ See `helm-comint-prompts-list'." (defun helm-comint-input-ring () "Preconfigured `helm' that provide completion of `comint' history." (interactive) - (when (derived-mode-p 'comint-mode) + (when (or (derived-mode-p 'comint-mode) + (member major-mode helm-comint-mode-list)) (helm :sources 'helm-source-comint-input-ring :input (buffer-substring-no-properties (comint-line-beginning-position) (point-at-eol)) diff --git a/elpa/helm-20210131.1946/helm-command.el b/elpa/helm-20210131.1946/helm-command.el new file mode 100644 index 00000000..2858d963 --- /dev/null +++ b/elpa/helm-20210131.1946/helm-command.el @@ -0,0 +1,360 @@ +;;; helm-command.el --- Helm execute-exended-command. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto + +;; This program 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 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-help) +(require 'helm-mode) +(require 'helm-elisp) + + +(defgroup helm-command nil + "Emacs command related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-M-x-always-save-history nil + "`helm-M-x' save command in `extended-command-history' even when it fails." + :group 'helm-command + :type 'boolean) + +(defcustom helm-M-x-reverse-history nil + "The history source of `helm-M-x' appear in second position when non-nil." + :group 'helm-command + :type 'boolean) + + +;;; Faces +;; +;; +(defgroup helm-command-faces nil + "Customize the appearance of helm-command." + :prefix "helm-" + :group 'helm-command + :group 'helm-faces) + +(defface helm-M-x-key + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "orange" :underline t)) + "Face used in helm-M-x to show keybinding." + :group 'helm-command-faces) + +(defface helm-command-active-mode + '((t :inherit font-lock-builtin-face)) + "Face used by `helm-M-x' for activated modes." + :group 'helm-command-faces) + + +(defvar helm-M-x-input-history nil) +(defvar helm-M-x-prefix-argument nil + "Prefix argument before calling `helm-M-x'.") +(defvar helm-M-x--timer nil) +(defvar helm-M-x--unwind-forms-done nil) + +(defun helm-M-x-get-major-mode-command-alist (mode-map) + "Return alist of MODE-MAP." + (when mode-map + (cl-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 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. +Return nil if no mode-map found." + (cl-loop ;; Start with a conventional mode-map name. + with mode-map = (intern-soft (format "%s-map" mode)) + with mode-string = (symbol-name mode) + with mode-name = (replace-regexp-in-string "-mode" "" mode-string) + while (not mode-map) + for count downfrom (length mode-name) + ;; Return when no result after parsing entire string. + when (eq count 0) return nil + for sub-name = (substring mode-name 0 count) + do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode")))) + finally return mode-map)) + +(defun helm-M-x-current-mode-map-alist () + "Return mode-map alist of current `major-mode'." + (let ((map-sym (helm-get-mode-map-from-mode major-mode))) + (when (and map-sym (boundp map-sym)) + (helm-M-x-get-major-mode-command-alist (symbol-value map-sym))))) + + +(defun helm-M-x-transformer-1 (candidates &optional sort) + "Transformer function to show bindings in emacs commands. +Show global bindings and local bindings according to current +`major-mode'. +If SORT is non nil sort list with `helm-generic-sort-fn'. +Note that SORT should not be used when fuzzy matching because +fuzzy matching is running its own sort function with a different +algorithm." + (with-helm-current-buffer + (cl-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)) + for sym = (intern cand) + for disp = (if (or (eq sym major-mode) + (and (memq sym minor-mode-list) + (boundp sym) + (buffer-local-value sym helm-current-buffer))) + (propertize cand 'face 'helm-command-active-mode) + cand) + unless (get (intern (if (consp cand) (car cand) cand)) 'helm-only) + collect + (cons (cond ((and (string-match "^M-x" key) local-key) + (format "%s (%s)" + disp (propertize + local-key + 'face 'helm-M-x-key))) + ((string-match "^M-x" key) disp) + (t (format "%s (%s)" + disp (propertize + key + 'face 'helm-M-x-key)))) + cand) + into ls + finally return + (if sort (sort ls #'helm-generic-sort-fn) ls)))) + +(defun helm-M-x-transformer (candidates _source) + "Transformer function for `helm-M-x' candidates." + ;; Generic sort function is handling helm-flex. + (helm-M-x-transformer-1 candidates (null helm--in-fuzzy))) + +(defun helm-M-x-transformer-no-sort (candidates _source) + "Transformer function for `helm-M-x' candidates." + (helm-M-x-transformer-1 candidates)) + +(defun helm-M-x--notify-prefix-arg () + ;; Notify a prefix-arg set AFTER calling M-x. + (when prefix-arg + (with-helm-window + (helm-display-mode-line (helm-get-current-source) 'force)))) + +(defun helm-cmd--get-current-function-name () + (save-excursion + (beginning-of-defun) + (cadr (split-string (buffer-substring-no-properties + (point-at-bol) (point-at-eol)))))) + +(defun helm-cmd--get-preconfigured-commands (&optional dir) + (let* ((helm-dir (or dir (helm-basedir (locate-library "helm")))) + (helm-autoload-file (expand-file-name "helm-autoloads.el" helm-dir)) + results) + (when (file-exists-p helm-autoload-file) + (with-temp-buffer + (insert-file-contents helm-autoload-file) + (while (re-search-forward "Preconfigured" nil t) + (push (substring (helm-cmd--get-current-function-name) 1) results)))) + results)) + +(defvar helm-M-x-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-comp-read-map) + (define-key map (kbd "C-u") nil) + (define-key map (kbd "C-u") 'helm-M-x-universal-argument) + map)) + +(defun helm-M-x-universal-argument () + "Same as `universal-argument' but for `helm-M-x'." + (interactive) + (if helm-M-x-prefix-argument + (progn (setq helm-M-x-prefix-argument nil) + (let ((inhibit-read-only t)) + (with-selected-window (minibuffer-window) + (save-excursion + (goto-char (point-min)) + (delete-char (- (minibuffer-prompt-width) (length "M-x ")))))) + (message "Initial prefix arg disabled")) + (setq prefix-arg (list 4)) + (universal-argument--mode))) +(put 'helm-M-x-universal-argument 'helm-only t) + +(defun helm-M-x-persistent-action (candidate) + (helm-elisp--persistent-help + candidate 'helm-describe-function)) + +(defun helm-M-x--move-selection-after-hook () + (setq current-prefix-arg nil)) + +(defun helm-M-x--before-action-hook () + (remove-hook 'helm-move-selection-after-hook + 'helm-M-x--move-selection-after-hook)) + +(defclass helm-M-x-class (helm-source-sync helm-type-command) + ((match-dynamic :initform t) + (requires-pattern :initform 0) + (must-match :initform t) + (filtered-candidate-transformer :initform 'helm-M-x-transformer-no-sort) + (persistent-help :initform "Describe this command") + (help-message :initform 'helm-M-x-help-message) + (nomark :initform t) + (keymap :initform helm-M-x-map))) + +(defun helm-M-x-read-extended-command (collection &optional predicate history) + "Read or execute action on command name in COLLECTION or HISTORY. + +When `helm-M-x-use-completion-styles' is used, several actions as +of `helm-type-command' are used and executed from here, otherwise +this function returns the command as a symbol. + +Helm completion is not provided when executing or defining kbd +macros. + +Arg COLLECTION should be an `obarray' but can be any object +suitable for `try-completion'. Arg PREDICATE is a function that +default to `commandp' see also `try-completion'. Arg HISTORY +default to `extended-command-history'." + (let* ((helm--mode-line-display-prefarg t) + (minibuffer-completion-confirm t) + (pred (or predicate #'commandp)) + (metadata (unless (assq 'flex completion-styles-alist) + '(metadata (display-sort-function + . + (lambda (candidates) + (sort candidates #'helm-generic-sort-fn)))))) + (sources `(,(helm-make-source "Emacs Commands history" 'helm-M-x-class + :candidates (helm-dynamic-completion + ;; A list of strings. + (or history extended-command-history) + (lambda (str) (funcall pred (intern-soft str))) + nil 'nosort t)) + ,(helm-make-source "Emacs Commands" 'helm-M-x-class + :candidates (helm-dynamic-completion + collection pred + nil metadata t)))) + (prompt (concat (cond + ((eq helm-M-x-prefix-argument '-) "- ") + ((and (consp helm-M-x-prefix-argument) + (eq (car helm-M-x-prefix-argument) 4)) "C-u ") + ((and (consp helm-M-x-prefix-argument) + (integerp (car helm-M-x-prefix-argument))) + (format "%d " (car helm-M-x-prefix-argument))) + ((integerp helm-M-x-prefix-argument) + (format "%d " helm-M-x-prefix-argument))) + "M-x "))) + (setq helm-M-x--timer (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg)) + ;; Fix Issue #2250, add `helm-move-selection-after-hook' which + ;; reset prefix arg to nil only for this helm session. + (add-hook 'helm-move-selection-after-hook + 'helm-M-x--move-selection-after-hook) + (add-hook 'helm-before-action-hook + 'helm-M-x--before-action-hook) + (when (and sources helm-M-x-reverse-history) + (setq sources (nreverse sources))) + (unwind-protect + (progn + (setq current-prefix-arg nil) + (helm :sources sources + :prompt prompt + :buffer "*helm M-x*" + :history 'helm-M-x-input-history)) + (helm-M-x--unwind-forms)))) + +;; When running a command involving again helm from helm-M-x, the +;; unwind-protect UNWINDS forms are executed only once this helm +;; command exit leaving the helm-M-x timer running and other variables +;; and hooks not unset, so the timer is now in a global var and all +;; the forms that should normally run in unwind-protect are running as +;; well as soon as helm-M-x-execute-command is called. +(defun helm-M-x--unwind-forms (&optional done) + ;; helm-M-x--unwind-forms-done is non nil when it have been called + ;; once from helm-M-x-execute-command. + (unless helm-M-x--unwind-forms-done + (when (timerp helm-M-x--timer) + (cancel-timer helm-M-x--timer) + (setq helm-M-x--timer nil)) + (setq helm--mode-line-display-prefarg nil) + ;; Be sure to remove it here as well in case of quit. + (remove-hook 'helm-move-selection-after-hook + 'helm-M-x--move-selection-after-hook) + (remove-hook 'helm-before-action-hook + 'helm-M-x--before-action-hook)) + ;; Reset helm-M-x--unwind-forms-done to nil when DONE is + ;; unspecified. + (setq helm-M-x--unwind-forms-done done)) + +(defun helm-M-x-execute-command (command) + "Execute COMMAND as an editor command. +COMMAND must be a symbol that satisfies the `commandp' predicate. +Save COMMAND to `extended-command-history'." + (helm-M-x--unwind-forms t) + (when command + ;; Avoid having `this-command' set to *exit-minibuffer. + (setq this-command command + ;; Handle C-x z (repeat) Issue #322 + real-this-command command) + ;; If helm-M-x is called with regular emacs completion (kmacro) + ;; use the value of arg otherwise use helm-current-prefix-arg. + (let ((prefix-arg (or helm-current-prefix-arg helm-M-x-prefix-argument)) + (command-name (symbol-name command))) + (condition-case-unless-debug err + (progn + (command-execute command 'record) + (add-to-history 'extended-command-history command-name)) + (error + (when helm-M-x-always-save-history + (add-to-history 'extended-command-history command-name)) + (signal (car err) (cdr err))))))) + +(defun helm-M-x--vanilla-M-x () + (helm-M-x-execute-command + (intern-soft + (if helm-mode + (unwind-protect + (progn + (helm-mode -1) + (read-extended-command)) + (helm-mode 1)) + (read-extended-command))))) + +;;;###autoload +(defun helm-M-x (_arg) + "Preconfigured `helm' for Emacs commands. +It is `helm' replacement of regular `M-x' +`execute-extended-command'. + +Unlike regular `M-x' Emacs vanilla `execute-extended-command' +command, the prefix args if needed, can be passed AFTER starting +`helm-M-x'. When a prefix arg is passed BEFORE starting +`helm-M-x', the first `C-u' while in `helm-M-x' session will +disable it. + +You can get help on each command by persistent action." + (interactive + (progn + (setq helm-M-x-prefix-argument current-prefix-arg) + (list current-prefix-arg))) + (if (or defining-kbd-macro executing-kbd-macro) + (helm-M-x--vanilla-M-x) + (helm-M-x-read-extended-command obarray))) +(put 'helm-M-x 'interactive-only 'command-execute) + +(provide 'helm-command) + +;; Local Variables: +;; byte-compile-warnings: (not obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-command.el ends here diff --git a/elpa/helm-20210131.1946/helm-config.el b/elpa/helm-20210131.1946/helm-config.el new file mode 100644 index 00000000..4440e0d3 --- /dev/null +++ b/elpa/helm-20210131.1946/helm-config.el @@ -0,0 +1,40 @@ +;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto + +;; This program 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 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see . + +;;; Commentary: +;; +;; Requiring this file is not needed when using a package manager to +;; install helm as this one will take care of loading the autoload +;; file. + +;;; Code: + +;;; Load the autoload file +;; It should have been generated either by +;; the package manager or the make file. + +(load "helm-autoloads" nil t) + +(provide 'helm-config) + +;; Local Variables: +;; byte-compile-warnings: (not obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-config.el ends here diff --git a/elpa/helm-20210131.1946/helm-dabbrev.el b/elpa/helm-20210131.1946/helm-dabbrev.el new file mode 100644 index 00000000..80c1accf --- /dev/null +++ b/elpa/helm-20210131.1946/helm-dabbrev.el @@ -0,0 +1,402 @@ +;;; helm-dabbrev.el --- Helm implementation of dabbrev. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto + +;; This program 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 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see . + +;;; Code: + +(require 'helm) +(require 'helm-lib) +(require 'helm-help) +(require 'helm-elisp) ; For show-completion. + +(defgroup helm-dabbrev nil + "Dabbrev related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-dabbrev-always-search-all t + "Always search in all buffers when non--nil. +Note that even if nil, a search in all buffers will occur if the +length of candidates is <= than +`helm-dabbrev-max-length-result'." + :group 'helm-dabbrev + :type 'boolean) + +(defcustom helm-dabbrev-candidates-number-limit 1000 + "Maximum number of candidates to collect. + +The higher this number is, the slower the computation of +candidates will be. You can use safely a higher value with +emacs-26+. +Note that this have nothing to do with +`helm-candidate-number-limit', this means that computation of +candidates stop when this value is reached but only +`helm-candidate-number-limit' candidates are displayed in the +Helm buffer." + :group 'helm-dabbrev + :type 'integer) + +(defcustom helm-dabbrev-ignored-buffers-regexps + '("\\*helm" "\\*Messages" "\\*Echo Area" "\\*Buffer List") + "List of regexps matching names of buffers that `helm-dabbrev' should not check." + :group 'helm-dabbrev + :type '(repeat regexp)) + +(defcustom helm-dabbrev-related-buffer-fn #'helm-dabbrev--same-major-mode-p + "A function that decide if a buffer to search in its related to `current-buffer'. + +This is actually determined by comparing `major-mode' of the +buffer to search and the `current-buffer'. + +The function take one arg, the buffer which is current, look at +`helm-dabbrev--same-major-mode-p' for an example. + +When nil all buffers are considered related to `current-buffer'." + :group 'helm-dabbrev + :type 'function) + +(defcustom helm-dabbrev-major-mode-assoc nil + "Major mode association alist. + +This allow helm-dabbrev searching in buffers with the associated +`major-mode'. +E.g. \(emacs-lisp-mode . lisp-interaction-mode\) + +will allow searching in the lisp-interaction-mode buffer when +`current-buffer' is an `emacs-lisp-mode' buffer and vice versa +i.e. no need to provide \(lisp-interaction-mode . +emacs-lisp-mode\) association. + +When nil check is the searched buffer has same `major-mode' than +the `current-buffer'. + +This has no effect when `helm-dabbrev-related-buffer-fn' is nil +or of course bound to a function that doesn't handle this var." + :type '(alist :key-type symbol :value-type symbol) + :group 'helm-dabbrev) + +(defcustom helm-dabbrev-lineno-around 30 + "Search first in this number of lines before and after point." + :group 'helm-dabbrev + :type 'integer) + +(defcustom helm-dabbrev-cycle-threshold 5 + "Number of time helm-dabbrev cycle before displaying helm completion. +When nil or 0 disable cycling." + :group 'helm-dabbrev + :type '(choice (const :tag "Cycling disabled" nil) integer)) + +(defcustom helm-dabbrev-case-fold-search 'smart + "Set `case-fold-search' in `helm-dabbrev'. +Same as `helm-case-fold-search' but for `helm-dabbrev'. +Note that this is not affecting searching in Helm buffer, but the +initial search for all candidates in buffer(s)." + :group 'helm-dabbrev + :type '(choice (const :tag "Ignore case" t) + (const :tag "Respect case" nil) + (other :tag "Smart" 'smart))) + +(defvaralias 'helm-dabbrev--regexp 'helm-dabbrev-separator-regexp) +(make-obsolete-variable 'helm-dabbrev--regexp + 'helm-dabbrev-separator-regexp "2.8.3") +;; Check for beginning of line should happen last (^\n\\|^). +(defvar helm-dabbrev-separator-regexp + "\\s-\\|\t\\|[(\\[\\{\"'`=<$;,@.#+]\\|\\s\\\\|^\n\\|^" + "Regexp matching the start of a dabbrev candidate.") + + +(defvar helm-dabbrev-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-/") 'helm-next-line) + (define-key map (kbd "M-:") 'helm-previous-line) + map)) + +;; Internal +(defvar helm-dabbrev--cache nil) +(defvar helm-dabbrev--data nil) +(cl-defstruct helm-dabbrev-info dabbrev limits iterator) +(defvar helm-dabbrev--already-tried nil) +(defvar helm-dabbrev--computing-cache nil + "[INTERNAL] Flag to notify helm-dabbrev is blocked. +Do nothing when non nil.") + +(defun helm-dabbrev--buffer-list () + (cl-loop for buf in (buffer-list) + unless (cl-loop for r in helm-dabbrev-ignored-buffers-regexps + thereis (string-match r (buffer-name buf))) + collect buf)) + +(defun helm-dabbrev--same-major-mode-p (start-buffer) + "Decide if current-buffer is related to START-BUFFER." + (helm-same-major-mode-p start-buffer helm-dabbrev-major-mode-assoc)) + +(defun helm-dabbrev--collect (str limit ignore-case all) + (let* ((case-fold-search ignore-case) + (buffer1 (current-buffer)) ; start buffer. + (minibuf (minibufferp buffer1)) + results pos-before pos-after) + (catch 'break + (dolist (buf (if all (helm-dabbrev--buffer-list) + (list (current-buffer)))) + (with-current-buffer buf + (when (or minibuf ; check against all buffers when in minibuffer. + (if helm-dabbrev-related-buffer-fn + (funcall helm-dabbrev-related-buffer-fn buffer1) + t)) + (save-excursion + ;; Start searching before thing before point. + (goto-char (- (point) (length str))) + ;; Search the last 30 lines BEFORE point and set POS-BEFORE. + (cl-multiple-value-bind (res _pa pb) + (helm-dabbrev--search-and-store str -2 limit results) + (setq results res + ;; No need to set POS-AFTER here. + pos-before pb))) + (save-excursion + ;; Search the next 30 lines AFTER point and set POS-AFTER. + (cl-multiple-value-bind (res pa _pb) + (helm-dabbrev--search-and-store str 2 limit results) + (setq results res + ;; No need to set POS-BEFORE, we keep the last + ;; value found. + pos-after pa))) + (save-excursion + ;; Search all BEFORE point maybe starting from + ;; POS-BEFORE to not search again what previously found. + ;; If limit is reached in previous call of + ;; `helm-dabbrev--search-and-store' POS-BEFORE is nil and + ;; goto-char will fail, so check it. + (when pos-before (goto-char pos-before)) + (cl-multiple-value-bind (res _pa _pb) + (helm-dabbrev--search-and-store str -1 limit results) + ;; No need to set POS-BEFORE and POS-AFTER here. + (setq results res))) + (save-excursion + ;; Search all AFTER point maybe starting from POS-AFTER. + ;; Same comment as above for POS-AFTER. + (when pos-after (goto-char pos-after)) + (cl-multiple-value-bind (res _pa _pb) + (helm-dabbrev--search-and-store str 1 limit results) + ;; No need to set POS-BEFORE and POS-AFTER here. + (setq results res))))) + (when (>= (length results) limit) (throw 'break nil)))) + (nreverse results))) + +(defun helm-dabbrev--search-and-store (pattern direction limit results) + "Search words or symbols matching PATTERN in DIRECTION up to LIMIT. +Finally returns all matched candidates appended to RESULTS. +Argument DIRECTION can be: + - (1): Search forward from point. + - (-1): Search backward from point. + - (2): Search forward from the + `helm-dabbrev-lineno-around' + lines after point. + - (-2): Search backward from the + `helm-dabbrev-lineno-around' + lines before point." + (let ((res results) + after before) + (while (and (<= (length res) limit) + (cl-case direction + (1 (search-forward pattern nil t)) + (-1 (search-backward pattern nil t)) + (2 (let ((pos + (save-excursion + (forward-line + helm-dabbrev-lineno-around) + (point)))) + (setq after pos) + (search-forward pattern pos t))) + (-2 (let ((pos + (save-excursion + (forward-line + (- helm-dabbrev-lineno-around)) + (point)))) + (setq before pos) + (search-backward pattern pos t))))) + (let* ((mb (match-beginning 0)) + (replace-regexp (concat "\\(" helm-dabbrev-separator-regexp + "\\)\\'")) + (match-word (helm-dabbrev--search + pattern mb replace-regexp))) + (when (and match-word (not (member match-word res))) + (push match-word res)))) + (list res after before))) + +(defun helm-dabbrev--search (pattern beg sep-regexp) + "Search word or symbol at point matching PATTERN. +Argument BEG is corresponding to the previous `match-beginning' +search. +The search starts at (1- BEG) with a regexp starting with +`helm-dabbrev-separator-regexp' followed by PATTERN followed by a +regexp matching syntactically any word or symbol. +The possible false positives matching SEP-REGEXP at end are +finally removed." + (let ((eol (point-at-eol))) + (save-excursion + (goto-char (1- beg)) + (when (re-search-forward + (concat "\\(" + helm-dabbrev-separator-regexp + "\\)" + "\\(?99:\\(" + (regexp-quote pattern) + "\\(\\sw\\|\\s_\\)+\\)\\)") + eol t) + (replace-regexp-in-string + sep-regexp "" + (match-string-no-properties 99)))))) + +(defun helm-dabbrev--get-candidates (dabbrev &optional limit) + (cl-assert dabbrev nil "[No Match]") + (helm-dabbrev--collect + dabbrev (or limit helm-dabbrev-candidates-number-limit) + (cl-case helm-dabbrev-case-fold-search + (smart (helm-set-case-fold-search-1 dabbrev)) + (t helm-dabbrev-case-fold-search)) + helm-dabbrev-always-search-all)) + +(defun helm-dabbrev-default-action (candidate) + (with-helm-current-buffer + (let* ((limits (helm-bounds-of-thing-before-point + helm-dabbrev-separator-regexp)) + (beg (car limits)) + (end (point))) + (run-with-timer + 0.01 nil + 'helm-insert-completion-at-point + beg end candidate)))) + +;;;###autoload +(cl-defun helm-dabbrev () + "Preconfigured helm for dynamic abbreviations." + (interactive) + (unless helm-dabbrev--computing-cache + (let ((dabbrev (helm-thing-before-point + nil helm-dabbrev-separator-regexp)) + (limits (helm-bounds-of-thing-before-point + helm-dabbrev-separator-regexp)) + (enable-recursive-minibuffers t) + (cycling-disabled-p (or (null helm-dabbrev-cycle-threshold) + (zerop helm-dabbrev-cycle-threshold))) + (helm-execute-action-at-once-if-one t) + (helm-quit-if-no-candidate + (lambda () + (message "[Helm-dabbrev: No expansion found]")))) + (cl-assert (and (stringp dabbrev) (not (string= dabbrev ""))) + nil "[Helm-dabbrev: Nothing found before point]") + (when (and + ;; have been called at least once. + (helm-dabbrev-info-p helm-dabbrev--data) + ;; But user have moved with some other command + ;; in the meaning time. + (not (eq last-command 'helm-dabbrev))) + (setq helm-dabbrev--data nil)) + ;; When candidates are requested in helm directly without cycling, + ;; we need them right now before running helm. + (when cycling-disabled-p + (message "Waiting for helm-dabbrev candidates...") + (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev))) + (unless (or cycling-disabled-p + (helm-dabbrev-info-p helm-dabbrev--data)) + (setq helm-dabbrev--data + (make-helm-dabbrev-info + :dabbrev dabbrev + :limits limits + :iterator + (helm-iter-list + (cl-loop for i in (helm-dabbrev--get-candidates + dabbrev helm-dabbrev-cycle-threshold) + when (string-match-p + (concat "^" (regexp-quote dabbrev)) i) + collect i))))) + (let ((iter (and (helm-dabbrev-info-p helm-dabbrev--data) + (helm-dabbrev-info-iterator helm-dabbrev--data))) + deactivate-mark) + ;; Cycle until iterator is consumed. + (helm-aif (and iter (helm-iter-next iter)) + (progn + (helm-insert-completion-at-point + (car (helm-dabbrev-info-limits helm-dabbrev--data)) + ;; END is the end of the previous inserted string, not + ;; the end (apart for first insertion) of the initial string. + (cdr limits) it) + ;; Move already tried candidates to end of list. + (push it helm-dabbrev--already-tried)) + ;; Iterator is now empty, or cycling was disabled, maybe + ;; reset dabbrev to initial value and start helm completion. + (let* ((old-dabbrev (if (helm-dabbrev-info-p helm-dabbrev--data) + (helm-dabbrev-info-dabbrev helm-dabbrev--data) + dabbrev)) + (only-one (eq (length helm-dabbrev--already-tried) 1))) + (unless helm-dabbrev--cache ; Already computed when + ; cycling is disabled. + (message "Waiting for helm-dabbrev candidates...") + (setq helm-dabbrev--computing-cache t) + (setq helm-dabbrev--cache + (helm-dabbrev--get-candidates old-dabbrev)) + ;; If user continues typing M-/ while display is blocked by + ;; helm-dabbrev--get-candidates delete these events. + (setq unread-command-events nil)) + ;; If the length of candidates is only one when computed + ;; that's mean the unique matched item have already been + ;; inserted by the iterator, so no need to reinsert the old dabbrev, + ;; just let helm exiting with "No expansion found". + (unless (or only-one cycling-disabled-p) + (setq dabbrev old-dabbrev + limits (helm-dabbrev-info-limits helm-dabbrev--data)) + (setq helm-dabbrev--data nil) + (delete-region (car limits) (point)) + (insert dabbrev)) + (when (and (null cycling-disabled-p) only-one) + (setq helm-dabbrev--cache nil + helm-dabbrev--already-tried nil + helm-dabbrev--computing-cache nil) + (cl-return-from helm-dabbrev + (message "[Helm-dabbrev: No expansion found]"))) + (with-helm-show-completion (car limits) (cdr limits) + (unwind-protect + (helm :sources + (helm-build-in-buffer-source "Dabbrev Expand" + :data + (append + (cl-loop with lst = helm-dabbrev--cache + for cand in helm-dabbrev--already-tried + do (setq lst (delete cand lst)) + finally return lst) + helm-dabbrev--already-tried) + :persistent-action 'ignore + :persistent-help "DoNothing" + :keymap helm-dabbrev-map + :action 'helm-dabbrev-default-action + :group 'helm-dabbrev) + :buffer "*helm dabbrev*" + :input (concat "^" dabbrev " ") + :resume 'noresume + :allow-nest t) + (setq helm-dabbrev--computing-cache nil + helm-dabbrev--already-tried nil + helm-dabbrev--cache nil))))))))) + +(provide 'helm-dabbrev) + +;; Local Variables: +;; byte-compile-warnings: (not obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-dabbrev.el ends here diff --git a/elpa/helm-20191101.641/helm-easymenu.el b/elpa/helm-20210131.1946/helm-easymenu.el similarity index 94% rename from elpa/helm-20191101.641/helm-easymenu.el rename to elpa/helm-20210131.1946/helm-easymenu.el index eb6878ba..7f717d08 100644 --- a/elpa/helm-20191101.641/helm-easymenu.el +++ b/elpa/helm-20210131.1946/helm-easymenu.el @@ -1,6 +1,6 @@ ;;; helm-easymenu.el --- Helm easymenu definitions. -*- lexical-binding: t -*- -;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2015 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -34,6 +34,9 @@ ["Bookmarks" helm-filtered-bookmarks t]) ("Buffers" ["Find buffers" helm-buffers-list t]) + ("Projects" + ["Browse project" helm-browse-project] + ["Projects history" helm-projects-history]) ("Commands" ["Emacs Commands" helm-M-x t] ["Externals Commands" helm-run-external-command t]) diff --git a/elpa/helm-20191101.641/helm-elisp-package.el b/elpa/helm-20210131.1946/helm-elisp-package.el similarity index 91% rename from elpa/helm-20191101.641/helm-elisp-package.el rename to elpa/helm-20210131.1946/helm-elisp-package.el index 77f2c763..c1237461 100644 --- a/elpa/helm-20191101.641/helm-elisp-package.el +++ b/elpa/helm-20210131.1946/helm-elisp-package.el @@ -1,6 +1,6 @@ ;;; helm-elisp-package.el --- helm interface for package.el -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -35,7 +35,19 @@ (const :tag "Show upgradable packages" upgrade))) (defcustom helm-el-truncate-lines t - "Truncate lines in helm-buffer when non--nil." + "Truncate lines in `helm-buffer' when non-nil." + :group 'helm-el-package + :type 'boolean) + + +(defcustom helm-el-package-upgrade-on-start nil + "Show package upgrades on startup when non nil." + :group 'helm-el-package + :type 'boolean) + +(defcustom helm-el-package-autoremove-on-start nil + "Try to autoremove no more needed packages on startup. +See `package-autoremove'." :group 'helm-el-package :type 'boolean) @@ -48,15 +60,27 @@ ;; Shutup bytecompiler for emacs-24* (defvar package-menu-async) ; Only available on emacs-25. +(defvar helm-marked-buffer-name) (declare-function async-byte-recompile-directory "ext:async-bytecomp.el") +(declare-function with-helm-display-marked-candidates "helm-utils.el") + (defun helm-el-package--init () + ;; In emacs-27 package-show-package-list returns an empty buffer + ;; until package-initialize have been called. + (unless (or package--initialized + (null (boundp 'package-quickstart))) + (package-initialize)) (let (package-menu-async (inhibit-read-only t)) (when (null package-alist) (setq helm-el-package--show-only 'all)) - (when (setq helm-el-package--removable-packages - (package--removable-packages)) + (unless (consp package-selected-packages) + (helm-aif (package--find-non-dependencies) + (setq package-selected-packages it))) + (when (and (setq helm-el-package--removable-packages + (package--removable-packages)) + helm-el-package-autoremove-on-start) (package-autoremove)) (unwind-protect (progn @@ -86,7 +110,8 @@ (message "Refreshing packages list done, [%d] package(s) to upgrade" (length helm-el-package--upgrades)) (message "Refreshing packages list done, no upgrades available")) - (setq helm-el-package--show-only (if helm-el-package--upgrades + (setq helm-el-package--show-only (if (and helm-el-package-upgrade-on-start + helm-el-package--upgrades) 'upgrade helm-el-package-initial-filter)))) (kill-buffer "*Packages*")))) @@ -250,8 +275,10 @@ (defun helm-el-package-upgrade-all () (if helm-el-package--upgrades (with-helm-display-marked-candidates - helm-marked-buffer-name (mapcar (lambda (x) (symbol-name (car x))) - helm-el-package--upgrades) + helm-marked-buffer-name (helm-fast-remove-dups + (mapcar (lambda (x) (symbol-name (car x))) + helm-el-package--upgrades) + :test 'equal) (when (y-or-n-p "Upgrade all packages? ") (helm-el-package-upgrade-1 helm-el-package--tabulated-list))) (message "No packages to upgrade actually!"))) @@ -437,7 +464,7 @@ ;;;###autoload (defun helm-list-elisp-packages (arg) - "Preconfigured helm for listing and handling emacs packages." + "Preconfigured `helm' for listing and handling Emacs packages." (interactive "P") (when arg (setq helm-el-package--initialized-p nil)) (unless helm-source-list-el-package @@ -450,10 +477,11 @@ ;;;###autoload (defun helm-list-elisp-packages-no-fetch (arg) - "Preconfigured helm for emacs packages. + "Preconfigured Helm for Emacs packages. -Same as `helm-list-elisp-packages' but don't fetch packages on remote. -Called with a prefix ARG always fetch packages on remote." +Same as `helm-list-elisp-packages' but don't fetch packages on +remote. Called with a prefix ARG always fetch packages on +remote." (interactive "P") (let ((helm-el-package--initialized-p (null arg))) (helm-list-elisp-packages nil))) diff --git a/elpa/helm-20191101.641/helm-elisp.el b/elpa/helm-20210131.1946/helm-elisp.el similarity index 90% rename from elpa/helm-20191101.641/helm-elisp.el rename to elpa/helm-20210131.1946/helm-elisp.el index 78a5a3ce..b3269053 100644 --- a/elpa/helm-20191101.641/helm-elisp.el +++ b/elpa/helm-20210131.1946/helm-elisp.el @@ -1,6 +1,6 @@ ;;; helm-elisp.el --- Elisp symbols completion for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,9 +26,11 @@ (require 'helm-eval) (require 'helm-files) -(declare-function 'helm-describe-function "helm-lib") -(declare-function 'helm-describe-variable "helm-lib") -(declare-function 'helm-describe-face "helm-lib") +(declare-function helm-describe-function "helm-lib") +(declare-function helm-describe-variable "helm-lib") +(declare-function helm-describe-face "helm-lib") +(declare-function helm-read-file-name "helm-mode") +(declare-function helm-comp-read "helm-mode") ;;; Customizable values @@ -53,14 +55,14 @@ This is used in macro `with-helm-show-completion'." callf callf2 cl-callf cl-callf2 fset fboundp fmakunbound symbol-function) "List of function where quoted function completion happen. -e.g give only function names after \(funcall '." +E.g. give only function names after \(funcall '." :group 'helm-elisp :type '(repeat (choice symbol))) (defcustom helm-lisp-unquoted-function-list '(function defadvice) "List of function where unquoted function completion happen. -e.g give only function names after \(function ." +E.g. give only function names after \(function ." :group 'helm-elisp :type '(repeat (choice symbol))) @@ -71,9 +73,9 @@ e.g give only function names after \(function ." (defcustom helm-lisp-fuzzy-completion nil "Enable fuzzy matching in emacs-lisp completion when non-nil. -NOTE: This enable fuzzy matching in helm native implementation of -elisp completion, but not on helmized elisp completion, i.e -fuzzy completion is not available in `completion-at-point'." +NOTE: This enables fuzzy matching in Helm native implementation of +elisp completion, but not on helmized elisp completion, i.e. fuzzy +completion is not available in `completion-at-point'." :group 'helm-elisp :type 'boolean) @@ -119,12 +121,14 @@ display." :group 'helm-faces) (defface helm-lisp-show-completion - '((t (:background "DarkSlateGray"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "DarkSlateGray")) "Face used for showing candidates in `helm-lisp-completion'." :group 'helm-elisp-faces) (defface helm-lisp-completion-info - '((t (:foreground "red"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red")) "Face used for showing info in `helm-lisp-completion'." :group 'helm-elisp-faces) @@ -162,7 +166,7 @@ display." 'face 'helm-lisp-show-completion)) (defun helm-show-completion-default-display-function (buffer &rest _args) - "A special resized helm window is used depending on position in BUFFER." + "A special resized Helm window is used depending on position in BUFFER." (with-selected-window (selected-window) (if (window-dedicated-p) (helm-default-display-buffer buffer) @@ -181,10 +185,10 @@ display." buffer))))) (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 `helm-current-buffer'. -BODY is an helm call where we want to enable show completion. + "Show Helm candidate in an overlay at point. +BEG and END are the beginning and end position of the current +completion in `helm-current-buffer'. +BODY is an Helm call where we want to enable show completion. If `helm-turn-on-show-completion' is nil do nothing." (declare (indent 2) (debug t)) `(unwind-protect @@ -291,7 +295,7 @@ Return a cons \(beg . end\)." (defvar helm-lgst-len nil) ;;;###autoload (defun helm-lisp-completion-at-point () - "Preconfigured helm for lisp symbol completion at point." + "Preconfigured Helm for Lisp symbol completion at point." (interactive) (setq helm-lgst-len 0) (let* ((target (helm-thing-before-point)) @@ -343,8 +347,9 @@ Return a cons \(beg . end\)." (defun helm-lisp-completion-persistent-action (candidate &optional name) "Show documentation for the function. -Documentation is shown briefly in mode-line or completely -in other window according to the value of `helm-elisp-help-function'." +Documentation is shown briefly in mode-line or completely in +other window according to the value of +`helm-elisp-help-function'." (funcall helm-elisp-help-function candidate name)) (defun helm-lisp-completion-persistent-help () @@ -368,15 +373,15 @@ in other window according to the value of `helm-elisp-help-function'." (defun helm-elisp-show-help (candidate &optional name) "Show full help for the function CANDIDATE. -Arg NAME specify the name of the top level function -calling helm generic completion (e.g \"describe-function\") -which allow calling the right function when CANDIDATE symbol -refers at the same time to variable and a function." +Arg NAME specifies the name of the top level function calling +Helm generic completion (e.g., \"describe-function\") which +allows calling the right function when CANDIDATE symbol refers at +the same time to variable and a function." (helm-elisp--persistent-help candidate 'helm-elisp--show-help-1 name)) (defun helm-elisp-show-doc-modeline (candidate &optional name) - "Show brief documentation for the function in modeline." + "Show brief documentation for the function in the mode-line." (let ((cursor-in-echo-area t) mode-line-in-non-selected-windows) (helm-show-info-in-mode-line @@ -386,7 +391,7 @@ refers at the same time to variable and a function." 'face 'helm-lisp-completion-info)))) (defun helm-lisp-completion-transformer (candidates _source) - "Helm candidates transformer for lisp completion." + "Helm candidates transformer for Lisp completion." (cl-loop for c in candidates for sym = (intern c) for annot = (cl-typecase sym @@ -426,7 +431,7 @@ If SYM is not documented, return \"Not documented\"." ;;;###autoload (defun helm-complete-file-name-at-point (&optional force) - "Preconfigured helm to complete file name at point." + "Preconfigured Helm to complete file name at point." (interactive) (require 'helm-mode) (let* ((tap (thing-at-point 'filename)) @@ -464,8 +469,9 @@ If SYM is not documented, return \"Not documented\"." ;;;###autoload (defun helm-lisp-completion-or-file-name-at-point () - "Preconfigured helm to complete lisp symbol or filename at point. -Filename completion happen if string start after or between a double quote." + "Preconfigured Helm to complete Lisp symbol or filename at point. +Filename completion happens if string start after or between a +double quote." (interactive) (let* ((tap (thing-at-point 'filename))) (if (and tap (save-excursion @@ -624,9 +630,7 @@ Filename completion happen if string start after or between a double quote." (helm-elisp--persistent-help candidate 'helm-describe-function)) :persistent-help "Toggle describe command" - :action '(("Describe function" . helm-describe-function) - ("Find function" . helm-find-function) - ("Info lookup" . helm-info-lookup-symbol)))) + :action 'helm-type-function-actions)) (defun helm-def-source--emacs-functions (&optional default) (helm-build-in-buffer-source "Functions" @@ -645,9 +649,7 @@ Filename completion happen if string start after or between a double quote." candidate 'helm-describe-function)) :persistent-help "Toggle describe function" :nomark t - :action '(("Describe function" . helm-describe-function) - ("Find function" . helm-find-function) - ("Info lookup" . helm-info-lookup-symbol)))) + :action 'helm-type-function-actions)) (defun helm-def-source--eieio-classes (&optional default) (helm-build-in-buffer-source "Classes" @@ -718,7 +720,7 @@ Filename completion happen if string start after or between a double quote." (list (helm-info-lookup-fallback-source c))) :resume 'noresume :buffer "*helm lookup*" - :input c))) + :input (helm-stringify c)))) (defun helm-info-lookup-symbol (candidate) ;; ???:Running an idle-timer allows not catching RET when exiting @@ -728,9 +730,9 @@ Filename completion happen if string start after or between a double quote." ;;;###autoload (defun helm-apropos (default) - "Preconfigured helm to describe commands, functions, variables and faces. -In non interactives calls DEFAULT argument should be provided as a string, -i.e the `symbol-name' of any existing symbol." + "Preconfigured Helm to describe commands, functions, variables and faces. +In non interactives calls DEFAULT argument should be provided as +a string, i.e. the `symbol-name' of any existing symbol." (interactive (list (thing-at-point 'symbol))) (helm :sources (mapcar (lambda (func) @@ -744,6 +746,14 @@ i.e the `symbol-name' of any existing symbol." ;;; Advices ;; ;; +(defvar ad-advised-functions) +(defvar ad-advice-classes) +(declare-function ad-make-single-advice-docstring "advice") +(declare-function ad-get-advice-info-field "advice") +(declare-function ad-advice-set-enabled "advice") +(declare-function ad-advice-set-enabled "advice") +(declare-function ad-advice-enabled "advice") + (defvar helm-source-advice (helm-build-sync-source "Function Advice" :init (lambda () (require 'advice)) @@ -904,46 +914,29 @@ i.e the `symbol-name' of any existing symbol." ;;; Complex command history ;; ;; -(defun helm-btf--usable-p () - "Return t if current version of `backtrace-frame' accept 2 arguments." - (condition-case nil - (progn (backtrace-frame 1 'condition-case) t) - (wrong-number-of-arguments nil))) - -(if (helm-btf--usable-p) ; Check if BTF accept more than one arg. - ;; Emacs 24.4. - (dont-compile - (defvar helm-sexp--last-sexp nil) - ;; This wont work compiled. - (defun helm-sexp-eval-1 () - (interactive) - (unwind-protect - (progn - ;; Trick called-interactively-p into thinking that `cand' is - ;; an interactive call, See `repeat-complex-command'. - (add-hook 'called-interactively-p-functions - #'helm-complex-command-history--called-interactively-skip) - (eval (read helm-sexp--last-sexp))) - (remove-hook 'called-interactively-p-functions - #'helm-complex-command-history--called-interactively-skip))) - - (defun helm-complex-command-history--called-interactively-skip (i _frame1 frame2) - (and (eq 'eval (cadr frame2)) - (eq 'helm-sexp-eval-1 - (cadr (backtrace-frame (+ i 2) #'called-interactively-p))) - 1)) - - (defun helm-sexp-eval (_candidate) - (call-interactively #'helm-sexp-eval-1))) - ;; Emacs 24.3 - (defun helm-sexp-eval (cand) - (let ((sexp (read cand))) - (condition-case err - (if (> (length (remove nil sexp)) 1) - (eval sexp) - (apply 'call-interactively sexp)) - (error (message "Evaluating gave an error: %S" err) - nil))))) + +(defvar helm-sexp--last-sexp nil) +;; This wont work compiled. +(defun helm-sexp-eval-1 () + (interactive) + (unwind-protect + (progn + ;; Trick called-interactively-p into thinking that `cand' is + ;; an interactive call, See `repeat-complex-command'. + (add-hook 'called-interactively-p-functions + #'helm-complex-command-history--called-interactively-skip) + (eval (read helm-sexp--last-sexp))) + (remove-hook 'called-interactively-p-functions + #'helm-complex-command-history--called-interactively-skip))) + +(defun helm-complex-command-history--called-interactively-skip (i _frame1 frame2) + (and (eq 'eval (cadr frame2)) + (eq 'helm-sexp-eval-1 + (cadr (backtrace-frame (+ i 2) #'called-interactively-p))) + 1)) + +(defun helm-sexp-eval (_candidate) + (call-interactively #'helm-sexp-eval-1)) (defvar helm-source-complex-command-history (helm-build-sync-source "Complex Command History" @@ -968,7 +961,7 @@ i.e the `symbol-name' of any existing symbol." ;;;###autoload (defun helm-complex-command-history () - "Preconfigured helm for complex command history." + "Preconfigured `helm' for complex command history." (interactive) (helm :sources 'helm-source-complex-command-history :buffer "*helm complex commands*")) diff --git a/elpa/helm-20210131.1946/helm-epa.el b/elpa/helm-20210131.1946/helm-epa.el new file mode 100644 index 00000000..412d0dc4 --- /dev/null +++ b/elpa/helm-20210131.1946/helm-epa.el @@ -0,0 +1,231 @@ +;;; helm-epa.el --- helm interface for epa/epg + +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto + +;; This program 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 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see . + + +;;; Code: + +(require 'helm) + +(eval-when-compile (require 'epg)) +(defvar epa-protocol) +(defvar epa-last-coding-system-specified) +(defvar epg-key-validity-alist) +(defvar mail-header-separator) +(declare-function epg-list-keys "epg") +(declare-function epg-make-context "epg") +(declare-function epg-key-sub-key-list "epg") +(declare-function epg-sub-key-id "epg") +(declare-function epg-key-user-id-list "epg") +(declare-function epg-user-id-string "epg") +(declare-function epg-user-id-validity "epg") +(declare-function epa-sign-region "epa") +(declare-function epa--read-signature-type "epa") +(declare-function epa-display-error "epa") +(declare-function epg-export-keys-to-string "epg") +(declare-function epg-context-armor "epg") +(declare-function epg-context-set-armor "epg") +(declare-function epg-delete-keys "epg") +(declare-function helm-read-file-name "helm-mode") + +(defvar helm-epa--list-only-secrets nil + "[INTERNAL] Used to pass MODE argument to `epg-list-keys'.") + +(defcustom helm-epa-actions '(("Show key" . epa--show-key) + ("encrypt file with key" . helm-epa-encrypt-file) + ("Copy keys to kill ring" . helm-epa-kill-keys-armor) + ("Delete keys" . helm-epa-delete-keys)) + "Actions for `helm-epa-list-keys'." + :type '(alist :key-type string :value-type symbol) + :group 'helm-misc) + +(defclass helm-epa (helm-source-sync) + ((init :initform (lambda () + (require 'epg) + (require 'epa))) + (candidates :initform 'helm-epa-get-key-list) + (keymap :initform helm-comp-read-map) + (mode-line :initform helm-comp-read-mode-line)) + "Allow building helm sources for GPG keys.") + +(defun helm-epa-get-key-list (&optional keys) + "Build candidate list for `helm-epa-list-keys'." + (cl-loop with all-keys = (or keys (epg-list-keys (epg-make-context epa-protocol) + nil helm-epa--list-only-secrets)) + for key in all-keys + for sublist = (car (epg-key-sub-key-list key)) + for subkey-id = (epg-sub-key-id sublist) + for uid-list = (epg-key-user-id-list key) + for uid = (epg-user-id-string (car uid-list)) + for validity = (epg-user-id-validity (car uid-list)) + collect (cons (format " %s %s %s" + (helm-aif (rassq validity epg-key-validity-alist) + (string (car it)) + "?") + (propertize + subkey-id + 'face (cl-case validity + (none 'epa-validity-medium) + ((revoked expired) + 'epa-validity-disabled) + (t 'epa-validity-high))) + (propertize + uid 'face 'font-lock-warning-face)) + key))) + +(defun helm-epa--select-keys (prompt keys) + "A helm replacement for `epa--select-keys'." + (let ((result (helm :sources (helm-make-source "Epa select keys" 'helm-epa + :candidates (lambda () + (helm-epa-get-key-list keys))) + :prompt (and prompt (helm-epa--format-prompt prompt)) + :buffer "*helm epa*"))) + (unless (equal result "") + result))) + +(defun helm-epa--format-prompt (prompt) + (let ((split (split-string prompt "\n"))) + (if (cdr split) + (format "%s\n(%s): " + (replace-regexp-in-string "\\.[\t ]*\\'" "" (car split)) + (replace-regexp-in-string "\\.[\t ]*\\'" "" (cadr split))) + (format "%s: " (replace-regexp-in-string "\\.[\t ]*\\'" "" (car split)))))) + +(defun helm-epa--read-signature-type () + "A helm replacement for `epa--read-signature-type'." + (let ((answer (helm-read-answer "Signature type: +(n - Create a normal signature) +(c - Create a cleartext signature) +(d - Create a detached signature)" + '("n" "c" "d")))) + (helm-acase answer + ("n" 'normal) + ("c" 'clear) + ("d" 'detached)))) + +;;;###autoload +(define-minor-mode helm-epa-mode + "Enable helm completion on gpg keys in epa functions." + :group 'helm-misc + :global t + (require 'epa) + (if helm-epa-mode + (progn + (advice-add 'epa--select-keys :override #'helm-epa--select-keys) + (advice-add 'epa--read-signature-type :override #'helm-epa--read-signature-type)) + (advice-remove 'epa-select-keys #'helm-epa--select-keys) + (advice-remove 'epa--read-signature-type #'helm-epa--read-signature-type))) + +(defun helm-epa-action-transformer (actions _candidate) + "Helm epa action transformer function." + (cond ((with-helm-current-buffer + (derived-mode-p 'message-mode 'mail-mode)) + (helm-append-at-nth + actions '(("Sign mail with key" . helm-epa-mail-sign) + ("Encrypt mail with key" . helm-epa-mail-encrypt)) + 3)) + (t actions))) + +(defun helm-epa-delete-keys (_candidate) + "Delete gpg marked keys from helm-epa." + (let ((context (epg-make-context epa-protocol)) + (keys (helm-marked-candidates))) + (message "Deleting gpg keys..") + (condition-case error + (epg-delete-keys context keys) + (error + (epa-display-error context) + (signal (car error) (cdr error)))) + (message "Deleting gpg keys done"))) + +(defun helm-epa-encrypt-file (candidate) + "Select a file to encrypt with key CANDIDATE." + (let ((file (helm-read-file-name "Encrypt file: ")) + (key (epg-sub-key-id (car (epg-key-sub-key-list candidate)))) + (id (epg-user-id-string (car (epg-key-user-id-list candidate))))) + (epa-encrypt-file file candidate) + (message "File encrypted with key `%s %s'" key id))) + +(defun helm-epa-kill-keys-armor (_candidate) + "Copy marked keys to kill ring." + (let ((keys (helm-marked-candidates)) + (context (epg-make-context epa-protocol))) + (with-no-warnings + (setf (epg-context-armor context) t)) + (condition-case error + (kill-new (epg-export-keys-to-string context keys)) + (error + (epa-display-error context) + (signal (car error) (cdr error)))))) + +(defun helm-epa-mail-sign (candidate) + "Sign email with key CANDIDATE." + (let ((key (epg-sub-key-id (car (epg-key-sub-key-list candidate)))) + (id (epg-user-id-string (car (epg-key-user-id-list candidate)))) + start end mode) + (save-excursion + (goto-char (point-min)) + (if (search-forward mail-header-separator nil t) + (forward-line)) + (setq epa-last-coding-system-specified + (or coding-system-for-write + (select-safe-coding-system (point) (point-max)))) + (let ((verbose current-prefix-arg)) + (setq start (point) + end (point-max) + mode (if verbose + (epa--read-signature-type) + 'clear)))) + ;; TODO Make non-interactive functions to replace epa-sign-region + ;; and epa-encrypt-region and inline them. + (with-no-warnings + (epa-sign-region start end candidate mode)) + (message "Mail signed with key `%s %s'" key id))) + +(defun helm-epa-mail-encrypt (candidate) + "Encrypt email with key CANDIDATE." + (let (start end) + (save-excursion + (goto-char (point-min)) + (when (search-forward mail-header-separator nil t) + (forward-line)) + (setq start (point) + end (point-max)) + (setq epa-last-coding-system-specified + (or coding-system-for-write + (select-safe-coding-system start end)))) + ;; Don't let some read-only text stop us from encrypting. + (let ((inhibit-read-only t) + (key (epg-sub-key-id (car (epg-key-sub-key-list candidate)))) + (id (epg-user-id-string (car (epg-key-user-id-list candidate))))) + (with-no-warnings + (epa-encrypt-region start end candidate nil nil)) + (message "Mail encrypted with key `%s %s'" key id)))) + +;;;###autoload +(defun helm-epa-list-keys () + "List all gpg keys. +This is the helm interface for `epa-list-keys'." + (interactive) + (helm :sources + (helm-make-source "Epg list keys" 'helm-epa + :action-transformer 'helm-epa-action-transformer + :action 'helm-epa-actions) + :buffer "*helm epg list keys*")) + +(provide 'helm-epa) + +;;; helm-epa.el ends here diff --git a/elpa/helm-20191101.641/helm-eshell.el b/elpa/helm-20210131.1946/helm-eshell.el similarity index 86% rename from elpa/helm-20191101.641/helm-eshell.el rename to elpa/helm-20210131.1946/helm-eshell.el index ac7c9003..6eb58cdd 100644 --- a/elpa/helm-20191101.641/helm-eshell.el +++ b/elpa/helm-20210131.1946/helm-eshell.el @@ -1,6 +1,6 @@ ;;; helm-eshell.el --- pcomplete and eshell completion for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -44,12 +44,12 @@ (defgroup helm-eshell nil - "Helm eshell completion and history." + "Helm completion and history for Eshell." :group 'helm) (defcustom helm-eshell-fuzzy-match nil - "Enable fuzzy matching in `helm-esh-pcomplete' when non--nil." + "Enable fuzzy matching in `helm-esh-pcomplete' when non-nil." :group 'helm-eshell :type 'boolean) @@ -71,38 +71,12 @@ (defvar helm-eshell--quit-flag nil) -(defclass helm-esh-source (helm-source-sync) - ((init :initform (lambda () - (setq pcomplete-current-completions nil - pcomplete-last-completion-raw nil) - ;; Eshell-command add this hook in all minibuffers - ;; Remove it for the helm one. (Fixed in Emacs24) - (remove-hook 'minibuffer-setup-hook 'eshell-mode))) - (candidates :initform 'helm-esh-get-candidates) - ;(nomark :initform t) - (persistent-action :initform 'ignore) - (nohighlight :initform t) - (filtered-candidate-transformer - :initform - (lambda (candidates _sources) - (cl-loop - for i in candidates - collect - (cond ((string-match "\\`~/?" helm-ec-target) - (abbreviate-file-name i)) - ((string-match "\\`/" helm-ec-target) i) - (t - (file-relative-name i))) - into lst - finally return (sort lst 'helm-generic-sort-fn)))) - (action :initform 'helm-ec-insert)) - "Helm class to define source for Eshell completion.") - ;; Internal. (defvar helm-ec-target "") (defun helm-ec-insert (_candidate) "Replace text at point with CANDIDATE. -The function that call this should set `helm-ec-target' to thing at point." +The function that call this should set `helm-ec-target' to thing +at point." (set (make-local-variable 'comint-file-name-quote-list) eshell-special-chars-outside-quoting) (let ((pt (point))) @@ -132,8 +106,35 @@ The function that call this should set `helm-ec-target' to thing at point." "") " "))))) +(defun helm-esh-transformer (candidates _sources) + (cl-loop + for i in candidates + collect + (cond ((string-match "\\`~/?" helm-ec-target) + (abbreviate-file-name i)) + ((string-match "\\`/" helm-ec-target) i) + (t + (file-relative-name i))) + into lst + finally return (sort lst 'helm-generic-sort-fn))) + +(defclass helm-esh-source (helm-source-sync) + ((init :initform (lambda () + (setq pcomplete-current-completions nil + pcomplete-last-completion-raw nil) + ;; Eshell-command add this hook in all minibuffers + ;; Remove it for the helm one. (Fixed in Emacs24) + (remove-hook 'minibuffer-setup-hook 'eshell-mode))) + (candidates :initform 'helm-esh-get-candidates) + ;(nomark :initform t) + (persistent-action :initform 'ignore) + (nohighlight :initform t) + (filtered-candidate-transformer :initform #'helm-esh-transformer) + (action :initform 'helm-ec-insert)) + "Helm class to define source for Eshell completion.") + (defun helm-esh-get-candidates () - "Get candidates for eshell completion using `pcomplete'." + "Get candidates for Eshell completion using `pcomplete'." (catch 'pcompleted (with-helm-current-buffer (let* ((pcomplete-stub) @@ -214,9 +215,44 @@ The function that call this should set `helm-ec-target' to thing at point." "Helm class to define source for Eshell history.") +(defun helm-esh-pcomplete-input (target users-comp last) + (if (and (stringp last) + (not (string= last "")) + (not users-comp) + ;; Fix completion on "../" see #1832. + (or (file-exists-p last) + (helm-aand + (file-name-directory last) + (file-directory-p it)))) + (if (and (file-directory-p last) + (string-match "\\`[~.]*.*/[.]\\'" target)) + ;; Fix completion on "~/.", "~/[...]/.", and "../." + (expand-file-name + (concat (helm-basedir (file-name-as-directory last)) + (regexp-quote (helm-basename target)))) + (expand-file-name last)) + ;; Don't add "~" to input to provide completion on all users instead of only + ;; on current $HOME (#1832). + (unless users-comp last))) + +(defun helm-esh-pcomplete-default-source () + "Make and return the default source for Eshell completion." + (helm-make-source "Eshell completions" 'helm-esh-source + :fuzzy-match helm-eshell-fuzzy-match + :keymap helm-esh-completion-map)) + +(defvar helm-esh-pcomplete-build-source-fn #'helm-esh-pcomplete-default-source + "Function that builds a source or a list of sources.") + +(defun helm-esh-pcomplete--make-helm (&optional input) + (helm :sources (funcall helm-esh-pcomplete-build-source-fn) + :buffer "*helm pcomplete*" + :resume 'noresume + :input input)) + ;;;###autoload (defun helm-esh-pcomplete () - "Preconfigured helm to provide helm completion in eshell." + "Preconfigured `helm' to provide Helm completion in Eshell." (interactive) (let* ((helm-quit-if-no-candidate t) (helm-execute-action-at-once-if-one t) @@ -265,33 +301,8 @@ The function that call this should set `helm-ec-target' to thing at point." (add-hook 'helm-quit-hook 'helm-eshell--quit-hook-fn) (with-helm-show-completion beg end (unwind-protect - (or (helm :sources (helm-make-source "Eshell completions" 'helm-esh-source - :fuzzy-match helm-eshell-fuzzy-match) - :buffer "*helm pcomplete*" - :keymap helm-esh-completion-map - :resume 'noresume - :input (if (and (stringp last) - (not (string= last "")) - (not users-comp) - ;; Fix completion on - ;; "../" see #1832. - (or (file-exists-p last) - (helm-aand - (file-name-directory last) - (file-directory-p it)))) - (if (and (file-directory-p last) - (string-match "\\`[~.]*.*/[.]\\'" target)) - ;; Fix completion on - ;; "~/.", "~/[...]/.", and "../." - (expand-file-name - (concat (helm-basedir (file-name-as-directory last)) - (regexp-quote (helm-basename target)))) - (expand-file-name last)) - ;; Don't add "~" to input to - ;; provide completion on all - ;; users instead of only on - ;; current $HOME (#1832). - (unless users-comp last))) + (or (helm-esh-pcomplete--make-helm + (helm-esh-pcomplete-input target users-comp last)) ;; Delete removed dot on quit (and del-dot (prog1 t (insert "."))) ;; A space is needed to have completion, remove @@ -322,7 +333,7 @@ The function that call this should set `helm-ec-target' to thing at point." ;;;###autoload (defun helm-eshell-history () - "Preconfigured helm for eshell history." + "Preconfigured Helm for Eshell history." (interactive) (let* ((end (point)) (beg (save-excursion (eshell-bol) (point))) @@ -348,12 +359,14 @@ The function that call this should set `helm-ec-target' to thing at point." ;;; Eshell prompts ;; (defface helm-eshell-prompts-promptidx - '((t (:foreground "cyan"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "cyan")) "Face used to highlight Eshell prompt index." :group 'helm-eshell-faces) (defface helm-eshell-prompts-buffer-name - '((t (:foreground "green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "green")) "Face used to highlight Eshell buffer name." :group 'helm-eshell-faces) @@ -377,7 +390,7 @@ The function that call this should set `helm-ec-target' to thing at point." "List the prompts in Eshell BUFFER. Return a list of (\"prompt\" (point) (buffer-name) prompt-index)) -e.g. (\"ls\" 162 \"*eshell*\" 3). +E.g. (\"ls\" 162 \"*eshell*\" 3). If BUFFER is nil, use current buffer." (with-current-buffer (or buffer (current-buffer)) (when (eq major-mode 'eshell-mode) diff --git a/elpa/helm-20191101.641/helm-eval.el b/elpa/helm-20210131.1946/helm-eval.el similarity index 91% rename from elpa/helm-20191101.641/helm-eval.el rename to elpa/helm-20210131.1946/helm-eval.el index caa31020..cee29752 100644 --- a/elpa/helm-20191101.641/helm-eval.el +++ b/elpa/helm-20210131.1946/helm-eval.el @@ -1,6 +1,6 @@ ;;; helm-eval.el --- eval expressions from helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -148,9 +148,13 @@ Should take one arg: the string to display." (helm-build-dummy-source "Calculation Result" :filtered-candidate-transformer (lambda (_candidates _source) (list - (condition-case nil - (calc-eval helm-pattern) - (error "error")))) + (condition-case err + (let ((result (calc-eval helm-pattern))) + (if (listp result) + (error "At pos %s: %s" + (car result) (cadr result)) + result)) + (error (cdr err))))) :nohighlight t :action '(("Copy result to kill-ring" . (lambda (candidate) (kill-new candidate) @@ -162,7 +166,7 @@ Should take one arg: the string to display." ;;;###autoload (defun helm-eval-expression (arg) - "Preconfigured helm for `helm-source-evaluation-result'." + "Preconfigured `helm' for `helm-source-evaluation-result'." (interactive "P") (helm :sources (helm-build-evaluation-result-source) :input (when arg (thing-at-point 'sexp)) @@ -173,7 +177,7 @@ Should take one arg: the string to display." (defvar eldoc-idle-delay) ;;;###autoload (defun helm-eval-expression-with-eldoc () - "Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support." + "Preconfigured `helm' for `helm-source-evaluation-result' with `eldoc' support." (interactive) (let ((timer (run-with-idle-timer eldoc-idle-delay 'repeat @@ -188,7 +192,7 @@ Should take one arg: the string to display." ;;;###autoload (defun helm-calcul-expression () - "Preconfigured helm for `helm-source-calculation-result'." + "Preconfigured `helm' for `helm-source-calculation-result'." (interactive) (helm :sources 'helm-source-calculation-result :buffer "*helm calcul*")) diff --git a/elpa/helm-20191101.641/helm-external.el b/elpa/helm-20210131.1946/helm-external.el similarity index 91% rename from elpa/helm-20191101.641/helm-external.el rename to elpa/helm-20210131.1946/helm-external.el index e539cde4..a7c25827 100644 --- a/elpa/helm-20191101.641/helm-external.el +++ b/elpa/helm-20210131.1946/helm-external.el @@ -1,6 +1,6 @@ ;;; helm-external.el --- Run Externals commands within Emacs with helm completion. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ (require 'helm-help) (require 'helm-net) +(declare-function helm-comp-read "helm-mode") + (defgroup helm-external nil "External related Applications and libraries for Helm." @@ -37,16 +39,16 @@ This will be use with `format', so use something like \"wmctrl -xa %s\"." (defcustom helm-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\"\)\) " +E.g.: '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) " :type '(alist :key-type string :value-type string) :group 'helm-external) (defcustom helm-default-external-file-browser "nautilus" "Default external file browser for your system. -Directories will be opened externally with it when -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. +Directories will be opened externally with it when opening file +externally in `helm-find-files'. +Set to nil if you do not have an external file browser or do not +want to use it. Windows users should set that to \"explorer.exe\"." :group 'helm-external :type 'string) @@ -61,9 +63,9 @@ automatically.") (defun helm-external-commands-list-1 (&optional sort) "Returns a list of all external commands the user can execute. -If `helm-external-commands-list' is non-nil it will -return its contents. Else it calculates all external commands -and sets `helm-external-commands-list'." +If `helm-external-commands-list' is non-nil it will return its +contents. Else it calculates all external commands and sets +`helm-external-commands-list'." (helm-aif helm-external-commands-list it (setq helm-external-commands-list @@ -82,8 +84,8 @@ and sets `helm-external-commands-list'." (defun helm-run-or-raise (exe &optional file) "Run asynchronously EXE or jump to the application window. -If EXE is already running just jump to his window if `helm-raise-command' -is non--nil. +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." (let* ((real-com (car (split-string exe))) (proc (if file (concat real-com " " file) real-com)) @@ -127,8 +129,8 @@ When FILE argument is provided run EXE with FILE." (defun helm-get-default-program-for-file (filename) "Try to find a default program to open FILENAME. -Try first in `helm-external-programs-associations' and then in mailcap file -if nothing found return nil." +Try first in `helm-external-programs-associations' and then in +mailcap file. If nothing found return nil." (let* ((ext (file-name-extension filename)) (def-prog (assoc-default ext helm-external-programs-associations))) (cond ((and def-prog (not (string= def-prog ""))) def-prog) @@ -138,8 +140,10 @@ if nothing found return nil." (defun helm-open-file-externally (file) "Open FILE with an external program. -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." +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 (helm-external-commands-list-1 'sort)) (def-prog (helm-get-default-program-for-file fname)) diff --git a/elpa/helm-20210131.1946/helm-fd.el b/elpa/helm-20210131.1946/helm-fd.el new file mode 100644 index 00000000..d54d7e87 --- /dev/null +++ b/elpa/helm-20210131.1946/helm-fd.el @@ -0,0 +1,127 @@ +;;; helm-fd.el --- helm interface for fd command line tool. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto + +;; This program 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 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see . + +;;; Code: + +(require 'helm) +(require 'helm-types) + +(defvar helm-fd-executable "fd" + "The fd shell command executable.") + +(defcustom helm-fd-switches '("--hidden" "--type" "f" "--type" "d" "--color" "always") + "A list of options to pass to fd shell command." + :type '(repeat string) + :group 'helm-files) + +(defface helm-fd-finish + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Green")) + "Face used in mode line when fd process ends." + :group 'helm-grep-faces) + +(defvar helm-fd-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-generic-files-map) + (define-key map (kbd "C-]") 'undefined) + (define-key map (kbd "DEL") 'helm-delete-backward-no-update) + (define-key map (kbd "M-") 'helm-fd-next-directory) + (define-key map (kbd "M-") 'helm-fd-previous-directory) + map)) + +(defun helm-fd-next-directory-1 (arg) + (with-helm-window + (let ((cur-dir (helm-basedir (helm-get-selection)))) + (while (equal cur-dir (helm-basedir (helm-get-selection))) + (if (> arg 0) + (helm-next-line) + (helm-previous-line)))))) + +(defun helm-fd-next-directory () + "Move to next directory in a helm-fd source." + (interactive) + (with-helm-alive-p + (helm-fd-next-directory-1 1))) + +(defun helm-fd-previous-directory () + "Move to previous directory in a helm-fd source." + (interactive) + (with-helm-alive-p + (helm-fd-next-directory-1 -1))) + +(defclass helm-fd-class (helm-source-async) + ((candidates-process :initform 'helm-fd-process) + (requires-pattern :initform 2) + (candidate-number-limit :initform 20000) + (nohighlight :initform t) + (help-message :initform 'helm-fd-help-message) + (filtered-candidate-transformer :initform 'helm-fd-fct) + (action :initform 'helm-type-file-actions) + (keymap :initform helm-fd-map))) + +(defun helm-fd-process () + "Initialize fd process in an helm async source." + (let* (process-connection-type + (cmd (append helm-fd-switches (split-string helm-pattern " "))) + (proc (apply #'start-process "fd" nil "fd" cmd)) + (start-time (float-time))) + (helm-log "Fd command:\nfd %s" (mapconcat 'identity cmd " ")) + (prog1 + proc + (set-process-sentinel + proc (lambda (_process event) + (if (string= event "finished\n") + (with-helm-window + (setq mode-line-format + `(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format + "[fd process finished in %.2fs - (%s results)] " + ,(- (float-time) start-time) + (helm-get-candidate-number)) + 'face 'helm-fd-finish)))) + (force-mode-line-update)) + (helm-log "Error: Fd %s" + (replace-regexp-in-string "\n" "" event)))))))) + +(defun helm-fd-fct (candidates _source) + "The filtered-candidate-transformer function for helm-fd." + (cl-loop for i in candidates + collect (helm--ansi-color-apply i))) + +(defun helm-fd-1 (directory) + "Run fd shell command on DIRECTORY with helm interface." + (cl-assert (executable-find helm-fd-executable) nil "Could not find fd executable") + (cl-assert (not (file-remote-p directory)) nil "Fd not supported on remote directories") + (let ((default-directory directory)) + (helm :sources (helm-make-source + (format "fd (%s)" + (abbreviate-file-name default-directory)) + 'helm-fd-class) + :buffer "*helm fd*"))) + + +(provide 'helm-fd) + +;; Local Variables: +;; byte-compile-warnings: (not obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-fd.el ends here diff --git a/elpa/helm-20191101.641/helm-files.el b/elpa/helm-20210131.1946/helm-files.el similarity index 73% rename from elpa/helm-20191101.641/helm-files.el rename to elpa/helm-20210131.1946/helm-files.el index 4263ae77..4aaec1d9 100644 --- a/elpa/helm-20191101.641/helm-files.el +++ b/elpa/helm-20210131.1946/helm-files.el @@ -1,6 +1,6 @@ ;;; helm-files.el --- helm file browser and related. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,13 +26,14 @@ (require 'helm-locate) (require 'helm-tags) (require 'helm-buffers) +(require 'tramp) (eval-when-compile (require 'thingatpt) (require 'ffap) (require 'dired-aux) (require 'dired-x) - (require 'tramp) (require 'image-dired)) +(require 'filenotify) (declare-function find-library-name "find-func.el" (library)) (declare-function w32-shell-execute "ext:w32fns.c" (operation document &optional parameters show-flag)) @@ -46,36 +47,73 @@ (declare-function eshell-reset "esh-mode.el") (declare-function eshell/cd "em-dirs.el") (declare-function eshell-next-prompt "em-prompt.el") -(declare-function eshell-quote-argument "esh-arg.el") +(declare-function eshell-resume-eval "esh-cmd") (declare-function helm-ls-git-ls "ext:helm-ls-git") (declare-function helm-hg-find-files-in-project "ext:helm-ls-hg") (declare-function helm-gid "helm-id-utils.el") (declare-function helm-find-1 "helm-find") +(declare-function helm-fd-1 "helm-fd") (declare-function helm-get-default-program-for-file "helm-external") (declare-function helm-open-file-externally "helm-external") - +(declare-function helm-comp-read "helm-mode") +(declare-function helm-read-file-name "helm-mode") +(declare-function term-line-mode "term") +(declare-function term-char-mode "term") +(declare-function term-send-input "term") +(declare-function term-next-prompt "term") +(declare-function term-process-mark "term") +(declare-function bookmark-prop-get "bookmark") +(declare-function comint-next-prompt "comint") +(declare-function comint-delete-input "comint") +(declare-function comint-send-input "comint") +(declare-function comint-goto-process-mark "comint") +(declare-function tramp-dissect-file-name "tramp") +(declare-function tramp-get-completion-function "tramp") +(declare-function seconds-to-time "time-date") +(declare-function ffap-fixup-url "ffap") +(declare-function ffap-url-at-point "ffap") +(declare-function ffap-file-at-point "ffap") +(declare-function dired-create-files "dired-aux") +(declare-function dired-goto-file "dired") +(declare-function dired-move-to-filename "dired") +(declare-function dired-move-to-end-of-filename "dired") +(declare-function dired-get-filename "dired") +(declare-function dired-get-marked-files "dired") +(declare-function tramp-list-connections "tramp-cache") +(declare-function tramp-get-connection-process "tramp") +(declare-function tramp-buffer-name "tramp") +(declare-function tramp-make-tramp-file-name "tramp") +(declare-function tramp-cleanup-connection "tramp-cmds") + +(defvar term-char-mode-point-at-process-mark) +(defvar term-char-mode-buffer-read-only) (defvar recentf-list) (defvar helm-mm-matching-method) (defvar dired-async-mode) (defvar org-directory) +(defvar eshell-current-command) +(defvar eshell-debug-command) +(defvar eshell-current-command) + + (defgroup helm-files nil "Files applications and libraries for Helm." :group 'helm) (defcustom helm-tramp-verbose 0 - "Just like `tramp-verbose' but specific to helm. -When set to 0 don't show tramp messages in helm. + "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 'helm-files) (defcustom helm-ff-auto-update-initial-value nil "Auto update when only one candidate directory is matched. -Default value when starting `helm-find-files' is nil to not confuse -new users. -For a better experience with `helm-find-files' set this to non--nil -and use C- to toggle it." +Default value when starting `helm-find-files' is nil to not +confuse new users. +For a better experience with `helm-find-files' set this to +non-nil and use C- to toggle it." :group 'helm-files :type 'boolean) @@ -108,8 +146,8 @@ This set `ffap-newfile-prompt'." (defcustom helm-ff-avfs-directory "~/.avfs" "The default avfs directory, usually '~/.avfs'. -When this is set you will be able to expand archive filenames with `C-j' -inside an avfs directory mounted with mountavfs. +When this is set you will be able to expand archive filenames +with `C-j' inside an avfs directory mounted with mountavfs. See ." :type 'string :group 'helm-files) @@ -121,10 +159,11 @@ See ." (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. +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, -`helm-ff-find-printers' will find a list of available printers for you." +On Unix based systems (lpstat command needed) you don't need to +set this, `helm-ff-find-printers' will find a list of available +printers for you." :type '(repeat (choice string)) :group 'helm-files) @@ -136,9 +175,10 @@ This can be toggled at anytime from `helm-find-files' with \ :group 'helm-files) (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." + "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 'helm-files :type 'boolean) @@ -158,44 +198,45 @@ WARNING: Setting this to nil is unsafe and can cause deletion of a whole tree." :type 'boolean) (defcustom helm-ff-skip-boring-files nil - "Non--nil to skip boring files. - + "Non-nil to skip boring files. I.e. the files matching regexps in `helm-boring-file-regexp-list'. -This take effect in `helm-find-files' and file completion used by `helm-mode' -i.e `helm-read-file-name'. +This takes effect in `helm-find-files' and file completion used by +`helm-mode' i.e. `helm-read-file-name'. Note that when non-nil this will slow down slightly `helm-find-files'." :group 'helm-files :type 'boolean) (defcustom helm-ff-skip-git-ignored-files nil - "Non--nil to skip git ignored files. - + "Non-nil to skip git ignored files. This take effect only in `helm-find-files'. Check is not done on remote files. -Note that when non-nil this will slow down slightly `helm-find-files'." +Note that when non-nil this will slow down slightly +`helm-find-files'." :group 'helm-files :type 'boolean) (defcustom helm-ff-candidate-number-limit 5000 "The `helm-candidate-number-limit' for `helm-find-files' and friends. -Note that when going one level up with `\\\\[helm-find-files-up-one-level]' -The length of directory will be used instead if it is higher than this -value, this to avoid failing to preselect the previous directory/file if -this one is situated lower than `helm-ff-candidate-number-limit' num -candidate." +Note that when going one level up with +`\\\\[helm-find-files-up-one-level]' the +length of directory will be used instead if it is higher than +this value. This is to avoid failing to preselect the previous +directory/file if this one is situated lower than +`helm-ff-candidate-number-limit' num candidate." :group 'helm-files :type 'integer) (defcustom helm-ff-up-one-level-preselect t "Always preselect previous directory when going one level up. -When non nil `candidate-number-limit' source value is modified +When non-nil `candidate-number-limit' source value is modified dynamically when going one level up if the position of previous -candidate in its directory is > to `helm-ff-candidate-number-limit'. +candidate in its directory is > to +`helm-ff-candidate-number-limit'. -This can be helpful to disable this and reduce -`helm-ff-candidate-number-limit' if you often navigate across very -large directories." +It can be helpful to disable this and reduce +`helm-ff-candidate-number-limit' if you often navigate across +very large directories." :group 'helm-files :type 'boolean) @@ -230,14 +271,15 @@ This doesn't disable url or mail at point, see (defcustom helm-ff-guess-ffap-urls t "Use ffap to guess local urls at point in `helm-find-files'. -This doesn't disable guessing filenames at point, -see `helm-ff-guess-ffap-filenames' for this. -See also `ffap-url-unwrap-remote' that may override this variable." +This doesn't disable guessing filenames at point, see +`helm-ff-guess-ffap-filenames' for this. +See also `ffap-url-unwrap-remote' that may override this +variable." :group 'helm-files :type 'boolean) (defcustom helm-ff-no-preselect nil - "When non--nil `helm-find-files' starts at root of current directory." + "When non-nil `helm-find-files' starts at root of current directory." :group 'helm-files :type 'boolean) @@ -248,9 +290,9 @@ See also `ffap-url-unwrap-remote' that may override this variable." (defcustom helm-find-files-ignore-thing-at-point nil "Use only `default-directory' as default input in `helm-find-files'. -I.e text under cursor in `current-buffer' is ignored. -Note that when non-nil you will be unable to complete filename at point -in `current-buffer'." +I.e. text under cursor in `current-buffer' is ignored. +Note that when non-nil you will be unable to complete filename at +point in `current-buffer'." :group 'helm-files :type 'boolean) @@ -267,15 +309,17 @@ in `current-buffer'." (defcustom helm-mounted-network-directories nil "A list of directories used for mounting remotes filesystem. -When nil `helm-file-on-mounted-network-p' always return nil otherwise -it checks if a file is in one of these directories. +When nil `helm-file-on-mounted-network-p' always return nil +otherwise check if a file is in one of these directories. Remote filesystem are generally mounted with sshfs." :group 'helm-files :type '(repeat string)) (defcustom helm-browse-project-default-find-files-fn - (cond ((executable-find "rg") + (cond ((executable-find "fd") + #'helm-browse-project-fd-find-files) + ((executable-find "rg") #'helm-browse-project-rg-find-files) ((executable-find "ag") #'helm-browse-project-ag-find-files) @@ -290,21 +334,22 @@ A function that takes a directory name as only arg." #'helm-ff-kill-or-find-buffer-fname "Default function used to expand non-directory filenames in `helm-find-files'. -This variable will take effect only in `helm-find-files', it affects -the behavior of persistent-action on filenames and non-existing -filenames. +This variable will take effect only in `helm-find-files'. It +affects the behavior of persistent-action on filenames and +non-existing filenames. The default is to expand filename on first hit on -\\\\[helm-execute-persistent-action], pop buffer in other -window on second hit and finally kill this buffer on third hit, this -is very handy to create several new buffers, or when navigating, show -quickly the buffer of file to see its contents briefly before killing -it and continue navigating. +\\\\[helm-execute-persistent-action], pop buffer in +other window on second hit and finally kill this buffer on third +hit. This is very handy to create several new buffers, or when +navigating, show quickly the buffer of file to see its contents +briefly before killing it and continue navigating. -However some users may not want this, so to disable this behavior just -set this to `ignore' function. +However some users may not want this, so to disable this behaviour +just set this to `ignore' function. -Of course you can also write your own function to do something else." +Of course you can also write your own function to do something +else." :group 'helm-files :type 'function) @@ -315,11 +360,11 @@ Of course you can also write your own function to do something else." :type '(repeat symbol)) (defcustom helm-ff-allow-recursive-deletes nil - "when 'always don't prompt for recursive deletion of directories. + "When 'always don't prompt for recursive deletion of directories. When nil, will ask for recursive deletion. -Note that when deleting multiple directories you can answer ! when -prompted to avoid beeing asked for next directories, so it is probably -better to not modify this variable." +Note that when deleting multiple directories you can answer ! +when prompted to avoid being asked for next directories, so it +is probably better to not modify this variable." :group 'helm-files :type '(choice (const :tag "Delete non-empty directories" t) @@ -328,15 +373,16 @@ better to not modify this variable." (defcustom helm-ff-delete-files-function #'helm-delete-marked-files "The function to use by default to delete files. -Default is to delete files synchronously, other choice is to delete -files asynchronously. +Default is to delete files synchronously, other choice is to +delete files asynchronously. BE AWARE that when deleting async you will not be warned about -recursive deletion of directories, IOW non empty directories will be -deleted with no warnings in background!!! +recursive deletion of directories, IOW non-empty directories will +be deleted with no warnings in background!!! -It is the function that will be used when using `\\\\[helm-ff-run-delete-file]' -from `helm-find-files'." +It is the function that will be used when using +`\\\\[helm-ff-run-delete-file]' from +`helm-find-files'." :group 'helm-files :type '(choice (function :tag "Delete files synchronously." helm-delete-marked-files) @@ -346,17 +392,18 @@ from `helm-find-files'." (defcustom helm-trash-remote-files nil "Allow trashing remote files when non-nil. -Trashing remote files with tramp doesn't work out of the box unless -'trash-cli' package is installed, it is why trashing remote files from -helm is disabled by default. +Trashing remote files with tramp doesn't work out of the box +unless the 'trash-cli' package is installed. This is why trashing +remote files from Helm is disabled by default. Tramp is using external 'trash' command in its `delete-file' and -`delete-directory' handlers when using `delete-by-moving-to-trash', -which is documented nowhere in Emacs. +`delete-directory' handlers when using +`delete-by-moving-to-trash', which is documented nowhere in +Emacs. -If you want to enable this you will have to install the 'trash' command -on remote (and/or locally if you want to trash as root), on Ubuntu -based distribution it is 'trash-cli'." +If you want to enable this you will have to install the 'trash' +command on remote (and/or locally if you want to trash as root). +On Ubuntu-based distributions it is 'trash-cli'." :group 'helm-files :type 'boolean) @@ -368,29 +415,29 @@ based distribution it is 'trash-cli'." (t #'helm-list-dir-lisp)) "The function used in `helm-find-files' to list remote directories. -Actually helm provides two functions to do this: `helm-list-dir-lisp' -and `helm-list-dir-external'. - -Using `helm-list-dir-external' will provides a similar display to what -provided with local files i.e. colorized symlinks, executables files -etc... whereas using `helm-list-dir-lisp' will allow colorizing only -directories but is more portable. - -NOTE: `helm-list-dir-external' needs ls and awk as dependencies. -Also the ls version installed on the remote side should support the -same arguments as the GNU/ls version that are -A -1 -F -b and -Q. -So even if you are using a GNU/ls version locally and you want to -connect e.g. on a Freebsd server you may have failures due to the -incompatible ls version installed on remote server. -In such case use `helm-list-dir-lisp' which work everywhere but is +Actually Helm provides two functions to do this: +`helm-list-dir-lisp' and `helm-list-dir-external'. + +Using `helm-list-dir-external' will provide a similar display to +what is provided with local files i.e. colorized symlinks, +executables files etc., whereas using `helm-list-dir-lisp' will +allow colorizing only directories but it is more portable. + +NOTE: `helm-list-dir-external' needs ls and awk as dependencies. +Also the ls version installed on the remote side should support +the same arguments as the GNU/ls version, which are -A -1 -F -b +and -Q. So even if you are using a GNU/ls version locally and you +want to connect e.g. on a Freebsd server, you may have failures +due to the incompatible ls version installed on remote server. In +such case use `helm-list-dir-lisp' which works everywhere but is slower and less featured (only directories colorized)." :type 'function :group 'helm-files) (defcustom helm-ff-initial-sort-method nil "Sort method to use when initially listing a directory. -Note that this doesn't affect the listing when matching inside the -directory (i.e. filenames)." +Note that this doesn't affect the listing when matching inside +the directory (i.e. filenames)." :group 'helm-files :type '(choice (const :tag "alphabetically" nil) @@ -398,7 +445,11 @@ directory (i.e. filenames)." (const :tag "size" size))) (defcustom helm-ff-rotate-image-program "exiftran" - "External program used to rotate images." + "External program used to rotate images. +When nil and `helm-ff-display-image-native' is enabled, fallback to +`image-rotate' without modification of exif data i.e. rotation is not +persistent otherwise an error is returned when not using +`helm-ff-display-image-native' i.e. using image-dired." :group 'helm-files :type '(choice (const :tag "Mogrify" "mogrify") @@ -407,11 +458,41 @@ directory (i.e. filenames)." (defcustom helm-ff-rotate-image-switch '("-i") "Options used with `helm-ff-rotate-image-program'. -If you are using Mogrify or Jpegtran mandatory option is \"-rotate\", -with Exiftran mandatory option is \"-i\"." +If you are using Mogrify or Jpegtran mandatory option is +\"-rotate\", with Exiftran mandatory option is \"-i\"." :group 'helm-files :type '(repeat string)) +(defcustom helm-ff-preferred-shell-mode 'eshell-mode + "Shell to use to switch to a shell buffer from `helm-find-files'. +Possible values are `shell-mode', `eshell-mode' and `term-mode'. +This affects `\\\\[helm-ff-run-switch-to-shell]' keybinding." + :group 'helm-files + :type '(choice + (const :tag "Use Eshell" eshell-mode) + (const :tag "Use Shell" shell-mode) + (const :tag "Use Shell" term-mode))) + +(defcustom helm-rsync-no-mode-line-update nil + "When non nil don't update mode-line when rsync is running. +This is useful if you display the progress bar somewhere else, +e.g. with minibuffer-line in minibuffer, in this case updating +mode-line may create flickering in other frame's mode-line." + :type 'boolean + :group 'helm-files) + +(defcustom helm-rsync-switches '("-a" "-z" "-h" "-s" "--info=all2") + "Rsync options to use with HFF Rsync action. +Note: Using \"--info=all2\" allows having the name of the file +currently transfered in an help-echo in mode-line, if you use +\"--info=progress2\" you will not have this information." + :type '(repeat string) + :group 'helm-files) + +(defcustom helm-rsync-percent-sign "%" + "Percentage unicode sign to use in Rsync reporter." + :type 'string + :group 'helm-files) ;;; Faces ;; @@ -423,89 +504,124 @@ with Exiftran mandatory option is \"-i\"." :group 'helm-faces) (defface helm-ff-prefix - '((t (:background "yellow" :foreground "black"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "yellow" :foreground "black")) "Face used to prefix new file or url paths in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-executable - '((t (:foreground "green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "green")) "Face used for executable files in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-suid - '((t (:background "red" :foreground "white"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "red" :foreground "white")) "Face used for suid files in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-directory - '((t (:foreground "DarkRed" :background "LightGray"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DarkRed" :background "LightGray")) "Face used for directories in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-dotted-directory - '((t (:foreground "black" :background "DimGray"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "black" :background "DimGray")) "Face used for dotted directories in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-dotted-symlink-directory - '((t (:foreground "DarkOrange" :background "DimGray"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DarkOrange" :background "DimGray")) "Face used for dotted symlinked directories in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-symlink - '((t :inherit font-lock-comment-face)) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-comment-face)) "Face used for symlinks in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-invalid-symlink - '((t (:foreground "black" :background "red"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "black" :background "red")) "Face used for invalid symlinks in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-denied - '((t (:foreground "red" :background "black"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red" :background "black")) "Face used for non accessible files in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-file - '((t (:inherit font-lock-builtin-face))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-builtin-face)) "Face used for file names in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-truename - '((t (:inherit font-lock-string-face))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-string-face)) "Face used for symlink truenames in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-dirs - '((t (:inherit font-lock-function-name-face))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-function-name-face)) "Face used for file names in recursive dirs completion in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-socket - '((t (:foreground "DeepPink"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DeepPink")) "Face used for socket files in `helm-find-files'." :group 'helm-files-faces) (defface helm-ff-pipe - '((t (:foreground "yellow" :background "black"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "yellow" :background "black")) "Face used for named pipes and character device files in `helm-find-files'." :group 'helm-files-faces) +(defface helm-ff-file-extension + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "magenta")) + "Face used for file extensions in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-backup-file + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DimGray")) + "Face used for backup files in `helm-find-files'." + :group 'helm-files-faces) + (defface helm-history-deleted - '((t (:inherit helm-ff-invalid-symlink))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit helm-ff-invalid-symlink)) "Face used for deleted files in `file-name-history'." :group 'helm-files-faces) (defface helm-history-remote - '((t (:foreground "Indianred1"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Indianred1")) "Face used for remote files in `file-name-history'." :group 'helm-files-faces) (defface helm-delete-async-message - '((t (:foreground "yellow"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "yellow")) "Face used for mode-line message." :group 'helm-files-faces) + +(defface helm-ff-rsync-progress + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-warning-face)) + "Face used for rsync mode-line indicator." + :group 'helm-files-faces) ;;; Helm-find-files - The helm file browser. ;; @@ -531,6 +647,8 @@ with Exiftran mandatory option is \"-i\"." (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) + (when (executable-find "rsync") + (define-key map (kbd "M-V") 'helm-ff-run-rsync-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) @@ -540,7 +658,7 @@ with Exiftran mandatory option is \"-i\"." (define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent) (define-key map (kbd "M-T") 'helm-ff-run-touch-files) (define-key map (kbd "C-c d") 'helm-ff-persistent-delete) - (define-key map (kbd "M-e") 'helm-ff-run-switch-to-eshell) + (define-key map (kbd "M-e") 'helm-ff-run-switch-to-shell) (define-key map (kbd "C-c i") '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) @@ -563,10 +681,14 @@ with Exiftran mandatory option is \"-i\"." (define-key map (kbd "C-c C-a") 'helm-ff-run-mail-attach-files) (define-key map (kbd "C-c p") 'helm-ff-run-print-file) (define-key map (kbd "C-c /") 'helm-ff-run-find-sh-command) + (define-key map (kbd "C-/") 'helm-ff-run-fd) ;; Next 2 have no effect if candidate is not an image file. (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 "M-+") 'helm-ff-increase-image-size-persistent) + (define-key map (kbd "M--") 'helm-ff-decrease-image-size-persistent) (define-key map (kbd "C-l") 'helm-find-files-up-one-level) + (define-key map (kbd "C-_") 'helm-ff-undo) (define-key map (kbd "C-r") 'helm-find-files-down-last-level) (define-key map (kbd "C-c r") 'helm-ff-run-find-file-as-root) (define-key map (kbd "C-x C-v") 'helm-ff-run-find-alternate-file) @@ -574,6 +696,8 @@ with Exiftran mandatory option is \"-i\"." (define-key map (kbd "S-") 'helm-ff-sort-alpha) (define-key map (kbd "S-") 'helm-ff-sort-by-newest) (define-key map (kbd "S-") 'helm-ff-sort-by-size) + (define-key map (kbd "S-") 'helm-ff-toggle-dirs-only) + (define-key map (kbd "S-") 'helm-ff-toggle-files-only) (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward '((C-backspace . helm-ff-run-toggle-auto-update) ([C-c DEL] . helm-ff-run-toggle-auto-update)) @@ -591,10 +715,12 @@ with Exiftran mandatory option is \"-i\"." (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) (define-key map (kbd "C-.") 'helm-find-files-up-one-level) (define-key map (kbd "C-l") 'helm-find-files-up-one-level) + (define-key map (kbd "C-_") 'helm-ff-undo) (define-key map (kbd "C-r") 'helm-find-files-down-last-level) (define-key map (kbd "C-c h") 'helm-ff-file-name-history) (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) (define-key map (kbd "C-c ") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "RET") 'helm-ff-RET) (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward '((C-backspace . helm-ff-run-toggle-auto-update) ([C-c DEL] . helm-ff-run-toggle-auto-update)) @@ -602,10 +728,10 @@ with Exiftran mandatory option is \"-i\"." map) "Keymap for `helm-read-file-name'.") -(defcustom helm-ff-lynx-style-map nil +(defcustom helm-ff-lynx-style-map t "Use arrow keys to navigate with `helm-find-files'. -Note that if you define this variable with `setq' your change will -have no effect, use customize instead." +Note that if you define this variable with `setq' your change +will have no effect, use customize instead." :group 'helm-files :type 'boolean :set (lambda (var val) @@ -624,12 +750,30 @@ have no effect, use customize instead." (defcustom helm-ff-DEL-up-one-level-maybe nil "Use DEL to maybe go up one level when non nil. -Going up one level works only when pattern is a directory endings with -\"/\", otherwise this command delete char backward. +Going up one level works only when pattern is a directory endings +with \"/\", otherwise this command deletes char backward. When nil always delete char backward." :group 'helm-files :type 'boolean) + +(defcustom helm-ff-display-image-native (>= emacs-major-version 27) + "Use native `image-mode' when non nil. + +You should use this only with Emacs>= 27 and `image-auto-resize' +enabled to have images resized properly. When this is enabled, +you have new commands to zoom in/out images. See +`image-transform-resize' and `image-auto-resize'. Otherwise, +when nil `image-dired' is used, using imagemagick as backend." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-reset-filters-on-update t + "Reset filter variables when changing directory. +When filtering directories/files only, switch back to a \"show all\" view +when moving out of directory when non nil." + :type 'boolean + :group 'helm-files) ;; Internal. (defvar helm-find-files-doc-header " (\\\\[helm-find-files-up-one-level]: Go up one level)" @@ -657,8 +801,23 @@ Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") (defvar helm-ff--move-to-first-real-candidate t) (defvar helm-find-files--toggle-bookmark nil) (defvar helm-ff--tramp-methods nil) -(defvar helm-ff--directory-files-hash (make-hash-table :test 'equal)) +(defvar helm-ff--directory-files-length (make-hash-table :test 'equal) + "Used to count number of candidates in directory. +candidate-number-limit is set to this value if this value is bigger +than `helm-candidate-number-limit'.") +(defvar helm-ff--list-directory-cache (make-hash-table :test 'equal) + "Cache for `helm-find-files' candidates.") +(defvar helm-ff--file-notify-watchers (make-hash-table :test 'equal) + "File-notify watchers for `helm-find-files' are stored here.") (defvar helm-ff-history-buffer-name "*helm-find-files history*") +(defvar helm-rsync-command-history nil) +(defvar helm-rsync--last-progress-bar-alist nil + "Used to store last valid rsync progress bar.") +(defvar helm-rsync-process-buffer "*helm-rsync*") +(defvar helm-rsync-progress-str-alist nil) +(defvar helm-ff--trash-directory-regexp "\\.?Trash[/0-9]+files/?\\'") +(defvar helm-ff--show-directories-only nil) +(defvar helm-ff--show-files-only nil) ;;; Helm-find-files ;; @@ -682,14 +841,16 @@ Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") "Complete at point `C-c i'" 'helm-insert-file-name-completion-at-point "Insert as org link `C-c @'" 'helm-files-insert-as-org-link "Find shell command `C-c /'" 'helm-ff-find-sh-command + "Fd shell command (C-/)" 'helm-ff-fd "Add marked files to file-cache" 'helm-ff-cache-add-file "Open file externally `C-c C-x, C-u to choose'" 'helm-open-file-externally "Grep File(s) `C-s, C-u Recurse'" 'helm-find-files-grep "Grep current directory with AG `M-g a, C-u select type'" 'helm-find-files-ag "Git grep `M-g g, C-u from root'" 'helm-ff-git-grep "Zgrep File(s) `M-g z, C-u Recurse'" 'helm-ff-zgrep + "Pdf Grep File(s)" 'helm-ff-pdfgrep "Gid `M-g i'" 'helm-ff-gid - "Switch to Eshell `M-e'" 'helm-ff-switch-to-eshell + "Switch to Eshell `M-e'" 'helm-ff-switch-to-shell "Etags `M-., C-u reload tag file'" 'helm-ff-etags-select "Eshell command on file(s) `M-!, C-u take all marked as arguments.'" 'helm-find-files-eshell-command-on-file @@ -704,6 +865,10 @@ Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") 'helm-ff-delete-files "Touch File(s) `M-T'" 'helm-ff-touch-files "Copy file(s) `M-C, C-u to follow'" 'helm-find-files-copy + (lambda () + (and (executable-find "rsync") + "Rsync file(s) `M-V' (C-u edit command)")) + 'helm-find-files-rsync "Rename file(s) `M-R, C-u to follow'" 'helm-find-files-rename "Backup files" 'helm-find-files-backup "Symlink files(s) `M-S, C-u to follow'" 'helm-find-files-symlink @@ -739,11 +904,16 @@ Should not be used among other sources.") #'helm-ff-make-bookmark-record) (require 'helm-external))) (candidates :initform 'helm-find-files-get-candidates) + (update :initform (lambda () + (remhash helm-ff-default-directory + helm-ff--list-directory-cache))) + (match-on-real :initform t) (filtered-candidate-transformer - :initform '((lambda (candidates _source) - (cl-loop for f in candidates - for ff = (helm-ff-filter-candidate-one-by-one f) - when ff collect ff)) + :initform '(helm-ff-fct + ;; These next two have to be called after + ;; `helm-ff-fct' as they use only cons cell candidates. + helm-ff-directories-only + helm-ff-files-only helm-ff-sort-candidates)) (persistent-action-if :initform 'helm-find-files-persistent-action-if) (persistent-help :initform "Hit1 Expand Candidate, Hit2 or (C-u) Find file") @@ -798,8 +968,8 @@ Should not be used among other sources.") (defcustom helm-dwim-target nil "Default target directory for file actions. -Define the directory where you want to start navigating for the target -directory when copying, renaming etc... You can use the +Define the directory where you want to start navigating for the +target directory when copying, renaming, etc.. You can use the `default-directory' of `next-window', the current `default-directory' or have completion on all the directories belonging to each window." @@ -854,15 +1024,27 @@ belonging to each window." (defun helm-find-files-do-action (action) "Generic function for creating actions from `helm-source-find-files'. -ACTION must be an action supported by `helm-dired-action'." +ACTION can be `rsync' or any action supported by `helm-dired-action'." (require 'dired-async) - (let* ((ifiles (mapcar 'expand-file-name ; Allow modify '/foo/.' -> '/foo' + (when (eq action 'rsync) + (cl-assert (executable-find "rsync") nil "No command named rsync")) + (let* ((rsync-switches + (when (and (eq action 'rsync) + helm-current-prefix-arg) + (cdr (split-string + (read-string "Run rsync like this: " + (mapconcat + 'identity + (cons "rsync" helm-rsync-switches) " ") + 'helm-rsync-command-history))))) + (ifiles (mapcar 'expand-file-name ; Allow modify '/foo/.' -> '/foo' (helm-marked-candidates :with-wildcard t))) (cand (helm-get-selection)) ; Target (prefarg helm-current-prefix-arg) (prompt (format "%s %s file(s) %s: " (if (and (and (fboundp 'dired-async-mode) dired-async-mode) + (not (eq action 'rsync)) (null prefarg)) (concat "Async " (symbol-name action)) (capitalize (symbol-name action))) @@ -897,8 +1079,189 @@ ACTION must be an action supported by `helm-dired-action'." (unless (or dest-dir-p (file-directory-p dest-dir)) (when (y-or-n-p (format "Create directory `%s'? " dest-dir)) (make-directory dest-dir t))) - (helm-dired-action - dest :files ifiles :action action :follow prefarg))) + (if (eq action 'rsync) + (helm-rsync-copy-files ifiles dest rsync-switches) + (helm-dired-action + dest :files ifiles :action action :follow prefarg)))) + +;; Rsync +;; +(defun helm-rsync-remote2rsync (file) + (if (file-remote-p file) + (let ((localname (directory-file-name + (expand-file-name (file-remote-p file 'localname)))) + (user (file-remote-p file 'user)) + ;; Tramp name may contain port e.g. /ssh:host#2222:/foo. + (host (replace-regexp-in-string + "#[0-9]+" "" (file-remote-p file 'host)))) + (if user + (format "%s@%s:%s" user host (shell-quote-argument localname)) + (format "%s:%s" host (shell-quote-argument localname)))) + (shell-quote-argument + (directory-file-name + (expand-file-name file))))) + +(defun helm-rsync-format-mode-line-str (proc) + (helm-aif (and (process-live-p proc) + (assoc-default proc helm-rsync-progress-str-alist)) + (progn + ;; When rsync progress bar stop for some reason (e.g. rsync + ;; takes time to finalize writing file to disk), no output is + ;; coming from filter process, as a result the progress bar + ;; disapear for a while giving no information to user while + ;; the rsync process continues, so keep printing the last valid + ;; progress bar (stored in `helm-rsync--last-progress-bar-alist') + ;; instead of sending empty string. + (unless (equal it "") + (push (cons proc it) helm-rsync--last-progress-bar-alist)) + (format " [%s]" (propertize + (or (assoc-default proc helm-rsync--last-progress-bar-alist) + ;; Avoid (wrong-type-argument stringp + ;; nil) when process is not ready. + "") + 'face 'helm-ff-rsync-progress))))) + +(defun helm-rsync-mode-line (proc) + "Add Rsync progress to the mode line." + (or global-mode-string (setq global-mode-string '(""))) + (unless (member `(:eval (helm-rsync-format-mode-line-str ,proc)) + global-mode-string) + (setq global-mode-string + (append global-mode-string + `((:eval (helm-rsync-format-mode-line-str ,proc))))))) + +(defun helm-rsync-restore-mode-line (proc) + "Restore the mode line when Rsync finishes." + (setq global-mode-string + (remove `(:eval (helm-rsync-format-mode-line-str ,proc)) + global-mode-string)) + (setq helm-rsync--last-progress-bar-alist nil) + (force-mode-line-update)) + +(defun helm-rsync-copy-files (files dest &optional switches) + "Send FILES to DEST using Rsync with SWITCHES as arguments. + +DEST must be a directory. SWITCHES when unspecified default to +`helm-rsync-switches'." + (cl-assert (file-directory-p dest) t) + (setq files (cl-loop for f in files + collect (helm-rsync-remote2rsync f)) + dest (helm-rsync-remote2rsync dest)) + (let* ((buf (generate-new-buffer-name helm-rsync-process-buffer)) + (port (when (helm-aand (file-remote-p dest 'host) + (string-match "#\\([0-9]+\\)" it)) + (match-string 1))) + (proc (start-process-shell-command + "rsync" buf + (format "rsync %s" + (mapconcat + 'identity + (append (or switches helm-rsync-switches) + (and port + ;; Add automatically port + ;; specified in tramp name + ;; unless user already specified + ;; it himself with the -e option + ;; by editing command. + (and switches + (cl-loop for arg in switches never + (string-match-p + "\\`-e" arg))) + (list (format "-e 'ssh -p %s'" + port))) + files (list dest)) + " "))))) + (helm-rsync-mode-line proc) + (set-process-sentinel + proc `(lambda (process event) + (cond ((string= event "finished\n") + (message "%s copied %s files" + (capitalize (process-name process)) + ,(length files))) + (t (error "Process %s %s with code %s" + (process-name process) + (process-status process) + (process-exit-status process)))) + (setq helm-rsync-progress-str-alist + (delete (assoc process helm-rsync-progress-str-alist) + helm-rsync-progress-str-alist)) + (helm-rsync-restore-mode-line process) + (force-mode-line-update))) + (set-process-filter proc #'helm-rsync-process-filter))) + +(defun helm-rsync-process-filter (proc output) + "Filter process function used by `helm-rsync-copy-files'." + (let ((inhibit-read-only t) + fname progbar) + (with-current-buffer (process-buffer proc) + (when (string-match comint-password-prompt-regexp output) + ;; FIXME: Fully not tested and + ;; use an agent or auth-source + ;; or whatever to get password if + ;; available. + (process-send-string + proc (concat (read-passwd (match-string 0 output)) "\n"))) + ;; Extract the progress bar. + (with-temp-buffer + (insert output) + (when (re-search-backward "[[:cntrl:]]" nil t) + (setq progbar (buffer-substring-no-properties + (match-end 0) (point-max))))) + ;; Insert the text, advancing the process marker. + (save-excursion + (goto-char (process-mark proc)) + (insert output) + (set-marker (process-mark proc) (point))) + (goto-char (process-mark proc)) + ;; Extract the file name currently + ;; copied (Imply --info=all2 or all1). + (save-excursion + (when (re-search-backward "^[^[:cntrl:]]" nil t) + (setq fname (helm-basename + (buffer-substring-no-properties + (point) (point-at-eol)))))) + ;; Now format the string for the mode-line. + (let ((ml-str (mapconcat 'identity + (split-string + (replace-regexp-in-string + "%" helm-rsync-percent-sign + progbar) + " " t) + " "))) + (setq ml-str (propertize ml-str 'help-echo + (format "%s->%s" (process-name proc) fname))) + ;; Now associate the formatted + ;; progress-bar string with process. + (helm-aif (assoc proc helm-rsync-progress-str-alist) + (setcdr it ml-str) + (setq helm-rsync-progress-str-alist + (push (cons proc ml-str) helm-rsync-progress-str-alist))))) + ;; Finally update mode-line. + (unless helm-rsync-no-mode-line-update + (force-mode-line-update)))) + +(defun helm-ff-kill-rsync-process (process) + "Kill rsync process PROCESS. + +When called interactively prompt user with completion when more than +one process." + (interactive (list (get-process + (helm-comp-read + "Kill rsync process: " + (mapcar (lambda (x) + (process-name (car x))) + helm-rsync-progress-str-alist) + :exec-when-only-one t)))) + (with-current-buffer (process-buffer process) + (delete-process process) + (kill-buffer)) + (setq helm-rsync-progress-str-alist + (delete (assoc process helm-rsync-progress-str-alist) + helm-rsync-progress-str-alist))) + +(defun helm-find-files-rsync (_candidate) + "Rsync files from `helm-find-files'." + (helm-find-files-do-action 'rsync)) (defun helm-find-files-copy (_candidate) "Copy files from `helm-find-files'." @@ -929,8 +1292,8 @@ This reproduce the behavior of \"cp --backup=numbered from to\"." (defun helm-find-files-other-window (_candidate) "Keep current-buffer and open files in separate windows. -When a prefix arg is detected files are opened in a vertical windows -layout." +When a prefix arg is detected files are opened in a vertical +windows layout." (let* ((files (helm-marked-candidates)) (buffers (mapcar 'find-file-noselect files))) (helm-window-show-buffers buffers t))) @@ -940,7 +1303,13 @@ layout." (let ((files (helm-marked-candidates :with-wildcard t)) (parg helm-current-prefix-arg)) (cl-loop for fname in files - do (byte-compile-file fname parg)))) + do (condition-case _err + (with-no-warnings + (byte-compile-file fname parg)) + (wrong-number-of-arguments + ;; Emacs-28 accepts only one arg. + (byte-compile-file fname) + (when parg (load fname))))))) (defun helm-find-files-load-files (_candidate) "Load elisp files from `helm-find-files'." @@ -1019,18 +1388,18 @@ layout." (defvar helm-eshell-command-on-file-input-history nil) (cl-defun helm-find-files-eshell-command-on-file-1 (&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. +This is done possibly with an Eshell alias. If no alias found, +you can type in an Eshell command. -Only aliases accepting a file as argument at the end of command line -are collected, i.e aliases ending with \"$1\" or \"$*\". +Only aliases accepting a file as argument at the end of command +line are collected, i.e. aliases ending with \"$1\" or \"$*\". Basename of CANDIDATE can be a wild-card. -e.g you can do \"eshell-command command *.el\" +E.g. you can do \"eshell-command command *.el\" Where \"*.el\" is the CANDIDATE. -It is possible to do eshell-command command -like this: \"command %s some more args\". +It is possible to do eshell-command command like this: \"command %s some more args\". If MAP is given run `eshell-command' on all marked files at once, Otherwise, run `eshell-command' on each marked files. @@ -1046,10 +1415,11 @@ otherwise do \"eshell-command command baz\" Note: -You have to setup some aliases in eshell with the `alias' command or -by editing yourself the file `eshell-aliases-file' to make this -working." +You have to setup some aliases in Eshell with the `alias' command +or by editing yourself the file `eshell-aliases-file' to make +this working." (require 'em-alias) (eshell-read-aliases-list) + (advice-add 'eshell-eval-command :override #'helm--advice-eshell-eval-command) (when (or eshell-command-aliases-list (y-or-n-p "No eshell aliases found, run eshell-command without alias anyway? ")) (let* ((cand-list (helm-marked-candidates :with-wildcard t)) @@ -1070,7 +1440,7 @@ working." (cl-loop for (a c) in (eshell-read-aliases-list) ;; Positional arguments may be double ;; quoted (Issue #1881). - when (string-match "[\"]?.*\\(\\$1\\|\\$\\*\\)[\"]?\\'" c) + when (string-match "[\"]?.*\\(\\$1\\|\\$\\*\\)[\"]?\\s-*&?\\'" c) collect (propertize a 'help-echo c) into ls finally return (sort ls 'string<)) :buffer "*helm eshell on file*" @@ -1088,9 +1458,9 @@ working." ;; Two time C-u from `helm-comp-read' mean print to current-buffer. ;; i.e `eshell-command' will use this value. (setq current-prefix-arg '(16)) - ;; Else reset the value of `current-prefix-arg' - ;; to avoid printing in current-buffer. - (setq current-prefix-arg nil)) + ;; Else reset the value of `current-prefix-arg' + ;; to avoid printing in current-buffer. + (setq current-prefix-arg nil)) (if (and (or ;; One prefix-arg have been passed before `helm-comp-read'. ;; If map have been set with C-u C-u (value == '(16)) @@ -1108,75 +1478,185 @@ working." ;; Run eshell-command with ALL marked files as arguments. ;; This wont work on remote files, because tramp handlers depends ;; on `default-directory' (limitation). - (let ((mapfiles (mapconcat 'eshell-quote-argument cand-list " "))) + (let ((mapfiles (mapconcat 'shell-quote-argument cand-list " "))) (if (string-match "%s" command) (setq cmd-line (format command mapfiles)) ; See [1] (setq cmd-line (format "%s %s" command mapfiles))) (eshell-command cmd-line)) - - ;; Run eshell-command on EACH marked files. - ;; To work with tramp handler we have to call - ;; COMMAND on basename of each file, using - ;; its basedir as `default-directory'. - (cl-loop for f in cand-list - for n from 1 - for dir = (and (not (string-match helm--url-regexp f)) - (helm-basedir f)) - ;; We can use basename here as the command will run - ;; under default-directory. - ;; This allow running e.g. "tar czvf test.tar.gz - ;; %s/*" without creating an archive expanding from /home. - for file = (eshell-quote-argument (helm-basename f)) - ;; \@ => placeholder for file without extension. - ;; \# => placeholder for incremental number. - for fcmd = (replace-regexp-in-string - "\\\\@" (regexp-quote (file-name-sans-extension file)) - (replace-regexp-in-string - "\\\\#" (format "%03d" n) command)) - for com = (if (string-match "%s" fcmd) - ;; [1] This allow to enter other args AFTER filename - ;; i.e - (format fcmd file) - (format "%s %s" fcmd file)) - do (let ((default-directory (or dir default-directory))) - (eshell-command com))))))) + (unwind-protect + (progn + ;; Run eshell-command on EACH marked files. + ;; To work with tramp handler we have to call + ;; COMMAND on basename of each file, using + ;; its basedir as `default-directory'. + (cl-loop for f in cand-list + for n from 1 + for dir = (and (not (string-match helm--url-regexp f)) + (helm-basedir f)) + ;; We can use basename here as the command will run + ;; under default-directory. + ;; This allow running e.g. "tar czvf test.tar.gz + ;; %s/*" without creating an archive expanding from /home. + for file = (shell-quote-argument (helm-basename f)) + ;; \@ => placeholder for file without extension. + ;; \# => placeholder for incremental number. + for fcmd = (replace-regexp-in-string + "\\\\@" (regexp-quote (file-name-sans-extension file)) + (replace-regexp-in-string + "\\\\#" (format "%03d" n) command)) + for com = (if (string-match "%s" fcmd) + ;; [1] This allow to enter other args AFTER filename + ;; i.e + (format fcmd file) + (format "%s %s" fcmd file)) + do (let ((default-directory (or dir default-directory))) + (eshell-command com)))) + ;; Async process continue running but don't need anymore + ;; the advice at this point (see the `eshell-eval-command' + ;; call in `eshell-command'.) . + (advice-remove 'eshell-eval-command #'helm--advice-eshell-eval-command)))))) + +(defun helm--advice-eshell-eval-command (command &optional input) + "Fix return value when command ends with \"&\"." + ;; Fix this emacs commit which is plain wrong as it returns + ;; either nil or an error (double because format spec doesn't + ;; always match specifier) whereas it should return either a + ;; single element (CAR DELIM) or DELIM itself if the car of + ;; DELIM is a process. + ;; + ;; 6b6f91b357f6fe2f1e0d72f046a1b8d8a2d6d8c3 + ;; Author: John Wiegley + ;; AuthorDate: Fri May 27 02:57:18 2005 +0000 + ;; Commit: John Wiegley + ;; CommitDate: Fri May 27 02:57:18 2005 +0000 + (if eshell-current-command + ;; we can just stick the new command at the end of the current + ;; one, and everything will happen as it should + (setcdr (last (cdr eshell-current-command)) + (list `(let ((here (and (eobp) (point)))) + ,(and input + `(insert-and-inherit ,(concat input "\n"))) + (if here + (eshell-update-markers here)) + (eshell-do-eval ',command)))) + (and eshell-debug-command + (with-current-buffer (get-buffer-create "*eshell last cmd*") + (erase-buffer) + (insert "command: \"" input "\"\n"))) + (setq eshell-current-command command) + (let* ((delim (catch 'eshell-incomplete + (eshell-resume-eval))) + (val (car delim))) + ;; If the return value of `eshell-resume-eval' is wrapped in a + ;; list, it indicates that the command was run asynchronously. + ;; In that case, unwrap the value before checking the delimiter + ;; value. + (if (and val + (not (processp val)) + (not (eq val t))) + (error "Unmatched delimiter: %S" val) + ;; Eshell-command expect a list like () to know if the + ;; command should be async or not. + (or (and (processp val) delim) val))))) (defun helm-find-files-eshell-command-on-file (_candidate) "Run `eshell-command' on CANDIDATE or marked candidates. See `helm-find-files-eshell-command-on-file-1' for more info." (helm-find-files-eshell-command-on-file-1 helm-current-prefix-arg)) -(defun helm-ff-switch-to-eshell (_candidate) - "Switch to eshell and cd to `helm-ff-default-directory'. - -With a numeric prefix arg switch to numbered eshell buffer, if no -prefix arg provided and more than one eshell buffer exists, provide -completions on those buffers. If only one eshell buffer exists, -switch to this one, if no eshell buffer exists or if the numeric -prefix arg eshell buffer doesn't exists, create it and switch to it." - (let ((cd-eshell (lambda () +(defun helm-ff--shell-interactive-buffer-p (buffer &optional mode) + (with-current-buffer buffer + (when (eq major-mode (or mode 'eshell-mode)) + (let ((next-prompt-fn (cl-case major-mode + (shell-mode #'comint-next-prompt) + (eshell-mode #'eshell-next-prompt) + (term-mode #'term-next-prompt)))) + (save-excursion + (goto-char (point-min)) + (funcall next-prompt-fn 1) + (null (eql (point) (point-min)))))))) + +(defun helm-ff-switch-to-shell (_candidate) + "Switch to a shell buffer and cd to `helm-ff-default-directory'. +Set your preferred shell mode in `helm-ff-preferred-shell-mode'. + +With a numeric prefix arg switch to numbered shell buffer, if no +prefix arg provided and more than one shell buffer exists, provide +completions on those buffers. If only one shell buffer exists, +switch to this one, if no shell buffer exists or if the numeric +prefix arg shell buffer doesn't exists, create it and switch to it." + ;; Reproduce the Emacs-25 behavior to be able to edit and send + ;; command in term buffer. + (let (term-char-mode-buffer-read-only ; Emacs-25 behavior. + term-char-mode-point-at-process-mark ; Emacs-25 behavior. + (cd-eshell (lambda () (eshell/cd helm-ff-default-directory) (eshell-reset))) + (cd-shell + (lambda () + (goto-char (point-max)) + (when (eq helm-ff-preferred-shell-mode 'shell-mode) + (comint-delete-input)) + (insert (format "cd %s" + (shell-quote-argument + (or (file-remote-p + helm-ff-default-directory 'localname) + helm-ff-default-directory)))) + (cl-case helm-ff-preferred-shell-mode + (shell-mode (comint-send-input)) + (term-mode (progn (term-char-mode) (term-send-input)))))) (bufs (cl-loop for b in (mapcar 'buffer-name (buffer-list)) - when (helm-ff--eshell-interactive-buffer-p b) + when (helm-ff--shell-interactive-buffer-p + b helm-ff-preferred-shell-mode) collect b))) - (helm-aif (and (null helm-current-prefix-arg) + ;; Jump to a shell buffer or open a new session. + (helm-aif (and (not helm-current-prefix-arg) (if (cdr bufs) - (helm-comp-read "Switch to eshell buffer: " bufs + (helm-comp-read "Switch to shell buffer: " bufs :must-match t) (car bufs))) - (switch-to-buffer it) - (eshell helm-current-prefix-arg)) - (unless (get-buffer-process (current-buffer)) - (funcall cd-eshell)))) - -(defun helm-ff--eshell-interactive-buffer-p (buffer) - (with-current-buffer buffer - (and (eq major-mode 'eshell-mode) - (save-excursion - (goto-char (point-min)) - (eshell-next-prompt 1) - (null (eql (point) (point-min))))))) + ;; Display in same window by default to preserve the + ;; historical behaviour + (pop-to-buffer it '(display-buffer-same-window)) + (cl-case helm-ff-preferred-shell-mode + (eshell-mode + (eshell helm-current-prefix-arg)) + (shell-mode + (shell (helm-aif (and helm-current-prefix-arg + (prefix-numeric-value + helm-current-prefix-arg)) + (format "*shell<%s>*" it)))) + (term-mode + (progn + (ansi-term (getenv "SHELL") + (helm-aif (and helm-current-prefix-arg + (prefix-numeric-value + helm-current-prefix-arg)) + (format "*ansi-term<%s>*" it))) + (term-line-mode))))) + ;; Now cd into directory. + (helm-aif (and (memq major-mode '(shell-mode term-mode)) + (get-buffer-process (current-buffer))) + (accept-process-output it 0.1)) + (unless (helm-ff-shell-alive-p major-mode) + (funcall + (if (eq major-mode 'eshell-mode) cd-eshell cd-shell))))) + +(defun helm-ff-shell-alive-p (mode) + "Returns non nil when a process is running inside `shell-mode' buffer." + (cl-ecase mode + (shell-mode + (save-excursion + (comint-goto-process-mark) + (or (null comint-last-prompt) + (not (eql (point) + (marker-position (cdr comint-last-prompt))))))) + (eshell-mode + (get-buffer-process (current-buffer))) + (term-mode + (save-excursion + (goto-char (term-process-mark)) + (not (looking-back "\\$ " (- (point) 2))))))) (defun helm-ff-touch-files (_candidate) "The touch files action for helm-find-files." @@ -1229,7 +1709,7 @@ prefix arg eshell buffer doesn't exists, create it and switch to it." (interactive) (unless (eq helm-ff-initial-sort-method 'size) (setq helm-ff-initial-sort-method 'size) - (helm-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) + (helm-force-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) (message "Sorting by size")) (put 'helm-ff-sort-by-size 'helm-only t) @@ -1237,7 +1717,7 @@ prefix arg eshell buffer doesn't exists, create it and switch to it." (interactive) (unless (eq helm-ff-initial-sort-method 'newest) (setq helm-ff-initial-sort-method 'newest) - (helm-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) + (helm-force-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) (message "Sorting by newest")) (put 'helm-ff-sort-by-newest 'helm-only t) @@ -1245,10 +1725,51 @@ prefix arg eshell buffer doesn't exists, create it and switch to it." (interactive) (unless (eq helm-ff-initial-sort-method nil) (setq helm-ff-initial-sort-method nil) - (helm-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) + (helm-force-update (helm-get-selection nil helm-ff-transformer-show-only-basename))) (message "Sorting alphabetically")) (put 'helm-ff-sort-alpha 'helm-only t) +(defun helm-ff-directories-only (candidates _source) + (if helm-ff--show-directories-only + (cl-loop for (d . r) in candidates + when (file-directory-p r) + ;; We can use this as long as this filtering function + ;; is called after `helm-ff-fct' otherwise candidates + ;; may not be cons cell at first call [1]. + collect (cons d r)) + candidates)) + +(defun helm-ff-files-only (candidates _source) + (if helm-ff--show-files-only + (cl-loop for (d . r) in candidates + unless (file-directory-p r) + ;; Same comment as in [1] above. + collect (cons d r)) + candidates)) + +(defun helm-ff-toggle-dirs-only () + "Show only directories in helm-find-files." + (interactive) + (with-helm-alive-p + (setq helm-ff--show-directories-only (not helm-ff--show-directories-only)) + (setq helm-ff--show-files-only nil) + (helm-update (helm-get-selection nil t)))) +(put 'helm-ff-toggle-dirs-only 'helm-only t) + +(defun helm-ff-toggle-files-only () + "Show only files in helm-find-files." + (interactive) + (with-helm-alive-p + (setq helm-ff--show-files-only (not helm-ff--show-files-only)) + (setq helm-ff--show-directories-only nil) + (helm-update (helm-get-selection nil t)))) +(put 'helm-ff-toggle-files-only 'helm-only t) + +(defun helm-ff-after-persistent-show-all () + (when helm-ff-reset-filters-on-update + (setq helm-ff--show-directories-only nil + helm-ff--show-files-only nil))) + (defun helm-ff-serial-rename-action (method) "Rename all marked files in `helm-ff-default-directory' with METHOD. See `helm-ff-serial-rename-1'." @@ -1296,13 +1817,13 @@ See `helm-ff-serial-rename-1'." (cl-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 files in COLLECTION to DIRECTORY with the prefix name NEW-NAME. Rename start at number START-AT-NUM - ex: prefixname-01.jpg. -EXTENSION is the file extension to use, in empty prompt, -reuse the original extension of file. +EXTENSION is the file extension to use. In empty prompt, reuse +the original extension of file. METHOD can be one of rename, copy or symlink. -Files will be renamed if they are files of current directory, otherwise they -will be treated with METHOD. +Files will be renamed if they are files of current directory, +otherwise they will be treated with METHOD. Default METHOD is rename." ;; Maybe remove directories selected by error in collection. (setq collection (cl-remove-if 'file-directory-p collection)) @@ -1351,8 +1872,8 @@ See `helm-ff-serial-rename-1'." (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. +Rename only file of current directory, and symlink files coming +from other directories. See `helm-ff-serial-rename-1'." (helm-ff-serial-rename-action 'symlink)) @@ -1559,18 +2080,19 @@ This doesn't replace inside the files, only modify filenames." (defun helm-ff-run-toggle-auto-update () (interactive) (with-helm-alive-p - (helm-attrset 'toggle-auto-update '(helm-ff-toggle-auto-update . never-split)) + (helm-set-attr 'toggle-auto-update '(helm-ff-toggle-auto-update . never-split)) (helm-execute-persistent-action 'toggle-auto-update))) (put 'helm-ff-run-toggle-auto-update 'helm-only t) (defun helm-ff-delete-char-backward () "Go up one level or disable HFF auto update and delete char backward. -Going up one level works only when pattern is a directory endings with -\"/\", otherwise this command delete char backward. +Going up one level works only when pattern is a directory endings +with \"/\", otherwise this command deletes char backward. -Going up one level can be disabled if necessary by deleting \"/\" at -end of pattern using \\\\[backward-char] and \\[helm-delete-minibuffer-contents]." +Going up one level can be disabled if necessary by deleting \"/\" +at end of pattern using \\\\[backward-char] and +\\[helm-delete-minibuffer-contents]." (interactive) (with-helm-alive-p (if (and helm-ff-DEL-up-one-level-maybe @@ -1595,14 +2117,21 @@ end of pattern using \\\\[backward-char] and \\[helm-delete-minibuffer See `helm-ff-RET' for details. If MUST-MATCH is specified exit with `helm-confirm-and-exit-minibuffer' which handle must-match mechanism." - (let ((sel (helm-get-selection))) + (let ((sel (helm-get-selection)) + ;; Ensure `file-directory-p' works on remote files. + non-essential) (cl-assert sel nil "Trying to exit with no candidates") - (if (and (file-directory-p sel) + (if (and (or (file-directory-p sel) + (helm-ff--invalid-tramp-name-p sel)) ;; Allows exiting with default action when a prefix arg ;; is specified. (null current-prefix-arg) (null helm-ff--RET-disabled) - (not (string= "." (helm-basename sel)))) + (or (and (file-remote-p sel) + (string= "." (helm-basename sel)) + (string-match-p "\\`[/].*:.*:\\'" + helm-pattern)) + (not (string= "." (helm-basename sel))))) (helm-execute-persistent-action) (if must-match (helm-confirm-and-exit-minibuffer) @@ -1611,7 +2140,7 @@ If MUST-MATCH is specified exit with (defun helm-ff-RET () "Default action for RET in `helm-find-files'. -Behave differently depending of `helm-selection': +Behave differently depending on `helm-selection': - candidate basename is \".\" => open it in dired. - candidate is a directory => expand it. @@ -1632,7 +2161,7 @@ Behave differently depending of `helm-selection': (defun helm-ff-TAB (arg) "Default action for TAB in `helm-find-files'. -Behave differently depending of `helm-selection': +Behave differently depending on `helm-selection': - candidate basename is \".\" => open the action menu. - candidate is a directory => expand it. @@ -1689,6 +2218,13 @@ Called with a prefix arg open menu unconditionally." (helm-exit-and-execute-action 'helm-find-files-copy))) (put 'helm-ff-run-copy-file 'helm-only t) +(defun helm-ff-run-rsync-file () + "Run Rsync file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-find-files-rsync))) +(put 'helm-ff-run-rsync-file 'helm-only t) + (defun helm-ff-run-rename-file () "Run Rename file action from `helm-source-find-files'." (interactive) @@ -1773,12 +2309,12 @@ Called with a prefix arg open menu unconditionally." 'helm-insert-file-name-completion-at-point))) (put 'helm-ff-run-complete-fn-at-point 'helm-only t) -(defun helm-ff-run-switch-to-eshell () +(defun helm-ff-run-switch-to-shell () "Run switch to eshell action from `helm-source-find-files'." (interactive) (with-helm-alive-p - (helm-exit-and-execute-action 'helm-ff-switch-to-eshell))) -(put 'helm-ff-run-switch-to-eshell 'helm-only t) + (helm-exit-and-execute-action 'helm-ff-switch-to-shell))) +(put 'helm-ff-run-switch-to-shell 'helm-only t) (defun helm-ff-run-switch-other-window () "Run switch to other window action from `helm-source-find-files'. @@ -1873,15 +2409,14 @@ When a prefix arg is provided, split is done vertically." (defun helm-ff-print (_candidate) "Print marked files. -You may to set in order -variables `lpr-command',`lpr-switches' and/or `printer-name', -but with no settings helm should detect your printer(s) and -print with the default `lpr' settings. +You may to set in order variables `lpr-command',`lpr-switches' +and/or `printer-name', but with no settings Helm should detect +your printer(s) and print with the default `lpr' settings. -NOTE: DO NOT set the \"-P\" flag in `lpr-switches', if you really +NOTE: DO NOT set the \"-P\" flag in `lpr-switches'. If you really have to modify this, do it in `lpr-printer-switch'. -Same as `dired-do-print' but for helm." +Same as `dired-do-print' but for Helm." (require 'lpr) (when (or helm-current-prefix-arg (not helm-ff-printer-list)) @@ -1894,10 +2429,10 @@ Same as `dired-do-print' but for helm." "Printer: " helm-ff-printer-list) printer-name)) (lpr-switches - (if (and (stringp printer-name) - (string< "" printer-name)) - (cons (concat lpr-printer-switch printer-name) - lpr-switches) + (if (and (stringp printer-name) + (string< "" printer-name)) + (cons (concat lpr-printer-switch printer-name) + lpr-switches) lpr-switches)) (command (helm-read-string (format "Print *%s File(s):\n%s with: " @@ -1929,11 +2464,11 @@ Same as `dired-do-print' but for helm." (defun helm-ff-checksum (file) "Calculate the checksum of FILE. -The checksum is copied to kill-ring. -Checksum is calculated with the md5sum, sha1sum, sha224sum, sha256sum, -sha384sum and sha512sum when available, otherwise the emacs function -`secure-hash' is used but it is slow and may crash Emacs and even the -whole system as it eats all memory." +The checksum is copied to `kill-ring'. +Checksum is calculated with the md5sum, sha1sum, sha224sum, +sha256sum, sha384sum and sha512sum when available, otherwise the +Emacs function `secure-hash' is used but it is slow and may crash +Emacs and even the whole system as it eats all memory." (cl-assert (file-regular-p file) nil "`%s' is not a regular file" file) (let* ((algo (intern (helm-comp-read @@ -2024,6 +2559,7 @@ whole system as it eats all memory." If prefix numeric arg is given go ARG level up." (interactive "p") (with-helm-alive-p + (helm-ff-after-persistent-show-all) (let ((src (helm-get-current-source))) (when (and (helm-file-completion-source-p src) (not (helm-ff--invalid-tramp-name-p))) @@ -2036,10 +2572,10 @@ If prefix numeric arg is given go ARG level up." (let ((cur-cand (helm-get-selection nil nil src)) (new-pattern (helm-reduce-file-name helm-pattern arg))) ;; Ensure visibility on all candidates for preselection. - (helm-attrset 'candidate-number-limit + (helm-set-attr 'candidate-number-limit (if helm-ff-up-one-level-preselect (max (gethash new-pattern - helm-ff--directory-files-hash + helm-ff--directory-files-length helm-ff-candidate-number-limit) helm-ff-candidate-number-limit) helm-ff-candidate-number-limit)) @@ -2084,8 +2620,8 @@ If prefix numeric arg is given go ARG level up." (defun helm-ff-retrieve-last-expanded () "Move overlay to last visited directory `helm-ff-last-expanded'. -This happen after using `helm-find-files-up-one-level', -or hitting C-j on \"..\"." +This happen after using `helm-find-files-up-one-level', or +hitting C-j on \"..\"." (when helm-ff-last-expanded (let ((presel (if helm-ff-transformer-show-only-basename (helm-basename @@ -2119,6 +2655,20 @@ or hitting C-j on \"..\"." (file-exists-p it)) (helm-next-line))))) +(defun helm-ff-undo () + "Undo minibuffer in `helm-find-files'. +Ensure disabling `helm-ff-auto-update-flag' before undoing." + (interactive) + (let ((old--flag helm-ff-auto-update-flag)) + (setq helm-ff-auto-update-flag nil) + (setq helm-ff--auto-update-state nil) + (unwind-protect + (progn + (undo) + (helm-check-minibuffer-input)) + (setq helm-ff-auto-update-flag old--flag) + (setq helm-ff--auto-update-state helm-ff-auto-update-flag)))) + ;;; Auto-update - helm-find-files auto expansion of directories. ;; ;; @@ -2126,8 +2676,8 @@ or hitting C-j on \"..\"." "Expand to directory when sole completion. When only one candidate is remaining and it is a directory, expand to this directory. -This happen only when `helm-ff-auto-update-flag' is non--nil -or when `helm-pattern' is equal to \"~/\"." +This happen only when `helm-ff-auto-update-flag' is non-nil or +when `helm-pattern' is equal to \"~/\"." (let ((src (helm-get-current-source))) (when (and (helm-file-completion-source-p src) (not (get-buffer-window helm-action-buffer 'visible)) @@ -2137,10 +2687,7 @@ or when `helm-pattern' is equal to \"~/\"." (with-helm-buffer (let* ((history-p (string= (assoc-default 'name src) "Read File Name History")) - (pat (if (string-match helm-tramp-file-name-regexp - helm-pattern) - (helm-ff--create-tramp-name helm-pattern) - helm-pattern)) + (pat (helm-ff-set-pattern helm-pattern)) (completed-p (string= (file-name-as-directory (expand-file-name (substitute-in-file-name pat))) @@ -2194,7 +2741,11 @@ or when `helm-pattern' is equal to \"~/\"." ;; is not one of "." or ".." [1] ;; and only one candidate is remaining [2], ;; assume candidate is a new directory to expand, and do it. - (helm-set-pattern (file-name-as-directory cur-cand)) + (progn + (helm-set-pattern (file-name-as-directory + (substring-no-properties cur-cand))) + ;; Reset flags to show all when changing dir. + (helm-ff-after-persistent-show-all)) ;; 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 @@ -2204,43 +2755,69 @@ or when `helm-pattern' is equal to \"~/\"." (helm-set-pattern ;; Need to expand-file-name to avoid e.g /ssh:host:./ in prompt. (expand-file-name (file-name-as-directory helm-pattern))))) + ;; When typing pattern in minibuffer, helm + ;; expand very fast to a directory matching pattern and + ;; don't let undo the time to set a boundary, the result + ;; is when e.g. going to root with "//" and undoing, undo + ;; doesn't undo to previous input. One fix for this is to + ;; advice `undo-auto--boundary-ensure-timer' so that it is + ;; possible to modify its delay (use a value of 1s for + ;; helm), a second fix is to run directly here `undo-boundary' + ;; inside a timer. + (run-at-time helm-input-idle-delay nil #'undo-boundary) (helm-check-minibuffer-input))))))) -(defun helm-ff-auto-expand-to-home-or-root () - "Allow expanding to home/user directory or root or text yanked after pattern." - (when (and (helm-file-completion-source-p) - (with-current-buffer (window-buffer (minibuffer-window)) (eolp)) - (not (string-match helm-ff-url-regexp helm-pattern))) - (cond ((and (not (file-remote-p helm-pattern)) - (null (file-exists-p helm-pattern)) +(cl-defun helm-ff-auto-expand-to-home-or-root (&optional (pattern helm-pattern spattern)) + "Allow expanding to $HOME or \"/\" or text yanked after pattern. + +Argument PATTERN default to `helm-pattern' and should _not_ be used for +other purpose than debugging the second cond clause of this function. +When PATTERN is specified, specific helm functions are not called to +avoid errors when called outside helm for debugging purpose." + (when (or spattern + (and (helm-file-completion-source-p) + (with-current-buffer (window-buffer (minibuffer-window)) (eolp)) + (not (string-match helm-ff-url-regexp pattern)))) + (cond ((and (not (file-remote-p pattern)) + (null (file-exists-p pattern)) (string-match-p - "\\`\\([.]\\|\\s-\\)\\{2\\}[^/]+" - (helm-basename helm-pattern)) - (string-match-p "/\\'" helm-pattern)) - (helm-ff-recursive-dirs helm-pattern) - (with-helm-window (helm-check-minibuffer-input))) + "\\`\\([.]\\)\\{2\\}[^/]+" + (helm-basename pattern)) + (string-match-p "/\\'" pattern) + (null spattern)) + (helm-ff-recursive-dirs pattern) + (helm-ff--maybe-set-pattern-and-update)) ((string-match - "\\(?:\\`~/\\)\\|/?\\$.*/\\|/\\./\\|/\\.\\./\\|/~.*/\\|//\\|\\(/[[:alpha:]]:/\\|\\s\\+\\)" - helm-pattern) - (let* ((match (match-string 0 helm-pattern)) + "\\(?:\\`~/\\)\\|/?\\$.*/\\|/\\./\\|/\\.\\./\\|/~.*/\\|//\\|\\(/[[:alpha:]]:/\\)" + pattern) + (let* ((match (match-string 0 pattern)) (input (cond ((string= match "/./") (expand-file-name default-directory)) - ((string= helm-pattern "/../") "/") + ((string= pattern "/../") "/") ((string-match-p "\\`/\\$" match) (let ((sub (substitute-in-file-name match))) (if (file-directory-p sub) sub (replace-regexp-in-string "/\\'" "" sub)))) - (t (helm-ff--expand-substitued-pattern helm-pattern))))) + (t (helm-ff--expand-substitued-pattern pattern))))) ;; `file-directory-p' returns t on "/home/me/." (issue #1844). (if (and (file-directory-p input) (not (string-match-p "[^.]\\.\\'" input))) - (setq helm-ff-default-directory - (setq input (file-name-as-directory input))) + (progn + (setq helm-ff-default-directory + (setq input (file-name-as-directory input))) + ;; When changing directory ensure to show all. + (helm-ff-after-persistent-show-all)) (setq helm-ff-default-directory (file-name-as-directory (file-name-directory input)))) - (with-helm-window - (helm-set-pattern input) - (helm-check-minibuffer-input))))))) + (if spattern input (helm-ff--maybe-set-pattern-and-update input)))) + ((and (string-match "\\`/\\(-\\):.*" pattern) (null spattern)) + (helm-ff--maybe-set-pattern-and-update + (replace-match tramp-default-method t t pattern 1)))))) + +(defun helm-ff--maybe-set-pattern-and-update (&optional str) + (with-helm-window + (when str (helm-set-pattern str)) + (helm-check-minibuffer-input))) (defun helm-ff--expand-file-name-no-dot (name &optional directory) "Prevent expanding \"/home/user/.\" to \"/home/user\"." @@ -2256,12 +2833,15 @@ or when `helm-pattern' is equal to \"~/\"." ;; so use the root of current Drive. (i.e "C:/") (let* ((directory (and (memq system-type '(windows-nt ms-dos)) (getenv "SystemDrive"))) + (subst (helm-substitute-in-filename pattern)) ;; On Windows use a simple call to `expand-file-name' to ;; avoid Issue #2004. (expand-fn (if directory #'expand-file-name #'helm-ff--expand-file-name-no-dot))) - (funcall expand-fn (helm-substitute-in-filename pattern) + ;; Fix issue #2223 with tilde in directory names e.g. "~/tmp/~test/". + (funcall expand-fn (if (string-match-p "\\`~[^/]" subst) + pattern subst) ;; directory is nil on Nix. directory))) @@ -2346,7 +2926,7 @@ With a prefix arg toggle dired buffer to wdired mode." ((and vec (pred vectorp)) vec))) (defun helm-ff--get-tramp-methods () - "Returns a list of the car of `tramp-methods'." + "Return a list of the car of `tramp-methods'." (or helm-ff--tramp-methods (setq helm-ff--tramp-methods (mapcar 'car tramp-methods)))) @@ -2385,8 +2965,8 @@ Return nil on valid file name remote or not." (cl-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." +Argument PATTERN default to `helm-pattern'. It is here only for +debugging purpose." (when (string-match helm-tramp-file-name-regexp pattern) (let* ((mh-method (helm-ff--previous-mh-tramp-method pattern)) (method (or (cadr mh-method) (match-string 1 pattern))) @@ -2398,15 +2978,22 @@ purpose." (comps (cl-loop for (f . h) in (tramp-get-completion-function method) append (cl-loop for e in (funcall f (car h)) for host = (and (consp e) (cadr e)) - when (and host (not (member host all-methods))) - collect (concat (or (car mh-method) "/") - method ":" host))))) + ;; On emacs-27 host may be + ;; ("root" t) in sudo method. + when (and (stringp host) + (not (member host all-methods))) + collect (helm-ff-filter-candidate-one-by-one + (concat (or (car mh-method) "/") + method ":" host)))))) (helm-fast-remove-dups - (delq nil (cons current-mh-host comps)) + (append (and current-mh-host + (list (helm-ff-filter-candidate-one-by-one + current-mh-host))) + comps) :test 'equal)))) (defun helm-ff-before-action-hook-fn () - "Exit helm when user try to execute action on an invalid tramp fname." + "Exit Helm when user try to execute action on an invalid tramp fname." (let* ((src (helm-get-current-source)) (cand (helm-get-selection nil nil src))) (when (and (helm-file-completion-source-p src) @@ -2417,12 +3004,13 @@ purpose." (add-hook 'helm-before-action-hook 'helm-ff-before-action-hook-fn) (cl-defun helm-ff--invalid-tramp-name-p (&optional (pattern helm-pattern)) - "Return non--nil when PATTERN is an invalid tramp filename." + "Return non-nil when PATTERN is an invalid tramp filename." (string= (helm-ff-set-pattern pattern) - "Invalid tramp file name")) + "@@TRAMP@@")) (defun helm-ff--tramp-postfixed-p (str) - (let (result) + (let ((methods (helm-ff--get-tramp-methods)) + result) (save-match-data (with-temp-buffer (save-excursion (insert str)) @@ -2430,10 +3018,10 @@ purpose." (if (save-excursion (forward-char -1) (looking-back - (mapconcat 'identity (helm-ff--get-tramp-methods) "\\|") + (mapconcat (lambda (m) (format "[/|]%s" m)) methods "\\|") (point-at-bol))) (setq result nil) - (setq result it))))) + (setq result it))))) result)) (defun helm-ff-set-pattern (pattern) @@ -2443,6 +3031,8 @@ purpose." (postfixed (helm-ff--tramp-postfixed-p pattern)) (reg "\\`/\\([^[/:]+\\|[^/]+]\\):.*:") cur-method tramp-name) + (when (string-match "\\`/\\(-\\):" pattern) + (setq pattern (replace-match tramp-default-method t t pattern 1))) ;; In some rare cases tramp can return a nil input, ;; so be sure pattern is a string for safety (Issue #476). (unless pattern (setq pattern "")) @@ -2492,7 +3082,8 @@ purpose." ((and (null postfixed) (string-match helm-tramp-file-name-regexp pattern) (member (match-string 1 pattern) methods)) - "Invalid tramp file name") ; Write in helm-buffer. + ;; A flag to notify tramp name is incomplete. + "@@TRAMP@@") ;; Return PATTERN unchanged. (t pattern)))) @@ -2511,7 +3102,7 @@ purpose." ;; Issue #118 allow creation of newdir+newfile. (unless (or ;; A tramp file name not completed. - (string= path "Invalid tramp file name") + (string= path "@@TRAMP@@") ;; An empty pattern (string= path "") (and (string-match-p ":\\'" path) @@ -2525,10 +3116,10 @@ purpose." ;; to write a non--existing path in minibuffer ;; probably to create a 'new_dir' or a 'new_dir+new_file'. (setq invalid-basedir t)) - ;; Don't set now `helm-pattern' if `path' == "Invalid tramp file name" + ;; Don't set now `helm-pattern' if `path' == "@@TRAMP@@" ;; like that the actual value (e.g /ssh:) is passed to ;; `helm-ff--tramp-hostnames'. - (unless (or (string= path "Invalid tramp file name") + (unless (or (string= path "@@TRAMP@@") invalid-basedir) ; Leave helm-pattern unchanged. (setq helm-ff-auto-update-flag ; [1] ;; Unless auto update is disabled start auto updating only @@ -2564,18 +3155,8 @@ purpose." (when (and (string-match ":\\'" path) (file-remote-p basedir nil t)) (setq helm-pattern basedir)) - (cond ((string= path "Invalid tramp file name") - (or (helm-ff--tramp-hostnames) ; Hostnames completion. - (prog2 - ;; `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 `helm-pattern' - ;; match single candidate "Invalid tramp file name". - (setq helm-pattern path) - ;; "Invalid tramp file name" is now printed - ;; in `helm-buffer'. - (list path)))) + (cond ((string= path "@@TRAMP@@") + (helm-ff--tramp-hostnames)) ; Hostnames completion. ((or (and (file-regular-p path) (eq last-repeatable-command 'helm-execute-persistent-action)) ;; `ffap-url-regexp' don't match until url is complete. @@ -2583,16 +3164,18 @@ purpose." invalid-basedir (and (not (file-exists-p path)) (string-match "/$" path)) (and helm--url-regexp (string-match helm--url-regexp path))) - (list path)) + ;; Do NOT filter boring files here (issue #2330). + (list (helm-ff-filter-candidate-one-by-one path nil t))) ((string= path "") (helm-ff-directory-files "/")) ;; Check here if directory is accessible (not working on Windows). ((and (file-directory-p path) (not (file-readable-p path))) - (list (format "file-error: Opening directory permission denied `%s'" path))) + (list (cons (format "file-error: Opening directory permission denied `%s'" path) + path))) ;; A fast expansion of PATH is made only if `helm-ff-auto-update-flag' ;; is enabled. ((and dir-p helm-ff-auto-update-flag) (helm-ff-directory-files path)) - (t (append (unless (or require-match + (t (append (unless (or (eq require-match t) ;; Check here if path is an existing ;; file before adding it to ;; candidates, it was previously done @@ -2613,14 +3196,15 @@ purpose." ;; disabled, whe don't want PATH to be added on top ;; if it is a directory. dir-p) - (list path)) + ;; Do NOT filter boring files here (issue #2330). + (list (helm-ff-filter-candidate-one-by-one path nil t))) (helm-ff-directory-files basedir)))))) (defun helm-list-directory (directory) "List directory DIRECTORY. -If DIRECTORY is remote use `helm-list-directory-function' otherwise use -`directory-files'." +If DIRECTORY is remote use `helm-list-directory-function', +otherwise use `directory-files'." (let* ((remote (file-remote-p directory 'method)) (helm-list-directory-function (if (and remote (not (string= remote "ftp"))) @@ -2670,9 +3254,9 @@ Add a `helm-ff-dir' property on each fname ending with \"/\"." (defun helm-list-dir-external (dir &optional sort-method) "List directory DIR with external shell command as backend. -This function is fast enough to be used for remote files and save the -type of files at the same time in a property for using it later in the -transformer." +This function is fast enough to be used for remote files and save +the type of files at the same time in a property for using it +later in the transformer." (let ((default-directory (file-name-as-directory (expand-file-name dir)))) (with-temp-buffer @@ -2711,33 +3295,66 @@ transformer." (add-text-properties (point-min) (point-max) '(helm-ff-file t)) (split-string (buffer-string) "\n" t))))) -(defun helm-ff-directory-files (directory) +(defun helm-ff-directory-files (directory &optional force-update) "List contents of DIRECTORY. Argument FULL mean absolute path. -It is same as `directory-files' but always returns the -dotted filename '.' and '..' even on root directories in Windows -systems." +It is same as `directory-files' but always returns the dotted +filename '.' and '..' even on root directories in Windows +systems. +When FORCE-UPDATE is non nil recompute candidates even if DIRECTORY is +in cache." (setq directory (file-name-as-directory (expand-file-name directory))) - (let* (file-error - (ls (condition-case err - (helm-list-directory directory) - ;; Handle file-error from here for Windows - ;; because predicates like `file-readable-p' and friends - ;; seem broken on emacs for Windows systems (always returns t). - ;; This should never be called on GNU/Linux/Unix - ;; as the error is properly intercepted in - ;; `helm-find-files-get-candidates' by `file-readable-p'. - (file-error - (prog1 - (list (format "%s:%s" - (car err) - (mapconcat 'identity (cdr err) " "))) - (setq file-error t))))) - (dot (concat directory ".")) - (dot2 (concat directory ".."))) - (puthash directory (+ (length ls) 2) helm-ff--directory-files-hash) - (append (and (not file-error) (list dot dot2)) ls))) + (or (and (not force-update) + (gethash directory helm-ff--list-directory-cache)) + (let* (file-error + (ls (condition-case err + (helm-list-directory directory) + ;; Handle file-error from here for Windows + ;; because predicates like `file-readable-p' and friends + ;; seem broken on emacs for Windows systems (always returns t). + ;; This should never be called on GNU/Linux/Unix + ;; as the error is properly intercepted in + ;; `helm-find-files-get-candidates' by `file-readable-p'. + (file-error + (prog1 + (list (format "%s:%s" + (car err) + (mapconcat 'identity (cdr err) " "))) + (setq file-error t))))) + (dot (concat directory ".")) + (dot2 (concat directory "..")) + (candidates (append (and (not file-error) (list dot dot2)) ls))) + (puthash directory (+ (length ls) 2) helm-ff--directory-files-length) + (prog1 + (puthash directory + (cl-loop for f in candidates + when (helm-ff-filter-candidate-one-by-one f) + collect it) + helm-ff--list-directory-cache) + ;; Put an inotify watcher to check directory modifications. + (unless (gethash directory helm-ff--file-notify-watchers) + (puthash directory + (file-notify-add-watch + directory + '(change attribute-change) + (helm-ff--inotify-make-callback directory)) + helm-ff--file-notify-watchers)))))) + +(defun helm-ff--inotify-make-callback (directory) + "Return a callback for `file-notify-add-watch'." + (lambda (event) + (let ((desc (cadr event))) + ;; `attribute-changed' means permissions have changed, not + ;; file modifications like file changes, visit + ;; etc... AFAIU the desc for this is `changed' and for our + ;; use case we don't care of this. + (when (memq desc '(created deleted renamed attribute-changed)) + ;; When DIRECTORY is modified remove it from cache. + (remhash directory helm-ff--list-directory-cache) + ;; Remove watch as well in case of rename or delete. + (file-notify-rm-watch (gethash directory helm-ff--file-notify-watchers)) + (remhash directory helm-ff--file-notify-watchers))))) (defun helm-ff-handle-backslash (fname) ;; Allow creation of filenames containing a backslash. @@ -2752,13 +3369,13 @@ systems." (defun helm-ff--transform-pattern-for-completion (pattern) "Maybe return PATTERN with it's basename modified as a regexp. -This happen only when `helm-ff-fuzzy-matching' is enabled. -This provide a similar behavior as `ido-enable-flex-matching'. +This happens only when `helm-ff-fuzzy-matching' is enabled. +This provides a similar behavior as `ido-enable-flex-matching'. See also `helm--mapconcat-pattern'. -If PATTERN is an url returns it unmodified. -When PATTERN contain a space fallback to multi-match. -If basename contain one or more space fallback to multi-match. -If PATTERN is a valid directory name,return PATTERN unchanged." +If PATTERN is an url return it unmodified. +When PATTERN contains a space fallback to multi-match. +If basename contains one or more space fallback to multi-match. +If PATTERN is a valid directory name, return PATTERN unchanged." ;; handle bad filenames containing a backslash (no more needed in ;; emacs-26, also prevent regexp matching with e.g. "\|"). ;; (setq pattern (helm-ff-handle-backslash pattern)) @@ -2787,14 +3404,19 @@ If PATTERN is a valid directory name,return PATTERN unchanged." ((or (not (helm-ff-fuzzy-matching-p)) (string-match "\\s-" bn)) ; Fall back to multi-match. (concat (regexp-quote bd) bn)) - ((or (string-match "[*][.]?.*" bn) ; Allow entering wilcard. + ((or (string-match "[*][.]?.*" bn) ; Allow entering wildcard. (string-match "/$" pattern) ; Allow mkdir. (string-match helm-ff-url-regexp pattern) (and (string= helm-ff-default-directory "/") tramp-p)) ;; Don't treat wildcards ("*") as regexp char. - ;; (e.g ./foo/*.el => ./foo/[*].el) + ;; (e.g ./foo/*.el => ./foo/\\*\\.el) or ./foo/*.[ch] => + ;; ./foo/\\*\\.\\[ch] (concat (regexp-quote bd) - (replace-regexp-in-string "[*]" "[*]" bn))) + ;; We were previously using + ;; (replace-regexp-in-string "[*]" "[*]" bn) but this + ;; doesn't handle wilcards like *.[ch], so regexp-quote + ;; bn as well. + (regexp-quote bn))) (t (concat (regexp-quote bd) (if (>= (length bn) 2) ; wait 2nd char before concating. (helm--mapconcat-pattern bn) @@ -2884,7 +3506,7 @@ Note that only existing directories are saved here." (format "Type: %s: %s\n" type mode-type) (when (string= type "symlink") (format "True name: '%s'\n" - (cond ((string-match "^\.#" (helm-basename candidate)) + (cond ((string-match "^\\.#" (helm-basename candidate)) "Autosave symlink") ((helm-ff-valid-symlink-p candidate) (file-truename candidate)) @@ -2893,10 +3515,14 @@ Note that only existing directories are saved here." (format "Group: %s: %s\n" group group-right) (format "Others: %s\n" other-right) (format "Size: %s\n" size) + (when (string= type "directory") + (format "Size used in directory: %s\n" + (helm-directory-size + candidate current-prefix-arg t))) (format "Modified: %s\n" modif) (format "Accessed: %s\n" access) (and (stringp trash) - (format "Trash: %s\n" + (format "Trash: %s\n" (abbreviate-file-name trash))))) (message dired-line) (sit-for 5))) (message "Permission denied, file not readable"))) @@ -2905,7 +3531,7 @@ Note that only existing directories are saved here." "Show properties without quitting helm." (interactive) (with-helm-alive-p - (helm-attrset 'properties-action '(helm-ff-properties . never-split)) + (helm-set-attr 'properties-action '(helm-ff-properties . never-split)) (helm-execute-persistent-action 'properties-action))) (put 'helm-ff-properties-persistent 'helm-only t) @@ -2913,7 +3539,7 @@ Note that only existing directories are saved here." "Delete current candidate without quitting." (interactive) (with-helm-alive-p - (helm-attrset 'quick-delete '(helm-ff-quick-delete . never-split)) + (helm-set-attr 'quick-delete '(helm-ff-quick-delete . never-split)) (helm-execute-persistent-action 'quick-delete))) (put 'helm-ff-persistent-delete 'helm-only t) @@ -2931,7 +3557,7 @@ Note that only existing directories are saved here." (t (message "No buffer to kill"))))) (defun helm-ff-kill-or-find-buffer-fname (candidate) - "Find file CANDIDATE or kill it's buffer if it is visible. + "Find file CANDIDATE or kill its buffer if it is visible. Never kill `helm-current-buffer'. Never kill buffer modified. This is called normally on third hit of \ @@ -2959,7 +3585,7 @@ in `helm-find-files-persistent-action-if'." "Execute `helm-ff-kill-buffer-fname' without quitting." (interactive) (with-helm-alive-p - (helm-attrset 'kill-buffer-fname 'helm-ff-kill-buffer-fname) + (helm-set-attr 'kill-buffer-fname 'helm-ff-kill-buffer-fname) (helm-execute-persistent-action 'kill-buffer-fname))) (put 'helm-ff-run-kill-buffer-persistent 'helm-only t) @@ -2974,16 +3600,18 @@ in `helm-find-files-persistent-action-if'." (defun helm-ff-run-preview-file-externally () (interactive) (with-helm-alive-p - (helm-attrset 'open-file-externally '(helm-ff-persistent-open-file-externally . never-split)) + (helm-set-attr 'open-file-externally '(helm-ff-persistent-open-file-externally . never-split)) (helm-execute-persistent-action 'open-file-externally))) (put 'helm-ff-run-preview-file-externally 'helm-only t) (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. -NEW-FILE when non--nil mean FNAME is a non existing file and -return FNAME prefixed with [?]." + "Add display property to FNAME. +Display property presents a string maybe prefixed with [?] or [@]. +If FILE-OR-SYMLINKP is non-nil this means we assume FNAME is an +existing filename or valid symlink and there is no need to test +it. +NEW-FILE when non-nil means FNAME is a non existing file and +return FNAME with display property prefixed with [?]." (let* ((prefix-new (propertize " " 'display (propertize "[?]" 'face 'helm-ff-prefix))) @@ -3042,6 +3670,7 @@ Return candidates prefixed with basename of `helm-input' first." (helm-ff-sort-candidates-1 candidates helm-input)) (defun helm-ff-boring-file-p (file) + "Returns non nil when FILE is matching boring regexps." ;; Prevent user doing silly thing like ;; adding the dotted files to boring regexps (#924). (and helm-ff-skip-boring-files @@ -3050,126 +3679,160 @@ Return candidates prefixed with basename of `helm-input' first." (defvar helm-ff--git-found-p nil) (defun helm-ff-git-ignored-p (file) + "Returns non nil when FILE is matched in \".gitignore\" file." (and helm-ff-skip-git-ignored-files (not (file-remote-p file)) (or helm-ff--git-found-p (setq helm-ff--git-found-p (executable-find "git"))) (zerop (call-process "git" nil nil nil "check-ignore" "-q" file)))) -(defun helm-ff-filter-candidate-one-by-one (file) - "`filter-one-by-one' Transformer function for `helm-source-find-files'." - ;; Handle boring files - (let ((basename (helm-basename file)) - dot) - (unless (or (helm-ff-boring-file-p basename) - (helm-ff-git-ignored-p file)) - +(defun helm-ff-fct (candidates _source) + "Filter in charge of displaying basename or full path in HFF. +Because CANDIDATES are directly stored as (basename . full_path), when +`helm-ff-transformer-show-only-basename' is non nil do nothing and +return directly CANDIDATES." + (if (null helm-ff-transformer-show-only-basename) + (cl-loop for (_disp . real) in candidates + for fc = (helm-ff-filter-candidate-one-by-one real 'reverse) + when fc collect fc) + candidates)) + +(defsubst helm-ff-file-extension (file) + "Returns FILE extension if it is not a number." + (helm-aif (file-name-extension file) + (and (not (string-match "\\`0+\\'" it)) + (zerop (string-to-number it)) + it))) + +(defun helm-ff-filter-candidate-one-by-one (file &optional reverse skip-boring-check) + "Transform file in a cons cell like (DISPLAY . REAL). +DISPLAY is shown as basename of FILE and REAL as full path of FILE. +If REVERSE is non nil DISPLAY is shown as full path. +If SKIP-BORING-CHECK is non nil don't filter boring files." + (let* ((basename (helm-basename file)) + (dot (helm-ff-dot-file-p file)) + (urlp (string-match-p helm-ff-url-regexp file)) + ;; Filename with cntrl chars e.g. foo^J + (disp (or (helm-ff--get-host-from-tramp-invalid-fname file) + (replace-regexp-in-string + "[[:cntrl:]]" "?" + (if (or reverse urlp) file basename)))) + (len (length disp)) + (backup (backup-file-name-p disp))) + ;; We want to filter boring files only on the files coming + ;; from the output of helm-ff-directory-files not on single + ;; candidate (issue #2330). + (unless (and (not skip-boring-check) + (or (helm-ff-boring-file-p basename) + (helm-ff-git-ignored-p file))) + ;; Highlight extensions. + (helm-aif (and (not backup) + (not urlp) + (helm-ff-file-extension disp)) + (when (condition-case _err + (string-match (format "\\.\\(%s\\)\\'" it) disp) + (invalid-regexp nil)) + (add-face-text-property + (match-beginning 1) (match-end 1) + 'helm-ff-file-extension t disp))) ;; Handle tramp files with minimal highlighting. (if (and (or (string-match-p helm-tramp-file-name-regexp helm-pattern) (helm-file-on-mounted-network-p helm-pattern))) - (let* (hostp - (disp (if (and helm-ff-transformer-show-only-basename - (not (setq dot (helm-dir-is-dot file)))) - (or (setq hostp - (helm-ff--get-host-from-tramp-invalid-fname - file)) - basename) - file))) - ;; Filename with cntrl chars e.g. foo^J - ;; This will not work as long as most tramp file handlers doesn't - ;; handle such case, e.g. file-name-all-completions, - ;; directory-files, file-name-nondirectory etc... - ;; Keep it though in case they fix this upstream... - (setq disp (replace-regexp-in-string "[[:cntrl:]]" "?" disp)) + (let* ((hostp (helm-ff--get-host-from-tramp-invalid-fname file))) (cond (;; Dot directories . and .. - dot (propertize file 'face 'helm-ff-dotted-directory)) + dot + (cons (propertize file 'face 'helm-ff-dotted-directory) file)) ;; Directories. ((get-text-property 1 'helm-ff-dir file) (cons (propertize disp 'face 'helm-ff-directory) file)) + ;; Backup files. + (backup + (cons (propertize disp 'face 'helm-ff-backup-file) file)) ;; Executable files. ((get-text-property 1 'helm-ff-exe file) - (cons (propertize disp 'face 'helm-ff-executable) file)) + (add-face-text-property 0 len 'helm-ff-executable t disp) + (cons disp file)) ;; Symlinks. ((get-text-property 1 'helm-ff-sym file) - (cons (propertize disp 'face 'helm-ff-symlink) file)) + (add-face-text-property 0 len 'helm-ff-symlink t disp) + (cons disp file)) ;; Regular files. ((get-text-property 1 'helm-ff-file file) - (cons (propertize disp 'face 'helm-ff-file) file)) + (add-face-text-property 0 len 'helm-ff-file t disp) + (cons disp file)) ;; non existing files. - (t (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-file) + (t + (add-face-text-property 0 len 'helm-ff-file t disp) + (cons (helm-ff-prefix-filename + disp hostp (unless hostp 'new-file)) file)))) ;; Highlight local files showing everything, symlinks, exe, ;; dirs etc... - (let* ((disp (if (and helm-ff-transformer-show-only-basename - (not (setq dot (helm-dir-is-dot file))) - (not (and helm--url-regexp - (string-match helm--url-regexp file))) - (not (string-match helm-ff-url-regexp file))) - (or (helm-ff--get-host-from-tramp-invalid-fname file) - basename) - file)) - (attr (file-attributes file)) + (let* ((attr (file-attributes file)) (type (car attr)) x-bit) - ;; Filename cntrl chars e.g. foo^J - (setq disp (replace-regexp-in-string "[[:cntrl:]]" "?" disp)) (cond ((string-match "file-error" file) file) (;; A dead symlink. (and (stringp type) (not (helm-ff-valid-symlink-p file)) (not (string-match "^\\.#" basename))) - (cons (propertize disp 'face 'helm-ff-invalid-symlink) - file)) + (add-face-text-property 0 len 'helm-ff-invalid-symlink t disp) + (cons disp file)) ;; A dotted directory symlinked. ((and dot (stringp type)) - (cons (propertize disp 'face 'helm-ff-dotted-symlink-directory) - file)) + (cons (propertize file 'face 'helm-ff-dotted-symlink-directory) file)) ;; A dotted directory. - ((helm-ff-dot-file-p file) - (cons (propertize disp 'face 'helm-ff-dotted-directory) - file)) + (dot + (cons (propertize file 'face 'helm-ff-dotted-directory) file)) + ;; Backup files. + (backup + (cons (propertize disp 'face 'helm-ff-backup-file) file)) ;; A symlink. ((stringp type) - (cons (propertize disp 'display - (concat (propertize disp 'face 'helm-ff-symlink) - " -> " - (propertize (abbreviate-file-name type) - 'face 'helm-ff-truename))) - file)) + (let* ((abbrev (abbreviate-file-name type)) + (len-abbrev (length abbrev))) + (helm-aif (helm-ff-file-extension abbrev) + (when (string-match (format "\\.\\(%s\\)\\'" it) abbrev) + (add-face-text-property + (match-beginning 1) (match-end 1) + 'helm-ff-file-extension t abbrev))) + (add-face-text-property 0 len-abbrev 'helm-ff-truename t abbrev) + ;; Colorize extension only on truename. + (add-face-text-property 0 len 'helm-ff-symlink nil disp) + (cons (propertize disp 'display (concat disp " -> " abbrev)) + file))) ;; A directory. ((eq t type) - (cons (propertize disp 'face 'helm-ff-directory) - file)) + (cons (propertize disp 'face 'helm-ff-directory) file)) ;; A character device file. ((and attr (string-match "\\`[cp]" (setq x-bit (substring (nth 8 attr) 0 4)))) - (cons (propertize disp 'face 'helm-ff-pipe) - file)) + (add-face-text-property 0 len 'helm-ff-pipe t disp) + (cons disp file)) ;; A socket file. ((and attr (string-match "\\`[s]" x-bit)) - (cons (propertize disp 'face 'helm-ff-socket) - file)) + (add-face-text-property 0 len 'helm-ff-socket t disp) + (cons disp file)) ;; An executable file. - ((and attr - (string-match - "x\\'" x-bit)) - (cons (propertize disp 'face 'helm-ff-executable) - file)) + ((and attr (string-match "x\\'" x-bit)) + (add-face-text-property 0 len 'helm-ff-executable t disp) + (cons disp file)) ;; An executable file with suid ((and attr (string-match "s\\'" x-bit)) - (cons (propertize disp 'face 'helm-ff-suid) - file)) + (add-face-text-property 0 len 'helm-ff-suid t disp) + (cons disp file)) ;; A file. ((and attr (null type)) - (cons (propertize disp 'face 'helm-ff-file) - file)) + (add-face-text-property 0 len 'helm-ff-file t disp) + (cons disp file)) ;; A non--existing file. - (t (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-file) nil 'new-file) - file)))))))) + (t + (add-face-text-property 0 len 'helm-ff-file t disp) + (cons (helm-ff-prefix-filename + disp nil 'new-file) + file)))))))) (defun helm-find-files-action-transformer (actions candidate) "Action transformer for `helm-source-find-files'." @@ -3180,7 +3843,7 @@ Return candidates prefixed with basename of `helm-input' first." (setq actions (helm-append-at-nth actions '(("Checksum File" . helm-ff-checksum)) 4))) (cond ((and (file-exists-p candidate) - (string-match "Trash/files/?\\'" (helm-basedir candidate)) + (string-match helm-ff--trash-directory-regexp (helm-basedir candidate)) (not (member (helm-basename candidate) '("." ".."))) (executable-find "trash")) (helm-append-at-nth @@ -3208,8 +3871,9 @@ Return candidates prefixed with basename of `helm-input' first." . helm-find-files-byte-compile) ("Load File(s) `M-L'" . helm-find-files-load-files)) 2)) - ((string-match "\\.elc?\\'" (helm-aif (helm-marked-candidates) - (car it) candidate)) + ((string-match (concat (regexp-opt load-suffixes) "\\'") + (helm-aif (helm-marked-candidates) + (car it) candidate)) (helm-append-at-nth actions '(("Load File(s) `M-L'" . helm-find-files-load-files)) @@ -3218,17 +3882,17 @@ Return candidates prefixed with basename of `helm-input' first." (file-exists-p candidate)) (helm-append-at-nth actions '(("Browse url file" . browse-url-of-file)) 2)) - ((or (string= (file-name-extension candidate) "pdf") - (string= (file-name-extension candidate) "PDF")) - (helm-append-at-nth - actions '(("Pdfgrep File(s)" . helm-ff-pdfgrep)) 4)) (t actions)))) +;;; Trashing files +;; (defun helm-ff-trash-action (fn names &rest args) "Execute a trash action FN on marked files. -Arg NAMES is a list of strings to pass to messages -e.g. '(\"delete\" \"deleting\"), ARGS are other args to be passed to FN." +Arg NAMES is a list of strings to pass to messages. +E.g. '(\"delete\" \"deleting\") + +ARGS are other arguments to be passed to FN." (let ((mkd (helm-marked-candidates)) errors) (with-helm-display-marked-candidates @@ -3264,9 +3928,9 @@ e.g. '(\"delete\" \"deleting\"), ARGS are other args to be passed to FN." "Delete marked-files from a Trash directory. The Trash directory should be a directory compliant with - and each file -should have its '*.trashinfo' correspondent file in Trash/info -directory." + and each +file should have its '*.trashinfo' correspondent file in +Trash/info directory." (helm-ff-trash-action 'helm-ff-trash-rm-1 '("delete" "deleting"))) (defun helm-ff-trash-rm-1 (file) @@ -3288,9 +3952,9 @@ directory." "Restore marked-files from a Trash directory. The Trash directory should be a directory compliant with - and each file -should have its '*.trashinfo' correspondent file in Trash/info -directory." + and each +file should have its '*.trashinfo' correspondent file in +Trash/info directory." (let* ((default-directory (file-name-as-directory helm-ff-default-directory)) (trashed-files (helm-ff-trash-list))) @@ -3300,12 +3964,12 @@ directory." (defun helm-restore-file-from-trash-1 (file trashed-files) "Restore FILE from a trash directory. -Arg TRASHED-FILES is an alist of (fname_in_trash . dest) obtained with -`helm-ff-trash-list'." +Arg TRASHED-FILES is an alist of (fname_in_trash . dest) obtained +with `helm-ff-trash-list'." ;; Emacs trash duplicate files with a unique name + .trashinfo in ;; the filename which is wrong, only files in info directory should ;; end with .trashinfo, so fix the filename before looking for dest name. - (let* ((fname (replace-regexp-in-string "\\.trashinfo\\'" "" file)) + (let* ((fname (replace-regexp-in-string "\\.trashinfo\\'" "" file)) (info-file (concat (helm-reduce-file-name fname 2) "info/" (helm-basename fname) @@ -3315,13 +3979,15 @@ Arg TRASHED-FILES is an alist of (fname_in_trash . dest) obtained with (cl-assert (not (file-exists-p dest-file)) nil (format "File `%s' already exists" dest-file)) (cl-assert dest-file nil "No such file in trash") + (message "Restoring %s to %s..." (helm-basename file) (helm-basedir dest-file)) (rename-file file dest-file) + (message "Restoring %s to %s done" (helm-basename file) (helm-basedir dest-file)) (delete-file info-file))) (defun helm-ff-trash-file-p (file) - "Return `t' when file is a trashed file." + "Return t when FILE is a trashed file." (and (file-exists-p file) - (string-match "Trash/files/?\\'" (helm-basedir file)) + (string-match helm-ff--trash-directory-regexp (helm-basedir file)) (not (member (helm-basename file) '("." ".."))))) (defun helm-ff--get-dest-file-from-trash (trashed-files file) @@ -3329,6 +3995,11 @@ Arg TRASHED-FILES is an alist of (fname_in_trash . dest) obtained with (defun helm-ff-trash-list () "Return an alist of trashed files basename and dest name." + ;; Files owned by root are trashed in /root/.local/share/Trash. + ;; Files owned by user and trashed by root are trashed in + ;; /home/.Trash. + ;; Files owned by user and trashed by user are trashed in + ;; ~/.local/share/Trash. (cl-loop for f in (directory-files (expand-file-name ;; helm-ff-default-directory is actually the @@ -3340,14 +4011,22 @@ Arg TRASHED-FILES is an alist of (fname_in_trash . dest) obtained with (save-excursion (insert-file-contents f)) (when (re-search-forward "^path=" nil t) - (helm-url-unhex-string - (buffer-substring-no-properties - (point) (point-at-eol)))))))) + (let ((path (helm-url-unhex-string + (buffer-substring-no-properties + (point) (point-at-eol))))) + (if (string-match "\\`/" path) + ;; path is absolute + path + ;; When path is relative, assume the + ;; trash directory is located at + ;; /home/.Trash and path is the + ;; relative name of file from /home. + (expand-file-name path "/home")))))))) (defun helm-ff-goto-linum (candidate) "Find file CANDIDATE and maybe jump to line number found in fname at point. -line number should be added at end of fname preceded with \":\". -e.g \"foo:12\"." +Line number should be added at end of fname preceded with \":\". +E.g. \"foo:12\"." (let ((linum (with-helm-current-buffer (let ((str (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) @@ -3386,45 +4065,61 @@ e.g \"foo:12\"." "application/octet-stream"))))))) (defvar image-dired-display-image-buffer) -(defun helm-ff-rotate-current-image-1 (file num-arg) - "Rotate current image at NUM-ARG degrees." +(defun helm-ff-rotate-current-image-1 (file angle) + "Rotate current image at ANGLE degrees." + (cl-assert (and (file-exists-p file) + (string-match (image-file-name-regexp) file)) + nil "Can't rotate non image file") (setq file (file-truename file)) ; For symlinked images. - ;; When FILE is not an image-file, do nothing. - (when (and (file-exists-p file) - (string-match (image-file-name-regexp) file)) - (setq num-arg (if (string= helm-ff-rotate-image-program "exiftran") - (cl-case num-arg - (90 "-9") ; 90 clockwise - (270 "-2")) ; 270 clockwise == -90 - (number-to-string num-arg))) - (if (executable-find helm-ff-rotate-image-program) - (let ((default-directory (file-name-directory file)) - (basename (helm-basename file))) - (apply #'process-file helm-ff-rotate-image-program nil nil nil - (append helm-ff-rotate-image-switch - (list num-arg basename))) - (when (buffer-live-p image-dired-display-image-buffer) - (kill-buffer image-dired-display-image-buffer)) - (image-dired-display-image basename) - (message nil) - (display-buffer (get-buffer image-dired-display-image-buffer))) - (error "%s not found" helm-ff-rotate-image-program)))) + (let ((default-directory (file-name-directory file)) + (basename (helm-basename file)) + ;; convert ANGLE to a suitable value for exiftran. + (num-arg (if (string= helm-ff-rotate-image-program "exiftran") + (cl-case angle + (90 "-9") ; 90 clockwise + (270 "-2")) ; 270 clockwise == -90 + (number-to-string angle))) + rotation-failed) + ;; Try to rotate image with exiftran even with helm-ff-display-image-native. + (if (and helm-ff-rotate-image-program + (executable-find helm-ff-rotate-image-program)) + (apply #'process-file helm-ff-rotate-image-program nil nil nil + (append helm-ff-rotate-image-switch + (list num-arg basename))) + (setq rotation-failed t)) + ;; Display image in image-mode. + (if helm-ff-display-image-native + (if rotation-failed + ;; When rotation fails fallback to `image-rotate' with no + ;; transformation of file. + (with-selected-window (helm-persistent-action-display-window) + (image-rotate angle)) + (helm-ff--display-image-native file)) + ;; Use image-dired to display image. + (when rotation-failed + (error "%s not found" (or helm-ff-rotate-image-program + "`helm-ff-rotate-image-program'"))) + (when (buffer-live-p image-dired-display-image-buffer) + (kill-buffer image-dired-display-image-buffer)) + (image-dired-display-image basename) + (message nil) + (display-buffer (get-buffer image-dired-display-image-buffer))))) (defun helm-ff-rotate-image-left (candidate) "Rotate image file CANDIDATE left. -This affect directly file CANDIDATE." +This affects directly file CANDIDATE." (helm-ff-rotate-current-image-1 candidate 270)) (defun helm-ff-rotate-image-right (candidate) "Rotate image file CANDIDATE right. -This affect directly file CANDIDATE." +This affects directly file CANDIDATE." (helm-ff-rotate-current-image-1 candidate 90)) (defun helm-ff-rotate-left-persistent () "Rotate image left without quitting helm." (interactive) (with-helm-alive-p - (helm-attrset 'image-action1 'helm-ff-rotate-image-left) + (helm-set-attr 'image-action1 'helm-ff-rotate-image-left) (helm-execute-persistent-action 'image-action1))) (put 'helm-ff-rotate-left-persistent 'helm-only t) @@ -3432,10 +4127,51 @@ This affect directly file CANDIDATE." "Rotate image right without quitting helm." (interactive) (with-helm-alive-p - (helm-attrset 'image-action2 'helm-ff-rotate-image-right) + (helm-set-attr 'image-action2 'helm-ff-rotate-image-right) (helm-execute-persistent-action 'image-action2))) (put 'helm-ff-rotate-right-persistent 'helm-only t) +(defun helm-ff-resize-image-1 (arg) + ;; `image-decrease-size' and `image-increase-size' are not usable + ;; because they run directly `image--change-size' in a timer without + ;; taking care of the selected-window. + (cl-assert (and (fboundp 'image--change-size) + helm-ff-display-image-native) + nil "Resizing image not available") + (if (> arg 0) + (run-with-idle-timer + 0.3 nil + (lambda () + (with-selected-window (helm-persistent-action-display-window) + (image--change-size 1.2)))) + (run-with-idle-timer + 0.3 nil + (lambda () + (with-selected-window (helm-persistent-action-display-window) + (image--change-size 0.8)))))) + +(defun helm-ff-increase-image-size (_candidate) + (helm-ff-resize-image-1 1)) + +(defun helm-ff-decrease-image-size (_candidate) + (helm-ff-resize-image-1 -1)) + +(defun helm-ff-increase-image-size-persistent () + "Increase image size without quitting helm." + (interactive) + (with-helm-alive-p + (helm-set-attr 'image-action3 'helm-ff-increase-image-size) + (helm-execute-persistent-action 'image-action3))) +(put 'helm-ff-increase-image-size-persistent 'helm-only t) + +(defun helm-ff-decrease-image-size-persistent () + "Decrease image size without quitting helm." + (interactive) + (with-helm-alive-p + (helm-set-attr 'image-action4 'helm-ff-decrease-image-size) + (helm-execute-persistent-action 'image-action4))) +(put 'helm-ff-decrease-image-size-persistent 'helm-only t) + (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 @@ -3447,19 +4183,24 @@ This affect directly file CANDIDATE." (format "No program %s found to extract exif" helm-ff-exif-data-program))) +(defvar helm-ff-image-native-buffer "*image-native-display*") + +(defvar helm-ff-sound-file-extensions '("wav" "au")) + (cl-defun helm-find-files-persistent-action-if (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-j expand CANDIDATE second hit open file. -If a prefix arg is given or `helm-follow-mode' is on open file." +That means: +First hit on C-j expands CANDIDATE, second hit opens file. +If a prefix arg is given or `helm-follow-mode' is on, then open +file." (let* ((follow (or (helm-follow-mode-p) helm--temp-follow-flag)) (image-cand (string-match-p (image-file-name-regexp) candidate)) - (new-pattern (helm-get-selection)) - (num-lines-buf (with-current-buffer helm-buffer - (count-lines (point-min) (point-max)))) + (sound-cand (member (file-name-extension candidate) + helm-ff-sound-file-extensions)) + (selection (helm-get-selection)) (insert-in-minibuffer (lambda (fname) (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) @@ -3468,12 +4209,14 @@ If a prefix arg is given or `helm-follow-mode' is on open file." (set-text-properties 0 (length fname) nil fname) (insert fname)))))) - (helm-attrset 'candidate-number-limit helm-ff-candidate-number-limit) + (helm-set-attr 'candidate-number-limit helm-ff-candidate-number-limit) (unless image-cand (when follow (helm-follow-mode -1) (cl-return-from helm-find-files-persistent-action-if - (message "Helm-follow-mode allowed only on images, disabling")))) + (prog1 + #'ignore + (message "Helm-follow-mode allowed only on images, disabling"))))) (cond ((and (helm-ff--invalid-tramp-name-p) (string-match helm-tramp-file-name-regexp candidate)) (cons (lambda (_candidate) @@ -3487,6 +4230,7 @@ If a prefix arg is given or `helm-follow-mode' is on open file." ;; unless a prefix arg is given. (and (file-directory-p candidate) (file-symlink-p candidate)) (cons (lambda (_candidate) + (helm-ff-after-persistent-show-all) (funcall insert-in-minibuffer (file-name-as-directory (if current-prefix-arg @@ -3496,10 +4240,12 @@ If a prefix arg is given or `helm-follow-mode' is on open file." ;; A directory, open it. ((file-directory-p candidate) (cons (lambda (_candidate) + (helm-ff-after-persistent-show-all) (when (string= (helm-basename candidate) "..") (setq helm-ff-last-expanded helm-ff-default-directory)) (funcall insert-in-minibuffer (file-name-as-directory - (expand-file-name candidate)))) + (expand-file-name candidate))) + (with-helm-after-update-hook (helm-ff-retrieve-last-expanded))) 'never-split)) ;; A symlink file, expand to it's true name. (first hit) ((and (file-symlink-p candidate) (not current-prefix-arg) (not follow)) @@ -3508,47 +4254,50 @@ If a prefix arg is given or `helm-follow-mode' is on open file." (helm-check-minibuffer-input)) ; Force update. 'never-split)) ;; A regular file, expand it, (first hit) - ((and (>= num-lines-buf 3) (not current-prefix-arg) (not follow)) + ((and (not (file-equal-p selection helm-pattern)) + (not current-prefix-arg) (not follow)) (cons (lambda (_candidate) - (funcall insert-in-minibuffer new-pattern) + (funcall insert-in-minibuffer selection) (helm-check-minibuffer-input)) ; Force update. 'never-split)) - ;; An image file and it is the second hit on C-j, - ;; show the file in `image-dired'. + (sound-cand (lambda (candidate) (play-sound-file candidate))) + ;; An image file and it is the second hit on C-j, display it. (image-cand - (lambda (_candidate) - (require 'image-dired) - (let* ((win (get-buffer-window - image-dired-display-image-buffer 'visible)) - (fname (and win - (with-selected-window win - (get-text-property (point-min) - 'original-file-name)))) - (remove-buf-only (and win - fname - (with-helm-buffer - (file-equal-p candidate fname))))) - (when remove-buf-only - (with-helm-window - (if (and helm-persistent-action-display-window - (window-dedicated-p (next-window win 1))) - (delete-window helm-persistent-action-display-window) - (set-window-buffer win helm-current-buffer)))) - (when (buffer-live-p (get-buffer image-dired-display-image-buffer)) - (kill-buffer image-dired-display-image-buffer)) - (unless remove-buf-only - ;; Fix emacs bug never fixed upstream. - (unless (file-directory-p image-dired-dir) - (make-directory image-dired-dir)) - (switch-to-buffer image-dired-display-image-buffer) - (message "Resizing image...") - (cl-letf (((symbol-function 'message) #'ignore)) - (image-dired-display-image candidate)) - (message "Resizing image done") - (with-current-buffer image-dired-display-image-buffer - (let ((exif-data (helm-ff-exif-data candidate))) - (setq default-directory helm-ff-default-directory) - (image-dired-update-property 'help-echo exif-data))))))) + (if helm-ff-display-image-native + #'helm-ff--display-or-kill-image-native + (lambda (_candidate) + (require 'image-dired) + (let* ((win (get-buffer-window + image-dired-display-image-buffer 'visible)) + (fname (and win + (with-selected-window win + (get-text-property (point-min) + 'original-file-name)))) + (remove-buf-only (and win + fname + (with-helm-buffer + (file-equal-p candidate fname))))) + (when remove-buf-only + (with-helm-window + (if (and helm-persistent-action-display-window + (window-dedicated-p (next-window win 1))) + (delete-window helm-persistent-action-display-window) + (set-window-buffer win helm-current-buffer)))) + (when (buffer-live-p (get-buffer image-dired-display-image-buffer)) + (kill-buffer image-dired-display-image-buffer)) + (unless remove-buf-only + ;; Fix emacs bug never fixed upstream. + (unless (file-directory-p image-dired-dir) + (make-directory image-dired-dir)) + (switch-to-buffer image-dired-display-image-buffer) + (message "Resizing image...") + (cl-letf (((symbol-function 'message) #'ignore)) + (image-dired-display-image candidate)) + (message "Resizing image done") + (with-current-buffer image-dired-display-image-buffer + (let ((exif-data (helm-ff-exif-data candidate))) + (setq default-directory helm-ff-default-directory) + (image-dired-update-property 'help-echo exif-data)))))))) ;; Allow browsing archive on avfs fs. ;; Assume volume is already mounted with mountavfs. ((helm-aand helm-ff-avfs-directory @@ -3584,14 +4333,38 @@ If a prefix arg is given or `helm-follow-mode' is on open file." ;; On second hit we open file. ;; On Third hit we kill it's buffer maybe. (t - (lambda (_candidate) + (lambda (candidate) (funcall helm-ff-kill-or-find-buffer-fname-fn candidate)))))) +(defun helm-ff--display-or-kill-image-native (candidate) + ;; Display images in same buffer + ;; `helm-ff-image-native-buffer'. + (if (and (buffer-live-p (get-buffer helm-ff-image-native-buffer)) + (file-equal-p (buffer-file-name + (get-buffer helm-ff-image-native-buffer)) + candidate) + ;; Allow redisplaying + ;; `helm-ff-image-native-buffer' when it + ;; already exists and display same image as candidate. + (get-buffer-window helm-ff-image-native-buffer 'visible)) + (progn + (set-window-buffer + helm-persistent-action-display-window helm-current-buffer) + (kill-buffer helm-ff-image-native-buffer)) + (helm-ff--display-image-native candidate))) + +(defun helm-ff--display-image-native (candidate) + (and (buffer-live-p (get-buffer helm-ff-image-native-buffer)) + (kill-buffer helm-ff-image-native-buffer)) + (cl-letf (((symbol-function 'message) #'ignore)) + (find-file candidate)) + (with-current-buffer (get-file-buffer candidate) + (rename-buffer helm-ff-image-native-buffer))) ;;; Recursive dirs completion ;; (defun helm-find-files-recursive-dirs (directory &optional input) - (when (string-match "\\(\\s-+\\|[.]\\)\\{2\\}" input) + (when (string-match "\\([.]\\)\\{2\\}" input) (setq input (replace-match "" nil t input))) (message "Recursively searching %s from %s ..." input (abbreviate-file-name directory)) @@ -3654,10 +4427,11 @@ If a prefix arg is given or `helm-follow-mode' is on open file." "Insert file name completion at point. When completing i.e. there is already something at point, insert -filename abbreviated, relative or full according to initial input, -whereas when inserting i.e. there is nothing at point, insert filename -full, abbreviated or relative according to prefix arg, respectively no -prefix arg, one prefix arg or two prefix arg." +filename abbreviated, relative or full according to initial +input, whereas when inserting i.e. there is nothing at point, +insert filename full, abbreviated or relative according to prefix +arg, respectively no prefix arg, one prefix arg or two prefix +arg." (with-helm-current-buffer (if buffer-read-only (error "Error: Buffer `%s' is read-only" (buffer-name)) @@ -3667,7 +4441,13 @@ prefix arg, one prefix arg or two prefix arg." (tap (helm-ffap-guesser)) (guess (and (stringp tap) (substring-no-properties tap))) - (beg (if guess (- (point) (length guess)) (point))) + (beg (helm-aif (and guess + (save-excursion + (when (re-search-backward + (regexp-quote guess) + (point-at-bol) t) + (point)))) + it (point))) (full-path-p (and (stringp guess) (or (string-match-p (concat "^" (getenv "HOME")) @@ -3675,34 +4455,40 @@ prefix arg, one prefix arg or two prefix arg." (string-match-p "\\`\\(/\\|[[:lower:][:upper:]]:/\\)" guess)))) - (escape-fn (with-helm-current-buffer - (if (memq major-mode - helm-modes-using-escaped-strings) - #'shell-quote-argument #'identity)))) + (escape-fn (if (memq major-mode + helm-modes-using-escaped-strings) + #'shell-quote-argument #'identity))) + (when (and beg end) + (delete-region beg end)) (insert - (funcall escape-fn (helm-ff--insert-fname - candidate beg end full-path-p guess)) + (funcall + escape-fn + (helm-ff--format-fname-to-insert + candidate beg end full-path-p guess + helm-current-prefix-arg)) (if (cdr mkds) " " "") (mapconcat escape-fn (cl-loop for f in (cdr mkds) - collect (helm-ff--insert-fname f)) + collect (helm-ff--format-fname-to-insert + f nil nil nil nil + helm-current-prefix-arg)) " ")))))) -(defun helm-ff--insert-fname (candidate &optional beg end full-path guess) +(defun helm-ff--format-fname-to-insert (candidate + &optional beg end full-path guess prefarg) (set-text-properties 0 (length candidate) nil candidate) (if (and beg end guess (not (string= guess "")) + (null prefarg) (or (string-match "^\\(~/\\|/\\|[[:lower:][:upper:]]:/\\)" guess) (file-exists-p candidate))) - (prog1 - (cond (full-path - (expand-file-name candidate)) - ((string= (match-string 1 guess) "~/") - (abbreviate-file-name candidate)) - (t (file-relative-name candidate))) - (delete-region beg end)) - (helm-acase helm-current-prefix-arg + (cond (full-path + (expand-file-name candidate)) + ((string= (match-string 1 guess) "~/") + (abbreviate-file-name candidate)) + (t (file-relative-name candidate))) + (helm-acase prefarg ('(4) (abbreviate-file-name candidate)) ('(16) (file-relative-name candidate)) ('(64) (helm-basename candidate)) @@ -3742,7 +4528,7 @@ Show the first `helm-ff-history-max-length' elements of (defun helm-find-files-1 (fname &optional preselect) "Find FNAME filename with PRESELECT filename preselected. -Use it for non--interactive calls of `helm-find-files'." +Use it for non-interactive calls of `helm-find-files'." (require 'tramp) ;; Resolve FNAME now outside of helm. ;; [FIXME] When `helm-find-files-1' is used directly from lisp @@ -3766,8 +4552,8 @@ Use it for non--interactive calls of `helm-find-files'." (unless helm-source-find-files (setq helm-source-find-files (helm-make-source "Find Files" 'helm-source-ffiles))) - (when (helm-attr 'follow helm-source-find-files) - (helm-attrset 'follow -1 helm-source-find-files)) + (when (helm-get-attr 'follow helm-source-find-files) + (helm-set-attr 'follow -1 helm-source-find-files)) (helm-ff-setup-update-hook) (add-hook 'helm-resume-after-hook 'helm-ff--update-resume-after-hook) (unwind-protect @@ -3785,11 +4571,11 @@ Use it for non--interactive calls of `helm-find-files'." (defun helm-ff--update-resume-after-hook (sources &optional nohook) "Meant to be used in `helm-resume-after-hook'. -When NOHOOK is non nil run inconditionally, otherwise only when source -is helm-source-find-files." +When NOHOOK is non-nil run inconditionally, otherwise only when +source is `helm-source-find-files'." (when (or nohook (string= "Find Files" (assoc-default 'name (car sources)))) - (helm-attrset 'resume `(lambda () + (helm-set-attr 'resume `(lambda () (helm-ff-setup-update-hook) (setq helm-ff-default-directory ,helm-ff-default-directory @@ -3816,7 +4602,9 @@ is helm-source-find-files." '(helm-ff-auto-expand-to-home-or-root helm-ff-update-when-only-one-matched helm-ff-move-to-first-real-candidate - helm-ff-clean-initial-input))) + helm-ff-clean-initial-input)) + (setq helm-ff--show-directories-only nil + helm-ff--show-files-only nil)) (defun helm-ff-bookmark () (helm :sources 'helm-source-bookmark-helm-find-files @@ -3981,8 +4769,8 @@ Find inside `require' and `declare-function' sexp." "Execute ACTION on FILES to CANDIDATE. Where ACTION is a symbol that can be one of: 'copy, 'rename, 'symlink,'relsymlink, 'hardlink or 'backup. -Argument FOLLOW when non--nil specify to follow FILES to destination for the actions -copy and rename." +Argument FOLLOW when non-nil specifies to follow FILES to +destination for the actions copy and rename." (require 'dired-async) (require 'dired-x) ; For dired-keep-marker-relsymlink (when (get-buffer dired-log-buffer) (kill-buffer dired-log-buffer)) @@ -4040,6 +4828,10 @@ copy and rename." (setq helm-ff-cand-to-mark (helm-get-dest-fnames-from-list files candidate dirflag)) (with-helm-after-update-hook (helm-ff-maybe-mark-candidates)) + ;; Refresh directory even if helm-ff-cache-mode is + ;; enabled, it will not have the time to update + ;; destination directory. + (helm-ff-directory-files candidate t) (if (and dirflag (eq action 'rename)) (helm-find-files-1 (file-name-directory target) (if helm-ff-transformer-show-only-basename @@ -4050,8 +4842,8 @@ copy and rename." (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." +If RENAME-DIR-FLAG is non-nil collect the `directory-file-name' +of transformed members of FLIST." ;; At this point files have been renamed/copied at destination. ;; That's mean DEST-CAND exists. (cl-loop @@ -4068,8 +4860,8 @@ members of FLIST." (defun helm-ff-maybe-mark-candidates () "Mark all candidates of list `helm-ff-cand-to-mark'. -This is used when copying/renaming/symlinking etc... and -following files to destination." +This is used when copying/renaming/symlinking etc. and following +files to destination." (when (and (string= (assoc-default 'name (helm-get-current-source)) (assoc-default 'name helm-source-find-files)) helm-ff-cand-to-mark) @@ -4089,7 +4881,7 @@ following files to destination." ;; ;; (defun helm-file-buffers (filename) - "Returns a list of buffer names corresponding to FILENAME." + "Return a list of buffer names corresponding to FILENAME." (cl-loop with name = (expand-file-name filename) for buf in (buffer-list) for bfn = (buffer-file-name buf) @@ -4098,7 +4890,7 @@ following files to destination." (defun helm-ff--delete-by-moving-to-trash (file) "Decide to trash or delete FILE. -Returns non-nil when FILE needs to be trashed." +Return non-nil when FILE needs to be trashed." (let ((remote (file-remote-p file))) (or (and delete-by-moving-to-trash @@ -4115,8 +4907,8 @@ Returns non-nil when FILE needs to be trashed." (defun helm-ff-quick-delete (_candidate) "Delete file CANDIDATE without quitting. -When a prefix arg is given, meaning of `delete-by-moving-to-trash' is -inversed." +When a prefix arg is given, meaning of +`delete-by-moving-to-trash' is the opposite." (with-helm-window (let ((marked (helm-marked-candidates))) (unwind-protect @@ -4148,11 +4940,11 @@ inversed." (defun helm-delete-file (file &optional error-if-dot-file-p synchro trash) "Delete FILE after querying the user. -When a prefix arg is given, meaning of `delete-by-moving-to-trash' is -inversed. +When a prefix arg is given, meaning of +`delete-by-moving-to-trash' is the opposite. -Return error when ERROR-IF-DOT-FILE-P is non nil and user tries to -delete a dotted file i.e. \".\" or \"..\". +Return error when ERROR-IF-DOT-FILE-P is non-nil and user tries +to delete a dotted file i.e. \".\" or \"..\". Ask user when directory are not empty to allow recursive deletion unless `helm-ff-allow-recursive-deletes' is non nil. @@ -4211,8 +5003,8 @@ is nil." (defun helm-delete-marked-files (_ignore) "Delete marked files with `helm-delete-file'. -When a prefix arg is given, meaning of `delete-by-moving-to-trash' is -inversed." +When a prefix arg is given, meaning of +`delete-by-moving-to-trash' is the opposite." (let* ((files (helm-marked-candidates :with-wildcard t)) (len 0) (trash (helm-ff--delete-by-moving-to-trash (car files))) @@ -4240,8 +5032,8 @@ inversed." ;; ;; (defvar helm-ff-delete-log-file - (expand-file-name "helm-delete-file.log" user-emacs-directory) - "The file use to communicate with emacs child when deleting files async.") + (locate-user-emacs-file "helm-delete-file.log") + "The file use to communicate with Emacs child when deleting files async.") (defvar helm-ff--trash-flag nil) @@ -4262,7 +5054,7 @@ inversed." (setq helm-ff--trash-flag nil))) (defun helm-delete-async-mode-line-message (text face &rest args) - "Notify end of async operation in `mode-line'." + "Notify end of async operation in mode-line." (message nil) (let ((mode-line-format (concat " " (propertize @@ -4277,12 +5069,12 @@ inversed." (defun helm-delete-marked-files-async (_ignore) "Same as `helm-delete-marked-files' but async. -When a prefix arg is given, meaning of `delete-by-moving-to-trash' is -inversed. +When a prefix arg is given, meaning of +`delete-by-moving-to-trash' is the opposite. -This function is not using `helm-delete-file' and BTW not asking user -for recursive deletion of directory, be warned that directories are -always deleted with no warnings." +This function is not using `helm-delete-file' and BTW not asking +user for recursive deletion of directory, be warned that +directories are always deleted with no warnings." (let* ((files (helm-marked-candidates :with-wildcard t)) (trash (helm-ff--delete-by-moving-to-trash (car files))) (prmt (if trash "Trash" "Delete")) @@ -4350,7 +5142,8 @@ always deleted with no warnings." "Open file CANDIDATE or open helm marked files in separate windows. Called with one prefix arg open files in separate windows in a vertical split. -Called with two prefix arg open files in background without selecting them." +Called with two prefix arg open files in background without +selecting them." (let ((marked (helm-marked-candidates :with-wildcard t)) (url-p (and helm--url-regexp ; we should have only one candidate. (string-match helm--url-regexp candidate))) @@ -4391,35 +5184,48 @@ Called with two prefix arg open files in background without selecting them." (helm-exit-and-execute-action 'find-file-other-tab))) (put 'helm-ff-find-file-other-tab 'helm-only t) +(defun helm-ff--new-dirs-to-update (path) + "Collect directories to update when creating new directory PATH." + (let ((result (list path))) + (helm-awhile (helm-reduce-file-name path 1) + (if (not (file-directory-p it)) + (progn (push it result) (setq path it)) + (push it result) + (cl-return))) + result)) + (defun helm-ff--mkdir (dir &optional helm-ff) (when (or (not confirm-nonexistent-file-or-buffer) (y-or-n-p (format "Create directory `%s'? " (abbreviate-file-name (expand-file-name dir))))) - (let ((dirfname (directory-file-name dir))) + (let ((dirfname (directory-file-name dir)) + (to-update (and helm-ff (helm-ff--new-dirs-to-update dir)))) (if (file-exists-p dirfname) (error "Mkdir: Unable to create directory `%s': file exists." (helm-basename dirfname)) - (make-directory dir 'parent))) - (when helm-ff - ;; Allow having this new dir in history - ;; to be able to retrieve it immediately - ;; if we want to e.g copy a file from somewhere in it. - (setq helm-ff-default-directory - (file-name-as-directory (expand-file-name dir))) - (push helm-ff-default-directory helm-ff-history)) - (or (and helm-ff (helm-find-files-1 dir)) t))) + (make-directory dir 'parent)) + (when helm-ff + ;; Refresh cache. + (mapc (lambda (x) (helm-ff-directory-files x t)) to-update) + ;; Allow having this new dir in history + ;; to be able to retrieve it immediately + ;; if we want to e.g copy a file from somewhere in it. + (setq helm-ff-default-directory + (file-name-as-directory (expand-file-name dir))) + (push helm-ff-default-directory helm-ff-history)) + (or (and helm-ff (helm-find-files-1 dir)) t)))) (defun helm-transform-file-load-el (actions candidate) - "Add action to load the file CANDIDATE if it is an emacs lisp + "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 helm-transform-file-browse-url (actions candidate) - "Add an action to browse the file CANDIDATE if it is a html file or URL. + "Add an action to browse the file CANDIDATE if it is a HTML file or URL. Else return ACTIONS unmodified." (let ((browse-action '("Browse with Browser" . browse-url))) (cond ((string-match "^http\\|^ftp" candidate) @@ -4429,9 +5235,10 @@ Else return ACTIONS unmodified." (t actions)))) (defun helm-file-on-mounted-network-p (file) - "Returns non-nil when FILE is part of a mounted remote directory. + "Return non-nil when FILE is part of a mounted remote directory. -This function is checking `helm-mounted-network-directories' list." +This function is checking `helm-mounted-network-directories' +list." (when helm-mounted-network-directories (cl-loop for dir in helm-mounted-network-directories thereis (file-in-directory-p file dir)))) @@ -4472,8 +5279,9 @@ This function is checking `helm-mounted-network-directories' list." :action 'helm-type-file-actions)) (defvar helm-source--ff-file-name-history nil - "[Internal] This source is build to be used with `helm-find-files'. -Don't use it in your own code unless you know what you are doing.") + "[INTERNAL] This source is build to be used with `helm-find-files'. +Don't use it in your own code unless you know what you are +doing.") (defvar helm--file-name-history-hide-deleted nil) @@ -4487,7 +5295,8 @@ Don't use it in your own code unless you know what you are doing.") (defvar helm-file-name-history-map (let ((map (make-sparse-keymap))) (set-keymap-parent map helm-map) - (define-key map (kbd "C-c d") 'helm-file-name-history-show-or-hide-deleted) + (define-key map (kbd "C-c d") 'helm-file-name-history-show-or-hide-deleted) + (define-key map (kbd "C-x C-f") 'helm-ff-file-name-history-run-ff) map)) (defun helm-file-name-history-transformer (candidates _source) @@ -4502,6 +5311,16 @@ Don't use it in your own code unless you know what you are doing.") (cons (propertize c 'face 'helm-history-deleted) c)))) collect it)) +(defun helm-ff-file-name-history-ff (candidate) + (helm-set-pattern + (expand-file-name candidate))) + +(defun helm-ff-file-name-history-run-ff () + "Switch back to current HFF session with selection as preselect." + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-ff-file-name-history-ff))) + (defun helm-ff-file-name-history () "Switch to `file-name-history' without quitting `helm-find-files'." (interactive) @@ -4528,9 +5347,7 @@ Don't use it in your own code unless you know what you are doing.") (helm-set-pattern (expand-file-name candidate)) (with-helm-after-update-hook (helm-exit-minibuffer))) - "Find file in helm" (lambda (candidate) - (helm-set-pattern - (expand-file-name candidate)))) + "Find file in helm" 'helm-ff-file-name-history-ff) :keymap helm-file-name-history-map))) (with-helm-alive-p (helm :sources 'helm-source--ff-file-name-history @@ -4552,7 +5369,7 @@ Don't use it in your own code unless you know what you are doing.") (set-keymap-parent map helm-generic-files-map) (define-key map (kbd "M-g a") 'helm-browse-project-run-ag) map)) - + (defun helm-browse-project-get-buffers (root-directory) (cl-loop for b in (helm-buffer-list) ;; FIXME: Why default-directory is root-directory @@ -4583,7 +5400,8 @@ Don't use it in your own code unless you know what you are doing.") "List files in DIRECTORY recursively with external PROGRAM." (let ((cmd (cl-ecase program (ag "ag --hidden -g '.*' %s") - (rg "rg --files --hidden -g '*' %s")))) + (rg "rg --files --hidden -g '*' %s") + (fd "fd --hidden --type f --glob '*' %s")))) (with-temp-buffer (call-process-shell-command (format cmd directory) @@ -4601,13 +5419,18 @@ Use AG as backend." Use RG as backend." (helm-browse-project-find-files-1 directory 'rg)) +(defun helm-browse-project-fd-find-files (directory) + "A suitable function for `helm-browse-project-default-find-files-fn'. +Use FD as backend." + (helm-browse-project-find-files-1 directory 'fd)) + (defun helm-browse-project-ag (_candidate) - "helm-grep AG action for helm-browse-project." - (let ((dir (with-helm-buffer (helm-attr 'root-dir)))) + "A `helm-grep' AG action for `helm-browse-project'." + (let ((dir (with-helm-buffer (helm-get-attr 'root-dir)))) (helm-grep-ag dir helm-current-prefix-arg))) (defun helm-browse-project-run-ag () - "Runs helm-grep AG from helm-browse-project." + "Run `helm-grep' AG from `helm-browse-project'." (interactive) (with-helm-alive-p (helm-exit-and-execute-action 'helm-browse-project-ag))) @@ -4633,8 +5456,8 @@ Use RG as backend." 'face 'helm-ff-file) c) (propertize c 'face 'helm-ff-file))))) - "Class to define a source in helm-browse-project handling non VC -handled directories.") + "Class to define a source in `helm-browse-project' handling non +VC handled directories.") (defmethod helm--setup-source :after ((source helm-browse-project-override-inheritor)) (let ((actions (slot-value source 'action))) @@ -4682,15 +5505,16 @@ handled directories.") ;;;###autoload (defun helm-browse-project (arg) "Preconfigured helm to browse projects. -Browse files and see status of project with its vcs. +Browse files and see status of project with its VCS. Only HG and GIT are supported for now. -Fall back to `helm-browse-project-find-files' -if current directory is not under control of one of those vcs. +Fall back to `helm-browse-project-find-files' if current +directory is not under control of one of those VCS. With a prefix ARG browse files recursively, with two prefix ARG rebuild the cache. If the current directory is found in the cache, start `helm-browse-project-find-files' even with no prefix ARG. -NOTE: The prefix ARG have no effect on the VCS controlled directories. +NOTE: The prefix ARG have no effect on the VCS controlled +directories. Needed dependencies for VCS: @@ -4767,13 +5591,26 @@ See `helm-browse-project'." (helm-exit-and-execute-action 'helm-ff-find-sh-command))) (put 'helm-ff-run-find-sh-command 'helm-only t) +;; helm-hd bindings for hff +(defun helm-ff-fd (_candidate) + "Run fd shell command from `helm-find-files'." + (require 'helm-fd) + (helm-fd-1 helm-ff-default-directory)) + +(defun helm-ff-run-fd () + "Run fd shell command action with key from `helm-find-files'." + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-ff-fd))) +(put 'helm-ff-run-fd 'helm-only t) ;;;###autoload (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 `helm-find-files-1' instead. -This is the starting point for nearly all actions you can do on files." +This is the starting point for nearly all actions you can do on +files." (interactive "P") (let* ((hist (and arg helm-ff-history (helm-find-files-history nil))) (smart-input (or hist (helm-find-files-initial-input))) @@ -4823,10 +5660,11 @@ This is the starting point for nearly all actions you can do on files." (defun helm-delete-tramp-connection () "Allow deleting tramp connection or marked tramp connections at once. -This replace `tramp-cleanup-connection' which is partially broken in -emacs < to 25.1.50.1 (See Emacs Bug#24432). +This replace `tramp-cleanup-connection' which is partially broken +in Emacs < to 25.1.50.1 (See Emacs Bug#24432). -It allows additionally to delete more than one connection at once." +It allows additionally to delete more than one connection at +once." (interactive) (let ((helm-quit-if-no-candidate (lambda () diff --git a/elpa/helm-20191101.641/helm-find.el b/elpa/helm-20210131.1946/helm-find.el similarity index 97% rename from elpa/helm-20191101.641/helm-find.el rename to elpa/helm-20210131.1946/helm-find.el index 9c1ab0ca..4c9637dd 100644 --- a/elpa/helm-20191101.641/helm-find.el +++ b/elpa/helm-20210131.1946/helm-find.el @@ -1,6 +1,6 @@ ;;; helm-find.el --- helm interface for find command. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,8 +26,9 @@ :type 'boolean) (defcustom helm-findutils-search-full-path nil - "Search in full path with shell command find when non--nil. -I.e use the -path/ipath arguments of find instead of -name/iname." + "Search in full path with shell command find when non-nil. +I.e. use the -path/ipath arguments of find instead of +-name/iname." :group 'helm-files :type 'boolean) diff --git a/elpa/helm-20191101.641/helm-font.el b/elpa/helm-20210131.1946/helm-font.el similarity index 93% rename from elpa/helm-20191101.641/helm-font.el rename to elpa/helm-20210131.1946/helm-font.el index d0a37a4a..064f2901 100644 --- a/elpa/helm-20191101.641/helm-font.el +++ b/elpa/helm-20210131.1946/helm-font.el @@ -1,6 +1,6 @@ ;;; helm-font --- Font and ucs selection for Helm -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -21,9 +21,10 @@ (require 'helm) (require 'helm-help) +(declare-function helm-generic-sort-fn "helm-utils") (defgroup helm-font nil - "Related applications to display fonts in helm." + "Related applications to display fonts in Helm." :group 'helm) (defcustom helm-ucs-recent-size 10 @@ -53,7 +54,9 @@ "Keymap for `helm-ucs'.") (defface helm-ucs-char - '((((class color) (background dark)) (:foreground "Gold"))) + `((((class color) (background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Gold")) "Face used to display ucs characters." :group 'helm-font) @@ -111,7 +114,7 @@ finally return (cons code char))) (defun helm-calculate-ucs-max-len () - "Calculate the length of longest `ucs-names' candidate." + "Calculate the length of the longest `ucs-names' candidate." (let ((ucs-struct (ucs-names))) (if (hash-table-p ucs-struct) (helm-calculate-ucs-hash-table-max-len ucs-struct) @@ -172,7 +175,7 @@ either be an alist or a hash-table." (helm-ucs-collect-symbols-alist ucs-struct))) (defun helm-ucs-init () - "Initialize an helm buffer with ucs symbols. + "Initialize a Helm buffer with ucs symbols. Only math* symbols are collected." (unless helm-ucs--max-len (setq helm-ucs--max-len @@ -185,7 +188,8 @@ Only math* symbols are collected." (defun helm-ucs-match (candidate n) "Return the N part of an ucs CANDIDATE. -Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name." +Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs +name." (when (string-match "^(\\(#x[a-f0-9]+\\)): *\\(.\\) *\\([^:]+\\)+" candidate) @@ -255,28 +259,28 @@ Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name." (defun helm-ucs-persistent-forward () (interactive) (with-helm-alive-p - (helm-attrset 'action-forward 'helm-ucs-forward-char) + (helm-set-attr 'action-forward 'helm-ucs-forward-char) (helm-execute-persistent-action 'action-forward))) (put 'helm-ucs-persistent-forward 'helm-only t) (defun helm-ucs-persistent-backward () (interactive) (with-helm-alive-p - (helm-attrset 'action-back 'helm-ucs-backward-char) + (helm-set-attr 'action-back 'helm-ucs-backward-char) (helm-execute-persistent-action 'action-back))) (put 'helm-ucs-persistent-backward 'helm-only t) (defun helm-ucs-persistent-delete () (interactive) (with-helm-alive-p - (helm-attrset 'action-delete 'helm-ucs-delete-backward) + (helm-set-attr 'action-delete 'helm-ucs-delete-backward) (helm-execute-persistent-action 'action-delete))) (put 'helm-ucs-persistent-delete 'helm-only t) (defun helm-ucs-persistent-insert-space () (interactive) (with-helm-alive-p - (helm-attrset 'action-insert-space 'helm-ucs-insert-space) + (helm-set-attr 'action-insert-space 'helm-ucs-insert-space) (helm-execute-persistent-action 'action-insert-space))) (defvar helm-source-ucs-recent @@ -310,7 +314,7 @@ Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name." ;;;###autoload (defun helm-ucs (arg) - "Preconfigured helm for `ucs-names'. + "Preconfigured `helm' for `ucs-names'. Called with a prefix arg force reloading cache." (interactive "P") diff --git a/elpa/helm-20191101.641/helm-for-files.el b/elpa/helm-20210131.1946/helm-for-files.el similarity index 97% rename from elpa/helm-20191101.641/helm-for-files.el rename to elpa/helm-20210131.1946/helm-for-files.el index e875c56e..e442b3e9 100644 --- a/elpa/helm-20191101.641/helm-for-files.el +++ b/elpa/helm-20210131.1946/helm-for-files.el @@ -1,6 +1,6 @@ ;;; helm-for-files.el --- helm-for-files and related. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -35,8 +35,8 @@ helm-source-locate) "Your preferred sources for `helm-for-files' and `helm-multi-files'. -When adding a source here it is up to you to ensure the library of -this source is accessible and properly loaded." +When adding a source here it is up to you to ensure the library +of this source is accessible and properly loaded." :type '(repeat (choice symbol)) :group 'helm-files) @@ -138,10 +138,11 @@ Be aware that a nil value will make tramp display very slow." (defvar helm-source-recentf nil "See (info \"(emacs)File Conveniences\"). -Set `recentf-max-saved-items' to a bigger value if default is too small.") +Set `recentf-max-saved-items' to a bigger value if default is too +small.") (defcustom helm-recentf-fuzzy-match nil - "Enable fuzzy matching in `helm-source-recentf' when non--nil." + "Enable fuzzy matching in `helm-source-recentf' when non-nil." :group 'helm-files :type 'boolean :set (lambda (var val) @@ -253,8 +254,8 @@ Run all sources defined in `helm-for-files-preferred-list'." Allow toggling back and forth from locate to others sources with `helm-multi-files-toggle-locate-binding' key. -This avoid launching needlessly locate when what you search is already -found." +This avoids launching locate needlessly when what you are +searching for is already found." (interactive) (require 'helm-x-files) (unless helm-source-buffers-list diff --git a/elpa/helm-20191101.641/helm-config.el b/elpa/helm-20210131.1946/helm-global-bindings.el similarity index 65% rename from elpa/helm-20191101.641/helm-config.el rename to elpa/helm-20210131.1946/helm-global-bindings.el index 36107538..35182509 100644 --- a/elpa/helm-20191101.641/helm-config.el +++ b/elpa/helm-20210131.1946/helm-global-bindings.el @@ -1,6 +1,6 @@ -;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*- +;;; helm-global-bindings.el --- Bind global helm commands -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -17,38 +17,10 @@ ;;; Code: - -;;; Require -;; -;; -(declare-function async-bytecomp-package-mode "ext:async-bytecomp.el") -(when (require 'async-bytecomp nil t) - (and (fboundp 'async-bytecomp-package-mode) - (async-bytecomp-package-mode 1))) - - -(defgroup helm-config nil - "Various configurations for Helm." - :group 'helm) - -(defcustom helm-command-prefix-key "C-x c" - "The key `helm-command-prefix' is bound to in the global map." - :type '(choice (string :tag "Key") (const :tag "no binding")) - :group 'helm-config - :set - (lambda (var key) - (when (and (boundp var) (symbol-value var)) - (define-key (current-global-map) - (read-kbd-macro (symbol-value var)) nil)) - (when key - (define-key (current-global-map) - (read-kbd-macro key) 'helm-command-prefix)) - (set var key))) - (defcustom helm-minibuffer-history-key "C-r" "The key `helm-minibuffer-history' is bound to in minibuffer local maps." :type '(choice (string :tag "Key") (const :tag "no binding")) - :group 'helm-config + :group 'helm-misc :set (lambda (var key) (cl-dolist (map '(minibuffer-local-completion-map @@ -59,18 +31,36 @@ minibuffer-local-must-match-filename-map ; Older Emacsen minibuffer-local-must-match-map minibuffer-local-ns-map)) - (when (and (boundp map) (keymapp (symbol-value map))) - (when (and (boundp var) (symbol-value var)) - (define-key (symbol-value map) - (read-kbd-macro (symbol-value var)) nil)) - (when key - (define-key (symbol-value map) - (read-kbd-macro key) 'helm-minibuffer-history)))) + (let ((vmap (and (boundp map) (symbol-value map)))) + (when (keymapp vmap) + (let ((val (and (boundp var) (symbol-value var)))) + (when val + (define-key vmap + (if (stringp val) (read-kbd-macro val) val) + nil))) + (when key + (define-key (symbol-value map) + (if (stringp key) (read-kbd-macro key) key) + 'helm-minibuffer-history))))) (set var key))) ;;; Command Keymap ;; ;; +(defcustom helm-command-prefix-key "C-x c" + "The key `helm-command-prefix' is bound to in the global map." + :type '(choice (string :tag "Key") (const :tag "no binding")) + :group 'helm-config + :set + (lambda (var key) + (when (and (boundp var) (symbol-value var)) + (define-key (current-global-map) + (read-kbd-macro (symbol-value var)) nil)) + (when key + (define-key (current-global-map) + (read-kbd-macro key) 'helm-command-prefix)) + (set var key))) + (defvar helm-command-map (let ((map (make-sparse-keymap))) (define-key map (kbd "a") 'helm-apropos) @@ -81,7 +71,7 @@ (define-key map (kbd "m") 'helm-man-woman) (define-key map (kbd "t") 'helm-top) (define-key map (kbd "/") 'helm-find) - (define-key map (kbd "i") 'helm-semantic-or-imenu) + (define-key map (kbd "i") 'helm-imenu) (define-key map (kbd "I") 'helm-imenu-in-all-buffers) (define-key map (kbd "") 'helm-lisp-completion-at-point) (define-key map (kbd "p") 'helm-list-emacs-process) @@ -124,44 +114,10 @@ (require 'helm-easymenu) - -;;;###autoload -(defun helm-configuration () - "Customize `helm'." - (interactive) - (customize-group "helm")) - - -;;; Fontlock -(cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode)) - (font-lock-add-keywords - mode - '(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-awhile\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-acond\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-aand\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-with-gensyms\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-read-answer\\)\\>" 1 font-lock-keyword-face)))) - - -;;; Load the autoload file -;; It should have been generated either by -;; package.el or the make file. -(load "helm-autoloads" nil t) +;;; Provide -(provide 'helm-config) +(provide 'helm-global-bindings) ;; Local Variables: ;; byte-compile-warnings: (not obsolete) @@ -169,4 +125,4 @@ ;; indent-tabs-mode: nil ;; End: -;;; helm-config.el ends here +;;; helm-global-bindings.el ends here diff --git a/elpa/helm-20191101.641/helm-grep.el b/elpa/helm-20210131.1946/helm-grep.el similarity index 87% rename from elpa/helm-20191101.641/helm-grep.el rename to elpa/helm-20210131.1946/helm-grep.el index 43b491e3..4f9ab18c 100644 --- a/elpa/helm-20191101.641/helm-grep.el +++ b/elpa/helm-20210131.1946/helm-grep.el @@ -1,6 +1,6 @@ ;;; helm-grep.el --- Helm Incremental Grep. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -31,7 +31,16 @@ (declare-function pdf-view-goto-page "pdf-view" (page &optional window)) (declare-function helm-mm-split-pattern "helm-multi-match") (declare-function helm--ansi-color-apply "helm-lib") +(declare-function helm-comp-read "helm-mode") +(declare-function helm-occur "helm-occur") + (defvar helm--ansi-color-regexp) +(defvar helm-ff-default-directory) +(defvar helm-tramp-verbose) +(defvar helm-grep-ack-types-cache) +(defvar helm-grep-git-grep-command) +(defvar helm-source-grep-git) +(defvar tramp-verbose) (defgroup helm-grep nil @@ -63,16 +72,17 @@ Where: If your grep version doesn't support the --exclude/include args don't specify the '%e' format spec. -Helm also support ack-grep and git-grep , -here a default command example for ack-grep: +Helm also support ack-grep and git-grep. The following is a +default command example for ack-grep: \(setq helm-grep-default-command \"ack-grep -Hn --color --smart-case --no-group %e %p %f\" helm-grep-default-recurse-command \"ack-grep -H --color --smart-case --no-group %e %p %f\") -You can ommit the %e spec if you don't want to be prompted for types. +You can ommit the %e spec if you don't want to be prompted for +types. NOTE: Helm for ack-grep support ANSI sequences, so you can remove -the \"--no-color\" option safely (recommended) +the \"--no-color\" option safely (recommended). However you should specify --color to enable multi matches highlighting because ack disable it when output is piped. @@ -87,24 +97,26 @@ you will have to setup this in your .gitconfig: [color \"grep\"] match = black yellow -where \"black\" is the foreground and \"yellow\" the background. +Where \"black\" is the foreground and \"yellow\" the background. See the git documentation for more infos. -`helm-grep-default-command' and `helm-grep-default-recurse-command'are -independents, so you can enable `helm-grep-default-command' with ack-grep -and `helm-grep-default-recurse-command' with grep if you want to be faster -on recursive grep. +`helm-grep-default-command' and +`helm-grep-default-recurse-command' are independent, so you can +enable `helm-grep-default-command' with ack-grep and +`helm-grep-default-recurse-command' with grep if you want to be +faster on recursive grep. -NOTE: Remote grepping is not available with ack-grep, - and badly supported with grep because tramp handle badly - repeated remote processes in a short delay (< to 5s)." +NOTE: Remote grepping is not available with ack-grep, and badly + supported with grep because tramp handles badly repeated + remote processes in a short delay (< to 5s)." :group 'helm-grep :type 'string) (defcustom helm-grep-default-recurse-command "grep --color=always -a -d recurse %e -n%cH -e %p %f" "Default recursive grep format command for `helm-do-grep-1'. -See `helm-grep-default-command' for format specs and infos about ack-grep." +See `helm-grep-default-command' for format specs and infos about +ack-grep." :group 'helm-grep :type 'string) @@ -112,37 +124,39 @@ See `helm-grep-default-command' for format specs and infos about ack-grep." "zgrep --color=always -a -n%cH -e %p %f" "Default command for Zgrep. See `helm-grep-default-command' for infos on format specs. -Option --color=always is supported and can be used safely -to replace the helm internal match highlighting, -see `helm-grep-default-command' for more infos." +Option --color=always is supported and can be used safely to +replace the Helm internal match highlighting. See +`helm-grep-default-command' for more infos." :group 'helm-grep :type 'string) (defcustom helm-pdfgrep-default-command "pdfgrep --color always -niH %s %s" "Default command for pdfgrep. -Option \"--color always\" is supported starting helm version 1.7.8, -when used matchs will be highlighted according to GREP_COLORS env var." +Option \"--color always\" is supported starting Helm version +1.7.8. When used matches will be highlighted according to +GREP_COLORS env var." :group 'helm-grep :type 'string) (defcustom helm-pdfgrep-default-recurse-command "pdfgrep --color always -rniH %s %s" "Default recurse command for pdfgrep. -Option \"--color always\" is supported starting helm version 1.7.8, -when used matchs will be highlighted according to GREP_COLORS env var." +Option \"--color always\" is supported starting Helm version +1.7.8. When used matches will be highlighted according to +GREP_COLORS env var." :group 'helm-grep :type 'string) (defcustom helm-pdfgrep-default-read-command nil "Default command to read pdf files from pdfgrep. Where '%f' format spec is filename and '%p' is page number. -e.g In Ubuntu you can set it to: +E.g. In Ubuntu you can set it to: \"evince --page-label=%p '%f'\" -If set to nil either `doc-view-mode' or `pdf-view-mode' will be used -instead of an external command." +If set to nil either `doc-view-mode' or `pdf-view-mode' will be +used instead of an external command." :group 'helm-grep :type 'string) @@ -163,7 +177,7 @@ instead of an external command." :type 'string) (defcustom helm-grep-save-buffer-name-no-confirm nil - "when *hgrep* already exists,auto append suffix." + "When *hgrep* already exists, auto append suffix." :group 'helm-grep :type 'boolean) @@ -210,32 +224,35 @@ Possible value are: (defcustom helm-grep-pipe-cmd-switches nil "A list of additional parameters to pass to grep pipe command. -This will be used for pipe command for multiple pattern matching +This will be used to pipe command for multiple pattern matching for grep, zgrep ack-grep and git-grep backends. -If you add extra args for ack-grep, use ack-grep options, -for others (grep, zgrep and git-grep) use grep options. +If you add extra args for ack-grep, use ack-grep options, for +others (grep, zgrep and git-grep) use grep options. Here are the commands where you may want to add switches: grep --color=always ack-grep --smart-case --color -You probably don't need to use this unless you know what you are doing." +You probably don't need to use this unless you know what you are +doing." :group 'helm-grep :type '(repeat string)) (defcustom helm-grep-ag-pipe-cmd-switches nil "A list of additional parameters to pass to grep-ag pipe command. Use parameters compatibles with the backend you are using -\(i.e AG for AG, PT for PT or RG for RG) +\(i.e. AG for AG, PT for PT or RG for RG) -You probably don't need to use this unless you know what you are doing." +You probably don't need to use this unless you know what you are +doing." :group 'helm-grep :type '(repeat string)) -(defcustom helm-grep-input-idle-delay 0.6 - "Same as `helm-input-idle-delay' but for grep commands. -It have a higher value than `helm-input-idle-delay' to avoid -flickering when updating." +(defcustom helm-grep-input-idle-delay 0.1 + "Idle time before updating, specified in seconds. +A lower value (default) means Helm will display the results +faster. Increasing it to a higher value (e.g. 0.6) prevents the +buffer from flickering when updating." :group 'helm-grep :type 'float) @@ -249,30 +266,38 @@ flickering when updating." :group 'helm-faces) (defface helm-grep-match - '((((background light)) :foreground "#b00000") - (((background dark)) :foreground "gold1")) + `((((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "#b00000") + (((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "gold1")) "Face used to highlight grep matches. Have no effect when grep backend use \"--color=\"." :group 'helm-grep-faces) (defface helm-grep-file - '((t (:foreground "BlueViolet" - :underline t))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "BlueViolet" + :underline t)) "Face used to highlight grep results filenames." :group 'helm-grep-faces) (defface helm-grep-lineno - '((t (:foreground "Darkorange1"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Darkorange1")) "Face used to highlight grep number lines." :group 'helm-grep-faces) (defface helm-grep-finish - '((t (:foreground "Green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Green")) "Face used in mode line when grep is finish." :group 'helm-grep-faces) (defface helm-grep-cmd-line - '((t (:inherit font-lock-type-face))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit font-lock-type-face)) "Face used to highlight grep command line when no results." :group 'helm-grep-faces) @@ -294,8 +319,8 @@ Have no effect when grep backend use \"--color=\"." (defcustom helm-grep-use-ioccur-style-keys t "Use Arrow keys to jump to occurences. -Note that if you define this variable with `setq' your change will -have no effect, use customize instead." +Note that if you define this variable with `setq' your change +will have no effect, use customize instead." :group 'helm-grep :type 'boolean :set (lambda (var val) @@ -512,7 +537,7 @@ It is intended to use as a let-bound variable, DON'T set this globaly.") (cons ?m pipes)))))) (defun helm-grep-init (cmd-line) - "Start an asynchronous grep process with CMD-LINE using ZGREP if non--nil." + "Start an asynchronous grep process with CMD-LINE using ZGREP if non-nil." (let* ((default-directory (or helm-ff-default-directory (helm-default-directory) default-directory)) @@ -607,7 +632,7 @@ It is intended to use as a let-bound variable, DON'T set this globaly.") ;; (defun helm-grep-action (candidate &optional where) "Define a default action for `helm-do-grep-1' on CANDIDATE. -WHERE can be one of other-window, other-frame." +WHERE can be `other-window' or `other-frame'." (let* ((split (helm-grep-split-line candidate)) (split-pat (helm-mm-split-pattern helm-input)) (lineno (string-to-number (nth 1 split))) @@ -615,15 +640,15 @@ WHERE can be one of other-window, other-frame." (if (eq major-mode 'helm-grep-mode) (current-buffer) helm-buffer) - (get-text-property (point-at-bol) 'helm-grep-fname)) + (get-text-property (point-at-bol) + 'helm-grep-fname)) (car split))) - (tramp-method (file-remote-p (or helm-ff-default-directory - default-directory) 'method)) - (tramp-host (file-remote-p (or helm-ff-default-directory - default-directory) 'host)) - (tramp-prefix (concat "/" tramp-method ":" tramp-host ":")) - (fname (if tramp-host - (concat tramp-prefix loc-fname) loc-fname))) + (tramp-fname (file-remote-p (or helm-ff-default-directory + default-directory))) + (fname (if tramp-fname + (concat tramp-fname loc-fname) + loc-fname))) + (helm-log "helm-grep-action fname: %s" fname ) (cl-case where (other-window (helm-window-show-buffers (list (find-file-noselect fname)) t)) @@ -631,9 +656,10 @@ WHERE can be one of other-window, other-frame." (grep (helm-grep-save-results-1)) (pdf (if helm-pdfgrep-default-read-command (helm-pdfgrep-action-1 split lineno (car split)) - (find-file (car split)) (if (derived-mode-p 'pdf-view-mode) - (pdf-view-goto-page lineno) - (doc-view-goto-page lineno)))) + (find-file (car split)) + (if (derived-mode-p 'pdf-view-mode) + (pdf-view-goto-page lineno) + (doc-view-goto-page lineno)))) (t (find-file fname))) (unless (or (eq where 'grep) (eq where 'pdf)) (helm-goto-line lineno)) @@ -719,7 +745,7 @@ If N is positive go forward otherwise go backward." ;;;###autoload (defun helm-goto-precedent-file () - "Go to precedent file in helm grep/etags buffers." + "Go to previous file in Helm grep/etags buffers." (interactive) (with-helm-alive-p (with-helm-window @@ -728,7 +754,7 @@ If N is positive go forward otherwise go backward." ;;;###autoload (defun helm-goto-next-file () - "Go to precedent file in helm grep/etags buffers." + "Go to previous file in Helm grep/etags buffers." (interactive) (with-helm-window (helm-goto-next-or-prec-file 1))) @@ -768,28 +794,31 @@ If N is positive go forward otherwise go backward." (defun helm-grep-save-results (candidate) (helm-grep-action candidate 'grep)) +(defvar helm-grep-mode-use-pcre nil) (defun helm-grep-save-results-1 () - "Save helm grep result in a `helm-grep-mode' buffer." - (let ((buf "*hgrep*") - new-buf - (pattern (with-helm-buffer helm-input-local)) - (src-name (assoc-default 'name (helm-get-current-source)))) + "Save Helm grep result in a `helm-grep-mode' buffer." + (let* ((buf "*hgrep*") + new-buf + (pattern (with-helm-buffer helm-input-local)) + (src (helm-get-current-source)) + (src-name (assoc-default 'name src))) (when (get-buffer buf) (if helm-grep-save-buffer-name-no-confirm (setq new-buf (format "*hgrep|%s|-%s" pattern (format-time-string "%H-%M-%S*"))) - (setq new-buf (helm-read-string "GrepBufferName: " buf)) - (cl-loop for b in (helm-buffer-list) - when (and (string= new-buf b) - (not (y-or-n-p - (format "Buffer `%s' already exists overwrite? " - new-buf)))) - do (setq new-buf (helm-read-string "GrepBufferName: " "*hgrep ")))) + (setq new-buf (helm-read-string "GrepBufferName: " buf)) + (cl-loop for b in (helm-buffer-list) + when (and (string= new-buf b) + (not (y-or-n-p + (format "Buffer `%s' already exists overwrite? " + new-buf)))) + do (setq new-buf (helm-read-string "GrepBufferName: " "*hgrep ")))) (setq buf new-buf)) (with-current-buffer (get-buffer-create buf) (setq default-directory (or helm-ff-default-directory (helm-default-directory) default-directory)) + (setq-local helm-grep-mode-use-pcre (helm-get-attr 'pcre src)) (setq buffer-read-only t) (let ((inhibit-read-only t) (map (make-sparse-keymap))) @@ -865,7 +894,8 @@ Special commands: (helm--ansi-color-apply l) l) when (string-match helm-grep-split-line-regexp line) do (insert (propertize - (car (helm-grep-filter-one-by-one line)) + (car (helm-grep-filter-one-by-one + line helm-grep-mode-use-pcre)) ;; needed for wgrep. 'helm-realvalue line) "\n")))) @@ -969,7 +999,8 @@ Special commands: ;; (defun helm-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." +These extensions will be added to command line with --include arg +of grep." (cl-loop with ext-list = (list helm-grep-preferred-ext "*") with lst = (if (file-directory-p (car files)) (directory-files @@ -1010,18 +1041,18 @@ These extensions will be added to command line with --include arg of grep." ;; ;; (defvar helm-grep-before-init-hook nil - "Hook that runs before initialization of the helm buffer.") + "Hook that runs before initialization of the Helm buffer.") (defvar helm-grep-after-init-hook nil - "Hook that runs after initialization of the helm buffer.") + "Hook that runs after initialization of the Helm buffer.") (defclass helm-grep-class (helm-source-async) ((candidates-process :initform 'helm-grep-collect-candidates) - (filter-one-by-one :initform 'helm-grep-filter-one-by-one) + (filtered-candidate-transformer :initform #'helm-grep-fc-transformer) (keymap :initform helm-grep-map) (pcre :initarg :pcre :initform nil :documentation - " Backend is using pcre regexp engine when non--nil.") + " Backend is using pcre regexp engine when non-nil.") (nohighlight :initform t) (nomark :initform t) (backend :initarg :backend @@ -1029,7 +1060,7 @@ These extensions will be added to command line with --include arg of grep." :documentation " The grep backend that will be used. It is actually used only as an internal flag - and don't set the backend by itself. + and doesn't set the backend by itself. You probably don't want to modify this.") (candidate-number-limit :initform 9999) (help-message :initform 'helm-grep-help-message) @@ -1058,24 +1089,26 @@ These extensions will be added to command line with --include arg of grep." "Launch helm using backend BACKEND on a list of TARGETS files. When RECURSE is given and BACKEND is 'grep' use -r option of -BACKEND and prompt user for EXTS to set the --include args of BACKEND. -Interactively you can give more than one arg separated by space at prompt. -e.g +BACKEND and prompt user for EXTS to set the --include args of +BACKEND. +Interactively you can give more than one arg separated by space +at prompt. +E.g.: $Pattern: *.el *.py *.tex -From lisp use the EXTS argument as a list of extensions as above. +From Lisp use the EXTS argument as a list of extensions as above. If you are using ack-grep, you will be prompted for --type -instead and EXTS will be ignored. -If prompt is empty `helm-grep-ignored-files' are added to --exclude. +instead and EXTS will be ignored. If prompt is empty +`helm-grep-ignored-files' are added to --exclude. -Argument DEFAULT-INPUT is use as `default' arg of `helm' and INPUT -is used as `input' arg of `helm', See `helm' docstring. +Argument DEFAULT-INPUT is use as `default' arg of `helm' and +INPUT is used as `input' arg of `helm'. See `helm' docstring. -Arg BACKEND when non--nil specify which backend to use +Arg BACKEND when non-nil specifies which backend to use. It is used actually to specify 'zgrep' or 'git'. -When BACKEND 'zgrep' is used don't prompt for a choice -in recurse, and ignore EXTS, search being made recursively on files matching -`helm-zgrep-file-extension-regexp' only." +When BACKEND 'zgrep' is used don't prompt for a choice in +recurse, and ignore EXTS, search being made recursively on files +matching `helm-zgrep-file-extension-regexp' only." (let* (non-essential (ack-rec-p (helm-grep-use-ack-p :where 'recursive)) (exts (and recurse @@ -1177,7 +1210,7 @@ in recurse, and ignore EXTS, search being made recursively on files matching ;; may contain a ":". (cl-loop for n from 1 to 3 collect (match-string n line)))) -(defun helm-grep--filter-candidate-1 (candidate &optional dir) +(defun helm-grep--filter-candidate-1 (candidate &optional dir pcre) (let* ((root (or dir (and helm-grep-default-directory-fn (funcall helm-grep-default-directory-fn)))) (ansi-p (string-match-p helm--ansi-color-regexp candidate)) @@ -1207,11 +1240,11 @@ in recurse, and ignore EXTS, search being made recursively on files matching ":" (propertize lineno 'face 'helm-grep-lineno) ":" - (if ansi-p str (helm-grep-highlight-match str t))) + (if ansi-p str (helm-grep-highlight-match str pcre))) line) ""))) -(defun helm-grep-filter-one-by-one (candidate) +(defun helm-grep-filter-one-by-one (candidate &optional pcre) "`filter-one-by-one' transformer function for `helm-do-grep-1'." (let ((helm-grep-default-directory-fn (or helm-grep-default-directory-fn @@ -1223,9 +1256,20 @@ in recurse, and ignore EXTS, search being made recursively on files matching ;; Already computed do nothing (default as input). candidate (and (stringp candidate) - (helm-grep--filter-candidate-1 candidate))))) + (helm-grep--filter-candidate-1 candidate nil pcre))))) + +(defun helm-grep-fc-transformer (candidates source) + (let ((helm-grep-default-directory-fn + (or helm-grep-default-directory-fn + (lambda () (or helm-ff-default-directory + (and (null (eq major-mode 'helm-grep-mode)) + (helm-default-directory)) + default-directory)))) + (pcre (helm-get-attr 'pcre source))) + (cl-loop for c in candidates + collect (helm-grep--filter-candidate-1 c nil pcre)))) -(defun helm-grep-highlight-match (str &optional multi-match) +(defun helm-grep-highlight-match (str &optional pcre) "Highlight in string STR all occurences matching `helm-pattern'." (let (beg end) (condition-case-unless-debug nil @@ -1233,21 +1277,22 @@ in recurse, and ignore EXTS, search being made recursively on files matching (insert (propertize str 'read-only nil)) ; Fix (#1176) (goto-char (point-min)) (cl-loop for reg in - (if multi-match - ;; (m)occur. - (cl-loop for r in (helm-mm-split-pattern - helm-pattern) - unless (string-match "\\`!" r) - collect - (helm-aif (and helm-migemo-mode - (assoc r helm-mm--previous-migemo-info)) - (cdr it) r)) - ;; async sources (grep, gid etc...) - (list helm-input)) + (cl-loop for r in (helm-mm-split-pattern + helm-input) + unless (string-match "\\`!" r) + collect + (helm-aif (and helm-migemo-mode + (assoc r helm-mm--previous-migemo-info)) + (cdr it) r)) do - (while (and (re-search-forward reg nil t) + (while (and (re-search-forward + (if pcre + (helm--translate-pcre-to-elisp reg) + reg) + nil t) (> (- (setq end (match-end 0)) - (setq beg (match-beginning 0))) 0)) + (setq beg (match-beginning 0))) + 0)) (helm-add-face-text-properties beg end 'helm-grep-match)) do (goto-char (point-min))) (buffer-string)) @@ -1258,12 +1303,13 @@ in recurse, and ignore EXTS, search being made recursively on files matching ;; ;; (defun helm-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, + "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 `helm-occur'. -If a prefix arg is given run grep on all buffers ignoring non--file-buffers." +If a prefix arg is given run grep on all buffers ignoring +non-file buffers." (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) (helm-ff-default-directory (if (and helm-ff-default-directory @@ -1400,34 +1446,53 @@ If a prefix arg is given run grep on all buffers ignoring non--file-buffers." ;; https://github.com/BurntSushi/ripgrep (defcustom helm-grep-ag-command - "ag --line-numbers -S --hidden --color --nogroup %s %s %s" + "ag --line-numbers -S --color --nogroup %s %s %s" "The default command for AG, PT or RG. -Takes three format specs, the first for type(s), the second for pattern -and the third for directory. +Takes three format specs, the first for type(s), the second for +pattern and the third for directory. + +You can use safely \"--color\" (used by default) with AG RG and +PT. -You can use safely \"--color\" (used by default) with AG RG and PT. +NOTE: Usage of \"--color=never\" is discouraged as it uses Elisp +to colorize matched items which is slower than using the native +colorization of backend, however it is still supported. For ripgrep here is the command line to use: rg --color=always --smart-case --no-heading --line-number %s %s %s -NOTE: Old versions of ripgrep was not supporting colors in emacs and a -workaround had to be used (i.e prefixing command line with -\"TERM=eterm-color\"), this is no more needed. -See issue for more infos. +And to customize colors (always for ripgrep) use something like this: + + rg --color=always --colors 'match:bg:yellow' --colors 'match:fg:black' +\--smart-case --no-heading --line-number %s %s %s + +This will change color for matched items from foreground red (the +default) to a yellow background with a black foreground. Note +that your color settings for RG will not work properly with +multiples pattern if you have configured colors in rg config file +instead of command line. For more enhanced settings of ansi +colors see https://github.com/emacs-helm/helm/issues/2313 You must use an output format that fit with helm grep, that is: \"filename:line-number:string\" The option \"--nogroup\" allow this. -The option \"--line-numbers\" is also mandatory except with PT (not supported). -For RG the options \"--no-heading\" and \"--line-number\" are the ones to use. - -When modifying the default colors of matches with e.g \"--color-match\" option of AG -you may want to modify as well `helm-grep-ag-pipe-cmd-switches' to have all matches -colorized with same color in multi match." +The option \"--line-numbers\" is also mandatory except with +PT (not supported). +For RG the options \"--no-heading\" and \"--line-number\" are the +ones to use. + +When modifying the default colors of matches with e.g. +\"--color-match\" option of AG or \"--colors\" option of ripgrep +you may want to modify as well `helm-grep-ag-pipe-cmd-switches' +to have all matches colorized with the same color in multi +match. + +Of course you can use several other options, see the man page of the +backend you are using." :group 'helm-grep :type 'string) @@ -1455,15 +1520,18 @@ Ripgrep (rg) types are also supported if this backend is used." (defun helm-grep-ag-prepare-cmd-line (pattern directory &optional type) "Prepare AG command line to search PATTERN in DIRECTORY. -When TYPE is specified it is one of what returns `helm-grep-ag-get-types' -if available with current AG version." +When TYPE is specified it is one of what `helm-grep-ag-get-types' +returns if available with current AG version." (let* ((patterns (helm-mm-split-pattern pattern t)) (pipe-switches (mapconcat 'identity helm-grep-ag-pipe-cmd-switches " ")) (pipe-cmd (helm-acase (helm-grep--ag-command) (("ag" "pt") (format "%s -S --color%s" it (concat " " pipe-switches))) - ("rg" (format "rg -N -S --color=always%s" - (concat " " pipe-switches))))) + ("rg" (format "rg -N -S --color=%s%s" + (when (string-match "--color=\\([a-z]+\\) " + helm-grep-ag-command) + (match-string 1 helm-grep-ag-command)) + (concat " " pipe-switches))))) (cmd (format helm-grep-ag-command (mapconcat 'identity type " ") (shell-quote-argument (car patterns)) @@ -1545,7 +1613,7 @@ if available with current AG version." (keymap :initform helm-grep-map) (history :initform 'helm-grep-ag-history) (help-message :initform 'helm-grep-help-message) - (filter-one-by-one :initform 'helm-grep-filter-one-by-one) + (filtered-candidate-transformer :initform #'helm-grep-fc-transformer) (persistent-action :initform 'helm-grep-persistent-action) (persistent-help :initform "Jump to line (`C-u' Record in mark ring)") (candidate-number-limit :initform 99999) @@ -1606,8 +1674,8 @@ The color of matched items can be customized in your .gitconfig See `helm-grep-default-command' for more infos. The \"--exclude-standard\" and \"--no-index\" switches allow -skipping unwanted files specified in ~/.gitignore_global -and searching files not already staged (not enabled by default). +skipping unwanted files specified in ~/.gitignore_global and +searching files not already staged (not enabled by default). You have also to enable this in global \".gitconfig\" with \"git config --global core.excludesfile ~/.gitignore_global\"." @@ -1617,8 +1685,8 @@ You have also to enable this in global \".gitconfig\" with (defun helm-grep-git-1 (directory &optional all default input) "Run git-grep on DIRECTORY. If DIRECTORY is not inside or part of a git repo exit with error. -If optional arg ALL is non-nil grep the whole repo otherwise start -at DIRECTORY. +If optional arg ALL is non-nil grep the whole repo otherwise +start at DIRECTORY. Arg DEFAULT is what you will have with `next-history-element', arg INPUT is what you will have by default at prompt on startup." (require 'vc) @@ -1635,15 +1703,16 @@ arg INPUT is what you will have by default at prompt on startup." ;;;###autoload (defun helm-do-grep-ag (arg) - "Preconfigured helm for grepping with AG in `default-directory'. -With prefix-arg prompt for type if available with your AG version." + "Preconfigured `helm' for grepping with AG in `default-directory'. +With prefix arg prompt for type if available with your AG +version." (interactive "P") (require 'helm-files) (helm-grep-ag (expand-file-name default-directory) arg)) ;;;###autoload (defun helm-grep-do-git-grep (arg) - "Preconfigured helm for git-grepping `default-directory'. + "Preconfigured `helm' for git-grepping `default-directory'. With a prefix arg ARG git-grep the whole repository." (interactive "P") (require 'helm-files) diff --git a/elpa/helm-20191101.641/helm-help.el b/elpa/helm-20210131.1946/helm-help.el similarity index 72% rename from elpa/helm-20191101.641/helm-help.el rename to elpa/helm-20210131.1946/helm-help.el index f86ae90e..daa4bc9b 100644 --- a/elpa/helm-20191101.641/helm-help.el +++ b/elpa/helm-20210131.1946/helm-help.el @@ -1,6 +1,6 @@ ;;; helm-help.el --- Help messages for Helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -24,7 +24,8 @@ :group 'helm) (defface helm-helper - '((t :inherit helm-header)) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit helm-header)) "Face for Helm help string in minibuffer." :group 'helm-help) @@ -33,6 +34,7 @@ helm-ff-help-message helm-read-file-name-help-message helm-generic-file-help-message + helm-fd-help-message helm-grep-help-message helm-pdfgrep-help-message helm-etags-help-message @@ -47,13 +49,15 @@ helm-imenu-help-message helm-colors-help-message helm-semantic-help-message - helm-kmacro-help-message)) + helm-kmacro-help-message + helm-kill-ring-help-message) + "A list of help messages (strings) used by `helm-documentation'.") (defvar helm-documentation-buffer-name "*helm documentation*") ;;;###autoload (defun helm-documentation () - "Preconfigured Helm for Helm documentation. + "Preconfigured `helm' for Helm documentation. With a prefix arg refresh the documentation. Find here the documentation of all documented sources." @@ -101,10 +105,19 @@ pattern. **** Search inside buffers If you enter a space and a pattern prefixed by \"@\", Helm searches for text -matching this pattern \*inside* the buffer (i.e. not in the name of the buffer). +matching this pattern *inside* the buffer (i.e. not in the name of the buffer). + +Negation are supported i.e. \"!\". + +When you specify more than one of such patterns, it will match +buffers with contents matching each of these patterns i.e. AND, +not OR. That means that if you specify \"@foo @bar\" the contents +of buffer will have to be matched by foo AND bar. If you specify +\"@foo @!bar\" it means the contents of the buffer have to be +matched by foo but NOT bar. If you enter a pattern prefixed with an escaped \"@\", Helm searches for a -buffer matching \"@pattern\" but does not search inside. +buffer matching \"@pattern\" but does not search inside the buffer. **** Search by directory name @@ -182,8 +195,8 @@ If buffer is associated to a file and is modified, it is by default colorized in see [[Meaning of colors and prefixes for buffers][Meaning of colors and prefixes for buffers]]. You can save these buffers with \\\\[helm-buffer-save-persistent]. If you want to save all these buffers, you can mark them with \\[helm-buffers-mark-similar-buffers] -and save them with \\[helm-buffer-save-persistent], you can also do this in one step with -\\[helm-buffer-run-save-some-buffers], note that you will not be asked for confirmation. +and save them with \\[helm-buffer-save-persistent]. You can also do this in one step with +\\[helm-buffer-run-save-some-buffers]. Note that you will not be asked for confirmation. *** Meaning of colors and prefixes for buffers @@ -234,9 +247,8 @@ enabled by default to not confuse new users. **** Navigate with arrow keys -You can use and arrows to go down or up one level, to enable +You can use and arrows to go down or up one level, to disable this customize `helm-ff-lynx-style-map'. -This is disabled by default. Note that using `setq' will NOT work. **** Use `\\\\[helm-execute-persistent-action]' (persistent action) on a directory to go down one level @@ -247,18 +259,18 @@ On a symlinked directory a prefix argument expands to its true name. ***** `DEL' behavior -`DEL' by default is deleting char backward. +`DEL' by default deletes char backward. -But when `helm-ff-DEL-up-one-level-maybe' is non nil `DEL' behave -differently depending of helm-pattern contents, it go up one -level if pattern is a directory endings with \"/\" or disable HFF -auto update and delete char backward if pattern is a filename or -refer to a non existing path. Going up one level can be disabled -if necessary by deleting \"/\" at end of pattern using +But when `helm-ff-DEL-up-one-level-maybe' is non nil `DEL' behaves +differently depending on the contents of helm-pattern. It goes up one +level if the pattern is a directory ending with \"/\" or disables HFF +auto update and delete char backward if the pattern is a filename or +refers to a non existing path. Going up one level can be disabled +if necessary by deleting \"/\" at the end of the pattern using \\\\[backward-char] and \\[helm-delete-minibuffer-contents]. -Note that when deleting char backward, helm takes care of -disabling update letting you the time to edit your pattern for +Note that when deleting char backward, Helm takes care of +disabling update giving you the opportunity to edit your pattern for e.g. renaming a file or creating a new file or directory. When `helm-ff-auto-update-initial-value' is non nil you may want to disable it temporarily, see [[Toggle auto-completion with `C-c DEL'][Toggle auto-completion with `C-c DEL']] for this. @@ -277,23 +289,16 @@ It behaves differently depending on `helm-selection' (current candidate in helm- - candidate is a file => Open it. If you have marked candidates and you press RET on a directory, -helm will navigate to this directory, if you want to exit with -RET with default action with these marked candidates, press RET -on a second time while you are on the root of this directory -e.g. \"/home/you/dir/.\" or press RET on any file which is not a +Helm will navigate to this directory. If you want to exit with +RET with default action with these marked candidates, press RET a +second time while you are on the root of this directory e.g. +\"/home/you/dir/.\" or press RET on any file which is not a directory. You can also exit with default action at any moment with `f1'. Note that when copying, renaming, etc. from `helm-find-files' the destination file is selected with `helm-read-file-name'. -To avoid confusion when using `read-file-name' or `read-directory-name', `RET' -follows its standard Emacs behaviour, i.e. it exits the minibuffer as soon as -you press `RET'. If you want the same behavior as in `helm-find-files', bind -`helm-ff-RET' to the `helm-read-file-map': - - (define-key helm-read-file-map (kbd \"RET\") 'helm-ff-RET) - **** `TAB' behavior Normally `TAB' is bound to `helm-select-action' in helm-map which @@ -304,8 +309,8 @@ a new command for `TAB': (define-key helm-find-files-map (kbd \"C-i\") 'helm-ff-TAB) -It will then behave slighly differently -depending of `helm-selection': +It will then behave slighly differently depending of +`helm-selection': - candidate basename is \".\" => open the action menu. - candidate is a directory => expand it (behave as \\\\[helm-execute-persistent-action]). @@ -313,6 +318,22 @@ depending of `helm-selection': Called with a prefix arg open menu unconditionally. +*** Filter out files or directories + +You can show files or directories only with respectively +\\\\[helm-ff-toggle-dirs-only] and \\\\[helm-ff-toggle-files-only]. +These are toggle commands i.e. filter/show_all. +Changing directory disable filtering. + +*** Sort directory contents + +When listing a directory without narrowing its contents, i.e. when pattern ends with \"/\", +you can sort alphabetically, by newest or by size by using respectively +\\\\[helm-ff-sort-alpha], \\[helm-ff-sort-by-newest] or \\[helm-ff-sort-by-size]. +NOTE: +When starting back narrowing i.e. entering something in minibuffer after \"/\" sorting is done +again with fuzzy sorting and no more with sorting methods previously selected. + *** Find file at point Helm uses `ffap' partially or completely to find file at point depending on the @@ -382,8 +403,6 @@ It starts from the third character of the pattern. For instance \"fob\" or \"fbr\" will complete \"foobar\" but \"fb\" needs a third character in order to complete it. -*** Use `\\[universal-argument] \\[helm-execute-persistent-action]' or `\\[helm-follow-action-forward]' to display an image - *** `\\[helm-execute-persistent-action]' on a filename expands to that filename in the Helm buffer Second hit displays the buffer filename. @@ -392,10 +411,49 @@ Note: `\\[universal-argument] \\[helm-execute-persistent-action]' displays the b *** Browse images directories with `helm-follow-mode' and navigate up/down +Before Emacs-27 Helm was using image-dired that works with +external ImageMagick tools. From Emacs-27 Helm use native +display of images with image-mode by default for Emacs-27 (see `helm-ff-display-image-native'), +this allows automatic resize when changing window size, zooming with `\\[helm-ff-increase-image-size-persistent]' and `\\[helm-ff-decrease-image-size-persistent]' +and rotate images as before. + You can also use `helm-follow-action-forward' and `helm-follow-action-backward' with `\\[helm-follow-action-forward]' and `\\[helm-follow-action-backward]' respectively. +Note that these commands have different behavior when `helm-follow-mode' +is enabled (go to next/previous line only). + +Use `\\[universal-argument] \\[helm-execute-persistent-action]' to display an image or kill its buffer. + +TIP: Use `\\\\[helm-toggle-resplit-and-swap-windows]' and `\\[helm-enlarge-window]' to display Helm window vertically +and to enlarge it while viewing images. +Note this may not work with exotic Helm windows settings such as the ones in Spacemacs. + +*** Open files externally + +- Open file with external program (`\\\\[helm-ff-run-open-file-externally]',`C-u' to choose). + +Helm is looking what is used by default to open file +externally (mailcap files) but have its own variable +`helm-external-programs-associations' to store external +applications. If you call the action or its binding without +prefix arg Helm will see if there is an application suitable in +`helm-external-programs-associations', otherwise it will look in +mailcap files. If you want to specify which external application +to use (and its options) use a prefix arg. + +Note: What you configure for Helm in `helm-external-programs-associations' +will take precedence on mailcap files. + +- Preview file with external program (`\\[helm-ff-run-preview-file-externally]'). + +Same as above but doesn't quit Helm session, it is apersistent action. + +- Open file externally with default tool (`\\[helm-ff-run-open-file-with-default-tool]'). + +This uses xdg-open which sucks most of the time, but perhaps it +works fine on Windows. This is why it is kept in Helm. -*** Toggle auto-completion with `\\[helm-ff-run-toggle-auto-update]' +*** Toggle auto-completion It is useful when trying to create a new file or directory and you don't want Helm to complete what you are writing. @@ -416,7 +474,7 @@ Note that when you enter a new name, this one is prefixed with \[?] if you are in a writable directory. If you are in a directory where you have no write permission the new file name is not prefixed and is colored in red. There is not such distinction -when using tramp, new filename just appear on top of buffer. +when using Tramp, new filename just appears on top of buffer. *** Recursive search from Helm-find-files @@ -436,7 +494,7 @@ List all the files under this directory and other subdirectories - With two prefix arguments: Same but the cache is refreshed. -**** You can start a recursive search with \"locate\" or \"find\" +**** You can start a recursive search with \"locate\", \"find\" or [[https://github.com/sharkdp/fd][Fd]] See \"Note\" in the [[Recursive completion on subdirectories][section on subdirectories]]. @@ -444,12 +502,15 @@ Using \"locate\", you can enable the local database with a prefix argument. If t local database doesn't already exists, you will be prompted for its creation. If it exists and you want to refresh it, give it two prefix args. -When using locate the helm-buffer remains empty until you type something. +When using locate the Helm buffer remains empty until you type something. Regardless Helm uses the basename of the pattern entered in the helm-find-files session by default. Hitting `\\[next-history-element]' should just kick in the locate search with this pattern. If you want Helm to automatically do this, add `helm-source-locate' to `helm-sources-using-default-as-input'. +NOTE: On Windows use Everything with its command line ~es~ as a replacement of locate. +See [[https://github.com/emacs-helm/helm/wiki/Locate#windows][Locate on Windows]] + **** Recursive completion on subdirectories Starting from the directory you are currently browsing, it is possible to have @@ -459,8 +520,6 @@ you want to go to \"/home/you/foo/bar/baz/somewhere/else\", simply type the final \"/\". Helm will then list all possible directories under \"foo\" matching \"else\". -Entering two spaces before \"else\" instead of two dots also works. - Note: Completion on subdirectories uses \"locate\" as backend, you can configure the command with `helm-locate-recursive-dirs-command'. Because this completion uses an index, the directory tree displayed may be out-of-date and not reflect @@ -476,6 +535,16 @@ Examples: - \"find %s -type d -name '*%s*'\" - \"find %s -type d -regex .*%s.*$\" +[[https://github.com/sharkdp/fd][Fd]] command is now also +supported which is regexp based and very fast. Here is the command +line to use: + +- \"fd --hidden --type d .*%s.*$ %s\" + +You can use also a glob based search, in this case use the --glob option: + +- \"fd --hidden --type d --glob '*%s*' %s\" + *** Insert filename at point or complete filename at point On insertion (not on completion, i.e. there is nothing at point): @@ -493,7 +562,7 @@ On completion: *** Use the wildcard to select multiple files -Use of wilcard is supported to run an action over a set of files. +Use of wildcard is supported to run an action over a set of files. Example: You can copy all the files with \".el\" extension by using \"*.el\" and then run copy action. @@ -516,7 +585,7 @@ When using an action that involves an external backend (e.g. grep), using \"**\" is not recommended (even thought it works fine) because it will be slower to select all the files. You are better off leaving the backend to do it, it will be faster. However, if you know you have not many files it is reasonable to use -this, also using not recursive wilcard (e.g. \"*.el\") is perfectly fine for +this, also using not recursive wildcard (e.g. \"*.el\") is perfectly fine for this. The \"**\" feature is active by default in the option `helm-file-globstar'. It @@ -525,6 +594,19 @@ a named extension recursively you would write \"**.el\" whereas in Bash it would be \"**/*.el\". Directory selection with \"**/\" like Bash \"shopt globstar\" option is not supported yet. +Helm supports different styles of wildcards: + +- `sh' style, the ones supported by `file-expand-wildcards'. +e.g. \"*.el\", \"*.[ch]\" which match respectively all \".el\" +files or all \".c\" and \".h\" files. + +- `bash' style (partially) In addition to what allowed in `sh' +style you can specify file extensions that have more than one +character like this: \"*.{sh,py}\" which match \".sh\" and +\".py\" files. + +Of course in both styles you can specify one or two \"*\". + *** Query replace regexp on filenames Replace different parts of a file basename with something else. @@ -568,8 +650,7 @@ are available as`%u', `%d' and `%c' respectively. Use the `helm-file-globstar' feature described in [[Use the wildcard to select multiple files][recursive globbing]] by entering \"**.JPG\" at the end of the Helm-find-files pattern, then hit -\\\\[helm-ff-query-replace-on-filenames]: First \"JPG\", then \"jpg\" -and hit `RET'. +\\\\[helm-ff-run-query-replace-fnames-on-marked] and enter \"JPG\" on first prompt, then \"jpg\" on second prompt and hit `RET'. Alternatively you can enter \".%\" at the first prompt, then \"jpg\" and hit `RET'. Note that when using this instead of using \"JPG\" at the first prompt, @@ -695,6 +776,18 @@ You can customize `helm-dwim-target' to behave differently depending on the windows open in the current frame. Default is to provide completion on all directories associated to each window. +*** Copying/Renaming from or to remote directories + +Never use ssh tramp method to copy/rename large files, use +instead its scp method if you want to avoid out of memory +problems and crash Emacs or the whole system. Moreover when using +scp method, you will hit a bug when copying more than 3 files at +the time, see [[https://github.com/emacs-helm/helm/issues/1945][bug#1945]]. +The best way actually is using Rsync to copy files from or to +remote, see [[Use Rsync to copy files][Use Rsync to copy files]]. +Also if you often work on remote you may consider using SSHFS +instead of relying on tramp. + *** Copying and renaming asynchronously If you have the async library installed (if you got Helm from MELPA you do), you @@ -708,11 +801,43 @@ When `dired-async-mode' is enabled, an additional action named \"Backup files\" will be available. (Such command is not natively available in Emacs). See [[Use the wildcard to select multiple files]] for details. +*** Use Rsync to copy files + +If Rsync is available, you can use it to copy/sync files or directories +with some restrictions though: + +- Copying from/to tramp sudo method may not work (permissions). +- Copying from remote to remote is not supported (rsync restriction). + +This command is mostly useful when copying large files as it is +fast, asynchronous and provide a progress bar in mode-line. Each +rsync process have its own progress bar, so you can run several +rsync jobs, they are independents. If rsync fails you can +consult the \"*helm-rsync*\" buffer to see rsync errors. An +help-echo (move mouse over progress bar) is provided to see which +file is in transfer. Note that when copying directories, no +trailing slashes are added to directory names, which mean that +directory is created on destination if it doesn't already exists, +see rsync documentation for more infos on rsync behavior. To +synchronize a directory, mark all in the directory and rsync all +marked to the destination directory or rsync the directory itself +to its parent, e.g. remote:/home/you/music => /home/you. + +The options are configurable through `helm-rsync-switches', but +you can modify them on the fly when needed by using a prefix arg, +in this case you will be prompted for modifications. + +NOTE: When selecting a remote file, if you use the tramp syntax +for specifying a port, i.e. host#2222, helm will add +automatically \"-e 'ssh -p 2222'\" to the rsync command line +unless you have specified yourself the \"-e\" option by editing +rsync command line with a prefix arg (see above). + *** Bookmark the `helm-find-files' session You can bookmark the `helm-find-files' session with `\\[helm-ff-bookmark-set]'. You can later retrieve these bookmarks by calling `helm-filtered-bookmarks' -or, from the current `helm-find-files' session, by hitting `\\[helm-find-files-toggle-to-bookmark]'. +or, from the current `helm-find-files' session, by hitting `\\[helm-find-files-switch-to-bookmark]'. *** Grep files from `helm-find-files' @@ -745,6 +870,11 @@ To toggle suspend-update, use `\\\\[helm-toggle-suspend-update]'. Setting up aliases in Eshell allows you to set up powerful customized commands. +Your aliases for using eshell command on file should allow +specifying one or more files, use e.g. \"alias foo $1\" or +\"alias foo $*\", if you want your command to be asynchronous add +at end \"&\", e.g. \"alias foo $* &\". + Adding Eshell aliases to your `eshell-aliases-file' or using the `alias' command from Eshell allows you to create personalized commands not available in `helm-find-files' actions and use them @@ -978,6 +1108,16 @@ Helm-find-files can ignore files matching `helm-boring-file-regexp-list' or files that are git ignored, you can set this with `helm-ff-skip-boring-files' or `helm-ff-skip-git-ignored-files'. +NOTE: This will slow down helm, be warned. + +*** Helm-find-files is using a cache + +Helm is caching each directory files list in a hash table for +faster search, when a directory is modified it is removed from cache +so that further visit in this directory refresh cache. +You may have in some rare cases to refresh directory manually with `\\\\[helm-refresh]' +for example when helm-find-files session is running and a file is modified/deleted +in current visited directory by an external command from outside Emacs. ** Commands \\ @@ -994,6 +1134,7 @@ can set this with `helm-ff-skip-boring-files' or \\[helm-ff-run-rename-file]\t\tRename Files (`\\[universal-argument]' to follow). \\[helm-ff-run-query-replace-fnames-on-marked]\t\tQuery replace on marked files. \\[helm-ff-run-copy-file]\t\tCopy Files (`\\[universal-argument]' to follow). +\\[helm-ff-run-rsync-file]\t\tRsync Files (`\\[universal-argument]' to edit command). \\[helm-ff-run-byte-compile-file]\t\tByte Compile Files (`\\[universal-argument]' to load). \\[helm-ff-run-load-file]\t\tLoad Files. \\[helm-ff-run-symlink-file]\t\tSymlink Files. @@ -1003,7 +1144,7 @@ can set this with `helm-ff-skip-boring-files' or \\[helm-ff-run-touch-files]\t\tTouch files. \\[helm-ff-run-kill-buffer-persistent]\t\tKill buffer candidate without leaving Helm. \\[helm-ff-persistent-delete]\t\tDelete file without leaving Helm. -\\[helm-ff-run-switch-to-eshell]\t\tSwitch to Eshell. +\\[helm-ff-run-switch-to-shell]\t\tSwitch to prefered shell. \\[helm-ff-run-eshell-command-on-file]\t\tEshell command on file (`\\[universal-argument]' to apply on marked files, otherwise treat them sequentially). \\[helm-ff-run-ediff-file]\t\tEdiff file. \\[helm-ff-run-ediff-merge-file]\t\tEdiff merge file. @@ -1015,6 +1156,8 @@ can set this with `helm-ff-skip-boring-files' or \\[helm-ff-run-open-file-with-default-tool]\t\tOpen file externally with default tool. \\[helm-ff-rotate-left-persistent]\t\tRotate image left. \\[helm-ff-rotate-right-persistent]\t\tRotate image right. +\\[helm-ff-increase-image-size-persistent]\t\tZoom in image. +\\[helm-ff-decrease-image-size-persistent]\t\tZoom out image. \\[helm-find-files-up-one-level]\t\tGo to parent directory. \\[helm-find-files-history]\t\tSwitch to the visited-directory history. \\[helm-ff-file-name-history]\t\tSwitch to file name history. @@ -1063,7 +1206,7 @@ You can toggle the view of deleted files, see commands below. "* Helm `%s' read file name completion This is `%s' read file name completion that have been \"helmized\" -because you have enabled [[Helm mode][helm-mode]]'. +because you have enabled [[Helm mode][helm-mode]]. Don't confuse this with `helm-find-files' which is a native helm command, see [[Helm functions vs helmized Emacs functions]]. @@ -1149,6 +1292,302 @@ C/\\[helm-cr-empty-string]\t\tReturn empty string unless `must-match' is non-nil \\[helm-previous-source]\t\tGo to previous source." name name))) +;;; FD help +;; +;; +(defvar helm-fd-help-message + "* Helm fd + +** Tips + +\[[https://github.com/sharkdp/fd][The Fd command line tool]] is very fast to search files recursively. +You may have to wait several seconds at first usage when your +hard drive cache is \"cold\", then once the cache is initialized +searchs are very fast. You can pass any [[https://github.com/sharkdp/fd#command-line-options][Fd options]] before pattern, e.g. \"-e py foo\". + +The [[https://github.com/sharkdp/fd][Fd]] command line can be customized with `helm-fd-switches' user variable. +Always use --color always as option otherwise you will have no colors. +To customize colors see [[https://github.com/sharkdp/fd#colorized-output][Fd colorized output]]. + +Search is (pcre) regexp based (see [[https://docs.rs/regex/1.0.0/regex/#syntax][Regexp syntax]]), multi patterns are _not_ supported. + +** Man page + +NAME + fd - find entries in the filesystem + +SYNOPSIS + fd [-HIEsiaLp0hV] [-d depth] [-t filetype] [-e ext] [-E exclude] [-c + when] [-j num] [-x cmd] [pattern] [path...] + +DESCRIPTION + fd is a simple, fast and user-friendly alternative to find(1). + +OPTIONS + -H, --hidden + Include hidden files and directories in the search results + (default: hidden files and directories are skipped). + + -I, --no-ignore + Show search results from files and directories that would other‐ + wise be ignored by .gitignore, .ignore, .fdignore, or the global + ignore file. + + -u, --unrestricted + Alias for '--no-ignore'. Can be repeated; '-uu' is an alias for + '--no-ignore --hidden'. + + --no-ignore-vcs + Show search results from files and directories that would other‐ + wise be ignored by .gitignore files. + + -s, --case-sensitive + Perform a case-sensitive search. By default, fd uses case-insen‐ + sitive searches, unless the pattern contains an uppercase char‐ + acter (smart case). + + -i, --ignore-case + Perform a case-insensitive search. By default, fd uses case- + insensitive searches, unless the pattern contains an uppercase + character (smart case). + + -g, --glob + Perform a glob-based search instead of a regular expression + search. + + --regex + Perform a regular-expression based seach (default). This can be + used to override --glob. + + -F, --fixed-strings + Treat the pattern as a literal string instead of a regular + expression. + + -a, --absolute-path + Shows the full path starting from the root as opposed to rela‐ + tive paths. + + -l, --list-details + Use a detailed listing format like 'ls -l'. This is basically an + alias for '--exec-batch ls -l' with some additional 'ls' + options. This can be used to see more metadata, to show symlink + targets and to achieve a deterministic sort order. + + -L, --follow + By default, fd does not descend into symlinked directories. + Using this flag, symbolic links are also traversed. + + -p, --full-path + By default, the search pattern is only matched against the file‐ + name (or directory name). Using this flag, the pattern is + matched against the full path. + + -0, --print0 + Separate search results by the null character (instead of new‐ + lines). Useful for piping results to xargs. + + --max-results count + Limit the number of search results to 'count' and quit immedi‐ + ately. + + -1 Limit the search to a single result and quit immediately. This + is an alias for '--max-results=1'. + + --show-errors + Enable the display of filesystem errors for situations such as + insufficient permissions or dead symlinks. + + --one-file-system, --mount, --xdev + By default, fd will traverse the file system tree as far as + other options dictate. With this flag, fd ensures that it does + not descend into a different file system than the one it started + in. Comparable to the -mount or -xdev filters of find(1). + + -h, --help + Print help information. + + -V, --version + Print version information. + + -d, --max-depth d + Limit directory traversal to at most d levels of depth. By + default, there is no limit on the search depth. + + --min-depth d + Only show search results starting at the given depth. See also: + '--max-depth' and '--exact-depth'. + + --exact-depth d + Only show search results at the exact given depth. This is an + alias for '--min-depth --max-depth '. + + -t, --type filetype + Filter search by type: + + f, file + regular files + + d, directory + directories + + l, symlink + symbolic links + + x, executable + executable (files) + + e, empty + empty files or directories + + s, socket + sockets + + p, pipe + named pipes (FIFOs) + + This option can be used repeatedly to allow for multiple file + types. + + -e, --extension ext + Filter search results by file extension ext. This option can be + used repeatedly to allow for multiple possible file extensions. + + -E, --exclude pattern + Exclude files/directories that match the given glob pattern. + This overrides any other ignore logic. Multiple exclude pat‐ + terns can be specified. + + --ignore-file path + Add a custom ignore-file in '.gitignore' format. These files + have a low precedence. + + -c, --color when + Declare when to colorize search results: + + auto Colorize output when standard output is connected to terminal (default). + + never Do not colorize output. + + always Always colorize output. + + -j, --threads num + Set number of threads to use for searching & executing (default: + number of available CPU cores). + + -S, --size size + Limit results based on the size of files using the format + <+-> + + '+' file size must be greater than or equal to this + + '-' file size must be less than or equal to this + + 'NUM' The numeric size (e.g. 500) + + 'UNIT' The units for NUM. They are not case-sensitive. Allowed + unit values: + + 'b' bytes + + 'k' kilobytes (base ten, 10^3 = 1000 bytes) + + 'm' megabytes + + 'g' gigabytes + + 't' terabytes + + 'ki' kibibytes (base two, 2^10 = 1024 bytes) + + 'mi' mebibytes + + 'gi' gibibytes + + 'ti' tebibytes + + --changed-within date|duration + Filter results based on the file modification time. The argument + can be provided as a specific point in time (YYYY-MM-DD + HH:MM:SS) or as a duration (10h, 1d, 35min). --change-newer- + than can be used as an alias. + + Examples: + --changed-within 2weeks + --change-newer-than \"2018-10-27 10:00:00\" + + --changed-before date|duration + Filter results based on the file modification time. The argument + can be provided as a specific point in time (YYYY-MM-DD + HH:MM:SS) or as a duration (10h, 1d, 35min). --change-older- + than can be used as an alias. + + Examples: + --changed-before \"2018-10-27 10:00:00\" + --change-older-than 2weeks + + -o, --owner [user][:group] + Filter files by their user and/or group. Format: + [(user|uid)][:(group|gid)]. Either side is optional. Precede + either side with a '!' to exclude files instead. + + Examples: + --owner john + --owner :students + --owner \"!john:students\" + + -x, --exec command + Execute command for each search result. The following placehold‐ + ers are substituted by a path derived from the current search + result: + + {} path + + {/} basename + + {//} parent directory + + {.} path without file extension + + {/.} basename without file extension + + -X, --exec-batch command + Execute command with all search results at once. A single + occurence of the following placeholders is authorized and + sub stituted by the paths derived from the search results before the + command is executed: + + {} path + + {/} basename + + {//} parent directory + + {.} path without file extension + + {/.} basename without file extension + +** Commands +\\ +\\[helm-ff-run-grep]\t\tRun grep (`\\[universal-argument]' to recurse). +\\[helm-ff-run-zgrep]\t\tRun zgrep. +\\[helm-ff-run-pdfgrep]\t\tRun PDFgrep on marked files. +\\[helm-ff-run-copy-file]\t\tCopy file(s) +\\[helm-ff-run-rename-file]\t\tRename file(s). +\\[helm-ff-run-symlink-file]\t\tSymlink file(s). +\\[helm-ff-run-hardlink-file]\t\tHardlink file(s). +\\[helm-ff-run-delete-file]\t\tDelete file(s). +\\[helm-ff-run-byte-compile-file]\t\tByte compile Elisp file(s) (`\\[universal-argument]' to load). +\\[helm-ff-run-load-file]\t\tLoad Elisp file(s). +\\[helm-ff-run-ediff-file]\t\tEdiff file. +\\[helm-ff-run-ediff-merge-file]\t\tEdiff-merge file. +\\[helm-ff-run-switch-other-window]\t\tSwitch to other window. +\\[helm-ff-properties-persistent]\t\tShow file properties. +\\[helm-ff-run-open-file-externally]\t\tOpen file with external program (`\\[universal-argument]' to choose). +\\[helm-ff-run-open-file-with-default-tool]\t\tOpen file externally with default tool. +\\[helm-ff-run-insert-org-link]\t\tInsert org link. +\\[helm-fd-previous-directory]\t\tMove to previous directory. +\\[helm-fd-next-directory]\tMove to next directory.") + ;;; Generic file help - Used by locate. ;; ;; @@ -1170,9 +1609,12 @@ search will be performed on basename only for efficiency (so don't add \"-b\" at prompt). As soon as you separate the patterns with spaces, fuzzy matching will be disabled and search will be done on the full filename. Note that in multi-match, fuzzy is completely disabled, which means that each pattern is a -match regexp (i.e. \"helm\" will match \"helm\" but \"hlm\" will \*not* match +match regexp (i.e. \"helm\" will match \"helm\" but \"hlm\" will *not* match \"helm\"). +NOTE: On Windows use Everything with its command line ~es~ as a replacement of locate. +See [[https://github.com/emacs-helm/helm/wiki/Locate#windows][Locate on Windows]] + *** Browse project When the current directory is not under version control, don't forget to refresh @@ -1197,7 +1639,6 @@ than 1 megabyte: \\[helm-ff-run-toggle-basename]\t\tToggle basename. \\[helm-ff-run-grep]\t\tRun grep (`\\[universal-argument]' to recurse). \\[helm-ff-run-zgrep]\t\tRun zgrep. -\\[helm-ff-run-gid]\t\tRun GID (id-utils). \\[helm-ff-run-pdfgrep]\t\tRun PDFgrep on marked files. \\[helm-ff-run-copy-file]\t\tCopy file(s) \\[helm-ff-run-rename-file]\t\tRename file(s). @@ -1210,7 +1651,6 @@ than 1 megabyte: \\[helm-ff-run-ediff-merge-file]\t\tEdiff-merge file. \\[helm-ff-run-switch-other-window]\t\tSwitch to other window. \\[helm-ff-properties-persistent]\t\tShow file properties. -\\[helm-ff-run-etags]\t\tRun etags (`\\[universal-argument]' to use tap, `\\[universal-argument] \\[universal-argument]' to reload the database). \\[helm-ff-run-open-file-externally]\t\tOpen file with external program (`\\[universal-argument]' to choose). \\[helm-ff-run-open-file-with-default-tool]\t\tOpen file externally with default tool. \\[helm-ff-run-insert-org-link]\t\tInsert org link.") @@ -1223,21 +1663,42 @@ than 1 megabyte: ** Tips -*** Use a prefix argument to grep recursively +With Helm supporting Git-grep and AG/RG, you are better off using +one of them for recursive searches, keeping grep or ack-grep to +grep individual or marked files. See [[Helm AG][Helm AG]]. + +*** Meaning of the prefix argument +**** With grep or ack-grep + +Grep recursively, in this case you are +prompted for types (ack-grep) or for wild cards (grep). + +**** With AG or RG -With Helm supporting git-grep and AG however, you are better off using one of -them for recursive searches. +the prefix arg allows you to specify a type of file to search in. *** You can use wild cards when selecting files (e.g. \"*.el\") -*** You can grep in many different directories by marking files or using wild cards +Note that a way to grep specific files recursively is to use +e.g. \"**.el\" to select files, the variable `helm-file-globstar' +controls this (it is non nil by default), however it is much +slower than using grep recusively (see helm-find-files +documentation about this feature). + +*** Grep hidden files + +You may want to customize your command line for grepping hidden +files, for AG/RG use \"--hidden\", see man page +of your backend for more infos. + +*** You can grep in different directories by marking files or using wild cards *** You can save the result in a `helm-grep-mode' buffer See [[Commands][commands]] below. -Once in that buffer you can use \"emacs-wgrep\" (external package not bundled with Helm) -to edit your changes. +Once in that buffer you can use [[https://github.com/mhayashi1120/Emacs-wgrep][emacs-wgrep]] (external package not bundled with Helm) +to edit your changes, for Helm the package name is `wgrep-helm', it is hightly recommended. *** Helm-grep supports multi-matching @@ -1245,10 +1706,15 @@ to edit your changes. Simply add a space between each pattern as for most Helm commands. +NOTE: Depending the regexp you use it may match as well the +filename, this because we pipe the first grep command which send +the filename in output. + *** See full path of selected candidate -Add (helm-popup-tip-mode 1) in your init file or enable it interactively with -M-x helm-popup-tip-mode. +Add (helm-popup-tip-mode 1) in your init file or enable it +interactively with M-x helm-popup-tip-mode, however it is +generally enough to just put your mouse cursor over candidate. *** Open file in other window @@ -1271,6 +1737,9 @@ SSHFS. * Helm GID +Still supported, but mostly deprecated, using AG/RG or Git-grep +is much more efficient, also `id-utils' seems no more maintained. + ** Tips Helm-GID reads the database created with the `mkid' command from id-utils. @@ -1288,11 +1757,15 @@ highlighted since there is no ~--color~-like option in GID itself. ** Tips -Helm-AG is different from grep or ack-grep in that it works on a directory and -not on a list of files. +Helm-AG is different from grep or ack-grep in that it works on a +directory recursively and not on a list of files. It is called +helm-AG but it support several backend, namely AG, RG and PT. +Nowaday the best backend is Ripgrep aka RG, it is the fastest and +is actively maintained, see `helm-grep-ag-command' and +`helm-grep-ag-pipe-cmd-switches' to configure it. You can ignore files and directories with a \".agignore\" file, local to a -directory or global when placed in the home directory. \(See the AG man page for +directory or global when placed in the home directory. (See the AG man page for more details.) That file follows the same syntax as `helm-grep-ignored-files' and `helm-grep-ignored-directories'. @@ -1301,7 +1774,8 @@ As always you can access Helm AG from `helm-find-files'. Starting with version 0.30, AG accepts one or more TYPE arguments on its command line. Helm provides completion on these TYPE arguments when available with your AG version. Use a prefix argument when starting a Helm-AG session to enable this -completion. +completion. See RG and AG man pages on how to add new types. + Note: You can mark several types to match in the AG query. The first AG versions providing this feature allowed only one type, so in this case only the @@ -1309,7 +1783,7 @@ last mark will be used. * Helm git-grep -Helm-git-grep searches the current directory, i.e the default directory or the +Helm-git-grep searches the current directory, i.e. the default directory or the directory in Helm-find-files. If this current directory is a subdirectory of a project and you want to also match parent directories (i.e the whole project), use a prefix argument. @@ -1451,6 +1925,16 @@ the command is called once for each file like this: file2 ... +*** Run eshell commands asynchronously + +You can run your commands asynchronously by adding \"&\" at end +of any commands, e.g. \"foo %s &\". You can also directly setup +your alias in the eshell alias file with e.g. \"alias foo $1 &\". + +NOTE: If you use \"&\" in a command with marked files and your +command accept many files as argument don't forget to pass the +prefix arg to ensure you run only one command on all marked async. + ** Commands \\") @@ -1477,6 +1961,12 @@ the command is called once for each file like this: ** Tips +*** Searching in many buffers + +Start from `helm-buffers-list' or `helm-mini', mark some buffers and hit \\\\[helm-execute-persistent-action]' (persistent-action), to do it repeatedly @@ -1627,15 +2132,33 @@ marking it (`C-c u' or `RET') . ** Tips -*** You can get help on any command with persistent action (\\[helm-execute-persistent-action]) +*** You can get help on any command with persistent action (\\\\[helm-execute-persistent-action]) *** Prefix arguments -You must pass prefix arguments \*after* starting `helm-M-x'. A mode-line +You can pass prefix arguments *after* starting `helm-M-x'. A mode-line counter will display the number of given prefix arguments. If you pass prefix arguments before running `helm-M-x', it will be displayed in the prompt. -The first `\\[universal-argument]' after `helm-M-x' clears those prefix arguments.") +The first `\\[universal-argument]' after `helm-M-x' clears those prefix arguments. + +NOTE: When you specify prefix arguments once `helm-M-x' is +started, the prefix argument apply on the next command, so if you +hit RET, it will apply on the selected command, but if you type a +new character at prompt to narrow down further candidates, the +prefix arg will apply to `self-insert-command' (e.g. if you type +`C-u e' \"eeee\" will be inserted in prompt) so select the +command you want to execute before specifying prefix arg. + +*** Completion styles in helm-M-x + +By default helm-M-x use 'helm completion style, if you want to enable fuzzy matching aka flex, +see [[Completion-styles][Completion-styles]]. + +*** Duplicate entries in helm-M-x history + +helm-M-x history obey to history variables, if you have +duplicates in your helm-M-x history set `history-delete-duplicates' to non nil.") ;;; Helm imenu ;; @@ -1682,7 +2205,7 @@ The first `\\[universal-argument]' after `helm-M-x' clears those prefix argument - End the kmacro recording with `f4'. - Run `helm-execute-kmacro' to list all your kmacros. -Use persistent action to run your kmacro as many time as needed. +Use persistent action to run your kmacro as many times as needed. You can browse the kmacros with `helm-next-line' and `helm-previous-line'. Note: You can't record keys running Helm commands except `helm-M-x', under the diff --git a/elpa/helm-20191101.641/helm-id-utils.el b/elpa/helm-20210131.1946/helm-id-utils.el similarity index 92% rename from elpa/helm-20191101.641/helm-id-utils.el rename to elpa/helm-20210131.1946/helm-id-utils.el index 8752fd55..90e9f8b9 100644 --- a/elpa/helm-20191101.641/helm-id-utils.el +++ b/elpa/helm-20210131.1946/helm-id-utils.el @@ -1,6 +1,6 @@ ;;; helm-id-utils.el --- Helm interface for id-utils. -*- lexical-binding: t -*- -;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2015 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ "Name of gid command (usually `gid'). For Mac OS X users, if you install GNU coreutils, the name `gid' might be occupied by `id' from GNU coreutils, and you should set -it to correct name (or absolute path), for example, if using +it to correct name (or absolute path). For example, if using MacPorts to install id-utils, it should be `gid32'." :group 'helm-id-utils :type 'file) @@ -79,7 +79,7 @@ MacPorts to install id-utils, it should be `gid32'." ((header-name :initform (lambda (name) - (concat name " [" (helm-attr 'db-dir) "]"))) + (concat name " [" (helm-get-attr 'db-dir) "]"))) (db-dir :initarg :db-dir :initform nil :custom string @@ -101,10 +101,10 @@ MacPorts to install id-utils, it should be `gid32'." ;;;###autoload (defun helm-gid () - "Preconfigured helm for `gid' command line of `ID-Utils'. -Need A database created with the command `mkid' -above `default-directory'. -Need id-utils as dependency which provide `mkid', `gid' etc... + "Preconfigured `helm' for `gid' command line of `ID-Utils'. +Need A database created with the command `mkid' above +`default-directory'. +Need id-utils as dependency which provide `mkid', `gid' etc.. See ." (interactive) (let* ((db (locate-dominating-file @@ -112,7 +112,7 @@ See ." helm-gid-db-file-name)) (helm-grep-default-directory-fn (lambda () default-directory)) - (helm--maybe-use-default-as-input t)) + (helm-maybe-use-default-as-input t)) (cl-assert db nil "No DataBase found, create one with `mkid'") (helm :sources (helm-make-source "Gid" 'helm-gid-source :db-dir db) diff --git a/elpa/helm-20191101.641/helm-imenu.el b/elpa/helm-20210131.1946/helm-imenu.el similarity index 82% rename from elpa/helm-20191101.641/helm-imenu.el rename to elpa/helm-20210131.1946/helm-imenu.el index 2ff19723..5a0d9cd0 100644 --- a/elpa/helm-20191101.641/helm-imenu.el +++ b/elpa/helm-20210131.1946/helm-imenu.el @@ -1,6 +1,6 @@ ;;; helm-imenu.el --- Helm interface for Imenu -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -24,13 +24,15 @@ (require 'helm-utils) (require 'helm-help) +(declare-function which-function "which-func") + (defgroup helm-imenu nil - "Imenu related libraries and applications for helm." + "Imenu related libraries and applications for Helm." :group 'helm) (defcustom helm-imenu-delimiter " / " - "Delimit types of candidates and his value in `helm-buffer'." + "Delimit types of candidates and their value in `helm-buffer'." :group 'helm-imenu :type 'string) @@ -42,9 +44,9 @@ (defcustom helm-imenu-all-buffer-assoc nil "Major mode association alist for `helm-imenu-in-all-buffers'. -Allow `helm-imenu-in-all-buffers' searching in these associated buffers -even if they are not derived from each other. -The alist is bidirectional, i.e no need to add '((foo . bar) (bar . foo)) +Allow `helm-imenu-in-all-buffers' searching in these associated +buffers even if they are not derived from each other. The alist +is bidirectional, i.e. no need to add '((foo . bar) (bar . foo)), only '((foo . bar)) is needed." :type '(alist :key-type symbol :value-type symbol) :group 'helm-imenu) @@ -56,9 +58,10 @@ When nil all candidates are displayed in a single source. NOTE: Each source will have as name \"Imenu \". `helm-source-imenu-all' will not be set, however it will continue -to be used as a flag for using default as input, if you do not want -this behavior, remove it from `helm-sources-using-default-as-input' -even if not using a single source to display imenu in all buffers." +to be used as a flag for using default as input. If you do not +want this behavior, remove it from +`helm-sources-using-default-as-input' even if not using a single +source to display imenu in all buffers." :type 'boolean :group 'helm-imenu) @@ -67,9 +70,10 @@ even if not using a single source to display imenu in all buffers." ("^\\(Function\\|Functions\\|Defuns\\)$" . font-lock-function-name-face) ("^\\(Types\\|Provides\\|Requires\\|Classes\\|Class\\|Includes\\|Imports\\|Misc\\|Code\\)$" . font-lock-type-face)) "Faces for showing type in helm-imenu. -This is a list of cons cells. The cdr of each cell is a face to be used, -and it can also just be like \\='(:foreground \"yellow\"). -Each car is a regexp match pattern of the imenu type string." +This is a list of cons cells. The cdr of each cell is a face to +be used, and it can also just be like \\='(:foreground +\"yellow\"). Each car is a regexp match pattern of the imenu type +string." :group 'helm-faces :type '(repeat (cons @@ -77,7 +81,7 @@ Each car is a regexp match pattern of the imenu type string." (sexp :tag "Face")))) (defcustom helm-imenu-extra-modes nil - "Extra modes where helm-imenu-in-all-buffers should look into." + "Extra modes where `helm-imenu-in-all-buffers' should look into." :group 'helm-imenu :type '(repeat symbol)) @@ -175,6 +179,10 @@ Each car is a regexp match pattern of the imenu type string." (save-excursion (goto-char (point-at-bol)) (point-marker))))) + ;; Happen when cursor is on the line where a definition is. This + ;; prevent jumping to the definition where we are already, instead + ;; display helm with all definitions and preselection to the place + ;; we already are. (if (equal (cdr cur) mb) (prog1 nil (helm-set-pattern "") @@ -310,25 +318,32 @@ Each car is a regexp match pattern of the imenu type string." (defun helm-imenu () "Preconfigured `helm' for `imenu'." (interactive) + (require 'which-func) (unless helm-source-imenu (setq helm-source-imenu (helm-make-source "Imenu" 'helm-imenu-source :fuzzy-match helm-imenu-fuzzy-match))) - (let ((imenu-auto-rescan t) - (str (thing-at-point 'symbol)) - (helm-execute-action-at-once-if-one - helm-imenu-execute-action-at-once-if-one)) + (let* ((imenu-auto-rescan t) + (helm-highlight-matches-around-point-max-lines 'never) + (str (thing-at-point 'symbol)) + (init-reg (and str (concat "\\_<" (regexp-quote str) "\\_>"))) + (helm-execute-action-at-once-if-one + helm-imenu-execute-action-at-once-if-one)) (helm :sources 'helm-source-imenu - :default (list (concat "\\_<" (and str (regexp-quote str)) "\\_>") str) - :preselect str + :default (and str (list init-reg str)) + :preselect (helm-aif (which-function) + (concat "\\_<" (regexp-quote it) "\\_>") + init-reg) :buffer "*helm imenu*"))) ;;;###autoload (defun helm-imenu-in-all-buffers () - "Preconfigured helm for fetching imenu entries in all buffers with similar mode as current. -A mode is similar as current if it is the same, it is derived i.e `derived-mode-p' -or it have an association in `helm-imenu-all-buffer-assoc'." + "Preconfigured `helm' for fetching imenu entries in all buffers with similar mode as current. +A mode is similar as current if it is the same, it is derived +i.e. `derived-mode-p' or it have an association in +`helm-imenu-all-buffer-assoc'." (interactive) + (require 'which-func) (unless helm-imenu-in-all-buffers-separate-sources (unless helm-source-imenu-all (setq helm-source-imenu-all @@ -341,19 +356,23 @@ or it have an association in `helm-imenu-all-buffer-assoc'." (helm-imenu-candidates-in-all-buffers))) :candidates 'helm-imenu--in-all-buffers-cache :fuzzy-match helm-imenu-fuzzy-match)))) - (let ((imenu-auto-rescan t) - (str (thing-at-point 'symbol)) - (helm-execute-action-at-once-if-one - helm-imenu-execute-action-at-once-if-one) - (helm--maybe-use-default-as-input - (not (null (memq 'helm-source-imenu-all - helm-sources-using-default-as-input)))) - (sources (if helm-imenu-in-all-buffers-separate-sources - (helm-imenu-candidates-in-all-buffers 'build-sources) - '(helm-source-imenu-all)))) + (let* ((imenu-auto-rescan t) + (helm-highlight-matches-around-point-max-lines 'never) + (str (thing-at-point 'symbol)) + (init-reg (and str (concat "\\_<" (regexp-quote str) "\\_>"))) + (helm-execute-action-at-once-if-one + helm-imenu-execute-action-at-once-if-one) + (helm-maybe-use-default-as-input + (not (null (memq 'helm-source-imenu-all + helm-sources-using-default-as-input)))) + (sources (if helm-imenu-in-all-buffers-separate-sources + (helm-imenu-candidates-in-all-buffers 'build-sources) + '(helm-source-imenu-all)))) (helm :sources sources - :default (list (concat "\\_<" (and str (regexp-quote str)) "\\_>") str) - :preselect (unless helm--maybe-use-default-as-input str) + :default (and str (list init-reg str)) + :preselect (helm-aif (which-function) + (concat "\\_<" (regexp-quote it) "\\_>") + init-reg) :buffer "*helm imenu all*"))) (provide 'helm-imenu) diff --git a/elpa/helm-20191101.641/helm-info.el b/elpa/helm-20210131.1946/helm-info.el similarity index 90% rename from elpa/helm-20191101.641/helm-info.el rename to elpa/helm-20210131.1946/helm-info.el index c484ab6c..5b343ad7 100644 --- a/elpa/helm-20191101.641/helm-info.el +++ b/elpa/helm-20210131.1946/helm-info.el @@ -1,6 +1,6 @@ ;;; helm-info.el --- Browse info index with helm -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -25,7 +25,10 @@ (declare-function Info-index-nodes "info" (&optional file)) (declare-function Info-goto-node "info" (&optional fork)) -(declare-function Info-find-node "info.el" (filename nodename &optional no-going-back)) +(declare-function Info-find-node "info" (filename nodename &optional no-going-back)) +(declare-function ring-insert "ring") +(declare-function ring-empty-p "ring") +(declare-function ring-ref "ring") (defvar Info-history) (defvar Info-directory-list) @@ -47,7 +50,7 @@ files with `helm-info-at-point'." ;;; Build info-index sources with `helm-info-source' class. -(cl-defun helm-info-init (&optional (file (helm-attr 'info-file))) +(cl-defun helm-info-init (&optional (file (helm-get-attr 'info-file))) ;; Allow reinit candidate buffer when using edebug. (helm-aif (and debug-on-error (helm-candidate-buffer)) @@ -89,7 +92,7 @@ files with `helm-info-at-point'." (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" (helm-attr 'info-file) (match-string 2 line)) + (cons (format "(%s)%s" (helm-get-attr 'info-file) (match-string 2 line)) (string-to-number (or (match-string 3 line) "1"))))) (defclass helm-info-source (helm-source-in-buffer) @@ -106,7 +109,7 @@ files with `helm-info-at-point'." :info-file ,fname ,@args)) (defun helm-build-info-index-command (name doc source buffer) - "Define a helm command NAME with documentation DOC. + "Define a Helm command NAME with documentation DOC. Arg SOURCE will be an existing helm source named `helm-source-info-' and BUFFER a string buffer name." (defalias (intern (concat "helm-info-" name)) @@ -118,9 +121,11 @@ Arg SOURCE will be an existing helm source named doc)) (defun helm-define-info-index-sources (var-value &optional commands) - "Define helm sources named helm-source-info-. -Sources are generated for all entries of `helm-default-info-index-list'. -If COMMANDS arg is non-nil, also build commands named `helm-info-'. + "Define Helm sources named helm-source-info-. +Sources are generated for all entries of +`helm-default-info-index-list'. +If COMMANDS arg is non-nil, also build commands named +`helm-info-'. Where NAME is an element of `helm-default-info-index-list'." (cl-loop for str in var-value for sym = (intern (concat "helm-source-info-" str)) @@ -146,7 +151,7 @@ Where NAME is an element of `helm-default-info-index-list'." "Return list of Info files to use for `helm-info'. Elements of the list are strings of Info file names without -extensions (e.g. \"emacs\" for file \"emacs.info.gz\"). Info +extensions (e.g., \"emacs\" for file \"emacs.info.gz\"). Info files are found by searching directories in `Info-directory-list'." (info-initialize) ; Build Info-directory-list from INFOPATH (Issue #2118) @@ -176,7 +181,7 @@ helm-info-." (ring-insert helm-info-searched candidate)))) (defun helm-def-source--info-files () - "Return a `helm' source for Info files." + "Return a Helm source for Info files." (helm-build-sync-source "Helm Info" :candidates (lambda () (copy-sequence helm-default-info-index-list)) @@ -191,12 +196,13 @@ helm-info-." (defun helm-info (&optional refresh) "Preconfigured `helm' for searching Info files' indices. -With a prefix argument \\[universal-argument], set REFRESH to non-nil. +With a prefix argument \\[universal-argument], set REFRESH to +non-nil. -Optional parameter REFRESH, when non-nil, reevaluates +Optional parameter REFRESH, when non-nil, re-evaluates `helm-default-info-index-list'. If the variable has been customized, set it to its saved value. If not, set it to its -standard value. See `custom-reevaluate-setting' for more. +standard value. See `custom-reevaluate-setting' for more. REFRESH is useful when new Info files are installed. If `helm-default-info-index-list' has not been customized, the new diff --git a/elpa/helm-20191101.641/helm-locate.el b/elpa/helm-20210131.1946/helm-locate.el similarity index 86% rename from elpa/helm-20191101.641/helm-locate.el rename to elpa/helm-20210131.1946/helm-locate.el index ecba5cd5..6448a56d 100644 --- a/elpa/helm-20191101.641/helm-locate.el +++ b/elpa/helm-20210131.1946/helm-locate.el @@ -1,6 +1,6 @@ ;;; helm-locate.el --- helm interface for locate. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,6 +26,9 @@ (require 'helm-types) (require 'helm-help) +(defvar helm-ff-default-directory) +(declare-function helm-read-file-name "helm-mode") + (defgroup helm-locate nil "Locate related Applications and libraries for Helm." @@ -39,19 +42,21 @@ If nil Search in all files." (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 `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." +When this is set and Helm finds 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 'helm-locate :type 'string) (defcustom helm-locate-command nil "A list of arguments for locate program. -Helm will calculate a default value for your system on startup unless -`helm-locate-command' is non-nil, here the default values it will use -according to your system: +Helm will calculate a default value for your system on startup +unless `helm-locate-command' is non-nil. + +Here are the default values it will use according to your system: Gnu/linux: \"locate %s -e -A --regex %s\" berkeley-unix: \"locate %s %s\" @@ -60,19 +65,20 @@ Others: \"locate %s %s\" This string will be passed to format so it should end with `%s'. The first format spec is used for the \"-i\" value of locate/es, -So don't set it directly but use `helm-locate-case-fold-search' +so don't set it directly but use `helm-locate-case-fold-search' for this. -The last option must be the one preceding pattern i.e \"-r\" or \"--regex\". +The last option must be the one preceding pattern i.e \"-r\" or +\"--regex\". You will be able to pass other options such as \"-b\" or \"l\" -during helm invocation after entering pattern only when multi matching, -not when fuzzy matching. +during Helm invocation after entering pattern only when multi +matching, not when fuzzy matching. -Note that the \"-b\" option is added automatically by helm when +Note that the \"-b\" option is added automatically by Helm when var `helm-locate-fuzzy-match' is non-nil and switching back from -multimatch to fuzzy matching (this is done automatically when a space -is detected in pattern)." +multimatch to fuzzy matching (this is done automatically when a +space is detected in pattern)." :type 'string :group 'helm-locate) @@ -86,8 +92,8 @@ is detected in pattern)." "It have the same meaning as `helm-case-fold-search'. The -i option of locate will be used depending of value of `helm-pattern' when this is set to 'smart. -When nil \"-i\" will not be used at all. -and when non--nil it will always be used. +When nil \"-i\" will not be used at all and when non-nil it will +always be used. NOTE: the -i option of the \"es\" command used on windows does the opposite of \"locate\" command." :group 'helm-locate @@ -107,8 +113,8 @@ Note that when this is enabled searching is done on basename." (defcustom helm-locate-project-list nil "A list of directories, your projects. -When set, allow browsing recursively files in all -directories of this list with `helm-projects-find-files'." +When set, allow browsing recursively files in all directories of +this list with `helm-projects-find-files'." :group 'helm-locate :type '(repeat string)) @@ -120,9 +126,9 @@ For Windows and `es' use something like \"es -r ^%s.*%s.*$\" The two format specs are mandatory. If for some reasons you can't use locate because your filesystem -doesn't have a data base, you can use find command from findutils but -be aware that it will be much slower, see `helm-find-files' embebded -help for more infos." +doesn't have a database, you can use find command from findutils +but be aware that it will be much slower. See `helm-find-files' +embedded help for more infos." :type 'string :group 'helm-files) @@ -134,15 +140,16 @@ help for more infos." map)) (defface helm-locate-finish - '((t (:foreground "Green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Green")) "Face used in mode line when locate process is finish." :group 'helm-locate) (defun helm-ff-find-locatedb (&optional from-ff) "Try to find if a local locatedb file is available. -The search is done in `helm-ff-default-directory' or -fall back to `default-directory' if FROM-FF is nil." +The search is done in `helm-ff-default-directory' or falls back to +`default-directory' if FROM-FF is nil." (helm-aif (and helm-ff-locate-db-filename (locate-dominating-file (or (and from-ff @@ -166,11 +173,11 @@ It should receive the same arguments as (defun helm-locate-1 (&optional localdb init from-ff default) "Generic function to run Locate. -Prefix arg LOCALDB when (4) search and use a local locate db file when it -exists or create it, when (16) force update of existing db file -even if exists. -It have no effect when locate command is 'es'. -INIT is a string to use as initial input in prompt. +Prefix arg LOCALDB when (4) search and use a local locate db file +when it exists or create it, when (16) force update of existing +db file even if exists. +It has no effect when locate command is 'es'. INIT is a string +to use as initial input in prompt. See `helm-locate-with-db' and `helm-locate'." (require 'helm-mode) (helm-locate-set-command) @@ -294,12 +301,14 @@ See also `helm-locate'." (t (if helm-locate-case-fold-search ignore-case-flag case-sensitive-flag))) - (concat - ;; The pattern itself. - (shell-quote-argument (car args)) " " - ;; Possible locate args added - ;; after pattern, don't quote them. - (mapconcat 'identity (cdr args) " ")))) + (helm-aif (cdr args) + (concat + ;; The pattern itself. + (shell-quote-argument (car args)) " " + ;; Possible locate args added + ;; after pattern, don't quote them. + (mapconcat 'identity it " ")) + (shell-quote-argument (car args))))) (default-directory (if (file-directory-p default-directory) default-directory "/"))) (helm-log "Starting helm-locate process") @@ -410,13 +419,17 @@ Sort is done on basename of CANDIDATES." (defun helm-locate-init-subdirs () (with-temp-buffer (call-process-shell-command - (format helm-locate-recursive-dirs-command - (if (string-match-p "\\`es" helm-locate-recursive-dirs-command) - ;; Fix W32 paths. - (replace-regexp-in-string - "/" "\\\\\\\\" (helm-attr 'basedir)) - (helm-attr 'basedir)) - (helm-attr 'subdir)) + (if (string-match-p "\\`fd" helm-locate-recursive-dirs-command) + (format helm-locate-recursive-dirs-command + ;; fd pass path at end. + (helm-get-attr 'subdir) (helm-get-attr 'basedir)) + (format helm-locate-recursive-dirs-command + (if (string-match-p "\\`es" helm-locate-recursive-dirs-command) + ;; Fix W32 paths. + (replace-regexp-in-string + "/" "\\\\\\\\" (helm-get-attr 'basedir)) + (helm-get-attr 'basedir)) + (helm-get-attr 'subdir))) nil t nil) (buffer-string))) @@ -441,8 +454,8 @@ Note: you can add locate options after entering pattern. See 'man locate' for valid options and also `helm-locate-command'. You can specify a local database with prefix argument ARG. -With two prefix arg, refresh the current local db or create it -if it doesn't exists. +With two prefix arg, refresh the current local db or create it if +it doesn't exists. To create a user specific db, use \"updatedb -l 0 -o db_path -U directory\". diff --git a/elpa/helm-20191101.641/helm-man.el b/elpa/helm-20210131.1946/helm-man.el similarity index 93% rename from elpa/helm-20191101.641/helm-man.el rename to elpa/helm-20210131.1946/helm-man.el index 26f8135f..5f1d7608 100644 --- a/elpa/helm-20191101.641/helm-man.el +++ b/elpa/helm-20210131.1946/helm-man.el @@ -1,6 +1,6 @@ ;;; helm-man.el --- Man and woman UI -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -31,9 +31,10 @@ (declare-function woman-expand-directory-path "woman.el" (path-dirs path-regexps)) (declare-function woman-topic-all-completions "woman.el" (path)) (declare-function helm-generic-sort-fn "helm-utils.el" (S1 S2)) +(declare-function helm-comp-read "helm-mode") (defgroup helm-man nil - "Man and Woman applications for helm." + "Man and Woman applications for Helm." :group 'helm) (defcustom helm-man-or-woman-function 'Man-getpage-in-background @@ -54,11 +55,11 @@ Arguments are passed to `manual-entry' with `format.'" ;; Internal (defvar helm-man--pages nil "All man pages on system. -Will be calculated the first time you invoke helm with this +Will be calculated the first time you invoke Helm with this source.") (defun helm-man-default-action (candidate) - "Default action for jumping to a woman or man page from helm." + "Default action for jumping to a woman or man page from Helm." (let ((wfiles (mapcar #'car (woman-file-name-all-completions candidate)))) (condition-case nil (let ((file (if (cdr wfiles) diff --git a/elpa/helm-20191101.641/helm-misc.el b/elpa/helm-20210131.1946/helm-misc.el similarity index 96% rename from elpa/helm-20191101.641/helm-misc.el rename to elpa/helm-20210131.1946/helm-misc.el index 7843f0fb..6e754620 100644 --- a/elpa/helm-20191101.641/helm-misc.el +++ b/elpa/helm-20210131.1946/helm-misc.el @@ -1,6 +1,6 @@ ;;; helm-misc.el --- Various functions for helm -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ (declare-function LaTeX-math-mode "ext:latex.el") (declare-function jabber-chat-with "ext:jabber.el") (declare-function jabber-read-account "ext:jabber.el") +(declare-function helm-comp-read "helm-mode") (defgroup helm-misc nil @@ -33,7 +34,7 @@ :group 'helm) (defcustom helm-time-zone-home-location "Paris" - "The time zone of your home" + "The time zone of your home." :group 'helm-misc :type 'string) @@ -45,12 +46,14 @@ :type '(alist :key-type string :value-type function)) (defface helm-time-zone-current - '((t (:foreground "green"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "green")) "Face used to colorize current time in `helm-world-time'." :group 'helm-misc) (defface helm-time-zone-home - '((t (:foreground "red"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red")) "Face used to colorize home time in `helm-world-time'." :group 'helm-misc) @@ -295,10 +298,10 @@ Default action change TZ environment variable locally to emacs." (let* ((enable-recursive-minibuffers t) (query-replace-p (or (eq last-command 'query-replace) (eq last-command 'query-replace-regexp))) - (elm (helm-comp-read "pattern: " + (elm (helm-comp-read "Next element matching (regexp): " (cl-loop for i in (symbol-value minibuffer-history-variable) - unless (string= "" i) collect i into history + unless (equal "" i) collect i into history finally return (if (consp (car history)) (mapcar 'prin1-to-string history) @@ -322,6 +325,7 @@ Default action change TZ environment variable locally to emacs." (delete-minibuffer-contents) (insert elm))) + (provide 'helm-misc) ;; Local Variables: diff --git a/elpa/helm-20191101.641/helm-mode.el b/elpa/helm-20210131.1946/helm-mode.el similarity index 61% rename from elpa/helm-20191101.641/helm-mode.el rename to elpa/helm-20210131.1946/helm-mode.el index d2f746c6..0431f707 100644 --- a/elpa/helm-20191101.641/helm-mode.el +++ b/elpa/helm-20210131.1946/helm-mode.el @@ -1,6 +1,6 @@ ;;; helm-mode.el --- Enable helm completion everywhere. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -24,30 +24,26 @@ (defvar crm-separator) (defvar ido-everywhere) +(defvar completion-flex-nospace) +(defvar helm-completion--sorting-done) +(defvar helm-mode) + (declare-function ido-mode "ido.el") +(declare-function helm-apropos-init "helm-elisp") +(declare-function helm-lisp-completion-persistent-action "helm-elisp") +(declare-function helm-lisp-completion-persistent-help "helm-elisp") (defgroup helm-mode nil "Enable helm completion." :group 'helm) (defcustom helm-completing-read-handlers-alist - '((describe-function . helm-completing-read-symbols) - (describe-variable . helm-completing-read-symbols) - (describe-symbol . helm-completing-read-symbols) - (debug-on-entry . helm-completing-read-symbols) - (find-function . helm-completing-read-symbols) - (disassemble . helm-completing-read-symbols) - (trace-function . helm-completing-read-symbols) - (trace-function-foreground . helm-completing-read-symbols) - (trace-function-background . helm-completing-read-symbols) - (find-tag . helm-completing-read-default-find-tag) + '((find-tag . helm-completing-read-default-find-tag) (xref-find-definitions . helm-completing-read-default-find-tag) (xref-find-references . helm-completing-read-default-find-tag) - (ffap-alternate-file . nil) + (ggtags-find-tag-dwim . helm-completing-read-default-find-tag) (tmm-menubar . nil) (find-file . nil) - (find-file-at-point . helm-completing-read-sync-default-handler) - (ffap . helm-completing-read-sync-default-handler) (execute-extended-command . nil) (dired-do-rename . helm-read-file-name-handler-1) (dired-do-copy . helm-read-file-name-handler-1) @@ -62,7 +58,7 @@ By default `helm-mode' use `helm-completing-read-default-handler' to provide helm completion in each `completing-read' or `read-file-name' found, but other functions can be specified here for specific -commands. This also allow disabling helm completion for some commands +commands. This also allows disabling helm completion for some commands when needed. Each entry is a cons cell like (EMACS_COMMAND . COMPLETING-READ_HANDLER) @@ -74,7 +70,7 @@ Each value maybe a helm function that takes same arguments as `completing-read' plus NAME and BUFFER, where NAME is the name of the new helm source and BUFFER the name of the buffer we will use, but it can be also a function not using helm, in this case the function should -take same args as `completing-read' and not be prefixed by \"helm-\". +take the same args as `completing-read' and not be prefixed by \"helm-\". `helm' will use the name of the command calling `completing-read' as NAME and BUFFER will be computed as well with NAME but prefixed with @@ -82,7 +78,7 @@ NAME and BUFFER will be computed as well with NAME but prefixed with This function prefix name must start by \"helm-\" when it uses helm, otherwise `helm' assumes the function is not a helm function and -expects same args as `completing-read', this allow you to define a +expects the same args as `completing-read', this allows you to define a handler not using helm completion. Example: @@ -105,16 +101,16 @@ Example: We want here to make the regular `completing-read' in `foo/test' -returns a list of candidate(s) instead of a single candidate. +return a list of candidate(s) instead of a single candidate. Note that this function will be reused for ALL the `completing-read' -of this command, so it should handle all cases, e.g -If first `completing-read' complete against symbols and +of this command, so it should handle all cases. E.g., +if first `completing-read' completes against symbols and second `completing-read' should handle only buffer, -your specialized function should handle the both. +your specialized function should handle both. If the value of an entry is nil completion will fall back to -emacs vanilla behavior. +Emacs vanilla behaviour. Example: If you want to disable helm completion for `describe-function', use: @@ -145,18 +141,20 @@ See `helm-case-fold-search' for more info." (defcustom helm-mode-handle-completion-in-region t "Whether to replace or not `completion-in-region-function'. -This enable support for `completing-read-multiple' and `completion-at-point' +This enables support for `completing-read-multiple' and `completion-at-point' when non--nil." :group 'helm-mode :type 'boolean) -(defcustom helm-mode-reverse-history t - "Display history source after current source in `helm-mode' handled commands." +(defcustom helm-mode-no-completion-in-region-in-modes nil + "A list of modes that do not want helm for `completion-in-region'." :group 'helm-mode :type 'boolean) -(defcustom helm-mode-no-completion-in-region-in-modes nil - "A list of modes that do not want helm for `completion-in-region'." +(defcustom helm-mode-reverse-history t + "Display history source after current source when non nil. + +Apply only in `helm-mode' handled commands." :group 'helm-mode :type 'boolean) @@ -167,7 +165,10 @@ when non--nil." When nil no sorting is done. The function is a `filtered-candidate-transformer' function which takes two args CANDIDATES and SOURCE. -It will be used only when `helm-completion-style' is either emacs or +The function must use the flag `helm-completion--sorting-done' and +return CANDIDATES unchanged when the flag is nil. +See default function `helm-completion-in-region-sort-fn' as example. +It will be used only when `helm-completion-style' is either Emacs or helm, otherwise when helm-fuzzy style is used, the fuzzy sort function will be used." :group 'helm-mode @@ -175,40 +176,29 @@ will be used." (defcustom helm-mode-fuzzy-match nil "Enable fuzzy matching in `helm-mode' globally. -Note that this will slow down completion and modify sorting -which is unwanted in many places. -This affect only the functions with completing-read helmized by helm-mode. -To fuzzy match `completion-at-point' and friends see -`helm-completion-style'." - :group 'helm-mode - :type 'boolean) -(defcustom helm-mode-minibuffer-setup-hook-black-list '(minibuffer-completion-help) - "Incompatible `minibuffer-setup-hook' functions go here. -A list of symbols. -Helm-mode is rejecting all lambda's, byte-code fns -and all functions belonging in this list from `minibuffer-setup-hook'." +This is deprecated, use instead helm-fuzzy as `helm-completion-style' or +even better 'emacs as `helm-completion-style' and add 'flex to +`completion-styles' (emacs-27) or 'helm-flex if 'flex is not available +in `completion-styles-alist' (emacs-26)." :group 'helm-mode - :type '(repeat (choice symbol))) - -(defcustom helm-completing-read-dynamic-complete nil - "Use dynamic completion in `completing-read' when non-nil. - -The default is to not use this because it is most of the time unneeded -in `completing-read' and thus it is much more slower. -If you feel one emacs function need this you have better time to tell -`helm-mode' to use a dynamic completion for this function only by using -`helm-completing-read-handlers-alist' with an entry like this: - - (my-function . helm-completing-read-sync-default-handler) + :type 'boolean) +(make-obsolete-variable 'helm-mode-fuzzy-match 'helm-completion-style "3.6.0") -So you should not change the default setting of this variable unless you -know what you are doing." +(defcustom helm-completion-mark-suffix t + "Push mark at end of suffix when non nil." :group 'helm-mode :type 'boolean) +(defvar helm-mode-minibuffer-setup-hook-black-list '(minibuffer-completion-help) + "Incompatible `minibuffer-setup-hook' functions go here. +A list of symbols. `helm-mode' is rejecting all lambda's, byte-code fns +and all functions belonging in this list from `minibuffer-setup-hook'. +This is mainly needed to prevent \"*Completions*\" buffers to popup.") + (defface helm-mode-prefix - '((t (:background "red" :foreground "black"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + (:background "red" :foreground "black"))) "Face used for prefix completion." :group 'helm-mode) @@ -246,28 +236,42 @@ know what you are doing." (helm-multi-key-defun helm-mode-delete-char-backward-maybe "Delete char backward when text is not the prefix helm is completing against. -First call warn user about deleting prefix completion. -Second call delete backward char in current-buffer and quit helm completion, -letting user starting a new completion with a new prefix." +First call warns user about deleting prefix completion. +Second call deletes backward char in current-buffer and quits helm completion, +letting the user start a new completion with a new prefix." '(helm-mode-delete-char-backward-1 helm-mode-delete-char-backward-2) 1) (defcustom helm-completion-style 'emacs "Style of completion to use in `completion-in-region'. -This affect only `completion-at-point' and friends, NOT -`completing-read' nor other helm commands. +This affects only `completion-at-point' and friends, and +the `completing-read' using the default handler +i.e. `helm-completing-read-default-handler'. + +NB: This has nothing to do with `completion-styles', it is independent from +helm, but when using 'emacs as helm-completion-style helm +will use the `completion-styles' for its completions. +Up to the user to configure `completion-styles'. -NB: This have nothing to do with `completion-styles', it is independent to -helm. +There are three possible values to use: -There is three possible value to use: - helm, use multi match regular helm completion. -- helm-fuzzy, use fuzzy matching, note that as usual when + +- helm-fuzzy, use fuzzy matching. Note that as usual when entering a space helm switch to multi matching mode. -- emacs, use regular emacs completion according to - `completion-styles', note that even in this style, helm allow using - multi match. Emacs-27 provide a style called flex that can be used - along this helm style (see `completion-styles-alist'). + +- emacs, use regular Emacs completion according to + `completion-styles'. Note that even in this style, helm allows using + multi match. Emacs-27 provides a style called `flex' that can be used + aside `helm' style (see `completion-styles-alist'). When `flex' style + is not available (Emacs<27) helm provides `helm-flex' style which is similar to + `flex' and helm fuzzy matching. + +For a better experience, if you don't know what to use, set +`completion-styles' to '(flex) if you are using emacs-27 or to +\'(helm-flex) if you are using emacs-26 and keep 'emacs as default +value for `helm-completion-style'. Advanced users can also have a +look to `completion-category-overrides' to set styles according to category. Please use custom interface or `customize-set-variable' to set this, NOT `setq'." @@ -281,18 +285,56 @@ NOT `setq'." (define-key helm-comp-read-map (kbd "DEL") 'helm-mode-delete-char-backward-maybe) (define-key helm-comp-read-map (kbd "DEL") 'delete-backward-char)))) -(defcustom helm-completion-styles-alist '((eshell-mode . helm)) +(defconst helm-completion--all-styles + (let ((flex (if (assq 'flex completion-styles-alist) + 'flex 'helm-flex))) + (helm-fast-remove-dups + (append (list 'helm flex) + (mapcar 'car completion-styles-alist))))) + +(defconst helm-completion--styles-type + `(repeat :tag "with other completion styles" + (choice ,@(mapcar (lambda (x) (list 'const x)) + helm-completion--all-styles)))) + +(defcustom helm-completion-styles-alist '((gud-mode . helm)) "Allow configuring `helm-completion-style' per mode. Each entry is a cons cell like (mode . style) where style must be a -suitable value for `helm-completion-style'." +suitable value for `helm-completion-style'. +When specifying emacs as style for a mode, `completion-styles' can be +specified by using a cons cell specifying completion-styles to use +with helm emacs style, e.g. (foo-mode . (emacs helm flex)) will set +`completion-styles' to '(helm flex) for foo-mode. This affects only +completions happening in buffers and not minibuffer completions, +i.e. completing-read's." :group 'helm-mode - :type '(alist :key-type (symbol :tag "Mode") - :value-type (symbol :tag "Style"))) + :type + `(alist :key-type (symbol :tag "Major Mode") + :value-type + (choice :tag "Use helm style or completion styles" + (radio :tag "Helm Style" + (const helm) + (const helm-fuzzy) + (const emacs)) + (cons :tag "Completion Styles" + (const :tag "Using Helm `emacs' style" emacs) + ,helm-completion--styles-type)))) ;;; helm-comp-read ;; ;; +(defvar helm-comp-read-use-marked nil + "[INTERNAL] When non nil `helm-comp-read' will return marked candidates. + +Use this ONLY in `let', NOT globally, this allows third party packages +to use a list as return value when `helm-mode' is enabled, e.g. + + (let ((helm-comp-read-use-marked t)) + (completing-read \"test: \" '(a b c d e f g))) + +") + (defun helm-cr-empty-string () "Return empty string." (interactive) @@ -343,7 +385,7 @@ INPUT is the string you want to complete against, defaulting to `helm-pattern' which is the value of what you enter in minibuffer. Note that when using a function as COLLECTION this value will be available with the input argument of the function only when using a -sync source from `helm-comp-read', i.e not using +sync source from `helm-comp-read', i.e. not using `:candidates-in-buffer', otherwise the function is called only once with an empty string as value for `helm-pattern' because `helm-pattern' is not yet computed, which is what we want otherwise @@ -387,8 +429,12 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." ;; but special cases like `find-file-at-point' do it. ;; Handle here specially such cases. ((and (functionp collection) (not (string= input "")) - minibuffer-completing-file-name) - (cl-loop for f in (funcall collection input test) + (or minibuffer-completing-file-name + (eq (completion-metadata-get + (completion-metadata input collection test) + 'category) + 'file))) + (cl-loop for f in (funcall collection input test t) unless (member f '("./" "../")) if (string-match helm--url-regexp input) collect f @@ -413,10 +459,11 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." (defun helm-cr-default-transformer (candidates source) "Default filter candidate function for `helm-comp-read'." - (let ((must-match (helm-attr 'must-match source)) + (let ((must-match (helm-get-attr 'must-match source)) unknown-pattern) (unless (or (eq must-match t) (string= helm-pattern "") + ;; Check if pattern is already member of candidates. (helm-cr--pattern-in-candidates-p candidates)) (setq candidates (append (list ;; Unquote helm-pattern @@ -451,19 +498,25 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." (defun helm-comp-read--move-to-first-real-candidate () (helm-aif (helm-get-selection nil 'withprop) - (when (string= (get-text-property 0 'display it) "[?]") + ;; Avoid error with candidates with an image as display (#2296). + (when (equal (get-text-property 0 'display it) "[?]") (helm-next-line)))) (defun helm-cr-default (default cands) (delq nil - (cond ((and (stringp default) (not (string= default ""))) + (cond ((and (stringp default) + (not (string= default "")) + (string= helm-pattern "")) (cons default (delete default cands))) - ((consp default) + ((and (consp default) (string= helm-pattern "")) (append (cl-loop for d in default ;; Don't convert ;; nil to "nil" (i.e the string) ;; it will be delq'ed on top. - collect (if (null d) d (helm-stringify d))) + for str = (if (null d) d (helm-stringify d)) + when (member str cands) + do (setq cands (delete d cands)) + when str collect str) cands)) (t cands)))) @@ -499,12 +552,13 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." sort fc-transformer hist-fc-transformer - marked-candidates + (marked-candidates helm-comp-read-use-marked) nomark (alistp t) (candidate-number-limit helm-candidate-number-limit) multiline allow-nest + coerce (group 'helm)) "Read a string in the minibuffer, with helm completion. @@ -542,7 +596,7 @@ Keys description: When it is non--nil, all elements of HISTORY are displayed in a special source before COLLECTION. -- INPUT-HISTORY: A symbol. the minibuffer input history will be +- INPUT-HISTORY: A symbol. The minibuffer input history will be stored there, if nil or not provided, `minibuffer-history' will be used instead. @@ -571,7 +625,7 @@ Keys description: - VOLATILE: Use volatile attribute. - SORT: A predicate to give to `sort' e.g `string-lessp' - Use this only on small data as it is ineficient. + Use this only on small data as it is inefficient. If you want to sort faster add a sort function to FC-TRANSFORMER. Note that FUZZY when enabled is already providing a sort function. @@ -596,20 +650,22 @@ Keys description: See match-part documentation in `helm-source'. - MATCH-DYNAMIC: See match-dynamic in `helm-source-sync' - It have no effect when used with CANDIDATES-IN-BUFFER. + It has no effect when used with CANDIDATES-IN-BUFFER. - ALLOW-NEST: Allow nesting this `helm-comp-read' in a helm session. See `helm'. - MULTILINE: See multiline in `helm-source'. +- COERCE: See coerce in `helm-source'. + - GROUP: See group in `helm-source'. 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 `helm-comp-read' See `helm-M-x' for example." +That means you can pass prefix args before or after calling a command +that use `helm-comp-read'. See `helm-M-x' for example." (when (get-buffer helm-action-buffer) (kill-buffer helm-action-buffer)) @@ -618,21 +674,7 @@ that use `helm-comp-read' See `helm-M-x' for example." (if ,marked-candidates (helm-marked-candidates) (identity candidate))))))) - ;; Assume completion have been already required, - ;; so always use 'confirm. - (when (eq must-match 'confirm-after-completion) - (setq must-match 'confirm)) - (let* ((minibuffer-completion-confirm must-match) - (must-match-map (when must-match - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") - 'helm-confirm-and-exit-minibuffer) - map))) - (loc-map (if must-match-map - (make-composed-keymap - must-match-map (or keymap helm-map)) - (or keymap helm-map))) - (minibuffer-completion-predicate test) + (let* ((minibuffer-completion-predicate test) (minibuffer-completion-table collection) (helm-read-file-name-mode-line-string (replace-regexp-in-string "helm-maybe-exit-minibuffer" @@ -673,8 +715,10 @@ that use `helm-comp-read' See `helm-M-x' for example." (and hist-fc-transformer (helm-mklist hist-fc-transformer))) :persistent-action persistent-action :persistent-help persistent-help - :keymap loc-map + :keymap keymap + :must-match must-match :group group + :coerce coerce :mode-line mode-line :help-message help-message :action action-fn)) @@ -692,8 +736,10 @@ that use `helm-comp-read' See `helm-M-x' for example." :persistent-action persistent-action :persistent-help persistent-help :fuzzy-match fuzzy - :keymap loc-map + :keymap keymap + :must-match must-match :group group + :coerce coerce :mode-line mode-line :match-dynamic match-dynamic :help-message help-message @@ -710,16 +756,17 @@ that use `helm-comp-read' See `helm-M-x' for example." :requires-pattern requires-pattern :persistent-action persistent-action :fuzzy-match fuzzy - :keymap loc-map + :keymap keymap + :must-match must-match :group group + :coerce coerce :persistent-help persistent-help :mode-line mode-line :help-message help-message :action action-fn)) (src-list (list src-hist - (cons (cons 'must-match must-match) - (if candidates-in-buffer - src-1 src)))) + (if candidates-in-buffer + src-1 src))) (helm-execute-action-at-once-if-one exec-when-only-one) (helm-quit-if-no-candidate quit-when-no-cand) result) @@ -736,7 +783,7 @@ that use `helm-comp-read' See `helm-M-x' for example." :preselect preselect :prompt prompt :resume 'noresume - :keymap loc-map ;; Needed with empty collection. + :keymap keymap ;; Needed with empty collection. :allow-nest allow-nest :candidate-number-limit candidate-number-limit :case-fold-search case-fold @@ -817,9 +864,9 @@ that use `helm-comp-read' See `helm-M-x' for example." init hist default _inherit-input-method name buffer &optional cands-in-buffer exec-when-only-one) "Call `helm-comp-read' with same args as `completing-read'. -Extra optional arg CANDS-IN-BUFFER mean use `candidates-in-buffer' +Extra optional arg CANDS-IN-BUFFER means use `candidates-in-buffer' method which is faster. -It should be used when candidate list don't need to rebuild dynamically." +It should be used when candidate list doesn't need to be rebuilt dynamically." (let ((history (or (car-safe hist) hist)) (initial-input (helm-aif (pcase init ((pred (stringp)) init) @@ -842,6 +889,7 @@ It should be used when candidate list don't need to rebuild dynamically." (eq require-match 'confirm-after-completion))) 1 0) + :nomark (null helm-comp-read-use-marked) :candidates-in-buffer cands-in-buffer :exec-when-only-one exec-when-only-one :fuzzy helm-mode-fuzzy-match @@ -855,6 +903,106 @@ It should be used when candidate list don't need to rebuild dynamically." ;; helm-comp-read. :initial-input initial-input))) +(defun helm-completing-read-default-2 + (prompt collection predicate require-match + init hist default _inherit-input-method + name buffer &optional _cands-in-buffer exec-when-only-one) + "Call `helm-comp-read' with same args as `completing-read'. + +This handler uses dynamic matching which allows honouring `completion-styles'." + (let* ((history (or (car-safe hist) hist)) + (input (pcase init + ((pred (stringp)) init) + ;; INIT is a cons cell. + (`(,l . ,_ll) l))) + (completion-flex-nospace t) + (completion-styles + (helm--prepare-completion-styles 'nomode)) + (metadata (or (completion-metadata (or input "") collection predicate) + '(metadata))) + (afun (or (plist-get completion-extra-properties :annotation-function) + (completion-metadata-get metadata 'annotation-function))) + (file-comp-p (eq (completion-metadata-get metadata 'category) 'file)) + (compfn (lambda (str _predicate _action) + (let* ((completion-ignore-case (helm-set-case-fold-search)) + (comps + (completion-all-completions + str ; This is helm-pattern + collection + predicate + (length str) + metadata)) + (last-data (last comps)) + ;; Helm syle sort fn is added to + ;; metadata only in emacs-27, so in + ;; emacs-26 use helm-generic-sort-fn + ;; which handle both helm and + ;; helm-flex styles. When + ;; helm-completion-style is helm or + ;; helm-fuzzy, sorting will be done + ;; later in FCT. + (sort-fn + (and (eq helm-completion-style 'emacs) + (or + ;; Emacs-27 + (completion-metadata-get + metadata 'display-sort-function) + ;; Emacs-26 + (lambda (candidates) + (sort candidates #'helm-generic-sort-fn))))) + all) + (when (cdr last-data) + ;; Remove the last element of + ;; comps by side-effect. + (setcdr last-data nil)) + (setq helm-completion--sorting-done (and sort-fn t)) + (setq all (copy-sequence comps)) + ;; Default is passed here only with helm + ;; h-c-styles, otherwise with emacs style it is + ;; passed with the :default arg of helm-comp-read + ;; and computed in its get-candidates function. + (append (and default + (memq helm-completion-style '(helm helm-fuzzy)) + (list default)) + (helm-completion-in-region--initial-filter + (if (and sort-fn (> (length str) 0)) + (funcall sort-fn all) + all) + afun file-comp-p))))) + (data (if (memq helm-completion-style '(helm helm-fuzzy)) + (funcall compfn (or input "") nil nil) + compfn)) + (helm-completion-in-region-default-sort-fn + (lambda (candidates _source) + (if (or helm-completion--sorting-done + (string= helm-pattern "")) + candidates + (sort candidates 'helm-generic-sort-fn))))) + (unwind-protect + (helm-comp-read + ;; Completion-at-point and friends have no prompt. + prompt + data + :name name + :initial-input input + :buffer buffer + :history history + :nomark (null helm-comp-read-use-marked) + :reverse-history helm-mode-reverse-history + ;; In helm h-c-styles default is passed directly in + ;; candidates. + :default (and (eq helm-completion-style 'emacs) default) + :fc-transformer + ;; Ensure sort fn is at the end. + (append '(helm-cr-default-transformer) + (and helm-completion-in-region-default-sort-fn + (list helm-completion-in-region-default-sort-fn))) + :match-dynamic (eq helm-completion-style 'emacs) + :fuzzy (eq helm-completion-style 'helm-fuzzy) + :exec-when-only-one exec-when-only-one + :must-match require-match) + (setq helm-completion--sorting-done nil)))) + (defun helm-completing-read-default-find-tag (prompt collection test require-match init hist default inherit-input-method @@ -879,22 +1027,49 @@ It should be used when candidate list don't need to rebuild dynamically." init hist default inherit-input-method name buffer)) -(defun helm-completing-read-default-handler +(defun helm-completing-read-inbuffer-default-handler (prompt collection test require-match init hist default inherit-input-method name buffer) - "Default `helm-mode' handler for all `completing-read'." + "`helm-mode' handler using inbuffer source as backend." (helm-completing-read-default-1 prompt collection test require-match init hist default inherit-input-method - name buffer - (null helm-completing-read-dynamic-complete))) + name buffer t)) + +(defun helm-completing-read-default-handler + (prompt collection test require-match + init hist default inherit-input-method + name buffer) + "Default `helm-mode' handler for all `completing-read'." + (let* ((standard (memq helm-completion-style '(helm helm-fuzzy))) + (fn (if standard + #'helm-completing-read-default-1 + #'helm-completing-read-default-2)) + (helm-mode-fuzzy-match (eq helm-completion-style 'helm-fuzzy))) + (apply fn + prompt collection test require-match + init hist default inherit-input-method + name buffer standard))) + +(defun helm-mode--read-buffer-to-switch (prompt) + "[INTERNAL] This is used to advice `read-buffer-to-switch'. +Don't use it directly." + ;; `read-buffer-to-switch' is passing `minibuffer-completion-table' + ;; to `read-buffer' through `minibuffer-setup-hook' which is too + ;; late to be known by `read-buffer-function', in our case + ;; `helm--generic-read-buffer'. It should let bind it to allow us + ;; using it. + (let ((minibuffer-completion-table (internal-complete-buffer-except))) + (read-buffer prompt (other-buffer (current-buffer)) + (confirm-nonexistent-file-or-buffer)))) (defun helm--generic-read-buffer (prompt &optional default require-match predicate) "The `read-buffer-function' for `helm-mode'. -Affects `switch-to-buffer' and related." - (let ((collection (helm-buffer-list))) - (helm--completing-read-default - prompt collection predicate require-match nil nil default))) +Affects `switch-to-buffer' `kill-buffer' and related." + (helm--completing-read-default + prompt (or minibuffer-completion-table + (internal-complete-buffer "" nil t)) + predicate require-match nil nil default)) (cl-defun helm--completing-read-default (prompt collection &optional @@ -918,7 +1093,7 @@ See documentation of `completing-read' and `all-completions' for details." initial-input hist def inherit-input-method)) ;; Append the two extra args needed to set the buffer and source name ;; in helm specialized functions. - (any-args (append def-args (list str-command buf-name))) + (others-args (append def-args (list str-command buf-name))) helm-completion-mode-start-message ; Be quiet helm-completion-mode-quit-message ;; Be sure this pesty *completion* buffer doesn't popup. @@ -937,20 +1112,17 @@ See documentation of `completing-read' and `all-completions' for details." (cl-loop for h in minibuffer-setup-hook unless (or (consp h) ; a lambda. (byte-code-function-p h) + (helm-subr-native-elisp-p h) (memq h helm-mode-minibuffer-setup-hook-black-list)) collect h)) ;; Disable hack that could be used before `completing-read'. ;; i.e (push ?\t unread-command-events). unread-command-events (default-handler - ;; Typically when COLLECTION is a function, we can assume - ;; the intention is completing dynamically according to - ;; input; If one want to use in-buffer handler for specific - ;; usage with a function as collection he can specify it in - ;; helm-completing-read-handlers-alist. - (if (functionp collection) - #'helm-completing-read-sync-default-handler - #'helm-completing-read-default-handler))) + ;; If nothing is found in + ;; helm-completing-read-handlers-alist use default + ;; handler. + #'helm-completing-read-default-handler)) (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 @@ -973,7 +1145,7 @@ See documentation of `completing-read' and `all-completions' for details." (unwind-protect (cond (;; An helm specialized function exists, run it. (and def-com helm-mode) - (apply def-com any-args)) + (apply def-com others-args)) (;; Try to handle `ido-completing-read' everywhere. (and def-com (eq def-com 'ido-completing-read)) (setcar (memq collection def-args) @@ -1033,9 +1205,9 @@ Keys description: - NAME: Source name, default to \"Read File Name\". -- INITIAL-INPUT: Where to start read file name, default to `default-directory'. +- INITIAL-INPUT: Where to start reading file name, default to `default-directory'. -- BUFFER: `helm-buffer' name default to \"*Helm Completions*\". +- BUFFER: `helm-buffer' name, defaults to \"*Helm Completions*\". - TEST: A predicate called with one arg 'candidate'. @@ -1066,10 +1238,6 @@ Keys description: (require 'tramp) (when (get-buffer helm-action-buffer) (kill-buffer helm-action-buffer)) - ;; Assume completion have been already required, - ;; so always use 'confirm. - (when (eq must-match 'confirm-after-completion) - (setq must-match 'confirm)) (mapc (lambda (hook) (add-hook 'helm-after-update-hook hook)) '(helm-ff-move-to-first-real-candidate @@ -1090,21 +1258,7 @@ Keys description: (not (memq helm-mm-matching-method '(multi1 multi3p))))) (hist (and history (helm-comp-read-get-candidates history nil nil alistp))) - (minibuffer-completion-confirm must-match) (helm-ff--RET-disabled noret) - (must-match-map (when must-match - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") - (let ((fn (lookup-key helm-read-file-map (kbd "RET")))) - (if (and (eq fn 'helm-ff-RET) - (null helm-ff--RET-disabled)) - #'helm-ff-RET-must-match - #'helm-confirm-and-exit-minibuffer))) - map))) - (cmap (if must-match-map - (make-composed-keymap - must-match-map helm-read-file-map) - helm-read-file-map)) (minibuffer-completion-predicate test) (minibuffer-completing-file-name t) (helm--completing-file-name t) @@ -1125,7 +1279,8 @@ Keys description: :fuzzy-match fuzzy :persistent-action-if persistent-action-if :persistent-help persistent-help - :keymap cmap + :keymap helm-read-file-map + :must-match must-match :nomark nomark :action action-fn) ;; Other source. @@ -1143,23 +1298,31 @@ Keys description: :nohighlight t :candidates (lambda () - (append (and (not (file-exists-p helm-pattern)) - (not (helm-ff--invalid-tramp-name-p helm-pattern)) - (list helm-pattern)) - (if test + (if test + (append (and (not (file-exists-p helm-pattern)) + (not (helm-ff--invalid-tramp-name-p helm-pattern)) + (list (helm-ff-filter-candidate-one-by-one + helm-pattern nil t))) (cl-loop with hn = (helm-ff--tramp-hostnames) - for i in (helm-find-files-get-candidates - must-match) - when (or (member i hn) ; A tramp host - (funcall test i)) ; Test ok - collect i) - (helm-find-files-get-candidates must-match)))) - :filtered-candidate-transformer 'helm-ff-sort-candidates - :filter-one-by-one 'helm-ff-filter-candidate-one-by-one + ;; helm-find-files-get-candidates is + ;; returning a list of cons cells. + for (d . r) in (helm-find-files-get-candidates + must-match) + when (or (member r hn) ; A tramp host + (funcall test r)) ; Test ok + collect (cons d r))) + (helm-find-files-get-candidates must-match))) + :update (lambda () + (remhash helm-ff-default-directory + helm-ff--list-directory-cache)) + :match-on-real t + :filtered-candidate-transformer '(helm-ff-fct + helm-ff-sort-candidates) :persistent-action-if persistent-action-if :persistent-help persistent-help :volatile t - :keymap cmap + :keymap helm-read-file-map + :must-match must-match :cleanup 'helm-find-files-cleanup :nomark nomark :action action-fn))) @@ -1224,11 +1387,16 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (def-args (list prompt dir default-filename mustmatch initial predicate)) ;; Append the two extra args needed to set the buffer and source name ;; in helm specialized functions. - (any-args (append def-args (list str-command buf-name))) + (others-args (append def-args (list str-command buf-name))) (reading-directory (eq predicate 'file-directory-p)) + (use-dialog (and (next-read-file-uses-dialog-p) + ;; Graphical file dialogs can't handle + ;; remote files. + (not (file-remote-p init)) + use-file-dialog)) helm-completion-mode-start-message ; Be quiet helm-completion-mode-quit-message ; Same here - fname) + add-to-history fname) ;; Build `default-filename' with `dir'+`initial' when ;; `default-filename' is not specified. ;; See `read-file-name' docstring for more infos. @@ -1251,25 +1419,37 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (helm-mode -1) (apply read-file-name-function def-args)) (helm-mode 1)))) - ;; If we use now `read-file-name' we MUST turn off `helm-mode' + ;; If we use now `read-file-name' or dialog 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) + (when (or (memq def-com '(read-file-name ido-read-file-name)) + use-dialog (and (stringp str-defcom) (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 helm. - ;; Note that the helm handler should ensure - ;; :initial-input is not nil i.e. Use init - ;; which fallback to default-directory instead - ;; of INITIAL. - (and def-com helm-mode + (cond (use-dialog + (let ((dialog-mustmatch + (not (memq mustmatch + '(nil confirm confirm-after-completion))))) + ;; Dialogs don't support a list of default fnames. + (when (and default-filename (consp default-filename)) + (setq default-filename + (expand-file-name (car default-filename) init))) + (setq add-to-history t) + (x-file-dialog prompt init default-filename + dialog-mustmatch + reading-directory))) + ;; A specialized function exists, run it + ;; with the two extra args specific to helm. + ;; Note that the helm handler should ensure + ;; :initial-input is not nil i.e. Use init + ;; which fallback to default-directory instead + ;; of INITIAL. + ((and def-com helm-mode (not (eq def-com 'ido-read-file-name)) (not (eq def-com 'incompatible))) - (apply def-com any-args)) + (apply def-com others-args)) (;; Def-com value is `ido-read-file-name' ;; run it with default args. (and def-com (eq def-com 'ido-read-file-name)) @@ -1279,7 +1459,7 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." ;; run it with default args. (eq def-com 'read-file-name) (apply def-com def-args)) - (t ; Fall back to classic `helm-read-file-name'. + (t ; Fall back to classic `helm-read-file-name'. (helm-read-file-name prompt :name str-command @@ -1288,6 +1468,8 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." ;; Helm handlers should always have a non nil INITIAL arg. :initial-input (expand-file-name init dir) :alistp nil + :nomark (null helm-comp-read-use-marked) + :marked-candidates helm-comp-read-use-marked :must-match mustmatch :test predicate :noret reading-directory)))) @@ -1295,13 +1477,17 @@ Don't use it directly, use instead `helm-read-file-name' in your programs." (helm-mode 1) ;; Same comment as in `helm--completing-read-default'. (setq this-command current-command)) + (when add-to-history + (add-to-history 'file-name-history + (minibuffer-maybe-quote-filename fname))) (if (and ;; Using `read-directory-name'. reading-directory ;; `file-name-as-directory' return "./" when FNAME is ;; empty string. (not (string= fname ""))) - (file-name-as-directory fname) fname))) + (file-name-as-directory fname) + fname))) ;; Read file name handler with history (issue #1652) (defun helm-read-file-name-handler-1 (prompt dir default-filename @@ -1338,7 +1524,7 @@ The `helm-find-files' history `helm-ff-history' is used here." (apply old--fn args))) (defvar helm-completion--sorting-done nil - "Flag that notify the FCT if sorting have been done in completion function.") + "Flag that notifies the FCT if sorting has been done in completion function.") (defun helm-completion-in-region-sort-fn (candidates _source) "Default sort function for completion-in-region." (if helm-completion--sorting-done @@ -1351,45 +1537,6 @@ The `helm-find-files' history `helm-ff-history' is used here." (propertize str 'read-only t 'face 'helm-mode-prefix 'rear-nonsticky t) str)) -(defun helm-completion-try-completion (string table pred point) - "The try completion function for `completing-styles-alist'. -Actually do nothing." - ;; AFAIU the try completion function is here to handle single - ;; element completion, in this case it throw this element without - ;; popping up *completions* buffer. If that's the case we don't need - ;; this because helm already handle this with - ;; `helm-execute-action-at-once-if-one', so returning unconditionaly - ;; nil should be fine. - (ignore string table pred point)) - -(defun helm-completion-all-completions (string table pred point) - "The all completions function for `completing-styles-alist'." - ;; FIXME: No need to bind all these value. - (cl-multiple-value-bind (all _pattern prefix _suffix _carbounds) - (helm-completion--multi-all-completions string table pred point) - (when all (nconc all (length prefix))))) - -(defun helm-completion--multi-all-completions-1 (string collection &optional predicate) - "Allow `all-completions' multi matching on its candidates." - (all-completions "" collection (lambda (x) - (if predicate - (and (funcall predicate x) - (helm-mm-match (helm-stringify x) string)) - (helm-mm-match (helm-stringify x) string))))) - -(defun helm-completion--multi-all-completions (string table pred point) - "Collect completions from TABLE for helm completion style." - (let* ((beforepoint (substring string 0 point)) - (afterpoint (substring string point)) - (bounds (completion-boundaries beforepoint table pred afterpoint)) - (prefix (substring beforepoint 0 (car bounds))) - (suffix (substring afterpoint (cdr bounds))) - (all (if (or (string-match-p " " string) - (string-match-p "\\`!" string)) - (helm-completion--multi-all-completions-1 string table pred) - (all-completions string table pred)))) - (list all string prefix suffix point))) - (defun helm-completion-in-region--initial-filter (comps afun file-comp-p) "Add annotations at end of candidates and filter out dot files." (if file-comp-p @@ -1417,66 +1564,221 @@ Actually do nothing." comps) comps))) -;; Setup completion styles for helm-mode -(defun helm-mode--setup-completion-styles () - (cl-pushnew '(helm helm-completion-try-completion - helm-completion-all-completions - "helm completion style.") - completion-styles-alist - :test 'equal)) - -(defun helm-mode--disable-completion-styles () - (setq completion-styles-alist - (delete (assq 'helm completion-styles-alist) - completion-styles-alist))) - -(defun helm-completion-in-region--fix-completion-styles () - "Add helm style to `completion-styles' and filter out invalid styles." - (if (memq helm-completion-style '(helm helm-fuzzy)) - '(basic partial-completion emacs22) - (cl-loop with all-styles = (mapcar 'car completion-styles-alist) - for style in (cons 'helm completion-styles) - when (and (memq style all-styles) - (not (memq style styles))) - collect style into styles - finally return styles))) +;; Helm multi matching style + +(defun helm-completion-try-completion (string table pred point) + "The try completion function for `completing-styles-alist'. +Actually does nothing." + ;; AFAIU the try-completions style functions + ;; are here to check if what is at point is suitable for TABLE but + ;; there is no way to pass a multiple pattern from what is at point + ;; apart sending STRING in a minibuffer like helm does. Perhaps + ;; minibuffer-complete should benefit of this but for now just do + ;; nothing as this is used nowhere. It is anyway not clear what the + ;; try-completions functions do in emacs so just do nothing for now. + (ignore string table pred point)) + +(defun helm-completion-all-completions (string table pred point) + "The all completions function for `completing-styles-alist'." + ;; FIXME: No need to bind all these value. + (cl-multiple-value-bind (all _pattern prefix _suffix _carbounds) + (helm-completion--multi-all-completions string table pred point) + (when all (nconc all (length prefix))))) +(defun helm-completion--multi-all-completions-1 (string collection &optional predicate) + "Allow `all-completions' multi matching on its candidates." + ;; Doing an initial call of all-completions on the first element of + ;; STRING speedup completion and fix file completion when CAPF + ;; returns relative paths to initial pattern (eshell and shell). + (let* ((split (helm-mm-split-pattern string)) + (fpat (or (car split) "")) + (file-comp-p (or minibuffer-completing-file-name + (eq + (completion-metadata-get + (completion-metadata string collection predicate) + 'category) + 'file))) + (all (and file-comp-p + (or (cdr split) + (and (not (cdr split)) + ;; Kickin when STRING is a simple string. + ;; Handle as well "foo " (space at end). + (not (string= fpat ""))) + (string= string "")) + (not (string-match "\\`!" fpat)) + ;; all-completions should return nil if FPAT is a + ;; regexp, it is what we expect. + (all-completions fpat collection + (lambda (x &optional _y) + (let ((elm (if (listp x) (car x) x))) + (funcall (or predicate #'identity) elm)))))) + (pattern (helm-aand all (string-match " " string) + ;; Returns the part of STRING after space + ;; e.g. "foo bar baz" => "bar baz". + (substring string (1+ it))))) + (if (or (and all (not (cdr split))) + (equal pattern "")) ; e.g. STRING == "foo ". + all + (all-completions "" (or all collection) + (lambda (x &optional _y) + ;; Second arg _y is needed when + ;; COLLECTION is a hash-table issue + ;; #2231 (C-x 8 RET). + ;; Elements of COLLECTION may be + ;; lists or alists, in this case consider the + ;; car of element (issue #2219 org-refile). + (let ((elm (if (listp x) (car x) x))) + ;; PREDICATE have been already called in + ;; initial all-completions, no need to call + ;; it a second time, thus ALL is now a list + ;; of strings maybe not supported by + ;; PREDICATE (e.g. symbols vs strings). + (if (and predicate (null all)) + (and (funcall predicate elm) + ;; ALL is nil so use whole STRING + ;; against COLLECTION. + (helm-mm-match (helm-stringify elm) string)) + (helm-mm-match (helm-stringify elm) + (or (and all pattern) string))))))))) + +(defun helm-completion--multi-all-completions (string table pred point) + "Collect completions from TABLE for helm completion style." + (let* ((beforepoint (substring string 0 point)) + (afterpoint (substring string point)) + (bounds (completion-boundaries beforepoint table pred afterpoint)) + (prefix (substring beforepoint 0 (car bounds))) + (suffix (substring afterpoint (cdr bounds))) + (all (helm-completion--multi-all-completions-1 + (regexp-quote string) table pred))) + (list all string prefix suffix point))) + +;; The adjust-metadata functions run only in emacs-27, they are NOT +;; used otherwise. (defun helm-completion--adjust-metadata (metadata) (if (memq helm-completion-style '(helm helm-fuzzy)) metadata - (cl-flet ((compose-helm-sort-fn - (_existing-sort-fn) - (lambda (candidates) - (let ((res candidates)) - (sort res #'helm-generic-sort-fn))))) - (let ((alist (cdr metadata))) - (helm-aif (assq 'display-sort-function alist) - (setq alist (remove it alist))) - `(metadata . ,(cons - (cons 'display-sort-function - (compose-helm-sort-fn - (alist-get 'display-sort-function alist))) - alist)))))) + (let ((compose-helm-sort-fn + (lambda (candidates) + (sort candidates #'helm-generic-sort-fn)))) + `(metadata + (display-sort-function + . ,compose-helm-sort-fn) + (cycle-sort-function + . ,compose-helm-sort-fn) + ,@(cdr metadata))))) (put 'helm 'completion--adjust-metadata 'helm-completion--adjust-metadata) -(defun helm--completion-in-region (start end collection &optional predicate) +;; Helm-flex style. +;; This is more or less the same as emacs-27 flex style. +(defun helm-flex-completion-try-completion (string table pred point) + "The try completion function for `completing-styles-alist'." + ;; It is needed here to make minibuffer-complete work in emacs-26, + ;; e.g. with regular M-x. + (unless (string-match-p " " string) + (cl-multiple-value-bind (all pattern prefix suffix _carbounds) + (helm-completion--flex-all-completions string table pred point) + (when minibuffer-completing-file-name + (setq all (completion-pcm--filename-try-filter all))) + (completion-pcm--merge-try pattern all prefix suffix)))) + +(defun helm-flex-completion-all-completions (string table pred point) + "The all completions function for `completing-styles-alist'." + ;; FIXME: No need to bind all these value. + (unless (string-match-p " " string) + (cl-multiple-value-bind (all pattern prefix _suffix _carbounds) + (helm-completion--flex-all-completions + string table pred point + #'helm-completion--flex-transform-pattern) + (let ((regexp (completion-pcm--pattern->regex pattern 'group))) + (when all (nconc (helm-flex-add-score-as-prop all regexp) + (length prefix))))))) + +(defun helm-flex-add-score-as-prop (candidates regexp) + (cl-loop with case-fold-search = (helm-set-case-fold-search) + for cand in candidates + collect (helm-flex--style-score cand regexp))) + +(defun helm-completion--flex-transform-pattern (pattern) + ;; "fob" => '(prefix "f" any "o" any "b" any point) + (cl-loop for p in pattern + if (stringp p) nconc + (cl-loop for str across p + nconc (list (string str) 'any)) + else nconc (list p))) + +;; Same as emacs-27 completion-substring--all-completions. +(defun helm-completion--flex-all-completions + (string table pred point &optional transform-pattern-fn) + "Match the presumed substring STRING to the entries in TABLE. +Respect PRED and POINT. The pattern used is a PCM-style substring +pattern, but it will be massaged by TRANSFORM-PATTERN-FN, if that +is non-nil." + (let* ((beforepoint (substring string 0 point)) + (afterpoint (substring string point)) + (bounds (completion-boundaries beforepoint table pred afterpoint)) + (suffix (substring afterpoint (cdr bounds))) + (prefix (substring beforepoint 0 (car bounds))) + (basic-pattern (completion-basic--pattern + beforepoint afterpoint bounds)) + (pattern (if (not (stringp (car basic-pattern))) + basic-pattern + (cons 'prefix basic-pattern))) + (pattern (if transform-pattern-fn + (funcall transform-pattern-fn pattern) + pattern)) + (all (completion-pcm--all-completions prefix pattern table pred))) + (list all pattern prefix suffix (car bounds)))) + +(defun helm-completion-in-region--selection () + (with-helm-buffer + (setq helm-saved-selection (helm-get-selection nil 'withprop)))) + +;; Completion-in-region-function + +(defun helm--completion-in-region (origfun start end collection &optional predicate) "Helm replacement of `completion--in-region'. -Can be used as value for `completion-in-region-function'." + +Can be used for `completion-in-region-function' by advicing it with an +:around advice to allow passing the old +`completion-in-region-function' value in ORIGFUN." (cl-declare (special require-match prompt)) (if (memq major-mode helm-mode-no-completion-in-region-in-modes) - (funcall helm--old-completion-in-region-function - start end collection predicate) + (funcall origfun start end collection predicate) (advice-add 'lisp--local-variables :around #'helm-mode--advice-lisp--local-variables) - (let ((old--helm-completion-style helm-completion-style)) + (let ((old--helm-completion-style helm-completion-style) + (exit-fun (plist-get completion-extra-properties :exit-function)) + ;; Always start with prefix to allow completing without + ;; the need of inserting a space after cursor or + ;; relaying on crap old completion-styles emacs22 which + ;; add suffix after prefix. e.g. def|else. + (initial-input (buffer-substring-no-properties start (point))) + string) (helm-aif (cdr (assq major-mode helm-completion-styles-alist)) - (customize-set-variable 'helm-completion-style it)) + (customize-set-variable 'helm-completion-style + (if (cdr-safe it) (car it) it))) + ;; This hook force usage of the display part of candidate with + ;; its properties, this is needed for lsp-mode in its + ;; :exit-function see issue #2265. + (add-hook 'helm-before-action-hook 'helm-completion-in-region--selection) (unwind-protect (let* ((enable-recursive-minibuffers t) - (completion-styles (helm-completion-in-region--fix-completion-styles)) - (input (buffer-substring start end)) - (current-command (or (helm-this-command) this-command)) + (completion-flex-nospace t) + (completion-styles (helm--prepare-completion-styles)) + (input (buffer-substring-no-properties start end)) + (prefix (and (eq helm-completion-style 'emacs) initial-input)) + (point (point)) + (current-command (or (helm-this-command) + this-command + ;; Some backends are async and + ;; use a callback, in those + ;; cases, we can't retrieve from + ;; frames the last interactive + ;; command, so fallback to + ;; `last-command' which may be + ;; the one that called the callback. + last-command)) (crm (eq current-command 'crm-complete)) (str-command (helm-symbol-name current-command)) (buf-name (format "*helm-mode-%s*" str-command)) @@ -1487,15 +1789,14 @@ Can be used as value for `completion-in-region-function'." ;; completion-at-point or friend, so use a non--nil ;; value for require-match. (not (boundp 'prompt)))) + (metadata (completion-metadata input collection predicate)) ;; `completion-extra-properties' is let-bounded in `completion-at-point'. ;; `afun' is a closure to call against each string in `data'. ;; it provide the annotation info for each string. ;; e.g "foo" => "foo " where foo is a function. ;; See Issue #407. - (afun (plist-get completion-extra-properties :annotation-function)) - (metadata (completion-metadata - (buffer-substring start (point)) - collection predicate)) + (afun (or (plist-get completion-extra-properties :annotation-function) + (completion-metadata-get metadata 'annotation-function))) (init-space-suffix (unless (or (memq helm-completion-style '(helm-fuzzy emacs)) (string-suffix-p " " input) (string= input "")) @@ -1509,39 +1810,58 @@ Can be used as value for `completion-in-region-function'." ;; so data looks like this: '(a b c d . 0) and (last data) == (d . 0). base-size (compfn (lambda (str _predicate _action) - (let* ((comps + (let* ((completion-ignore-case (helm-set-case-fold-search)) + (comps (completion-all-completions - ;; `helm-comp-read-get-candidates' - ;; set input to `helm-pattern' - ;; so no need to pass - ;; `helm-pattern' directly here. - str + str ; This is helm-pattern collection predicate - (length str) + ;; Use prefix length at first call to + ;; allow styles matching + ;; "prefix*suffix" to kick in. + (length (or prefix str)) metadata)) (last-data (last comps)) - (sort-fn (and (eq helm-completion-style 'emacs) - (completion-metadata-get - metadata 'display-sort-function))) + (bs (helm-aif (cdr last-data) + (prog1 it + ;; Remove the last element of + ;; comps by side-effect. + (setcdr last-data nil)) + 0)) + ;; Helm syle sort fn is added to + ;; metadata only in emacs-27, so in + ;; emacs-26 use helm-generic-sort-fn + ;; which handle both helm and + ;; helm-flex styles. When + ;; helm-completion-style is helm or + ;; helm-fuzzy, sorting will be done + ;; later in FCT. + (sort-fn + (and (eq helm-completion-style 'emacs) + (or + ;; Emacs-27 + (completion-metadata-get + metadata 'display-sort-function) + ;; Emacs-26 + (lambda (candidates) + (sort candidates #'helm-generic-sort-fn))))) all) - (setq base-size - (helm-aif (cdr last-data) - (prog1 (or base-size it) - (setcdr last-data nil)) - 0)) + ;; Reset prefix to allow using length of + ;; helm-pattern on next calls (this avoid + ;; args-out-of-range error). + (and prefix (setq prefix nil)) + ;; base-size needs to be set only once at + ;; first call. + (unless base-size (setq base-size bs)) (setq helm-completion--sorting-done (and sort-fn t)) (setq all (copy-sequence comps)) - ;; Fall back to string-lessp sorting when - ;; str is too small as specialized - ;; sorting may be too slow (flex). - (when (and sort-fn (<= (length str) 1)) - (setq sort-fn (lambda (all) (sort all #'string-lessp)))) (helm-completion-in-region--initial-filter - (if sort-fn (funcall sort-fn all) all) + (if (and sort-fn (> (length str) 0)) + (funcall sort-fn all) + all) afun file-comp-p)))) (data (if (memq helm-completion-style '(helm helm-fuzzy)) - (funcall compfn (buffer-substring start end) nil nil) + (funcall compfn input nil nil) compfn)) (result (if (stringp data) data @@ -1554,15 +1874,18 @@ Can be used as value for `completion-in-region-function'." :marked-candidates crm :initial-input (cond ((and file-comp-p - (not (string-match "/\\'" input))) + (not (string-match "/\\'" initial-input))) (concat (helm-mode--completion-in-region-initial-input - (helm-basename input)) + (if (memq helm-completion-style '(helm helm-fuzzy)) + (helm-basename initial-input) + initial-input)) init-space-suffix)) - ((string-match "/\\'" input) nil) + ((string-match "/\\'" initial-input) + (and (eq helm-completion-style 'emacs) initial-input)) ((or (null require-match) (stringp require-match)) - (helm-mode--completion-in-region-initial-input input)) - (t (concat (helm-mode--completion-in-region-initial-input input) + (helm-mode--completion-in-region-initial-input initial-input)) + (t (concat (helm-mode--completion-in-region-initial-input initial-input) init-space-suffix))) :buffer buf-name :fc-transformer @@ -1582,37 +1905,92 @@ Can be used as value for `completion-in-region-function'." (message "[No matches]"))) t) ; exit minibuffer immediately. :must-match require-match)))) - (helm-completion-in-region--insert-result result start end base-size)) + ;; `helm-completion-in-region--insert-result' is stripping + ;; out properties on RESULT by side-effect (perhaps + ;; `choose-completion-string'?) so make a copy of STRING + ;; to not loose props. + (setq string (copy-sequence result)) + (helm-completion-in-region--insert-result + result start point end base-size)) + ;; Allow running extra property `:exit-function' (Issues #2265, + ;; #2356). Function is called with 'exact if for a unique + ;; match which is exact, the return value of `try-completion' + ;; is t or a string ending with "/" i.e. possibly a directory + ;; (issue #2274), + ;; otherwise it is called with 'finished. + (when (and (stringp string) exit-fun) + (let ((tcomp (try-completion initial-input collection))) + (funcall exit-fun string + (if (or (eq tcomp t) ; Unique. + (and (stringp tcomp) + (string-match "/\\'" tcomp))) ; A directory. + 'exact 'finished)))) + (remove-hook 'helm-before-action-hook 'helm-completion-in-region--selection) (customize-set-variable 'helm-completion-style old--helm-completion-style) (setq helm-completion--sorting-done nil) (advice-remove 'lisp--local-variables #'helm-mode--advice-lisp--local-variables))))) -(defun helm-completion-in-region--insert-result (result start end base-size) +(defvar helm-crm-default-separator "," + "Default separator for `completing-read-multiple'. + +`crm-separator' will take precedence on this when it is a string composed +of a single character. +If used globally, it is a string composed of a single character, +if let-bounded, it can be also nil or a symbol which mean no +separator. Don't set this to a string composed of more than one +character. +Be sure to know what you are doing when modifying this.") +(defun helm-completion-in-region--insert-result (result start point end base-size) (cond ((stringp result) + ;; When RESULT have annotation, annotation is displayed + ;; in it with a display property attached to a space + ;; added at end of string, take care of removing this + ;; space (issue #2360). However keep RESULT intact to + ;; pass it to `:exit-function' i.e. Don't store the + ;; modified string in STRING. (choose-completion-string - result (current-buffer) - (list (+ start base-size) end) - completion-list-insert-choice-function)) + (replace-regexp-in-string " \\'" "" result) + (current-buffer) + (list (+ start base-size) point) + completion-list-insert-choice-function) + (when helm-completion-mark-suffix + (run-with-idle-timer 0.01 nil + (lambda () + (helm-aand + (+ (- (point) point) end) + (and (> it (point)) it) + (push-mark it t t)))))) ((consp result) ; crm. (let ((beg (+ start base-size)) - (sep ",")) - ;; Try to find a default separator. - (save-excursion - (goto-char beg) - (when (looking-back crm-separator (1- (point))) - (setq sep (match-string 0)))) + (sep (or (and + ;; If `crm-separator' is a string of length 1 + ;; assume it can be used as separator (#2298), + ;; otherwise it is a regexp and use the value + ;; it matches or default to "," if no match. + (eq (length crm-separator) 1) + crm-separator) + helm-crm-default-separator))) + ;; Try to find a default separator. If `crm-separator' is a + ;; regexp use the string the regexp is matching. + ;; If SEP is not a string, it have been probably bound to a + ;; symbol or nil through `helm-crm-default-separator' that serve + ;; as a flag to say "Please no separator" (Issue #2353 with + ;; `magit-completing-read-multiple'). + (if (stringp sep) + (save-excursion + (goto-char beg) + (when (looking-back crm-separator (1- (point))) + (setq sep (match-string 0)))) + (setq sep nil)) (funcall completion-list-insert-choice-function - beg end (mapconcat 'identity result sep)))) + beg end (mapconcat 'identity (append result '("")) sep)))) (t nil))) (defun helm-mode--in-file-completion-p () (with-helm-current-buffer (run-hook-with-args-until-success 'file-name-at-point-functions))) -(when (boundp 'completion-in-region-function) - (defconst helm--old-completion-in-region-function completion-in-region-function)) - (defun helm-mode--disable-ido-maybe (&optional from-hook) (when (and (boundp 'ido-everywhere) ido-everywhere) (remove-function read-file-name-function #'ido-read-file-name) @@ -1632,29 +2010,20 @@ Can be used as value for `completion-in-region-function'." (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 helm interface -when this mode is turned on. +All functions in Emacs that use `completing-read', +`read-file-name', `completion-in-region' and friends will use helm +interface when this mode is turned on. However you can modify this behavior for functions of your choice with `helm-completing-read-handlers-alist'. -Also commands using `completion-in-region' will be helmized when -`helm-mode-handle-completion-in-region' is non nil, you can modify -this behavior with `helm-mode-no-completion-in-region-in-modes'. - Called with a positive arg, turn on unconditionally, with a negative arg turn off. -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 `helm-completing-read-handlers-alist' -with a nil value. +You can toggle it with M-x `helm-mode'. About `ido-mode': -When you are using `helm-mode', DO NOT use `ido-mode', instead if you -want some commands use `ido', add these commands to +DO NOT enable `ido-everywhere' when using `helm-mode'. Instead of +using `ido-mode', add the commands where you want to use ido to `helm-completing-read-handlers-alist' with `ido' as value. Note: This mode is incompatible with Emacs23." @@ -1664,52 +2033,39 @@ Note: This mode is incompatible with Emacs23." (cl-assert (boundp 'completing-read-function) nil "`helm-mode' not available, upgrade to Emacs-24") (if helm-mode - (if (fboundp 'add-function) - (progn - (add-function :override completing-read-function - #'helm--completing-read-default) - (add-function :override read-file-name-function - #'helm--generic-read-file-name) - (add-function :override read-buffer-function - #'helm--generic-read-buffer) - (when helm-mode-handle-completion-in-region - (add-function :override completion-in-region-function - #'helm--completion-in-region) - (helm-mode--setup-completion-styles)) - ;; If user have enabled ido-everywhere BEFORE enabling - ;; helm-mode disable it and warn user about its - ;; incompatibility with helm-mode (issue #2085). - (helm-mode--disable-ido-maybe) - ;; If ido-everywhere is not enabled yet anticipate and - ;; disable it if user attempt to enable it while helm-mode - ;; is running (issue #2085). - (add-hook 'ido-everywhere-hook #'helm-mode--ido-everywhere-hook)) - (setq completing-read-function 'helm--completing-read-default - read-file-name-function 'helm--generic-read-file-name - read-buffer-function 'helm--generic-read-buffer) - (when (and (boundp 'completion-in-region-function) - helm-mode-handle-completion-in-region) - (setq completion-in-region-function #'helm--completion-in-region) - (helm-mode--setup-completion-styles)) - (message helm-completion-mode-start-message)) - (if (fboundp 'remove-function) - (progn - (remove-function completing-read-function #'helm--completing-read-default) - (remove-function read-file-name-function #'helm--generic-read-file-name) - (remove-function read-buffer-function #'helm--generic-read-buffer) - (remove-function completion-in-region-function #'helm--completion-in-region) - (helm-mode--disable-completion-styles) - (remove-hook 'ido-everywhere-hook #'helm-mode--ido-everywhere-hook)) - (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) - read-buffer-function (and (fboundp 'read-buffer) 'read-buffer)) - (when (and (boundp 'completion-in-region-function) - (boundp 'helm--old-completion-in-region-function)) - (setq completion-in-region-function helm--old-completion-in-region-function) - (helm-mode--disable-completion-styles)) - (message helm-completion-mode-quit-message)))) + (progn + (add-function :override completing-read-function + #'helm--completing-read-default) + (add-function :override read-file-name-function + #'helm--generic-read-file-name) + (add-function :override read-buffer-function + #'helm--generic-read-buffer) + (when helm-mode-handle-completion-in-region + (add-function :around completion-in-region-function + #'helm--completion-in-region)) + ;; If user have enabled ido-everywhere BEFORE enabling + ;; helm-mode disable it and warn user about its + ;; incompatibility with helm-mode (issue #2085). + (helm-mode--disable-ido-maybe) + ;; If ido-everywhere is not enabled yet anticipate and + ;; disable it if user attempt to enable it while helm-mode + ;; is running (issue #2085). + (add-hook 'ido-everywhere-hook #'helm-mode--ido-everywhere-hook) + (when (fboundp 'ffap-read-file-or-url-internal) + ;; `ffap-read-file-or-url-internal' have been removed in + ;; emacs-27 and `ffap-read-file-or-url' is fixed, so no need + ;; to advice it. + (advice-add 'ffap-read-file-or-url :override #'helm-advice--ffap-read-file-or-url)) + (advice-add 'read-buffer-to-switch :override #'helm-mode--read-buffer-to-switch)) + (progn + (remove-function completing-read-function #'helm--completing-read-default) + (remove-function read-file-name-function #'helm--generic-read-file-name) + (remove-function read-buffer-function #'helm--generic-read-buffer) + (remove-function completion-in-region-function #'helm--completion-in-region) + (remove-hook 'ido-everywhere-hook #'helm-mode--ido-everywhere-hook) + (when (fboundp 'ffap-read-file-or-url-internal) + (advice-remove 'ffap-read-file-or-url #'helm-advice--ffap-read-file-or-url)) + (advice-remove 'read-buffer-to-switch #'helm-mode--read-buffer-to-switch)))) (provide 'helm-mode) diff --git a/elpa/helm-20191101.641/helm-net.el b/elpa/helm-20210131.1946/helm-net.el similarity index 91% rename from elpa/helm-20191101.641/helm-net.el rename to elpa/helm-20210131.1946/helm-net.el index 59687009..895d3c7d 100644 --- a/elpa/helm-20191101.641/helm-net.el +++ b/elpa/helm-20210131.1946/helm-net.el @@ -1,6 +1,6 @@ ;;; helm-net.el --- helm browse url and search web. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -24,13 +24,15 @@ (require 'xml) (require 'browse-url) +(declare-function helm-comp-read "helm-mode") + (defgroup helm-net nil "Net related applications and libraries for Helm." :group 'helm) (defcustom helm-google-suggest-default-browser-function nil - "The browse url function you prefer to use with google suggest. + "The browse url function you prefer to use with Google suggest. When nil, use the first browser function available See `helm-browse-url-default-browser-alist'." :group 'helm-net @@ -72,7 +74,7 @@ Otherwise `url-retrieve-synchronously' is used." (defcustom helm-surfraw-duckduckgo-url "https://duckduckgo.com/lite/?q=%s&kp=1" - "The duckduckgo url. + "The Duckduckgo url. This is a format string, don't forget the `%s'. If you have personal settings saved on duckduckgo you should have a personal url, see your settings on duckduckgo." @@ -157,7 +159,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." ;; ;; ;; Internal - +(defvar helm-net-curl-log-file (expand-file-name "helm-curl.log" user-emacs-directory)) (defun helm-search-suggest-perform-additional-action (url query) "Perform the search via URL using QUERY as input." (browse-url (format url (url-hexify-string query)))) @@ -166,7 +168,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." (if helm-net-prefer-curl (with-temp-buffer (apply #'call-process "curl" - nil t nil request helm-net-curl-switches) + nil `(t ,helm-net-curl-log-file) nil request helm-net-curl-switches) (funcall parser)) (with-current-buffer (url-retrieve-synchronously request) (funcall parser)))) @@ -192,7 +194,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." request #'helm-google-suggest-parser))) (defun helm-google-suggest-set-candidates (&optional request-prefix) - "Set candidates with result and number of google results found." + "Set candidates with result and number of Google results found." (let ((suggestions (helm-google-suggest-fetch (or (and request-prefix (concat request-prefix @@ -223,7 +225,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." "?")) (defun helm-google-suggest-action (candidate) - "Default action to jump to a google suggested candidate." + "Default action to jump to a Google suggested candidate." (let ((arg (format helm-google-suggest-search-url (url-hexify-string candidate)))) (helm-aif helm-google-suggest-default-browser-function @@ -232,7 +234,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." (defvar helm-google-suggest-default-function 'helm-google-suggest-set-candidates - "Default function to use in helm google suggest.") + "Default function to use in `helm-google-suggest'.") (defvar helm-source-google-suggest (helm-build-sync-source "Google Suggest" @@ -244,7 +246,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." :requires-pattern 3)) (defun helm-google-suggest-emacs-lisp () - "Try to emacs lisp complete with google suggestions." + "Try to emacs lisp complete with Google suggestions." (helm-google-suggest-set-candidates "emacs lisp")) @@ -257,6 +259,7 @@ Can be \"-new-tab\" (default) or \"-new-window\"." (defvar helm-browse-url-chromium-program "chromium-browser") (defvar helm-browse-url-uzbl-program "uzbl-browser") +(defvar helm-browse-url-next-program "next") (defvar helm-browse-url-conkeror-program "conkeror") (defvar helm-browse-url-opera-program "opera") (defvar helm-browse-url-default-browser-alist @@ -272,7 +275,6 @@ Can be \"-new-tab\" (default) or \"-new-window\"." (,browse-url-mozilla-program . browse-url-mozilla) (,browse-url-galeon-program . browse-url-galeon) (,browse-url-netscape-program . browse-url-netscape) - (,browse-url-mosaic-program . browse-url-mosaic) (,browse-url-xterm-program . browse-url-text-xterm) ("emacs" . eww-browse-url)) "*Alist of \(executable . function\) to try to find a suitable url browser.") @@ -291,12 +293,12 @@ Can be \"-new-tab\" (default) or \"-new-window\"." ;;;###autoload (defun helm-browse-url-firefox (url &optional _ignore) - "Same as `browse-url-firefox' but detach from emacs. + "Same as `browse-url-firefox' but detach from Emacs. -So when you quit emacs you can keep your firefox session open -and not be prompted to kill firefox process. +So when you quit Emacs you can keep your Firefox session open and +not be prompted to kill the Firefox process. -NOTE: Probably not supported on some systems (e.g Windows)." +NOTE: Probably not supported on some systems (e.g., Windows)." (interactive (list (read-string "URL: " (browse-url-url-at-point)) nil)) (setq url (browse-url-encode-url url)) @@ -309,12 +311,12 @@ NOTE: Probably not supported on some systems (e.g Windows)." ;;;###autoload (defun helm-browse-url-opera (url &optional _ignore) - "Browse URL with opera browser and detach from emacs. + "Browse URL with Opera browser and detach from Emacs. -So when you quit emacs you can keep your opera session open -and not be prompted to kill opera process. +So when you quit Emacs you can keep your Opera session open and +not be prompted to kill the Opera process. -NOTE: Probably not supported on some systems (e.g Windows)." +NOTE: Probably not supported on some systems (e.g., Windows)." (interactive (list (read-string "URL: " (browse-url-url-at-point)) nil)) (setq url (browse-url-encode-url url)) @@ -325,7 +327,7 @@ NOTE: Probably not supported on some systems (e.g Windows)." ;;;###autoload (defun helm-browse-url-chromium (url &optional _ignore) - "Browse URL with google chrome browser." + "Browse URL with Google Chrome browser." (interactive "sURL: ") (helm-generic-browser url helm-browse-url-chromium-program)) @@ -342,6 +344,12 @@ NOTE: Probably not supported on some systems (e.g Windows)." (interactive "sURL: ") (helm-generic-browser url helm-browse-url-conkeror-program)) +;;;###autoload +(defun helm-browse-url-next (url &optional _ignore) + "Browse URL with next browser." + (interactive "sURL: ") + (helm-generic-browser url helm-browse-url-next-program)) + (defun helm-browse-url-default-browser (url &rest args) "Find the first available browser and ask it to load URL." (let ((default-browser-fn @@ -416,7 +424,7 @@ NOTE: Probably not supported on some systems (e.g Windows)." ;;;###autoload (defun helm-google-suggest () - "Preconfigured `helm' for google search with google suggest." + "Preconfigured `helm' for Google search with Google suggest." (interactive) (helm-other-buffer 'helm-source-google-suggest "*helm google*")) diff --git a/elpa/helm-20191101.641/helm-occur.el b/elpa/helm-20210131.1946/helm-occur.el similarity index 81% rename from elpa/helm-20191101.641/helm-occur.el rename to elpa/helm-20210131.1946/helm-occur.el index 72fc70ad..d567c66c 100644 --- a/elpa/helm-20191101.641/helm-occur.el +++ b/elpa/helm-20210131.1946/helm-occur.el @@ -1,6 +1,6 @@ ;;; helm-occur.el --- Incremental Occur for Helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -23,9 +23,17 @@ (require 'helm-help) (require 'helm-utils) +(declare-function helm-buffers-get-visible-buffers "helm-buffers") +(declare-function helm-buffer-list "helm-buffers") +(declare-function helm-grep-split-line "helm-grep") +(declare-function helm-grep-highlight-match "helm-grep") +(declare-function helm-comp-read "helm-mode") + ;;; Internals ;; -(defvar helm-source-occur nil) +(defvar helm-source-occur nil + "This will be the name of the source related to `current-buffer'. +Don't use it as it value changes always.") (defvar helm-source-moccur nil "This is just a flag to add to `helm-sources-using-default-as-input'. Don't set it to any value, it will have no effect.") @@ -35,7 +43,7 @@ Don't set it to any value, it will have no effect.") (defvar helm-occur--search-buffer-regexp "\\`\\([0-9]*\\)\\s-\\{1\\}\\(.*\\)\\'" "The regexp matching candidates in helm-occur candidate buffer.") (defvar helm-occur-mode--last-pattern nil) - +(defvar helm-occur--initial-pos 0) (defvar helm-occur-map (let ((map (make-sparse-keymap))) @@ -116,18 +124,57 @@ Note that when using `buffer-substring' initialization will be slower." :value-type (radio (const :tag "With text properties" buffer-substring) (const :tag "Without text properties" buffer-substring-no-properties)))) +(defcustom helm-occur-keep-closest-position t + "When non nil select closest candidate from point after update. +This happen only in `helm-source-occur' which is always related to `current-buffer'." + :group 'helm-regexp + :type 'boolean) (defface helm-moccur-buffer - '((t (:foreground "DarkTurquoise" :underline t))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "DarkTurquoise" :underline t)) "Face used to highlight occur buffer names." :group 'helm-occur) (defface helm-resume-need-update - '((t (:background "red"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "red")) "Face used to flash occur buffer when it needs update." :group 'helm-occur) +(defun helm-occur--select-closest-candidate () + ;; Prevent error with `with-helm-window' when switching to help. + (unless (or (not (get-buffer-window helm-buffer 'visible)) + (string-equal helm-pattern "")) + (with-helm-window + (let ((lst '()) + (name (helm-get-attr 'name helm-source-occur)) + closest beg end) + (while-no-input + (goto-char (point-min)) + (if (string= name "Helm occur") + (setq beg (point) + end (point-max)) + (helm-awhile (helm-get-next-header-pos) + (when (string= name (buffer-substring-no-properties + (point-at-bol) (point-at-eol))) + (forward-line 1) + (setq beg (point) + end (or (helm-get-next-header-pos) (point-max))) + (cl-return)))) + (save-excursion + (when (and beg end) + (goto-char beg) + (while (re-search-forward "^[0-9]+" end t) + (push (string-to-number (match-string 0)) lst)) + (setq closest (helm-closest-number-in-list + helm-occur--initial-pos lst)))) + (when (and closest (re-search-forward (format "^%s" closest) end t)) + (helm-mark-current-line) + (goto-char (overlay-start + helm-selection-overlay)))))))) + ;;;###autoload (defun helm-occur () "Preconfigured helm for searching lines matching pattern in `current-buffer'. @@ -143,7 +190,7 @@ buffers (i.e. a helm command using `helm-source-buffers-list' like `helm-mini') and use the multi occur buffers action. This is the helm implementation that collect lines matching pattern -like vanilla emacs `occur' but have nothing to do with it, the search +like vanilla Emacs `occur' but have nothing to do with it, the search engine beeing completely different and also much faster." (interactive) (setq helm-source-occur @@ -151,8 +198,18 @@ engine beeing completely different and also much faster." (helm-set-local-variable 'helm-occur--buffer-list (list (current-buffer)) 'helm-occur--buffer-tick (list (buffer-chars-modified-tick (current-buffer)))) + (helm-set-attr 'header-name (lambda (_name) + (format "HO [%s]" + (buffer-name helm-current-buffer))) + helm-source-occur) + (when helm-occur-keep-closest-position + (setq helm-occur--initial-pos (line-number-at-pos)) + (add-hook 'helm-after-update-hook 'helm-occur--select-closest-candidate)) (save-restriction - (let (def pos) + (let ((helm-sources-using-default-as-input + (unless (> (buffer-size) 2000000) + helm-sources-using-default-as-input)) + def pos) (when (use-region-p) ;; When user mark defun with `mark-defun' with intention of ;; using helm-occur on this region, it is relevant to use the @@ -173,11 +230,22 @@ engine beeing completely different and also much faster." (format "^%d:" (line-number-at-pos (or pos (point))))) :truncate-lines helm-occur-truncate-lines) - (deactivate-mark t))))) + (deactivate-mark t) + (remove-hook 'helm-after-update-hook 'helm-occur--select-closest-candidate))))) + +;;;###autoload +(defun helm-occur-visible-buffers () + "Run helm-occur on all visible buffers in frame." + (interactive) + (require 'helm-buffers) + (if (or (one-window-p) (region-active-p)) + (call-interactively #'helm-occur) + (let ((buffers (helm-buffers-get-visible-buffers))) + (helm-multi-occur-1 (mapcar 'get-buffer buffers))))) (defun helm-occur-transformer (candidates source) - "Returns CANDIDATES prefixed with line number." - (cl-loop with buf = (helm-attr 'buffer-name source) + "Return CANDIDATES prefixed with line number." + (cl-loop with buf = (helm-get-attr 'buffer-name source) for c in candidates collect (when (string-match helm-occur--search-buffer-regexp c) (let ((linum (match-string 1 c)) @@ -197,14 +265,16 @@ engine beeing completely different and also much faster." :initform nil))) (defun helm-occur-build-sources (buffers &optional source-name) - "Build sources for helm-occur for each buffer in BUFFERS list." + "Build sources for `helm-occur' for each buffer in BUFFERS list." (cl-loop for buf in buffers + for bname = (buffer-name buf) collect - (helm-make-source (or source-name - (format "HO [%s]" - (buffer-name buf))) + (helm-make-source (or source-name bname) 'helm-moccur-class - :buffer-name (buffer-name buf) + :header-name (lambda (name) + (format "HO [%s]" (if (string= name "Helm occur") + bname name))) + :buffer-name bname :match-part (lambda (candidate) ;; The regexp should match what is in candidate buffer, @@ -226,8 +296,8 @@ engine beeing completely different and also much faster." helm-occur-buffer-substring-fn-for-modes)) #'buffer-substring-no-properties)) (contents (funcall bsfn (point-min) (point-max)))) - (helm-attrset 'get-line bsfn) - (with-current-buffer (helm-candidate-buffer 'local) + (helm-set-attr 'get-line bsfn) + (with-current-buffer (helm-candidate-buffer 'global) (insert contents) (goto-char (point-min)) (let ((linum 1)) @@ -251,14 +321,22 @@ engine beeing completely different and also much faster." :moccur-buffers buffers))) (defun helm-multi-occur-1 (buffers &optional input) - "Runs helm-occur on a list of buffers. + "Run `helm-occur' on a list of buffers. Each buffer's result is displayed in a separated source." (let* ((curbuf (current-buffer)) (bufs (if helm-occur-always-search-in-current (cons curbuf (remove curbuf buffers)) buffers)) - (sources (helm-occur-build-sources bufs)) - (helm--maybe-use-default-as-input + (helm-sources-using-default-as-input + (unless (cl-loop with total_size = 0 + for b in bufs + do (setq total_size (buffer-size b)) + finally return (> total_size 2000000)) + helm-sources-using-default-as-input)) + (sources (helm-occur-build-sources bufs (and (eql curbuf (car bufs)) + (not (cdr bufs)) + "Helm occur"))) + (helm-maybe-use-default-as-input (not (null (memq 'helm-source-moccur helm-sources-using-default-as-input))))) (helm-set-local-variable 'helm-occur--buffer-list bufs @@ -266,23 +344,34 @@ Each buffer's result is displayed in a separated source." (cl-loop for b in bufs collect (buffer-chars-modified-tick (get-buffer b)))) - (helm :sources sources - :buffer "*helm moccur*" - :history 'helm-occur-history - :default (helm-aif (thing-at-point 'symbol) (regexp-quote it)) - :input input - :truncate-lines helm-occur-truncate-lines))) + (when (and helm-occur-always-search-in-current + helm-occur-keep-closest-position) + (setq helm-source-occur + (cl-loop for s in sources + when (eql helm-current-buffer + (get-buffer (helm-get-attr 'buffer-name s))) + return s)) + (setq helm-occur--initial-pos (line-number-at-pos)) + (add-hook 'helm-after-update-hook 'helm-occur--select-closest-candidate)) + (unwind-protect + (helm :sources sources + :buffer "*helm moccur*" + :history 'helm-occur-history + :default (helm-aif (thing-at-point 'symbol) (regexp-quote it)) + :input input + :truncate-lines helm-occur-truncate-lines) + (remove-hook 'helm-after-update-hook 'helm-occur--select-closest-candidate)))) ;;; Actions ;; (cl-defun helm-occur-action (lineno &optional (method (quote buffer))) "Jump to line number LINENO with METHOD. -arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame." +METHOD can be one of buffer, buffer-other-window, buffer-other-frame." (require 'helm-grep) (let ((buf (if (eq major-mode 'helm-occur-mode) (get-text-property (point) 'buffer-name) - (helm-attr 'buffer-name))) + (helm-get-attr 'buffer-name))) (split-pat (helm-mm-split-pattern helm-input))) (cl-case method (buffer (switch-to-buffer buf)) @@ -346,12 +435,12 @@ Same as `helm-occur-goto-line' but go in new frame." (put 'helm-moccur-run-save-buffer 'helm-only t) (defun helm-occur-right () - "helm-occur action for right arrow. + "`helm-occur' action for right arrow. This is used when `helm-occur-use-ioccur-style-keys' is enabled. If follow is enabled (default) go to next source, otherwise execute persistent action." (interactive) - (if (helm-aand (helm-attr 'follow) (> it 0)) + (if (helm-aand (helm-get-attr 'follow) (> it 0)) (helm-next-source) (helm-execute-persistent-action))) (put 'helm-occur-right 'helm-only t) @@ -485,7 +574,7 @@ persistent action." (helm-multi-occur-1 helm-occur--buffer-list helm-occur-mode--last-pattern)) (defun helm-occur-buffer-substring-with-linums () - "Returns current-buffer contents as a string with all lines + "Return current-buffer contents as a string with all lines numbered. The property 'buffer-name is added to the whole string." (let ((bufstr (buffer-substring-no-properties (point-min) (point-max))) (bufname (buffer-name))) @@ -573,10 +662,9 @@ numbered. The property 'buffer-name is added to the whole string." ":" (propertize lineno 'face 'helm-grep-lineno) ":" - (helm-grep-highlight-match str t)) + (helm-grep-highlight-match str)) candidate))) -;;;###autoload (define-derived-mode helm-occur-mode special-mode "helm-moccur" "Major mode to provide actions in helm moccur saved buffer. @@ -602,8 +690,8 @@ Special commands: when (buffer-live-p (get-buffer b)) collect b)) (setq buffer-is-modified (/= (length helm-occur--buffer-list) - (length (helm-attr 'moccur-buffers)))) - (helm-attrset 'moccur-buffers helm-occur--buffer-list) + (length (helm-get-attr 'moccur-buffers)))) + (helm-set-attr 'moccur-buffers helm-occur--buffer-list) (setq new-tick-ls (cl-loop for b in helm-occur--buffer-list collect (buffer-chars-modified-tick (get-buffer b)))) @@ -657,7 +745,10 @@ To use this bind it to a key in `isearch-mode-map'." (let ((input (if isearch-regexp isearch-string (regexp-quote isearch-string))) - (bufs (list (current-buffer)))) + (bufs (list (current-buffer))) + ;; Use `helm-occur-always-search-in-current' as a flag for + ;; `helm-occur--select-closest-candidate'. + (helm-occur-always-search-in-current t)) (isearch-exit) (helm-multi-occur-1 bufs input))) diff --git a/elpa/helm-20210131.1946/helm-pkg.el b/elpa/helm-20210131.1946/helm-pkg.el new file mode 100644 index 00000000..55e156f5 --- /dev/null +++ b/elpa/helm-20210131.1946/helm-pkg.el @@ -0,0 +1,13 @@ +(define-package "helm" "20210131.1946" "Helm is an Emacs incremental and narrowing framework" + '((emacs "25.1") + (async "1.9.4") + (popup "0.5.3") + (helm-core "3.6.5")) + :commit "7023ed51ee839806adb07537e23351326ce04fd2" :authors + '(("Thierry Volpiatto" . "thierry.volpiatto@gmail.com")) + :maintainer + '("Thierry Volpiatto" . "thierry.volpiatto@gmail.com") + :url "https://github.com/emacs-helm/helm") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/helm-20191101.641/helm-regexp.el b/elpa/helm-20210131.1946/helm-regexp.el similarity index 95% rename from elpa/helm-20191101.641/helm-regexp.el rename to elpa/helm-20210131.1946/helm-regexp.el index 8c2e2b3e..61c5c3ca 100644 --- a/elpa/helm-20191101.641/helm-regexp.el +++ b/elpa/helm-20210131.1946/helm-regexp.el @@ -1,6 +1,6 @@ ;;; helm-regexp.el --- In buffer regexp searching and replacement for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ (defun helm-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." +i.e. don't replace inside a word, regexp is surrounded with \\bregexp\\b." (let ((regexp helm-input)) (apply 'query-replace-regexp (helm-query-replace-args regexp)))) @@ -52,7 +52,7 @@ i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." (helm-regexp-kill-new helm-input)) (defun helm-query-replace-args (regexp) - "create arguments of `query-replace-regexp' action in `helm-regexp'." + "Create arguments of `query-replace-regexp' action in `helm-regexp'." (let ((region-only (helm-region-active-p))) (list regexp diff --git a/elpa/helm-20191101.641/helm-ring.el b/elpa/helm-20210131.1946/helm-ring.el similarity index 93% rename from elpa/helm-20191101.641/helm-ring.el rename to elpa/helm-20210131.1946/helm-ring.el index f4504d53..fbe2fef0 100644 --- a/elpa/helm-20191101.641/helm-ring.el +++ b/elpa/helm-20210131.1946/helm-ring.el @@ -1,6 +1,6 @@ ;;; helm-ring.el --- kill-ring, mark-ring, and register browsers for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -39,16 +39,17 @@ "Max number of chars displayed per candidate in kill-ring browser. When `t', don't truncate candidate, show all. By default it is approximatively the number of bits contained in five lines -of 80 chars each i.e 80*5. -Note that if you set this to nil multiline will be disabled, i.e you -will not have anymore separators between candidates." +of 80 chars each, i.e. 80*5. +Note that if you set this to nil multiline will be disabled, i.e. you +will not have separators between candidates any more." :type '(choice (const :tag "Disabled" t) (integer :tag "Max candidate offset")) :group 'helm-ring) (defcustom helm-kill-ring-actions '(("Yank marked" . helm-kill-ring-action-yank) - ("Delete marked" . helm-kill-ring-action-delete)) + ("Delete marked" . helm-kill-ring-action-delete) + ("Search from candidate" . helm-kill-ring-search-from-string)) "List of actions for kill ring source." :group 'helm-ring :type '(alist :key-type string :value-type function)) @@ -72,6 +73,7 @@ will not have anymore separators between candidates." (define-key map (kbd "M-y") 'helm-next-line) (define-key map (kbd "M-u") 'helm-previous-line) (define-key map (kbd "M-D") 'helm-kill-ring-delete) + (define-key map (kbd "C-s") 'helm-kill-ring-run-search-from-string) (define-key map (kbd "C-]") 'helm-kill-ring-toggle-truncated) (define-key map (kbd "C-c C-k") 'helm-kill-ring-kill-selection) (define-key map (kbd "C-c d") 'helm-kill-ring-run-persistent-delete) @@ -81,8 +83,8 @@ will not have anymore separators between candidates." (defvar helm-source-kill-ring (helm-build-sync-source "Kill Ring" :init (lambda () - (helm-attrset 'last-command last-command) - (helm-attrset 'multiline helm-kill-ring-max-offset)) + (helm-set-attr 'last-command last-command) + (helm-set-attr 'multiline helm-kill-ring-max-offset)) :candidates #'helm-kill-ring-candidates :filtered-candidate-transformer #'helm-kill-ring-transformer :action 'helm-kill-ring-actions @@ -97,7 +99,7 @@ will not have anymore separators between candidates." (defun helm-kill-ring-candidates () (cl-loop with cands = (helm-fast-remove-dups kill-ring :test 'equal) - for kill in (if (eq (helm-attr 'last-command) 'yank) + for kill in (if (eq (helm-get-attr 'last-command) 'yank) (cdr cands) cands) unless (or (< (length kill) helm-kill-ring-threshold) @@ -120,7 +122,7 @@ will not have anymore separators between candidates." (let* ((cur-cand (helm-get-selection)) (presel-fn (lambda () (helm-kill-ring--preselect-fn cur-cand)))) - (helm-attrset 'multiline + (helm-set-attr 'multiline (if helm-kill-ring--truncated-flag 15000000 helm-kill-ring-max-offset)) @@ -163,10 +165,10 @@ use `helm-kill-ring-separator' as default." (defun helm-kill-ring-action-yank-1 (str) "Insert STR in `kill-ring' and set STR to the head. -When called with a prefix arg, point and mark are exchanged without -activating region. -If this action is executed just after `yank', -replace with STR as yanked string." +When called with a prefix arg, point and mark are exchanged +without activating region. +If this action is executed just after `yank', replace with STR as +yanked string." (let ((yank-fn (lambda (&optional before yank-pop) (insert-for-yank str) ;; Set the window start back where it was in @@ -192,7 +194,7 @@ replace with STR as yanked string." ;; so use this workaround (Issue #1520). (when (and (region-active-p) delete-selection-mode) (delete-region (region-beginning) (region-end))) - (if (not (eq (helm-attr 'last-command helm-source-kill-ring) 'yank)) + (if (not (eq (helm-get-attr 'last-command helm-source-kill-ring) 'yank)) (progn ;; Ensure mark is at beginning of inserted text. (push-mark) @@ -214,6 +216,18 @@ replace with STR as yanked string." (kill-new str))))) (define-obsolete-function-alias 'helm-kill-ring-action 'helm-kill-ring-action-yank "2.4.0") +(defun helm-kill-ring-search-from-string (candidate) + (let ((str (car (split-string candidate "\n")))) + (helm-multi-occur-1 + (list (current-buffer)) + (regexp-quote (substring-no-properties str))))) + +(defun helm-kill-ring-run-search-from-string () + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-kill-ring-search-from-string))) +(put 'helm-kill-ring-run-search-from-string 'helm-only t) + (defun helm-kill-ring-action-delete (_candidate) "Delete marked candidates from `kill-ring'." (cl-loop for c in (helm-marked-candidates) @@ -237,7 +251,7 @@ replace with STR as yanked string." "Delete current candidate without quitting." (interactive) (with-helm-alive-p - (helm-attrset 'quick-delete '(helm-kill-ring-persistent-delete . never-split)) + (helm-set-attr 'quick-delete '(helm-kill-ring-persistent-delete . never-split)) (helm-execute-persistent-action 'quick-delete))) (put 'helm-kill-ring-run-persistent-delete 'helm-only t) @@ -358,8 +372,12 @@ This is a command for `helm-kill-ring-map'." (defun helm-register-candidates () "Collecting register contents and appropriate commands." - (cl-loop for (char . val) in register-alist + (cl-loop for (char . rval) in register-alist for key = (single-key-description char) + for e27 = (registerv-p rval) + for val = (if e27 ; emacs-27 + (registerv-data rval) + rval) for string-actions = (cond ((numberp val) @@ -382,7 +400,7 @@ This is a command for `helm-kill-ring-map'." 'jump-to-register)) ((and (vectorp val) (fboundp 'undo-tree-register-data-p) - (undo-tree-register-data-p (elt val 1))) + (undo-tree-register-data-p (if e27 val (elt val 1)))) (list "Undo-tree entry." 'undo-tree-restore-state-from-register)) diff --git a/elpa/helm-20191101.641/helm-semantic.el b/elpa/helm-20210131.1946/helm-semantic.el similarity index 97% rename from elpa/helm-20191101.641/helm-semantic.el rename to elpa/helm-20210131.1946/helm-semantic.el index f5691244..3c277ac6 100644 --- a/elpa/helm-20191101.641/helm-semantic.el +++ b/elpa/helm-20210131.1946/helm-semantic.el @@ -1,7 +1,7 @@ ;;; helm-semantic.el --- Helm interface for Semantic -*- lexical-binding: t -*- ;; Copyright (C) 2012 ~ 2017 Daniel Hackney -;; 2012 ~ 2019 Thierry Volpiatto +;; 2012 ~ 2020 Thierry Volpiatto ;; Author: Daniel Hackney @@ -165,7 +165,7 @@ you have completion on these functions with `C-M i' in the customize interface." ;;;###autoload (defun helm-semantic (arg) "Preconfigured `helm' for `semantic'. -If ARG is supplied, pre-select symbol at point instead of current" +If ARG is supplied, pre-select symbol at point instead of current." (interactive "P") (let ((tag (helm-aif (car (semantic-current-tag-parent)) (let ((curtag (car (semantic-current-tag)))) @@ -173,7 +173,8 @@ If ARG is supplied, pre-select symbol at point instead of current" (format "\\_<%s\\_>" curtag) (cons (format "\\_<%s\\_>" it) (format "\\_<%s\\_>" curtag)))) - (format "\\_<%s\\_>" (car (semantic-current-tag)))))) + (format "\\_<%s\\_>" (car (semantic-current-tag))))) + (helm-highlight-matches-around-point-max-lines 'never)) (unless helm-source-semantic (setq helm-source-semantic (helm-make-source "Semantic Tags" 'helm-semantic-source @@ -206,6 +207,7 @@ Fill in the symbol at point by default." (let* ((source (if (semantic-active-p) 'helm-source-semantic 'helm-source-imenu)) + (helm-highlight-matches-around-point-max-lines 'never) (imenu-p (eq source 'helm-source-imenu)) (imenu-auto-rescan imenu-p) (str (thing-at-point 'symbol)) diff --git a/elpa/helm-20191101.641/helm-shell.el b/elpa/helm-20210131.1946/helm-shell.el similarity index 95% rename from elpa/helm-20191101.641/helm-shell.el rename to elpa/helm-20210131.1946/helm-shell.el index 5f946dc5..7be64aa3 100644 --- a/elpa/helm-20191101.641/helm-shell.el +++ b/elpa/helm-20210131.1946/helm-shell.el @@ -1,6 +1,6 @@ ;;; helm-shell.el --- Shell prompt navigation for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2019 Pierre Neidhardt +;; Copyright (C) 2020 Pierre Neidhardt ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/elpa/helm-20191101.641/helm-sys.el b/elpa/helm-20210131.1946/helm-sys.el similarity index 92% rename from elpa/helm-20191101.641/helm-sys.el rename to elpa/helm-20210131.1946/helm-sys.el index cfe015ec..250ef97b 100644 --- a/elpa/helm-20191101.641/helm-sys.el +++ b/elpa/helm-20210131.1946/helm-sys.el @@ -1,6 +1,6 @@ ;;; helm-sys.el --- System related functions for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -28,7 +28,8 @@ :group 'helm) (defface helm-top-columns - '((t :inherit helm-header)) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit helm-header)) "Face for helm help string in minibuffer." :group 'helm-sys) @@ -40,20 +41,22 @@ "Top command used to display output of top. A format string where %s will be replaced with `frame-width'. -To use 'top' command, a version supporting batch mode (-b option) is needed. -On Mac OSX 'top' command doesn't support this, so ps command -is used instead by default. -Normally 'top' command output have 12 columns, but in some versions you may -have less than this, so you can either customize top to use 12 columns with the -interactives 'f' and 'W' commands of top, or modify -`helm-top-sort-columns-alist' to fit with the number of columns -your 'top' command is using. - -If you modify 'ps' command be sure that 'pid' comes in first -and \"env COLUMNS=%s\" is specified at beginning of command. -Ensure also that no elements contain spaces (e.g use start_time and not start). -Same as for 'top' you can customize `helm-top-sort-columns-alist' to make sort commands -working properly according to your settings." +To use 'top' command, a version supporting batch mode (-b option) +is needed. On Mac OSX 'top' command doesn't support this, so the +'ps' command is used instead by default. + +Normally 'top' command output have 12 columns, but in some +versions you may have less than this, so you can either customize +top to use 12 columns with the interactives 'f' and 'W' commands +of top, or modify `helm-top-sort-columns-alist' to fit with the +number of columns your 'top' command is using. + +If you modify 'ps' command be sure that 'pid' comes in first and +\"env COLUMNS=%s\" is specified at beginning of command. Ensure +also that no elements contain spaces (e.g., use start_time and +not start). Same as for 'top': you can customize +`helm-top-sort-columns-alist' to make sort commands working +properly according to your settings." :group 'helm-sys :type 'string) @@ -64,7 +67,7 @@ working properly according to your settings." "Allow defining which column to use when sorting output of top/ps command. Only com, mem, cpu and user are sorted, so no need to put something else there, it will have no effect. -Note that column numbers are counted from zero, i.e column 1 is the nth 0 column." +Note that column numbers are counted from zero, i.e. column 1 is the nth 0 column." :group 'helm-sys :type '(alist :key-type symbol :value-type (integer :tag "Column number"))) @@ -76,15 +79,15 @@ The minimal delay allowed is 1.5, if less than this helm-top will use 1.5." (defcustom helm-top-poll-delay-post-command 1.0 "Helm top stop polling during this delay. -This delay is additioned to `helm-top-poll-delay' after emacs stop +This delay is added to `helm-top-poll-delay' after Emacs stops being idle." :group 'helm-sys :type 'float) (defcustom helm-top-poll-preselection 'linum - "Stay on same line or follow candidate when `helm-top-poll' update display. + "Stay on same line or follow candidate when `helm-top-poll' updates display. Possible values are 'candidate or 'linum. -This affect also sorting functions in the same way." +This affects also sorting functions in the same way." :group'helm-sys :type '(radio :tag "Preferred preselection action for helm-top" (const :tag "Follow candidate" candidate) @@ -143,9 +146,9 @@ This affect also sorting functions in the same way." helm-top-poll-delay-post-command))) (defun helm-top-initialize-poll-hooks () - ;; When emacs is idle during say 20s + ;; When Emacs is idle during say 20s ;; the idle timer will run in 20+1.5 s. - ;; This is fine when emacs stays idle, because the next timer + ;; This is fine when Emacs stays idle, because the next timer ;; will run at 21.5+1.5 etc... so the display will be updated ;; at every 1.5 seconds. ;; But as soon as emacs looses its idleness, the next update @@ -437,7 +440,7 @@ Show actions only on line starting by a PID." ;;;###autoload (defun helm-list-emacs-process () - "Preconfigured `helm' for emacs process." + "Preconfigured `helm' for Emacs process." (interactive) (helm-other-buffer 'helm-source-emacs-process "*helm process*")) diff --git a/elpa/helm-20191101.641/helm-tags.el b/elpa/helm-20210131.1946/helm-tags.el similarity index 96% rename from elpa/helm-20191101.641/helm-tags.el rename to elpa/helm-20210131.1946/helm-tags.el index 782e87b4..6b18811e 100644 --- a/elpa/helm-20191101.641/helm-tags.el +++ b/elpa/helm-20210131.1946/helm-tags.el @@ -1,6 +1,6 @@ ;;; helm-tags.el --- Helm for Etags. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -23,6 +23,9 @@ (require 'helm-utils) (require 'helm-grep) +(defvar helm-etags-fuzzy-match) +(declare-function ring-insert "ring") + (defgroup helm-tags nil "Tags related Applications and libraries for Helm." @@ -64,8 +67,9 @@ one match." :group 'helm-faces) (defface helm-etags-file - '((t (:foreground "Lightgoldenrod4" - :underline t))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "Lightgoldenrod4" + :underline t)) "Face used to highlight etags filenames." :group 'helm-tags-faces) @@ -107,8 +111,8 @@ one match." "Cache content of etags files used here for faster access.") (defun helm-etags-get-tag-file (&optional directory) - "Return the path of etags file if found. -Lookes recursively in parents directorys for a + "Return the path of etags file if found in DIRECTORY. +Look recursively in parents directorys for a `helm-etags-tag-file-name' file." ;; Get tag file from `default-directory' or upper directory. (let ((current-dir (helm-etags-find-tag-file-directory @@ -118,7 +122,7 @@ Lookes recursively in parents directorys for a (expand-file-name helm-etags-tag-file-name current-dir)))) (defun helm-etags-all-tag-files () - "Return files from the following sources; + "Return files from the following sources: 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. 2) `tags-file-name', which is commonly set by `find-tag' command. 3) `tags-table-list' which is commonly set by `visit-tags-table' command." @@ -186,7 +190,7 @@ If not found in CURRENT-DIR search in upper directory." (defun helm-etags-init () "Feed `helm-buffer' using `helm-etags-cache' or tag file. -If no entry in cache, create one." +If there is no entry in cache, create one." (let ((tagfiles (helm-etags-all-tag-files))) (when tagfiles (with-current-buffer (helm-candidate-buffer 'global) diff --git a/elpa/helm-20191101.641/helm-types.el b/elpa/helm-20210131.1946/helm-types.el similarity index 88% rename from elpa/helm-20191101.641/helm-types.el rename to elpa/helm-20210131.1946/helm-types.el index 868e7974..cef1c64c 100644 --- a/elpa/helm-20191101.641/helm-types.el +++ b/elpa/helm-20210131.1946/helm-types.el @@ -1,6 +1,6 @@ ;;; helm-types.el --- Helm types classes and methods. -*- lexical-binding: t -*- -;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2015 ~ 2020 Thierry Volpiatto ;; Author: Thierry Volpiatto ;; URL: http://github.com/emacs-helm/helm @@ -24,6 +24,13 @@ (require 'cl-lib) (require 'eieio) +(defvar helm-map) +(defvar helm-mode-line-string) +(defvar helm-bookmark-map) +(declare-function helm-make-actions "helm-lib") +(declare-function helm-ediff-marked-buffers "helm-buffers") +(declare-function helm-make-type "helm-source") + ;; Files (defclass helm-type-file (helm-source) () @@ -45,7 +52,6 @@ (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 "C-c g") 'helm-ff-run-gid) (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) @@ -61,7 +67,6 @@ (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-c X") 'helm-ff-run-open-file-with-default-tool) - (define-key map (kbd "M-.") 'helm-ff-run-etags) (define-key map (kbd "C-c @") 'helm-ff-run-insert-org-link) (define-key map (kbd "C-x C-q") 'helm-ff-run-marked-files-in-dired) (define-key map (kbd "C-c C-a") 'helm-ff-run-mail-attach-files) @@ -84,7 +89,6 @@ "Checksum File" 'helm-ff-checksum "Ediff File" 'helm-find-files-ediff-files "Ediff Merge File" 'helm-find-files-ediff-merge-files - "Etags `M-., C-u reload tag file'" 'helm-ff-etags-select "View file" 'view-file "Insert file" 'insert-file "Add marked files to file-cache" 'helm-ff-cache-add-file @@ -169,7 +173,9 @@ 'switch-to-buffer-other-frame (lambda () (and (fboundp 'tab-bar-mode) "Switch to buffer other tab `C-c C-t'")) - 'switch-to-buffer-other-tab + 'helm-buffers-switch-to-buffer-other-tab + "Switch to buffer at line number" + 'helm-switch-to-buffer-at-linum "Browse project `C-x C-d'" 'helm-buffers-browse-project "Query replace regexp `C-M-%'" @@ -202,7 +208,11 @@ (defmethod helm--setup-source :before ((source helm-type-buffer)) (setf (slot-value source 'action) 'helm-type-buffer-actions) (setf (slot-value source 'persistent-help) "Show this buffer") - (setf (slot-value source 'mode-line) (list "Buffer(s)" helm-mode-line-string)) + (setf (slot-value source 'mode-line) + ;; Use default-value of `helm-mode-line-string' in case user + ;; starts with a helm buffer as current-buffer otherwise the + ;; local value of this helm buffer is used (issues #1517,#2377). + (list "Buffer(s)" (default-value 'helm-mode-line-string))) (setf (slot-value source 'filtered-candidate-transformer) '(helm-skip-boring-buffers helm-buffers-sort-transformer @@ -215,9 +225,11 @@ (defcustom helm-type-function-actions (helm-make-actions - "Describe command" 'describe-function - "Add command to kill ring" 'helm-kill-new - "Go to command's definition" 'find-function + "Describe function" 'helm-describe-function + "Find function" (if (fboundp 'xref-find-definitions) + ;; Find-function is broken in emacs-27. + 'xref-find-definitions 'find-function) + "Info lookup" 'helm-info-lookup-symbol "Debug on entry" 'debug-on-entry "Cancel debug on entry" 'cancel-debug-on-entry "Trace function" 'trace-function @@ -225,7 +237,9 @@ "Untrace function" 'untrace-function) "Default actions for type functions." :group 'helm-elisp - :type '(alist :key-type string :value-type function)) + ;; Use symbol as value type because some functions may not be + ;; autoloaded (like untrace-function). + :type '(alist :key-type string :value-type symbol)) (defmethod helm-source-get-action-from-type ((object helm-type-function)) (slot-value object 'action)) @@ -257,18 +271,20 @@ (defcustom helm-type-command-actions (append (helm-make-actions - "Call interactively" 'helm-call-interactively) - (helm-actions-from-type-function)) + "Execute command" 'helm-M-x-execute-command) + (symbol-value + (helm-actions-from-type-function))) "Default actions for type command." :group 'helm-command - :type '(alist :key-type string :value-type function)) + :type '(alist :key-type string :value-type symbol)) (defmethod helm--setup-source :primary ((_source helm-type-command))) (defmethod helm--setup-source :before ((source helm-type-command)) (setf (slot-value source 'action) 'helm-type-command-actions) (setf (slot-value source 'coerce) 'helm-symbolify) - (setf (slot-value source 'persistent-action) 'describe-function) + (setf (slot-value source 'persistent-action) 'helm-M-x-persistent-action) + (setf (slot-value source 'persistent-help) "Describe this command") (setf (slot-value source 'group) 'helm-command)) ;; Timers @@ -284,7 +300,8 @@ (describe-function (timer--function tm)))) ("Find Function" . (lambda (tm) (helm-aif (timer--function tm) - (if (byte-code-function-p it) + (if (or (byte-code-function-p it) + (helm-subr-native-elisp-p it)) (message "Can't find anonymous function `%s'" it) (find-function it)))))) "Default actions for type timers." diff --git a/elpa/helm-20191101.641/helm-utils.el b/elpa/helm-20210131.1946/helm-utils.el similarity index 85% rename from elpa/helm-20191101.641/helm-utils.el rename to elpa/helm-20210131.1946/helm-utils.el index f246dd51..bb2e2904 100644 --- a/elpa/helm-20191101.641/helm-utils.el +++ b/elpa/helm-20210131.1946/helm-utils.el @@ -1,6 +1,6 @@ ;;; helm-utils.el --- Utilities Functions for helm. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -20,18 +20,32 @@ (require 'cl-lib) (require 'helm) (require 'helm-help) -(eval-when-compile (require 'dired)) -(declare-function helm-find-files-1 "helm-files.el" (fname &optional preselect)) +(declare-function helm-find-files-1 "helm-files" (fname &optional preselect)) +(declare-function helm-grep-split-line "helm-grep" (line)) (declare-function popup-tip "ext:popup") -(declare-function markdown-show-subtree "outline.el") -(declare-function outline-show-subtree "outline.el") -(declare-function org-reveal "org.el") -(declare-function tab-bar-tabs "tab-bar.el") -(declare-function tab-bar-select-tab "tab-bar.el") +(declare-function markdown-show-entry "ext:markdown-mode.el") +(declare-function outline-show-subtree "outline") +(declare-function org-reveal "org") +(declare-function hs-show-block "hideshow.el") +(declare-function tab-bar-tabs "tab-bar") +(declare-function tab-bar-select-tab "tab-bar") +(declare-function dired-goto-file "dired") +(declare-function bookmark-get-filename "bookmark") +(declare-function package-installed-p "package") +(declare-function package-desc-dir "package") + +(defvar hs-minor-mode) +(defvar hs-show-hook) (defvar org-directory) (defvar winner-boring-buffers) +(defvar bookmark-alist) +(defvar dired-buffers) (defvar helm-show-completion-overlay) +(defvar helm-buffers-maybe-switch-to-tab) +(defvar helm-ff-transformer-show-only-basename) +(defvar helm-popup-tip-mode) + (defgroup helm-utils nil @@ -54,10 +68,24 @@ It is a float, usually 1024.0 but could be 1000.0 on some systems." 'helm-highlight-matches-around-point-max-lines "20160119") -(defcustom helm-highlight-matches-around-point-max-lines 15 - "Number of lines around point where matched items are highlighted." +(defcustom helm-highlight-matches-around-point-max-lines '(15 . 15) + "Number of lines around point where matched items are highlighted. + +Possible value are: +- A cons cell (x . y) + Match x lines before point and y lines after point. +- An integer + Positive means this number lines after point. + Negative means this number lines before point. + A zero value means highlight only inside matched lines. +- The symbol never + Means do not highlight matched items. " :group 'helm-utils - :type 'integer) + :type '(choice (cons (integer :tag "Match before") + (integer :tag "Match after")) + (const :tag "Match in line only" 0) + (integer :tag "Match after or before (+/-)") + (const :tag "Never match" 'never))) (defcustom helm-buffers-to-resize-on-pa nil "A list of helm buffers where the helm-window should be reduced on persistent actions." @@ -76,11 +104,11 @@ It is a float, usually 1024.0 but could be 1000.0 on some systems." :type '(repeat (choice string))) (defcustom helm-html-decode-entities-function #'helm-html-decode-entities-string - "Function used to decode html entities in html bookmarks. + "Function used to decode HTML entities in HTML bookmarks. Helm comes by default with `helm-html-decode-entities-string', if you need something more sophisticated you can use `w3m-decode-entities-string' if available. -In emacs itself org-entities seems broken and `xml-substitute-numeric-entities' +In Emacs itself org-entities seem broken and `xml-substitute-numeric-entities' supports only numeric entities." :group 'helm-utils :type 'function) @@ -88,17 +116,17 @@ supports only numeric entities." (defvar helm-goto-line-before-hook '(helm-save-current-pos-to-mark-ring) "Run before jumping to line. -This hook run when jumping from `helm-goto-line', `helm-etags-default-action', +This hook runs when jumping from `helm-goto-line', `helm-etags-default-action', and `helm-imenu-default-action'. -This allow you to retrieve a previous position after using the different helm +This allows you to retrieve a previous position after using the different helm tools for searching (etags, grep, gid, (m)occur etc...). -By default positions are added to `mark-ring' you can also add to register -by using instead (or adding) `helm-save-pos-to-register-before-jump'. -In this case last position is added to the register -`helm-save-pos-before-jump-register'.") +By default positions are added to `mark-ring'. +You can also add to register by using (or adding) +`helm-save-pos-to-register-before-jump' instead. In this case +last position is added to the register `helm-save-pos-before-jump-register'.") (defvar helm-save-pos-before-jump-register ?_ - "The register where `helm-save-pos-to-register-before-jump' save position.") + "The register where `helm-save-pos-to-register-before-jump' saves position.") (defconst helm-html-entities-alist '((""" . 34) ;; " @@ -206,18 +234,20 @@ In this case last position is added to the register "Table of html character entities and values.") (defvar helm-find-many-files-after-hook nil - "Hook that run at end of `helm-find-many-files'.") + "Hook that runs at end of `helm-find-many-files'.") ;;; Faces. ;; (defface helm-selection-line - '((t (:inherit highlight :distant-foreground "black"))) - "Face used in the `helm-current-buffer' when jumping to candidate." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit highlight :distant-foreground "black")) + "Face used in the `helm-current-buffer' when jumping to a candidate." :group 'helm-faces) (defface helm-match-item - '((t (:inherit isearch))) - "Face used to highlight item matched in a selected line." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit isearch)) + "Face used to highlight the item matched in a selected line." :group 'helm-faces) @@ -236,7 +266,7 @@ according to the setting of `split-width-threshold' and the size of the window from where splitting is done. Note that when using `decide' and `split-width-threshold' is nil, the -behavior is the same that with a nil value." +behavior is the same as with a nil value." :group 'helm-utils :type '(choice (const :tag "Split window vertically" t) @@ -258,8 +288,8 @@ It is typically used to rearrange windows." (defun helm-window-show-buffers (buffers &optional other-window) "Show BUFFERS. -If more than one buffer marked switch to these buffers in separate windows. -If OTHER-WINDOW is non-nil, keep current buffer and switch to others buffers +With more than one buffer marked switch to these buffers in separate windows. +If OTHER-WINDOW is non-nil, keep current buffer and switch to other buffers in separate windows. If a prefix arg is given split windows vertically." (let ((initial-ow-fn (if (cdr (window-list)) @@ -272,19 +302,24 @@ If a prefix arg is given split windows vertically." (funcall initial-ow-fn (car buffers)) (helm-buffers-switch-to-buffer-or-tab (car buffers)))))) +(defvar tab-bar-tab-name-function) +(declare-function tab-bar-switch-to-tab "tab-bar.el") +(declare-function tab-bar-tab-name-all "tab-bar.el") + (defun helm-buffers-switch-to-buffer-or-tab (buffer) "Switch to BUFFER in its tab if some." (if (and (fboundp 'tab-bar-mode) helm-buffers-maybe-switch-to-tab) - (let* ((tabs (tab-bar-tabs)) + (let* ((tab-bar-tab-name-function #'tab-bar-tab-name-all) + (tabs (tab-bar-tabs)) (tab-names (mapcar (lambda (tab) (cdr (assq 'name tab))) - (tab-bar-tabs))) + tabs)) (bname (buffer-name (get-buffer buffer))) (tab (helm-buffers--get-tab-from-name bname tabs))) (if (helm-buffers--buffer-in-tab-p bname tab-names) (progn - (tab-bar-select-tab tab) + (tab-bar-switch-to-tab (alist-get 'name tab)) (select-window (get-buffer-window bname))) (switch-to-buffer buffer))) (switch-to-buffer buffer))) @@ -449,12 +484,16 @@ Default is `helm-current-buffer'." ((and (boundp 'outline-minor-mode) outline-minor-mode) #'outline-show-subtree) + ((and (boundp 'hs-minor-mode) + hs-minor-mode) + #'hs-show-block) ((and (boundp 'markdown-mode-map) (derived-mode-p 'markdown-mode)) - #'markdown-show-subtree)))) + #'markdown-show-entry))) + (hs-show-hook (list (lambda () (goto-char loc))))) ;; outline may fail in some conditions e.g. with markdown enabled ;; (issue #1919). - (condition-case nil + (condition-case-unless-debug nil (and fn (funcall fn)) (error nil)))) @@ -489,7 +528,7 @@ To use this add it to `helm-goto-line-before-hook'." (defun helm-show-all-candidates-in-source (arg) "Toggle all or only candidate-number-limit cands in current source. With a numeric prefix arg show only the ARG number of candidates. -The prefix arg have no effect when toggling to only +The prefix arg has no effect when toggling to only candidate-number-limit." (interactive "p") (with-helm-alive-p @@ -538,6 +577,7 @@ from its directory." (with-helm-alive-p (require 'helm-grep) (require 'helm-elisp) + (require 'bookmark) ; For bookmark-alist (helm-run-after-exit (lambda (f) ;; Ensure specifics `helm-execute-action-at-once-if-one' @@ -557,7 +597,7 @@ from its directory." (grep-line (and (stringp sel) (helm-grep-split-line sel))) (occur-fname (helm-aand (numberp sel) - (helm-attr 'buffer-name) + (helm-get-attr 'buffer-name) (buffer-file-name (get-buffer it)))) (bmk-name (and (stringp sel) (not grep-line) @@ -641,18 +681,22 @@ that is sorting is done against real value of candidate." ((string-match r2 str) 2) ((string-match r3 str) 1) (t 0))))) - (sc1 (funcall score str1 reg1 reg2 reg3 split)) - (sc2 (funcall score str2 reg1 reg2 reg3 split))) - (cond ((or (zerop (string-width qpattern)) - (and (zerop sc1) (zerop sc2))) + (sc1 (get-text-property 0 'completion-score str1)) + (sc2 (get-text-property 0 'completion-score str2)) + (sc3 (if sc1 0 (funcall score str1 reg1 reg2 reg3 split))) + (sc4 (if sc2 0 (funcall score str2 reg1 reg2 reg3 split)))) + (cond ((and sc1 sc2) ; helm-flex style. + (> sc1 sc2)) + ((or (zerop (string-width qpattern)) + (and (zerop sc3) (zerop sc4))) (string-lessp str1 str2)) - ((= sc1 sc2) + ((= sc3 sc4) (< (length str1) (length str2))) - (t (> sc1 sc2))))) + (t (> sc3 sc4))))) (cl-defun helm-file-human-size (size &optional (kbsize helm-default-kbsize)) "Return a string showing SIZE of a file in human readable form. -SIZE can be an integer or a float depending it's value. +SIZE can be an integer or a float depending on it's value. `file-attributes' will take care of that to avoid overflow error. KBSIZE is a floating point number, defaulting to `helm-default-kbsize'." (cl-loop with result = (cons "B" size) @@ -664,6 +708,24 @@ KBSIZE is a floating point number, defaulting to `helm-default-kbsize'." ("B" (format "%s" size)) (t (format "%.1f%s" (cdr result) it))))) +(defun helm-directory-size (directory &optional recursive human) + "Return the resulting size of the sum of all files in DIRECTORY. + +If RECURSIVE is non nil return the size of all files in DIRECTORY and +its subdirectories. With arg HUMAN format the size in a human +readable format,see `helm-file-human-size'." + (cl-loop with files = (if recursive + (helm-walk-directory + directory + :path 'full + :directories t) + (directory-files directory t)) + for file in files + sum (nth 7 (file-attributes file)) into total + finally return (if human + (helm-file-human-size total) + total))) + (cl-defun helm-file-attributes (file &key type links uid gid access-time modif-time status size mode gid-change inode device-num dired human-size @@ -781,8 +843,9 @@ Inlined here for compatibility." (defmacro with-helm-display-marked-candidates (buffer-or-name candidates &rest body) (declare (indent 0) (debug t)) - (helm-with-gensyms (buffer window) + (helm-with-gensyms (buffer window winconf) `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name)) + (,winconf helm-last-frame-or-window-configuration) (helm-always-two-windows t) (helm-split-window-default-side (if (eq helm-split-window-default-side 'same) @@ -799,7 +862,8 @@ Inlined here for compatibility." '(display-buffer-below-selected (window-height . fit-window-to-buffer)))) (progn ,@body)) - (quit-window 'kill ,window))))) + (quit-window 'kill ,window) + (and ,winconf (set-window-configuration ,winconf)))))) ;;; Persistent Action Helpers ;; @@ -808,7 +872,7 @@ Inlined here for compatibility." (defvar helm-match-line-overlay nil) (defvar helm--match-item-overlays nil) -(defun helm-highlight-current-line (&optional start end buf face) +(cl-defun helm-highlight-current-line (&optional start end buf face) "Highlight and underline current position" (let* ((start (or start (line-beginning-position))) (end (or end (1+ (line-end-position)))) @@ -826,20 +890,40 @@ Inlined here for compatibility." ;; Now highlight matches only if we are in helm session, we are ;; maybe coming from helm-grep-mode or helm-moccur-mode buffers. (when helm-alive-p - (if (or (null helm-highlight-matches-around-point-max-lines) - (zerop helm-highlight-matches-around-point-max-lines)) - (setq start-match start - end-match end) - (setq start-match - (save-excursion - (forward-line - (- helm-highlight-matches-around-point-max-lines)) - (point-at-bol)) - end-match - (save-excursion - (forward-line - helm-highlight-matches-around-point-max-lines) - (point-at-bol)))) + (cond (;; These 2 clauses have to be the first otherwise + ;; `helm-highlight-matches-around-point-max-lines' is + ;; compared as a number by other clauses and return an error. + (eq helm-highlight-matches-around-point-max-lines 'never) + (cl-return-from helm-highlight-current-line)) + ((consp helm-highlight-matches-around-point-max-lines) + (setq start-match + (save-excursion + (forward-line + (- (car helm-highlight-matches-around-point-max-lines))) + (point-at-bol)) + end-match + (save-excursion + (forward-line + (cdr helm-highlight-matches-around-point-max-lines)) + (point-at-bol)))) + ((or (null helm-highlight-matches-around-point-max-lines) + (zerop helm-highlight-matches-around-point-max-lines)) + (setq start-match start + end-match end)) + ((< helm-highlight-matches-around-point-max-lines 0) + (setq start-match + (save-excursion + (forward-line + helm-highlight-matches-around-point-max-lines) + (point-at-bol)) + end-match start)) + ((> helm-highlight-matches-around-point-max-lines 0) + (setq start-match start + end-match + (save-excursion + (forward-line + helm-highlight-matches-around-point-max-lines) + (point-at-bol))))) (catch 'empty-line (cl-loop with ov for r in (helm-remove-if-match @@ -852,9 +936,10 @@ Inlined here for compatibility." do (save-excursion (goto-char start-match) (while (condition-case _err - (if helm-migemo-mode - (helm-mm-migemo-forward r end-match t) - (re-search-forward r end-match t)) + (and (not (= start-match end-match)) + (if helm-migemo-mode + (helm-mm-migemo-forward r end-match t) + (re-search-forward r end-match t))) (invalid-regexp nil)) (let ((s (match-beginning 0)) (e (match-end 0))) @@ -898,6 +983,8 @@ Assume regexp is a pcre based regexp." (helm-match-line-cleanup))) (defun helm-match-line-update () + (when helm--match-item-overlays + (mapc 'delete-overlay helm--match-item-overlays)) (when helm-match-line-overlay (delete-overlay helm-match-line-overlay) (helm-highlight-current-line))) @@ -974,8 +1061,9 @@ Assume regexp is a pcre based regexp." file)))) (defun helm-open-dired (file) - "Opens a dired buffer in FILE's directory. If FILE is a -directory, open this directory." + "Open a dired buffer in FILE's directory. +If FILE is a directory, open this directory." + (require 'dired) (if (file-directory-p file) (dired file) (dired (file-name-directory file)) @@ -1004,7 +1092,7 @@ directory, open this directory." (defun helm-find-many-files (_ignore) "Simple action that run `find-file' on marked candidates. -Run `helm-find-many-files-after-hook' at end" +Run `helm-find-many-files-after-hook' at end." (let ((helm--reading-passwd-or-string t)) (mapc 'find-file (helm-marked-candidates)) (helm-log-run-hook 'helm-find-many-files-after-hook))) @@ -1021,7 +1109,7 @@ If COUNT is non--nil add a number after each prompt." finally return (remove "" lis))) (defun helm-html-bookmarks-to-alist (file url-regexp bmk-regexp) - "Parse html bookmark FILE and return an alist with (title . url) as elements." + "Parse HTML bookmark FILE and return an alist with (title . url) as elements." (let (bookmarks-alist url title) (with-temp-buffer (insert-file-contents file) @@ -1039,7 +1127,7 @@ If COUNT is non--nil add a number after each prompt." (nreverse bookmarks-alist))) (defun helm-html-entity-to-string (entity) - "Replace an html ENTITY by its string value. + "Replace an HTML ENTITY with its string value. When unable to decode ENTITY returns nil." (helm-aif (assoc entity helm-html-entities-alist) (string (cdr it)) diff --git a/elpa/helm-20191101.641/helm-x-files.el b/elpa/helm-20210131.1946/helm-x-files.el similarity index 93% rename from elpa/helm-20191101.641/helm-x-files.el rename to elpa/helm-20210131.1946/helm-x-files.el index 3dc9639f..a1c97275 100644 --- a/elpa/helm-20191101.641/helm-x-files.el +++ b/elpa/helm-20210131.1946/helm-x-files.el @@ -1,6 +1,6 @@ ;;; helm-x-files.el --- helm auxiliary functions and sources. -*- lexical-binding: t -*- -;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -15,6 +15,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +;;; Commentary: + ;;; Code: (require 'helm-for-files) @@ -23,7 +25,10 @@ ;;; List of files gleaned from every dired buffer ;; ;; +(defvar dired-buffers) +(defvar dired-re-no-dot) (defun helm-files-in-all-dired-candidates () + "Return a list of files from live `dired' buffers." (save-excursion (cl-loop for (f . b) in dired-buffers when (buffer-live-p b) @@ -74,6 +79,7 @@ ;; Tracker desktop search (defun helm-source-tracker-transformer (candidates _source) + "Return file names from tracker CANDIDATES." ;; loop through tracker candidates selecting out file:// lines ;; then select part after file:// and url decode to get straight filenames (cl-loop for cand in candidates @@ -101,7 +107,7 @@ :action-transformer '(helm-transform-file-load-el helm-transform-file-browse-url) :requires-pattern 3) - "Source for retrieving files matching the current input pattern + "Source for retrieving files matching the current input pattern \ with the tracker desktop search.") ;; Spotlight (MacOS X desktop search) @@ -114,8 +120,7 @@ with the tracker desktop search.") (defvar helm-source-mac-spotlight (helm-make-source "mdfind" 'helm-mac-spotlight-source) - "Source for retrieving files via Spotlight's command line -utility mdfind.") + "Source for retrieving files via Spotlight's command line utility mdfind.") (provide 'helm-x-files) diff --git a/elpa/helm-core-20191031.1931/helm-core-pkg.el b/elpa/helm-core-20191031.1931/helm-core-pkg.el deleted file mode 100644 index 9a486e1b..00000000 --- a/elpa/helm-core-20191031.1931/helm-core-pkg.el +++ /dev/null @@ -1,7 +0,0 @@ -(define-package "helm-core" "20191031.1931" "Development files for Helm" - '((emacs "24.4") - (async "1.9.3")) - :url "https://emacs-helm.github.io/helm/") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/helm-core-20191031.1931/helm-core-autoloads.el b/elpa/helm-core-20210128.1814/helm-core-autoloads.el similarity index 82% rename from elpa/helm-core-20191031.1931/helm-core-autoloads.el rename to elpa/helm-core-20210128.1814/helm-core-autoloads.el index 48f40c77..7d831568 100644 --- a/elpa/helm-core-20191031.1931/helm-core-autoloads.el +++ b/elpa/helm-core-20210128.1814/helm-core-autoloads.el @@ -9,13 +9,16 @@ ;;;### (autoloads nil "helm" "helm.el" (0 0 0 0)) ;;; Generated autoloads from helm.el +(autoload 'helm-configuration "helm" "\ +Customize Helm." t nil) + (autoload 'helm-define-multi-key "helm" "\ In KEYMAP, define key sequence KEY for function list FUNCTIONS. Each function runs sequentially for each KEY press. If DELAY is specified, switch back to initial function of FUNCTIONS list after DELAY seconds. The functions in FUNCTIONS list take no args. -e.g +E.g. (defun foo () (interactive) (message \"Run foo\")) @@ -28,9 +31,9 @@ e.g \(helm-define-multi-key global-map (kbd \" q\") '(foo bar baz) 2) -Each time \" q\" is pressed, the next function is executed. Waiting -more than 2 seconds between key presses switches back to executing the first -function on the next hit. +Each time \" q\" is pressed, the next function is executed. +Waiting more than 2 seconds between key presses switches back to +executing the first function on the next hit. \(fn KEYMAP KEY FUNCTIONS &optional DELAY)" nil nil) @@ -44,44 +47,41 @@ See `helm-define-multi-key'. (function-put 'helm-multi-key-defun 'lisp-indent-function '2) (autoload 'helm-define-key-with-subkeys "helm" "\ -Defines in MAP a KEY and SUBKEY to COMMAND. +Define in MAP a KEY and SUBKEY to COMMAND. This allows typing KEY to call COMMAND the first time and type only SUBKEY on subsequent calls. -Arg MAP is the keymap to use, SUBKEY is the initial short key-binding to -call COMMAND. +Arg MAP is the keymap to use, SUBKEY is the initial short +key binding to call COMMAND. -Arg OTHER-SUBKEYS is an alist specifying other short key-bindings -to use once started e.g: +Arg OTHER-SUBKEYS is an alist specifying other short key bindings +to use once started, e.g.: (helm-define-key-with-subkeys global-map (kbd \"C-x v n\") ?n 'git-gutter:next-hunk '((?p . git-gutter:previous-hunk))) - In this example, `C-x v n' will run `git-gutter:next-hunk' -subsequent \"n\"'s run this command again -and subsequent \"p\"'s run `git-gutter:previous-hunk'. +subsequent \"n\" will run this command again and subsequent \"p\" +will run `git-gutter:previous-hunk'. -If specified PROMPT can be displayed in minibuffer to -describe SUBKEY and OTHER-SUBKEYS. -Arg EXIT-FN specifies a function to run on exit. +If specified PROMPT can be displayed in minibuffer to describe +SUBKEY and OTHER-SUBKEYS. Arg EXIT-FN specifies a function to run +on exit. -For any other keys pressed, run their assigned command as defined +For any other key pressed, run their assigned command as defined in MAP and then exit the loop running EXIT-FN, if specified. -NOTE: SUBKEY and OTHER-SUBKEYS bindings support only char syntax and -vectors, so don't use strings to define them. +NOTE: SUBKEY and OTHER-SUBKEYS bindings support only char syntax +and vectors, so don't use strings to define them. \(fn MAP KEY SUBKEY COMMAND &optional OTHER-SUBKEYS PROMPT EXIT-FN)" nil nil) (function-put 'helm-define-key-with-subkeys 'lisp-indent-function '1) (autoload 'helm-debug-open-last-log "helm" "\ -Open helm log file or buffer of last helm session. - -\(fn)" t nil) +Open Helm log file or buffer of last Helm session." t nil) (autoload 'helm "helm" "\ Main function to execute helm sources. @@ -173,9 +173,9 @@ the list items, starting with the first. If nil, `thing-at-point' is used. -If `helm--maybe-use-default-as-input' is non-`nil', display is -updated using this value, unless :input is specified, in which -case that value is used instead. +If `helm-maybe-use-default-as-input' is non-nil, display is +updated using this value if this value matches, otherwise it is +ignored. If :input is specified, it takes precedence on :default. *** :history @@ -197,7 +197,7 @@ session. The `helm-' prefix can be omitted. For example, :buffer \"*helm buffers*\" :candidate-number-limit 10) -starts a Helm session with the variable +Starts a Helm session with the variable `helm-candidate-number-limit' set to 10. ** Backward compatibility @@ -213,15 +213,13 @@ However, the use of non-keyword args is deprecated. \(fn &key SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT HISTORY ALLOW-NEST OTHER-LOCAL-VARS)" nil nil) (autoload 'helm-cycle-resume "helm" "\ -Cycle in `helm-buffers' list and resume when waiting more than 1.2s. - -\(fn)" t nil) +Cycle in `helm-buffers' list and resume when waiting more than 1.2s." t nil) (autoload 'helm-other-buffer "helm" "\ -Simplified `helm' interface with other `helm-buffer'. -Call `helm' only with ANY-SOURCES and ANY-BUFFER as args. +Simplified Helm interface with other `helm-buffer'. +Call `helm' only with SOURCES and BUFFER as args. -\(fn ANY-SOURCES ANY-BUFFER)" nil nil) +\(fn SOURCES BUFFER)" nil nil) (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm" '("helm-" "with-helm-"))) diff --git a/elpa/helm-core-20210128.1814/helm-core-pkg.el b/elpa/helm-core-20210128.1814/helm-core-pkg.el new file mode 100644 index 00000000..61921426 --- /dev/null +++ b/elpa/helm-core-20210128.1814/helm-core-pkg.el @@ -0,0 +1,7 @@ +(define-package "helm-core" "20210128.1814" "Development files for Helm" + '((emacs "25.1") + (async "1.9.4")) + :commit "7023ed51ee839806adb07537e23351326ce04fd2") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/helm-core-20191031.1931/helm-lib.el b/elpa/helm-core-20210128.1814/helm-lib.el similarity index 69% rename from elpa/helm-core-20191031.1931/helm-lib.el rename to elpa/helm-core-20210128.1814/helm-lib.el index f8366bff..67d71a6f 100644 --- a/elpa/helm-core-20191031.1931/helm-lib.el +++ b/elpa/helm-core-20210128.1814/helm-lib.el @@ -1,6 +1,6 @@ ;;; helm-lib.el --- Helm routines. -*- lexical-binding: t -*- -;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2015 ~ 2020 Thierry Volpiatto ;; Author: Thierry Volpiatto ;; URL: http://github.com/emacs-helm/helm @@ -25,30 +25,36 @@ (require 'cl-lib) -(declare-function wdired-change-to-dired-mode "wdired.el") -(declare-function wdired-do-symlink-changes "wdired.el") -(declare-function wdired-do-perm-changes "wdired.el") -(declare-function wdired-get-filename "wdired.el") -(declare-function wdired-do-renames "wdired.el") -(declare-function wdired-flag-for-deletion "wdired.el") -(declare-function wdired-normalize-filename "wdired.el") -(declare-function dired-mark-remembered "dired.el") -(declare-function dired-log-summary "dired.el") -(declare-function dired-current-directory "dired.el") (declare-function ansi-color--find-face "ansi-color.el") (declare-function ansi-color-apply-sequence "ansi-color.el") +(declare-function dired-current-directory "dired.el") +(declare-function dired-log-summary "dired.el") +(declare-function dired-mark-remembered "dired.el") +(declare-function ffap-file-remote-p "ffap.el") +(declare-function ffap-url-p "ffap.el") +(declare-function helm-get-attr "helm.el") +(declare-function helm-set-attr "helm.el") +(declare-function helm-follow-mode-p "helm.el") +(declare-function helm-get-current-source "helm.el") +(declare-function helm-get-selection "helm.el") (declare-function helm-get-sources "helm.el") +(declare-function helm-interpret-value "helm.el") +(declare-function helm-log-run-hook "helm.el") (declare-function helm-marked-candidates "helm.el") -(declare-function helm-follow-mode-p "helm.el") -(declare-function helm-attr "helm.el") -(declare-function helm-attrset "helm.el") -(declare-function org-open-at-point "org.el") +(declare-function helm-set-case-fold-search "helm.el") +(declare-function helm-source--cl--print-table "helm-source.el") +(declare-function helm-update "helm.el") (declare-function org-content "org.el") (declare-function org-mark-ring-goto "org.el") (declare-function org-mark-ring-push "org.el") -(declare-function helm-interpret-value "helm.el") -(declare-function helm-get-current-source "helm.el") -(declare-function helm-source--cl--print-table "helm-source.el") +(declare-function org-open-at-point "org.el") +(declare-function wdired-change-to-dired-mode "wdired.el") +(declare-function wdired-do-perm-changes "wdired.el") +(declare-function wdired-do-renames "wdired.el") +(declare-function wdired-do-symlink-changes "wdired.el") +(declare-function wdired-flag-for-deletion "wdired.el") +(declare-function wdired-get-filename "wdired.el") +(declare-function wdired-normalize-filename "wdired.el") (defvar helm-sources) (defvar helm-initial-frame) @@ -58,12 +64,18 @@ (defvar wdired-allow-to-change-permissions) (defvar wdired-allow-to-redirect-links) (defvar helm-persistent-action-display-window) +(defvar helm--buffer-in-new-frame-p) +(defvar helm-completion-style) +(defvar helm-completion-styles-alist) +(defvar helm-persistent-action-window-buffer) +(defvar completion-flex-nospace) ;;; User vars. ;; (defcustom helm-file-globstar t "Same as globstar bash shopt option. -When non--nil a pattern beginning with two stars will expand recursively. +When non-nil a pattern beginning with two stars will expand +recursively. Directories expansion is not supported yet." :group 'helm :type 'boolean) @@ -72,8 +84,8 @@ Directories expansion is not supported yet." "The function used to forward point with `helm-yank-text-at-point'. With a nil value, fallback to default `forward-word'. The function should take one arg, an integer like `forward-word'. -NOTE: Using `forward-symbol' here is not very useful as it is already -provided by \\\\[next-history-element]." +NOTE: Using `forward-symbol' here is not very useful as it is +already provided by \\\\[next-history-element]." :type 'function :group 'helm) @@ -89,9 +101,9 @@ If you prefer scrolling line by line, set this value to 1." (defcustom helm-help-full-frame t "Display help window in full frame when non nil. -Even when `nil' probably the same result (full frame) -can be reach by tweaking `display-buffer-alist' but it is -much more convenient to use a simple boolean value here." +Even when nil probably the same result (full frame) can be +reached by tweaking `display-buffer-alist', but it is much more +convenient to use a simple boolean value here." :type 'boolean :group 'helm-help) @@ -120,15 +132,16 @@ much more convenient to use a simple boolean value here." "A list of regexps matching boring files. This list is build by default on `completion-ignored-extensions'. -The directory names should end with \"/?\" e.g. \"\\.git/?\" and the -file names should end with \"$\" e.g. \"\\.o$\". +The directory names should end with \"/?\" e.g. \"\\.git/?\" and +the file names should end with \"$\" e.g. \"\\.o$\". -These regexps may be used to match the entire path, not just the file -name, so for example to ignore files with a prefix \".bak.\", use -\"\\.bak\\..*$\" as the regexp. +These regexps may be used to match the entire path, not just the +file name, so for example to ignore files with a prefix +\".bak.\", use \"\\.bak\\..*$\" as the regexp. -NOTE: When modifying this, be sure to use customize interface or the -customize functions e.g. `customize-set-variable' and NOT `setq'." +NOTE: When modifying this, be sure to use customize interface or +the customize functions e.g. `customize-set-variable' and NOT +`setq'." :group 'helm-files :type '(repeat (choice regexp)) :set 'helm-ff--setup-boring-regex) @@ -162,9 +175,10 @@ customize functions e.g. `customize-set-variable' and NOT `setq'." ;; (defun helm-add-face-text-properties (beg end face &optional append object) "Add the face property to the text from START to END. -It is a compatibility function which behave exactly like -`add-face-text-property' if available otherwise like `add-text-properties'. -When only `add-text-properties' is available APPEND is ignored." +It is a compatibility function which behaves exactly like +`add-face-text-property' if available, otherwise like +`add-text-properties'. When only `add-text-properties' is +available APPEND is ignored." (if (fboundp 'add-face-text-property) (add-face-text-property beg end face append object) (add-text-properties beg end `(face ,face) object))) @@ -331,14 +345,35 @@ When only `add-text-properties' is available APPEND is ignored." nil) (defcustom helm-advice-push-mark t - "Override `push-mark' with a version avoiding duplicates when non nil." + "Override `push-mark' with a version avoiding duplicates when non-nil." :group 'helm :type 'boolean :set (lambda (var val) (set var val) (if val - (advice-add 'push-mark :override #'helm--advice-push-mark) + (advice-add 'push-mark :override #'helm--advice-push-mark '((depth . 100))) (advice-remove 'push-mark #'helm--advice-push-mark)))) + +;; This the version of Emacs-27 written by Stefan +(defun helm-advice--ffap-read-file-or-url (prompt guess) + (or guess (setq guess default-directory)) + (if (ffap-url-p guess) + (read-string prompt guess nil nil t) + (unless (ffap-file-remote-p guess) + (setq guess (abbreviate-file-name (expand-file-name guess)))) + (read-file-name prompt (file-name-directory guess) nil nil + (file-name-nondirectory guess)))) + +;; The native-comp branch of emacs "is a modified Emacs capable of compiling +;; and running Emacs Lisp as native code in form of re-loadable elf files." +;; (https://akrl.sdf.org/gccemacs.html). The function subr-native-elisp-p is a +;; native function available only in this branch and evaluates to true if the +;; argument supplied is a natively compiled lisp function. Use this function +;; if it's available, otherwise return nil. Helm needs to distinguish compiled +;; functions from other symbols in a various places. +(defun helm-subr-native-elisp-p (object) + (when (fboundp 'subr-native-elisp-p) + (subr-native-elisp-p object))) ;;; Macros helper. ;; @@ -358,9 +393,9 @@ When only `add-text-properties' is available APPEND is ignored." ;;; Command loop helper ;; (defun helm-this-command () - "Returns the actual command in action. -Like `this-command' but return the real command, -and not `exit-minibuffer' or other unwanted functions." + "Return the actual command in action. +Like `this-command' but return the real command, and not +`exit-minibuffer' or other unwanted functions." (cl-loop with bl = '(helm-maybe-exit-minibuffer helm-confirm-and-exit-minibuffer helm-exit-minibuffer @@ -390,7 +425,7 @@ and not `exit-minibuffer' or other unwanted functions." Returns ITEM first occurence position found in SEQ. When SEQ is a string, ITEM have to be specified as a char. Argument TEST when unspecified default to `eq'. -When argument ALL is non--nil return a list of all ITEM positions +When argument ALL is non-nil return a list of all ITEM positions found in SEQ." (let ((key (if (stringp seq) 'across 'in))) `(cl-loop with deftest = 'eq @@ -434,18 +469,19 @@ found in SEQ." ;; (defmacro helm-aif (test-form then-form &rest else-forms) "Anaphoric version of `if'. -Like `if' but set the result of TEST-FORM in a temporary variable called `it'. -THEN-FORM and ELSE-FORMS are then excuted just like in `if'." +Like `if' but set the result of TEST-FORM in a temporary variable +called `it'. THEN-FORM and ELSE-FORMS are then executed just like +in `if'." (declare (indent 2) (debug t)) `(let ((it ,test-form)) (if it ,then-form ,@else-forms))) (defmacro helm-awhile (sexp &rest body) "Anaphoric version of `while'. -Same usage as `while' except that SEXP is bound to -a temporary variable called `it' at each turn. -An implicit nil block is bound to the loop so usage -of `cl-return' is possible to exit the loop." +Same usage as `while' except that SEXP is bound to a temporary +variable called `it' at each turn. +An implicit nil block is bound to the loop so usage of +`cl-return' is possible to exit the loop." (declare (indent 1) (debug t)) (helm-with-gensyms (flag) `(let ((,flag t)) @@ -457,10 +493,10 @@ of `cl-return' is possible to exit the loop." (defmacro helm-acond (&rest clauses) "Anaphoric version of `cond'. -In each clause of CLAUSES, the result of the car of clause -is stored in a temporary variable called `it' and usable in the cdr -of this same clause. Each `it' variable is independent of its clause. -The usage is the same as `cond'." +In each clause of CLAUSES, the result of the car of clause is +stored in a temporary variable called `it' and usable in the cdr +of this same clause. Each `it' variable is independent of its +clause. The usage is the same as `cond'." (declare (debug cond)) (unless (null clauses) (helm-with-gensyms (sym) @@ -474,8 +510,8 @@ The usage is the same as `cond'." (defmacro helm-aand (&rest conditions) "Anaphoric version of `and'. -Each condition is bound to a temporary variable called `it' which is -usable in next condition." +Each condition is bound to a temporary variable called `it' which +is usable in next condition." (declare (debug (&rest form))) (cond ((null conditions) t) ((null (cdr conditions)) (car conditions)) @@ -484,8 +520,8 @@ usable in next condition." (defmacro helm-acase (expr &rest clauses) "A simple anaphoric `cl-case' implementation handling strings. -EXPR is bound to a temporary variable called `it' which is usable in -CLAUSES to refer to EXPR. +EXPR is bound to a temporary variable called `it' which is usable +in CLAUSES to refer to EXPR. NOTE: Duplicate keys in CLAUSES are deliberately not handled. \(fn EXPR (KEYLIST BODY...)...)" @@ -504,10 +540,10 @@ NOTE: Duplicate keys in CLAUSES are deliberately not handled. ;; (defsubst helm--mapconcat-pattern (pattern) "Transform string PATTERN in regexp for further fuzzy matching. -e.g helm.el$ - => \"[^h]*h[^e]*e[^l]*l[^m]*m[^.]*[.][^e]*e[^l]*l$\" - ^helm.el$ - => \"helm[.]el$\"." +E.g.: helm.el$ + => \"[^h]*h[^e]*e[^l]*l[^m]*m[^.]*[.][^e]*e[^l]*l$\" + ^helm.el$ + => \"helm[.]el$\"." (let ((ls (split-string-and-unquote pattern ""))) (if (string= "^" (car ls)) ;; Exact match. @@ -530,12 +566,76 @@ e.g helm.el$ ;;; Help routines. ;; +(defvar helm-help--iter-org-state nil) + +(defvar helm-help-mode-before-hook nil + "A hook that runs before helm-help starts.") + +(defvar helm-help-mode-after-hook nil + "A hook that runs when helm-help exits.") + +(defcustom helm-help-default-prompt + "[SPC,C-v,next:ScrollUp b,M-v,prior:ScrollDown TAB:Cycle M-TAB:All C-s/r:Isearch q:Quit]" + "The prompt used in `helm-help'." + :type 'string + :group 'helm) + +(defcustom helm-help-hkmap + '(("C-v" . helm-help-scroll-up) + ("SPC" . helm-help-scroll-up) + ("" . helm-help-scroll-up) + ("M-v" . helm-help-scroll-down) + ("b" . helm-help-scroll-down) + ("" . helm-help-scroll-down) + ("C-s" . isearch-forward) + ("C-r" . isearch-backward) + ("C-a" . move-beginning-of-line) + ("C-e" . move-end-of-line) + ("C-f" . forward-char) + ("" . forward-char) + ("C-b" . backward-char) + ("" . backward-char) + ("C-n" . helm-help-next-line) + ("C-p" . helm-help-previous-line) + ("" . helm-help-next-line) + ("" . helm-help-previous-line) + ("M-a" . backward-sentence) + ("M-e" . forward-sentence) + ("M-f" . forward-word) + ("M-b" . backward-word) + ("M->" . end-of-buffer) + ("M-<" . beginning-of-buffer) + ("C-SPC" . helm-help-toggle-mark) + ("C-M-SPC" . mark-sexp) + ("TAB" . org-cycle) + ("C-m" . helm-help-org-open-at-point) + ("C-&" . helm-help-org-mark-ring-goto) + ("C-%" . org-mark-ring-push) + ("M-TAB" . helm-help-org-cycle) + ("M-w" . helm-help-copy-region-as-kill) + ("q" . helm-help-quit)) + "Alist of (KEY . FUNCTION) for `helm-help'. + +This is not a standard keymap, just an alist where it is possible to +define a simple KEY (a string with no spaces) associated with a +FUNCTION. More complex key like \"C-x C-x\" are not supported. +Interactive functions will be called interactively whereas other +functions will be called with funcall except commands that are in +`helm-help-not-interactive-command'. +For convenience you can add bindings here with `helm-help-define-key'." + :type '(alist :key-type string :key-value symbol) + :group 'helm) + +(defvar helm-help-not-interactive-command '(isearch-forward isearch-backward) + "Commands that we don't want to call interactively in `helm-help'.") + (defun helm-help-internal (bufname insert-content-fn) - "Show long message during `helm' session in BUFNAME. -INSERT-CONTENT-FN is the function that insert -text to be displayed in BUFNAME." + "Show long message during Helm session in BUFNAME. +INSERT-CONTENT-FN is the function that inserts text to be +displayed in BUFNAME." (let ((winconf (current-frame-configuration)) (hframe (selected-frame))) + (helm-log-run-hook 'helm-help-mode-before-hook) (with-selected-frame helm-initial-frame (select-frame-set-input-focus helm-initial-frame) (unwind-protect @@ -552,88 +652,120 @@ text to be displayed in BUFNAME." (buffer-disable-undo) (helm-help-event-loop)) (raise-frame hframe) + (helm-log-run-hook 'helm-help-mode-after-hook) (setq helm-suspend-update-flag nil) (set-frame-configuration winconf))))) -(defun helm-help-scroll-up (amount) +(cl-defun helm-help-scroll-up (&optional (amount helm-scroll-amount)) + "Scroll up in `helm-help'." (condition-case _err (scroll-up-command amount) (beginning-of-buffer nil) (end-of-buffer nil))) -(defun helm-help-scroll-down (amount) +(cl-defun helm-help-scroll-down (&optional (amount helm-scroll-amount)) + "Scroll down in `helm-help'." (condition-case _err (scroll-down-command amount) (beginning-of-buffer nil) (end-of-buffer nil))) (defun helm-help-next-line () + "Next line function for `helm-help'." (condition-case _err (call-interactively #'next-line) (beginning-of-buffer nil) (end-of-buffer nil))) (defun helm-help-previous-line () + "Previous line function for `helm-help'." (condition-case _err (call-interactively #'previous-line) (beginning-of-buffer nil) (end-of-buffer nil))) (defun helm-help-toggle-mark () + "Toggle mark in `helm-help'." (if (region-active-p) (deactivate-mark) (push-mark nil nil t))) -;; For movement of cursor in help buffer we need to call interactively -;; commands for impaired people using a synthetizer (#1347). +(defun helm-help-org-cycle () + "Runs `org-cycle' in `helm-help'." + (pcase (helm-iter-next helm-help--iter-org-state) + ((pred numberp) (org-content)) + ((and state) (org-cycle state)))) + +(defun helm-help-copy-region-as-kill () + "Copy region function for `helm-help'" + (copy-region-as-kill + (region-beginning) (region-end)) + (deactivate-mark)) + +(defun helm-help-quit () + "Quit `helm-help'." + (throw 'helm-help-quit nil)) + +(defun helm-help-org-open-at-point () + "Calls `org-open-at-point' ignoring errors." + (ignore-errors + (org-open-at-point))) + +(defun helm-help-org-mark-ring-goto () + "Calls `org-mark-ring-goto' ignoring errors." + (ignore-errors + (org-mark-ring-goto))) + (defun helm-help-event-loop () + "The loop in charge of scanning keybindings in `helm-help'." (let ((prompt (propertize - "[SPC,C-v,next:ScrollUp b,M-v,prior:ScrollDown TAB:Cycle M-TAB:All C-s/r:Isearch q:Quit]" + helm-help-default-prompt 'face 'helm-helper)) scroll-error-top-bottom - (iter-org-state (helm-iter-circular '(1 (16) (64))))) - (helm-awhile (read-key prompt) - (cl-case it - ((?\C-v ? next) (helm-help-scroll-up helm-scroll-amount)) - ((?\M-v ?b prior) (helm-help-scroll-down helm-scroll-amount)) - (?\C-s (isearch-forward)) - (?\C-r (isearch-backward)) - (?\C-a (call-interactively #'move-beginning-of-line)) - (?\C-e (call-interactively #'move-end-of-line)) - ((?\C-f right) (call-interactively #'forward-char)) - ((?\C-b left) (call-interactively #'backward-char)) - ((?\C-n down) (helm-help-next-line)) - ((?\C-p up) (helm-help-previous-line)) - (?\M-a (call-interactively #'backward-sentence)) - (?\M-e (call-interactively #'forward-sentence)) - (?\M-f (call-interactively #'forward-word)) - (?\M-b (call-interactively #'backward-word)) - (?\M-> (call-interactively #'end-of-buffer)) - (?\M-< (call-interactively #'beginning-of-buffer)) - (?\C- (helm-help-toggle-mark)) - (?\t (org-cycle)) - (?\C-m (ignore-errors (call-interactively #'org-open-at-point))) - (?\C-& (ignore-errors (call-interactively #'org-mark-ring-goto))) - (?\C-% (call-interactively #'org-mark-ring-push)) - (?\M-\t (pcase (helm-iter-next iter-org-state) - ((pred numberp) (org-content)) - ((and state) (org-cycle state)))) - (?\M-w (copy-region-as-kill - (region-beginning) (region-end)) - (deactivate-mark)) - (?q (cl-return)) - (t (ignore)))))) - + (helm-help--iter-org-state (helm-iter-circular '(1 (16) (64))))) + (catch 'helm-help-quit + (helm-awhile (read-key prompt) + (let ((fun (cl-loop for (k . v) in helm-help-hkmap + when (eql (aref (kbd k) 0) it) + return v))) + (when fun + (if (and (commandp fun) + (not (memq fun helm-help-not-interactive-command))) + ;; For movement of cursor in help buffer we need to + ;; call interactively commands for impaired people + ;; using a synthetizer (#1347). + (call-interactively fun) + (funcall fun)))))))) + +(defun helm-help-define-key (key function &optional override) + "Add KEY bound to fUNCTION in `helm-help-hkmap'. + +If OVERRIDE is non nil, all bindings associated with FUNCTION are +removed and only (KEY . FUNCTION) is kept. +If FUNCTION is nil (KEY . FUNCTION) is not added and removed from +alist if already present. +See `helm-help-hkmap' for supported keys and functions." + (cl-assert (not (cdr (split-string key))) nil + (format "Error: Unsuported key `%s'" key)) + (when override + (helm-awhile (rassoc function helm-help-hkmap) + (setq helm-help-hkmap (delete it helm-help-hkmap)))) + (helm-aif (and (null function) (assoc key helm-help-hkmap)) + (setq helm-help-hkmap (delete it helm-help-hkmap)) + (and function (add-to-list 'helm-help-hkmap `(,key . ,function))))) ;;; Multiline transformer ;; (defun helm-multiline-transformer (candidates _source) (cl-loop with offset = (helm-interpret-value (assoc-default 'multiline (helm-get-current-source))) - for i in candidates + for cand in candidates + for disp = (or (car-safe cand) cand) + for real = (or (cdr-safe cand) cand) if (numberp offset) - collect (cons (helm--multiline-get-truncated-candidate i offset) i) - else collect i)) + collect (cons (helm--multiline-get-truncated-candidate disp offset) + real) + else collect (cons disp real))) (defun helm--multiline-get-truncated-candidate (candidate offset) "Truncate CANDIDATE when its length is > than OFFSET." @@ -688,12 +820,13 @@ This is same as `remove-duplicates' but with memoisation. It is much faster, especially in large lists. A test function can be provided with TEST argument key. Default is `eq'. -NOTE: Comparison of special elisp objects (e.g. markers etc...) fails -because their printed representations which are stored in hash-table -can't be compared with with the real object in SEQ. -This is a bug in `puthash' which store the printable representation of -object instead of storing the object itself, this to provide at the -end a printable representation of hashtable itself." +NOTE: Comparison of special Elisp objects (e.g., markers etc.) +fails because their printed representations which are stored in +hash-table can't be compared with with the real object in SEQ. +This is a bug in `puthash' which store the printable +representation of object instead of storing the object itself, +this to provide at the end a printable representation of +hashtable itself." (cl-loop with cont = (make-hash-table :test test) for elm in seq unless (gethash elm cont) @@ -707,10 +840,10 @@ end a printable representation of hashtable itself." "Return a regexp which matches any of the regexps in REGEXP-LIST." (if regexp-list (concat "\\(?:" (helm--string-join regexp-list "\\)\\|\\(?:") "\\)") - "\\<\\>")) ; Match nothing + "\\`\\'")) ; Match nothing (defun helm-skip-entries (seq black-regexp-list &optional white-regexp-list) - "Remove entries which matches one of REGEXP-LIST from SEQ." + "Remove entries which match one of REGEXP-LIST from SEQ." (let ((black-regexp (helm--concat-regexps black-regexp-list)) (white-regexp (helm--concat-regexps white-regexp-list))) (cl-loop for i in seq @@ -721,10 +854,13 @@ end a printable representation of hashtable itself." collect i))) (defun helm-boring-directory-p (directory black-list) - "Check if one regexp in BLACK-LIST match DIRECTORY." + "Check if one regexp in BLACK-LIST matches DIRECTORY." (helm-awhile (helm-basedir (directory-file-name (expand-file-name directory))) - (when (string= it "/") (cl-return nil)) + ;; Break at root to avoid infloop, root is / or on Windows + ;; C:/ i.e. :/ (issue #2308). + (when (string-match-p "\\`[A-Za-z]?:?/\\'" it) + (cl-return nil)) (when (cl-loop for r in black-list thereis (string-match-p r (directory-file-name directory))) @@ -779,24 +915,35 @@ ARGS is (cand1 cand2 ...) or ((disp1 . real1) (disp2 . real2) ...) else collect (funcall function arg))) +(defsubst helm-append-1 (elm seq) + "Append ELM to SEQ. +If ELM is not a list transform it in list." + (append (helm-mklist elm) seq)) + (defun helm-append-at-nth (seq elm index) "Append ELM at INDEX in SEQ." (let ((len (length seq))) - (cond ((> index len) (setq index len)) - ((< index 0) (setq index 0))) + (setq index (min (max index 0) len)) (if (zerop index) - (append elm seq) + (helm-append-1 elm seq) (cl-loop for i in seq for count from 1 collect i when (= count index) - if (listp elm) append elm + if (and (listp elm) (not (functionp elm))) + append elm else collect elm)))) +(defun helm-take-first-elements (seq n) + "Return the first N elements of SEQ if SEQ is longer than N. +It is used for narrowing list of candidates to the +`helm-candidate-number-limit'." + (if (> (length seq) n) (cl-subseq seq 0 n) seq)) + (defun helm-source-by-name (name &optional sources) "Get a Helm source in SOURCES by NAME. -Optional argument SOURCES is a list of Helm sources which default to -`helm-sources'." +Optional argument SOURCES is a list of Helm sources which default +to `helm-sources'." (cl-loop with src-list = (if sources (cl-loop for src in sources collect (if (listp src) @@ -808,8 +955,8 @@ Optional argument SOURCES is a list of Helm sources which default to (defun helm-make-actions (&rest args) "Build an alist with (NAME . ACTION) elements with each pairs in ARGS. -Where NAME is a string or a function returning a string or nil and ACTION -a function. +Where NAME is a string or a function returning a string or nil +and ACTION a function. If NAME returns nil the pair is skipped. \(fn NAME ACTION ...)" @@ -818,6 +965,15 @@ If NAME returns nil the pair is skipped. do (setq name (funcall name)) when name collect (cons name fn))) + +(defun helm-closest-number-in-list (num list) + "Return closest number to NUM found in LIST. +LIST is a list of numbers and NUM a number." + (cl-loop for i in list + for diff = (if (> num i) (- num i) (- i num)) + collect (cons diff i) into res + minimize diff into min + finally return (cdr (assq min res)))) ;;; Strings processing. ;; @@ -842,7 +998,8 @@ Handle multibyte characters by moving by columns." "Truncate string STR to end at column WIDTH. Similar to `truncate-string-to-width'. Add ENDSTR at end of truncated STR. -Add spaces at end if needed to reach WIDTH when STR is shorter than WIDTH." +Add spaces at end if needed to reach WIDTH when STR is shorter +than WIDTH." (cl-loop for ini-str = str then (substring ini-str 0 (1- (length ini-str))) for sw = (string-width ini-str) @@ -890,7 +1047,7 @@ Add spaces at end if needed to reach WIDTH when STR is shorter than WIDTH." Same as `replace-regexp-in-string' but handle properly REP as function with SUBEXP specified. -e.g +E.g.: (helm--replace-regexp-in-buffer-string \"e\\\\(m\\\\)acs\" 'upcase \"emacs\" t nil 1) => \"eMacs\" @@ -898,10 +1055,10 @@ e.g (replace-regexp-in-string \"e\\\\(m\\\\)acs\" 'upcase \"emacs\" t nil 1) => \"eEMACSacs\" -Also START argument behave as expected unlike +Also START argument behaves as expected unlike `replace-regexp-in-string'. -e.g +E.g.: (helm--replace-regexp-in-buffer-string \"f\" \"r\" \"foofoo\" t nil nil 3) => \"fooroo\" @@ -910,14 +1067,14 @@ e.g => \"roo\" Unlike `replace-regexp-in-string' this function is buffer-based -implemented i.e replacement is computed inside a temp buffer, so +implemented i.e. replacement is computed inside a temp buffer, so REGEXP should be used differently than with `replace-regexp-in-string'. NOTE: This function is used internally for `helm-ff-query-replace-on-filenames' and builded for this. -You should use `replace-regexp-in-string' instead unless the behavior -of this function is really needed." +You should use `replace-regexp-in-string' instead unless the +behaviour of this function is really needed." (with-temp-buffer (insert str) (goto-char (or start (point-min))) @@ -948,7 +1105,7 @@ of this function is really needed." "Prompt user for an answer. Arg PROMPT is the prompt to present user the different possible answers, ANSWER-LIST is a list of strings. -If user enter an answer which is one of ANSWER-LIST return this +If user enters an answer which is one of ANSWER-LIST return this answer, otherwise keep prompting for a valid answer. Note that answer should be a single char, only short answer are accepted. @@ -965,30 +1122,32 @@ Example: (\"q\" \"quit\"))) " - (helm-awhile (string - (read-key (propertize prompt 'face 'minibuffer-prompt))) - (if (member it answer-list) - (cl-return it) - (message "Please answer by %s" (mapconcat 'identity answer-list ", ")) - (sit-for 1)))) + (helm-awhile (read-key (propertize prompt 'face 'minibuffer-prompt)) + (let ((str (and (characterp it) (string it)))) + (if (and str (member str answer-list)) + (cl-return str) + (message "Please answer by %s" (mapconcat 'identity answer-list ", ")) + (sit-for 1))))) ;;; Symbols routines ;; (defun helm-symbolify (str-or-sym) "Get symbol of STR-OR-SYM." - (if (symbolp str-or-sym) - str-or-sym - (intern str-or-sym))) + (cond ((symbolp str-or-sym) + str-or-sym) + ((equal str-or-sym "") nil) + (t (intern str-or-sym)))) (defun helm-symbol-name (obj) (if (or (and (consp obj) (functionp obj)) - (byte-code-function-p obj)) + (byte-code-function-p obj) + (helm-subr-native-elisp-p obj)) "Anonymous" (symbol-name obj))) (defun helm-describe-class (class) "Display documentation of Eieio CLASS, a symbol or a string." - (advice-add 'cl--print-table :override #'helm-source--cl--print-table) + (advice-add 'cl--print-table :override #'helm-source--cl--print-table '((depth . 100))) (unwind-protect (let ((helm-describe-function-function 'describe-function)) (helm-describe-function class)) @@ -1014,16 +1173,17 @@ Example: (defun helm-elisp--persistent-help (candidate fun &optional name) "Used to build persistent actions describing CANDIDATE with FUN. -Argument NAME is used internally to know which command to use when -symbol CANDIDATE refers at the same time to variable and a function. +Argument NAME is used internally to know which command to use +when symbol CANDIDATE refers at the same time to a variable and a +function. See `helm-elisp-show-help'." (let ((hbuf (get-buffer (help-buffer)))) (cond ((helm-follow-mode-p) (if name (funcall fun candidate name) (funcall fun candidate))) - ((or (and (helm-attr 'help-running-p) - (string= candidate (helm-attr 'help-current-symbol)))) + ((or (and (helm-get-attr 'help-running-p) + (string= candidate (helm-get-attr 'help-current-symbol)))) (progn ;; When started from a help buffer, ;; Don't kill this buffer as it is helm-current-buffer. @@ -1037,18 +1197,18 @@ See `helm-elisp-show-help'." (if helm--buffer-in-new-frame-p helm-current-buffer helm-persistent-action-window-buffer))) - (helm-attrset 'help-running-p nil)) + (helm-set-attr 'help-running-p nil)) ;; Force running update hook to may be delete ;; helm-persistent-action-display-window, this is done in - ;; helm-persistent-action-display-window (the function). + ;; helm-persistent-action-display-window (the function). (unless helm--buffer-in-new-frame-p (helm-update (regexp-quote (helm-get-selection))))) (t (if name (funcall fun candidate name) (funcall fun candidate)) - (helm-attrset 'help-running-p t))) - (helm-attrset 'help-current-symbol candidate))) + (helm-set-attr 'help-running-p t))) + (helm-set-attr 'help-current-symbol candidate))) (defun helm-find-function (func) "FUNC is symbol or string." @@ -1120,12 +1280,12 @@ Argument ALIST is an alist of associated major modes." it))) (defun helm-basename (fname &optional ext) - "Print FNAME with any leading directory components removed. + "Print FNAME with any leading directory components removed. If specified, also remove filename extension EXT. -Arg EXT can be specified as a string with or without dot, -in this case it should match file-name-extension. -It can also be non-nil (`t') in this case no checking -of file-name-extension is done and the extension is removed +Arg EXT can be specified as a string with or without dot, in this +case it should match `file-name-extension'. +It can also be non-nil (t) in this case no checking of +`file-name-extension' is done and the extension is removed unconditionally." (let ((non-essential t)) (if (and ext (or (string= (file-name-extension fname) ext) @@ -1205,20 +1365,22 @@ other candidate transformers." noerror) "Walk through DIRECTORY tree. -Argument PATH can be one of basename, relative, full, or a function -called on file name, default to basename. +Argument PATH can be one of basename, relative, full, or a +function called on file name, default to basename. -Argument DIRECTORIES when `t' return also directories names, +Argument DIRECTORIES when t return also directories names, otherwise skip directories names, with a value of `only' returns -only subdirectories, i.e files are skipped. +only subdirectories, i.e. files are skipped. Argument MATCH is a regexp matching files or directories. -Argument SKIP-SUBDIRS when `t' will skip `helm-walk-ignore-directories' -otherwise if it is given as a list of directories, this list will be used -instead of `helm-walk-ignore-directories'. +Argument SKIP-SUBDIRS when t will skip +`helm-walk-ignore-directories', otherwise if it is given as a +list of directories, this list will be used instead of +`helm-walk-ignore-directories'. -Argument NOERROR when `t' will skip directories which are not accessible." +Argument NOERROR when t will skip directories which are not +accessible." (let ((fn (cl-case path (basename 'file-name-nondirectory) (relative 'file-relative-name) @@ -1256,7 +1418,7 @@ Argument NOERROR when `t' will skip directories which are not accessible." (defun helm-file-expand-wildcards (pattern &optional full) "Same as `file-expand-wildcards' but allow recursion. -Recursion happen when PATTERN starts with two stars. +Recursion happens when PATTERN starts with two stars. Directories expansion is not supported." (let ((bn (helm-basename pattern)) (case-fold-search nil)) @@ -1269,15 +1431,25 @@ Directories expansion is not supported." ((basename nil) 'basename) (t 'full)) :directories nil - :match (wildcard-to-regexp bn) + :match (or (helm-wildcard-to-regexp bn) + (wildcard-to-regexp bn)) :skip-subdirs t) - (file-expand-wildcards pattern full)))) + (helm-aif (helm-wildcard-to-regexp bn) + (directory-files (helm-basedir pattern) full it) + (file-expand-wildcards pattern full))))) + +(defun helm-wildcard-to-regexp (wc) + "Transform wilcard WC like \"**.{jpg,jpeg}\" in REGEXP." + (when (string-match ".*\\(\\*\\{1,2\\}\\)\\.[{]\\(.*\\)[}]\\'" wc) + (format ".*\\.\\(%s\\)$" + (replace-regexp-in-string + "," "\\\\|" (match-string 2 wc))))) ;;; helm internals ;; (defun helm-set-pattern (pattern &optional noupdate) "Set minibuffer contents to PATTERN. -if optional NOUPDATE is non-nil, helm buffer is not changed." +If optional NOUPDATE is non-nil, the Helm buffer is not changed." (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) (delete-minibuffer-contents) (insert pattern)) @@ -1332,6 +1504,136 @@ I.e. when using `helm-next-line' and friends in BODY." (lambda (&optional _) nil))) (let (helm-follow-mode-persistent) (progn ,@body)))) + +;; Completion styles related functions +;; +(defun helm--setup-completion-styles-alist () + (cl-pushnew '(helm helm-completion-try-completion + helm-completion-all-completions + "helm multi completion style.") + completion-styles-alist + :test 'equal) + (unless (assq 'flex completion-styles-alist) + ;; Add helm-fuzzy style only if flex is not available. + (cl-pushnew '(helm-flex helm-flex-completion-try-completion + helm-flex-completion-all-completions + "helm flex completion style.\nProvide flex matching for emacs-26.") + completion-styles-alist + :test 'equal))) + +(defvar helm-blacklist-completion-styles '(emacs21 emacs22)) +(defun helm--prepare-completion-styles (&optional nomode styles) + "Return a suitable list of styles for `completion-styles'. + +When `helm-completion-style' is not `emacs' the Emacs vanilla +default `completion-styles' is used except for +`helm-dynamic-completion' which uses inconditionally `emacs' as +value for `helm-completion-style'. + +If styles are specified in `helm-completion-styles-alist' for a +particular mode, use these styles unless NOMODE is non nil. +If STYLES is specified as a list of styles suitable for +`completion-styles' these styles are used in the given order. +Otherwise helm style is added to `completion-styles' always after +flex or helm-flex completion style if present." + ;; For `helm-completion-style' and `helm-completion-styles-alist'. + (require 'helm-mode) + (if (memq helm-completion-style '(helm helm-fuzzy)) + ;; Keep default settings, but probably nil is fine as well. + '(basic partial-completion emacs22) + (or + styles + (pcase (and (null nomode) + (cdr (assq major-mode helm-completion-styles-alist))) + (`(,_l . ,ll) ll)) + ;; We need to have flex always behind helm, otherwise + ;; when matching against e.g. '(foo foobar foao frogo bar + ;; baz) with pattern "foo" helm style if before flex will + ;; return foo and foobar only defeating flex that would + ;; return foo foobar foao and frogo. + (let* ((wflex (car (or (assq 'flex completion-styles-alist) + (assq 'helm-flex completion-styles-alist)))) + (styles (append (and (memq wflex completion-styles) + (list wflex)) + (cl-loop for s in completion-styles + unless (or (memq s helm-blacklist-completion-styles) + (memq wflex completion-styles)) + collect s)))) + (helm-append-at-nth + styles '(helm) + (if (memq wflex completion-styles) + 1 0)))))) + +(defun helm-dynamic-completion (collection predicate &optional point metadata nomode styles) + "Build a function listing the possible completions of `helm-pattern' in COLLECTION. + +Only the elements of COLLECTION that satisfy PREDICATE are considered. + +Argument POINT is the same as in `completion-all-completions' and +is meaningful only when using some kind of `completion-at-point'. + +The return value is a list of completions that may be sorted by +the sort function provided by the completion-style in +use (emacs-27 only), otherwise (emacs-26) the sort function has +to be provided if needed either with an FCT function in source or +by passing the sort function with METADATA +E.g.: (metadata (display-sort-function . foo)). + +If you don't want the sort fn provided by style to kick +in (emacs-27) you can use as metadata value the symbol `nosort'. + +Example: + + (helm :sources (helm-build-sync-source \"test\" + :candidates (helm-dynamic-completion + '(foo bar baz foab) + 'symbolp) + :match-dynamic t) + :buffer \"*helm test*\") + +When argument NOMODE is non nil don't use `completion-styles' as +specified in `helm-completion-styles-alist' for specific modes. + +When STYLES is specified use these `completion-styles', see +`helm--prepare-completion-styles'. + +Also `helm-completion-style' settings have no effect here, +`emacs' being used inconditionally as value." + (lambda () + (let* (;; Force usage of emacs style otherwise + ;; helm--prepare-completion-styles will reset + ;; completion-styles to default value i.e. (basic partial + ;; emacs22). + (helm-completion-style 'emacs) + (completion-styles + (with-helm-current-buffer + (helm--prepare-completion-styles nomode styles))) + (completion-flex-nospace t) + (nosort (eq metadata 'nosort)) + (compsfn (lambda (str pred _action) + (let* ((completion-ignore-case (helm-set-case-fold-search)) + (comps (completion-all-completions + str + (if (functionp collection) + (funcall collection str pred t) + collection) + pred + (or point 0) + (or (and (listp metadata) metadata) + (setq metadata '(metadata))))) + (last-data (last comps)) + (sort-fn (unless nosort + (completion-metadata-get + metadata 'display-sort-function))) + all) + (when (cdr last-data) + (setcdr last-data nil)) + (setq all (copy-sequence comps)) + (if (and sort-fn (> (length str) 0)) + (funcall sort-fn all) + all))))) + ;; Ensure circular objects are removed. + (complete-with-action t compsfn helm-pattern predicate)))) ;; Yank text at point. ;; @@ -1390,14 +1692,16 @@ I.e. when using `helm-next-line' and friends in BODY." (defun helm--ansi-color-apply (string) "A version of `ansi-color-apply' immune to upstream changes. -Similar to the emacs-24.5 version without support to `ansi-color-context' -which is buggy in emacs. +Similar to the emacs-24.5 version without support to +`ansi-color-context' which is buggy in Emacs. -Modify also `ansi-color-regexp' by using own variable `helm--ansi-color-regexp' -that match whole STRING. +Modify also `ansi-color-regexp' by using own variable +`helm--ansi-color-regexp' that matches whole STRING. -This is needed to provide compatibility for both emacs-25 and emacs-24.5 -as emacs-25 version of `ansi-color-apply' is partially broken." +This is needed to provide compatibility for both emacs-25 and +emacs-24.5 as emacs-25 version of `ansi-color-apply' is partially +broken." + (require 'ansi-color) (let ((start 0) codes end escape-sequence result colorized-substring) @@ -1428,6 +1732,29 @@ as emacs-25 version of `ansi-color-apply' is partially broken." (push (substring string start) result)) (apply 'concat (nreverse result)))) + +;;; Fontlock +(cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode)) + (font-lock-add-keywords + mode + '(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-awhile\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-acond\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-aand\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-with-gensyms\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-read-answer\\)\\>" 1 font-lock-keyword-face)))) + (provide 'helm-lib) ;; Local Variables: diff --git a/elpa/helm-core-20191031.1931/helm-multi-match.el b/elpa/helm-core-20210128.1814/helm-multi-match.el similarity index 79% rename from elpa/helm-core-20191031.1931/helm-multi-match.el rename to elpa/helm-core-20210128.1814/helm-multi-match.el index e5d3c9da..5ee35d76 100644 --- a/elpa/helm-core-20191031.1931/helm-multi-match.el +++ b/elpa/helm-core-20210128.1814/helm-multi-match.el @@ -3,7 +3,7 @@ ;; Original Author: rubikitch ;; Copyright (C) 2008 ~ 2011 rubikitch -;; Copyright (C) 2011 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2011 ~ 2020 Thierry Volpiatto ;; Author: Thierry Volpiatto ;; URL: http://github.com/emacs-helm/helm @@ -67,7 +67,7 @@ when these options are used." "Regexp to represent space itself in multiple regexp match.") (defun helm-mm-split-pattern (pattern &optional grep-space) - "Split PATTERN if it contain spaces and return resulting list. + "Split PATTERN if it contains spaces and return resulting list. If spaces in PATTERN are escaped, don't split at this place. i.e \"foo bar baz\"=> (\"foo\" \"bar\" \"baz\") but \"foo\\ bar baz\"=> (\"foo\\s-bar\" \"baz\"). @@ -98,13 +98,13 @@ If GREP-SPACE is used translate escaped space to \"\\s\" instead of \"\\s-\"." helm-mm-exact-pattern-real) -(cl-defun helm-mm-exact-match (str &optional (pattern helm-pattern)) +(cl-defun helm-mm-exact-match (candidate &optional (pattern helm-pattern)) (if case-fold-search (progn - (setq str (downcase str) + (setq candidate (downcase candidate) pattern (downcase pattern)) - (string= str pattern)) - (string= str pattern))) + (string= candidate pattern)) + (string= candidate pattern))) (defun helm-mm-exact-search (pattern &rest _ignore) (and (search-forward (helm-mm-exact-get-pattern pattern) nil t) @@ -124,14 +124,14 @@ If GREP-SPACE is used translate escaped space to \"\\s\" instead of \"\\s-\"." helm-mm-prefix-pattern-real (concat "\n" pattern))) helm-mm-prefix-pattern-real) -(defun helm-mm-prefix-match (str &optional pattern) +(defun helm-mm-prefix-match (candidate &optional pattern) ;; In filename completion basename and basedir may be ;; quoted, unquote them for string comparison (Issue #1283). (setq pattern (replace-regexp-in-string "\\\\" "" (or pattern helm-pattern))) (let ((len (length pattern))) - (and (<= len (length str)) - (string= (substring str 0 len) pattern )))) + (and (<= len (length candidate)) + (string= (substring candidate 0 len) pattern )))) (defun helm-mm-prefix-search (pattern &rest _ignore) (search-forward (helm-mm-prefix-get-pattern pattern) nil t)) @@ -151,8 +151,8 @@ If GREP-SPACE is used translate escaped space to \"\\s\" instead of \"\\s-\"." (concat "^" (helm-mm-1-make-regexp pattern)))) helm-mm-1-pattern-real) -(cl-defun helm-mm-1-match (str &optional (pattern helm-pattern)) - (string-match (helm-mm-1-get-pattern pattern) str)) +(cl-defun helm-mm-1-match (candidate &optional (pattern helm-pattern)) + (string-match (helm-mm-1-get-pattern pattern) candidate)) (defun helm-mm-1-search (pattern &rest _ignore) (re-search-forward (helm-mm-1-get-pattern pattern) nil t)) @@ -172,8 +172,8 @@ If GREP-SPACE is used translate escaped space to \"\\s\" instead of \"\\s-\"." (concat "^.*" (helm-mm-1-make-regexp pattern)))) helm-mm-2-pattern-real) -(cl-defun helm-mm-2-match (str &optional (pattern helm-pattern)) - (string-match (helm-mm-2-get-pattern pattern) str)) +(cl-defun helm-mm-2-match (candidate &optional (pattern helm-pattern)) + (string-match (helm-mm-2-get-pattern pattern) candidate)) (defun helm-mm-2-search (pattern &rest _ignore) (re-search-forward (helm-mm-2-get-pattern pattern) nil t)) @@ -183,39 +183,40 @@ If GREP-SPACE is used translate escaped space to \"\\s\" instead of \"\\s-\"." ;; ;; ;; Internal -(defvar helm-mm-3-pattern-str nil) -(defvar helm-mm-3-pattern-list nil) +(defvar helm-mm--3-pattern-str nil) +(defvar helm-mm--3-pattern-list nil) (defun helm-mm-3-get-patterns (pattern) - "Return `helm-mm-3-pattern-list', a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\")). -This is done only if `helm-mm-3-pattern-str' is same as PATTERN." - (unless (equal pattern helm-mm-3-pattern-str) - (setq helm-mm-3-pattern-str pattern - helm-mm-3-pattern-list + "Return a list of predicate/regexp cons cells. +E.g., ((identity . \"foo\") (not . \"bar\")). +If PATTERN is unchanged, don't recompute PATTERN and return the +previous value stored in `helm-mm--3-pattern-list'." + (unless (equal pattern helm-mm--3-pattern-str) + (setq helm-mm--3-pattern-str pattern + helm-mm--3-pattern-list (helm-mm-3-get-patterns-internal pattern))) - helm-mm-3-pattern-list) + helm-mm--3-pattern-list) (defun helm-mm-3-get-patterns-internal (pattern) "Return a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\"))." +E.g., ((identity . \"foo\") (not . \"bar\"))." (unless (string= pattern "") (cl-loop for pat in (helm-mm-split-pattern pattern) - collect (if (string= "!" (substring pat 0 1)) + collect (if (char-equal ?! (aref pat 0)) (cons 'not (substring pat 1)) (cons 'identity pat))))) -(cl-defun helm-mm-3-match (str &optional (pattern helm-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-mm-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." +(cl-defun helm-mm-3-match (candidate &optional (pattern helm-pattern)) + "Check if PATTERN match CANDIDATE. +When PATTERN contains a space, it is splitted and matching is +done with the several resulting regexps against CANDIDATE. +E.g., \"bar foo\" will match \"foobar\" and \"barfoo\". +Argument PATTERN, a string, is transformed in a list of cons cell +with `helm-mm-3-get-patterns' if it contains a space. +E.g., \"foo bar\"=>((identity . \"foo\") (identity . \"bar\")). +Then each predicate of cons cell(s) is called with the regexp of +the same cons cell against CANDIDATE. +I.e. (identity (string-match \"foo\" \"foo bar\")) => t." (let ((pat (helm-mm-3-get-patterns pattern))) (cl-loop for (predicate . regexp) in pat always (funcall predicate @@ -223,7 +224,7 @@ i.e (identity (string-match \"foo\" \"foo bar\")) => t." ;; FIXME: Probably do nothing when ;; using fuzzy leaving the job ;; to the fuzzy fn. - (string-match regexp str) + (string-match regexp candidate) (invalid-regexp nil)))))) (defun helm-mm-3-search-base (pattern searchfn1 searchfn2) @@ -260,7 +261,7 @@ i.e (identity (re-search-forward \"foo\" (point-at-eol) t)) => t." pattern 're-search-forward 're-search-forward)) ;;; mp-3 with migemo -;; +;; Needs https://github.com/emacs-jp/migemo ;; (defvar helm-mm--previous-migemo-info nil "[Internal] Cache previous migemo query.") @@ -272,7 +273,7 @@ i.e (identity (re-search-forward \"foo\" (point-at-eol) t)) => t." (define-minor-mode helm-migemo-mode "Enable migemo in helm. It will be available in the sources handling it, -i.e the sources which have the slot :migemo with non--nil value." +i.e. the sources which have the slot :migemo with non--nil value." :lighter " Hmio" :group 'helm :global t @@ -298,10 +299,10 @@ i.e the sources which have the slot :migemo with non--nil value." helm-mm--previous-migemo-info)))) (string-match (assoc-default pattern helm-mm--previous-migemo-info) str)) -(cl-defun helm-mm-3-migemo-match (str &optional (pattern helm-pattern)) +(cl-defun helm-mm-3-migemo-match (candidate &optional (pattern helm-pattern)) (and helm-migemo-mode (cl-loop for (pred . re) in (helm-mm-3-get-patterns pattern) - always (funcall pred (helm-mm-migemo-string-match re str))))) + always (funcall pred (helm-mm-migemo-string-match re candidate))))) (defun helm-mm-migemo-forward (word &optional bound noerror count) (with-helm-buffer @@ -323,16 +324,17 @@ i.e the sources which have the slot :migemo with non--nil value." ;;; mp-3p- (multiple regexp pattern 3 with prefix search) ;; ;; -(defun helm-mm-3p-match (str &optional pattern) - "Check if PATTERN match STR. -Same as `helm-mm-3-match' but more strict, matching against prefix also. -e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to -`helm-mm-3-match'." +(defun helm-mm-3p-match (candidate &optional pattern) + "Check if PATTERN match CANDIDATE. +Same as `helm-mm-3-match' but only for the cdr of patterns, the car of +patterns must always match CANDIDATE prefix. +E.g. \"bar foo baz\" will match \"barfoobaz\" or \"barbazfoo\" but not +\"foobarbaz\" whereas `helm-mm-3-match' would match all." (let* ((pat (helm-mm-3-get-patterns (or pattern helm-pattern))) (first (car pat))) - (and (funcall (car first) (helm-mm-prefix-match str (cdr first))) + (and (funcall (car first) (helm-mm-prefix-match candidate (cdr first))) (cl-loop for (predicate . regexp) in (cdr pat) - always (funcall predicate (string-match regexp str)))))) + always (funcall predicate (string-match regexp candidate)))))) (defun helm-mm-3p-search (pattern &rest _ignore) (when (stringp pattern) @@ -344,15 +346,17 @@ e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to ;;; Generic multi-match/search functions ;; ;; -(cl-defun helm-mm-match (str &optional (pattern helm-pattern)) +(cl-defun helm-mm-match (candidate &optional (pattern helm-pattern)) + "Call `helm-mm-matching-method' function against CANDIDATE." (let ((fun (cl-ecase helm-mm-matching-method (multi1 #'helm-mm-1-match) (multi2 #'helm-mm-2-match) (multi3 #'helm-mm-3-match) (multi3p #'helm-mm-3p-match)))) - (funcall fun str pattern))) + (funcall fun candidate pattern))) (defun helm-mm-search (pattern &rest _ignore) + "Search for PATTERN with `helm-mm-matching-method' function." (let ((fun (cl-ecase helm-mm-matching-method (multi1 #'helm-mm-1-search) (multi2 #'helm-mm-2-search) diff --git a/elpa/helm-core-20191031.1931/helm-source.el b/elpa/helm-core-20210128.1814/helm-source.el similarity index 94% rename from elpa/helm-core-20191031.1931/helm-source.el rename to elpa/helm-core-20210128.1814/helm-source.el index 05bcb3e5..795e8be5 100644 --- a/elpa/helm-core-20191031.1931/helm-source.el +++ b/elpa/helm-core-20210128.1814/helm-source.el @@ -1,6 +1,6 @@ ;;; helm-source.el --- Helm source creation. -*- lexical-binding: t -*- -;; Copyright (C) 2015 ~ 2019 Thierry Volpiatto +;; Copyright (C) 2015 ~ 2020 Thierry Volpiatto ;; Author: Thierry Volpiatto ;; URL: http://github.com/emacs-helm/helm @@ -48,7 +48,7 @@ "Advice for `cl--print-table' to make readable class slots docstrings." (let ((format "%s\n\n Initform=%s\n\n%s")) (dolist (row rows) - (setcar row (propertize (car row) 'face 'italic)) + (setcar row (propertize (car row) 'face 'bold)) (setcdr row (nthcdr 1 (cdr row))) (insert "\n* " (apply #'format format row) "\n")))) @@ -103,6 +103,9 @@ It can either be a variable name, a function called with no parameters or the actual list of candidates. + Do NOT use this for asynchronous sources, use `candidates-process' + instead. + The list must be a list whose members are strings, symbols or (DISPLAY . REAL) pairs. @@ -201,7 +204,7 @@ \"Delete current candidate without quitting.\" (interactive) (with-helm-alive-p - (helm-attrset 'quick-delete '(helm-ff-quick-delete . never-split)) + (helm-set-attr 'quick-delete '(helm-ff-quick-delete . never-split)) (helm-execute-persistent-action 'quick-delete))) This function is then bound in `helm-find-files-map'.") @@ -266,7 +269,7 @@ (requires-pattern :initarg :requires-pattern - :initform nil + :initform 0 :custom integer :documentation " If present matches from the source are shown only if the @@ -450,11 +453,18 @@ functions, respectively. This attribute has no effect for asynchronous sources (see - attribute `candidates'), since they perform pattern matching - themselves. + attribute `candidates'), and sources using `match-dynamic' + since they perform pattern matching themselves. Note that FUZZY-MATCH slot will overhide value of this slot.") + (match-on-real + :initarg :match-on-real + :initform nil + :custom boolean + :documentation + " Match the real value of candidates when non nil.") + (fuzzy-match :initarg :fuzzy-match :initform nil @@ -644,6 +654,22 @@ " This slot have no more effect and is just kept for backward compatibility. Please don't use it.") + (must-match + :initarg :must-match + :initform nil + :custom symbol + :documentation + " Same as `completing-read' require-match arg. + Possible values are: + - `t' which prevent exiting with an empty helm-buffer i.e. no matches. + - `confirm' which ask for confirmation i.e. need to press a second + time RET. + - `nil' is the default and is doing nothing i.e. returns nil when + pressing RET with an empty helm-buffer. + - Any other non nil values e.g. `ignore' allow exiting with + minibuffer contents as candidate value (in this case helm-buffer + is empty).") + (group :initarg :group :initform helm @@ -708,7 +734,10 @@ Matching is done basically with `string-match' against each candidate.") :custom function :documentation " This attribute is used to define a process as candidate. - The value must be a process. + The function called with no arguments must return a process + i.e. `processp', it use typically `start-process' or `make-process', + see (info \"(elisp) Asynchronous Processes\"). + NOTE: When building the source at runtime you can give directly a process @@ -848,7 +877,7 @@ See `helm-candidates-in-buffer' for more infos.") (defclass helm-source-in-file (helm-source-in-buffer) ((init :initform (lambda () - (let ((file (helm-attr 'candidates-file)) + (let ((file (helm-get-attr 'candidates-file)) (count 1)) (with-current-buffer (helm-candidate-buffer 'global) (insert-file-contents file) @@ -889,7 +918,7 @@ Where OBJECT is an instance of an eieio class." (cl-loop for s in (object-slots object) for slot-val = (slot-value object s) when slot-val - collect (cons s (unless (eq t slot-val) slot-val)))) + collect (cons s slot-val))) (defun helm-make-source (name class &rest args) "Build a `helm' source named NAME with ARGS for CLASS. @@ -1016,12 +1045,25 @@ an eieio class." (warn "Deprecated usage of helm `delayed' slot in `%s'" (slot-value source 'name))) (helm-aif (slot-value source 'keymap) - (and (symbolp it) (setf (slot-value source 'keymap) (symbol-value it)))) + (let* ((map (if (symbolp it) + (symbol-value it) + it)) + (must-match-map (when (slot-value source 'must-match) + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") + 'helm-confirm-and-exit-minibuffer) + map))) + (loc-map (if must-match-map + (make-composed-keymap + must-match-map map) + map))) + (setf (slot-value source 'keymap) loc-map))) (helm-aif (slot-value source 'persistent-help) (setf (slot-value source 'header-line) (helm-source--persistent-help-string it source)) (setf (slot-value source 'header-line) (helm-source--header-line source))) - (when (and (slot-value source 'fuzzy-match) helm-fuzzy-sort-fn) + (when (slot-value source 'fuzzy-match) + (cl-assert helm-fuzzy-sort-fn nil "Wrong type argument functionp: nil") (setf (slot-value source 'filtered-candidate-transformer) (helm-aif (slot-value source 'filtered-candidate-transformer) (append (helm-mklist it) @@ -1038,7 +1080,12 @@ an eieio class." (helm-aif (slot-value source 'filtered-candidate-transformer) (append (helm-mklist it) (list #'helm-multiline-transformer)) - (list #'helm-multiline-transformer))))) + (list #'helm-multiline-transformer)))) + (helm-aif (slot-value source 'requires-pattern) + (let ((val (if (symbolp it) + (symbol-value it) + it))) + (setf (slot-value source 'requires-pattern) val)))) (defmethod helm-setup-user-source ((_source helm-source))) @@ -1060,6 +1107,7 @@ an eieio class." '(helm-mm-3-migemo-match))))) (when (slot-value source 'match-dynamic) (setf (slot-value source 'match) 'identity) + (setf (slot-value source 'match-part) nil) (setf (slot-value source 'multimatch) nil) (setf (slot-value source 'fuzzy-match) nil) (setf (slot-value source 'volatile) t))) diff --git a/elpa/helm-core-20191031.1931/helm.el b/elpa/helm-core-20210128.1814/helm.el similarity index 73% rename from elpa/helm-core-20191031.1931/helm.el rename to elpa/helm-core-20210128.1814/helm.el index dde4b5a6..eb3c0a44 100644 --- a/elpa/helm-core-20191031.1931/helm.el +++ b/elpa/helm-core-20210128.1814/helm.el @@ -1,8 +1,11 @@ ;;; helm.el --- Emacs incremental and narrowing framework -*- lexical-binding: t -*- +;; Version: 3.6.2 +;; URL: https://github.com/emacs-helm/helm + ;; Copyright (C) 2007 Tamas Patrovics ;; 2008 ~ 2011 rubikitch -;; 2011 ~ 2019 Thierry Volpiatto +;; 2011 ~ 2020 Thierry Volpiatto ;; This is a fork of anything.el wrote by Tamas Patrovics. @@ -30,13 +33,32 @@ (require 'cl-lib) (require 'async) -(require 'advice) ; Shutup byte compiler about ad-deactivate. (require 'helm-lib) (require 'helm-multi-match) (require 'helm-source) +;; Soft require this as it is not bundled with helm-core package. +(require 'helm-global-bindings nil t) + +;; Ensure async-bytecomp is used even with helm-core package. +(declare-function async-bytecomp-package-mode "ext:async-bytecomp.el") +(when (require 'async-bytecomp nil t) + (and (fboundp 'async-bytecomp-package-mode) + (async-bytecomp-package-mode 1))) + +;; Setup completion styles for helm-mode +(helm--setup-completion-styles-alist) (declare-function helm-comp-read "helm-mode.el") (declare-function custom-unlispify-tag-name "cus-edit.el") + +(defvar helm-marked-buffer-name) + +;; Easy access to customize +;;;###autoload +(defun helm-configuration () + "Customize Helm." + (interactive) + (customize-group "helm")) ;;; Multi keys ;; @@ -48,7 +70,7 @@ Each function runs sequentially for each KEY press. If DELAY is specified, switch back to initial function of FUNCTIONS list after DELAY seconds. The functions in FUNCTIONS list take no args. -e.g +E.g. (defun foo () (interactive) (message \"Run foo\")) @@ -61,9 +83,9 @@ e.g \(helm-define-multi-key global-map (kbd \" q\") '(foo bar baz) 2) -Each time \" q\" is pressed, the next function is executed. Waiting -more than 2 seconds between key presses switches back to executing the first -function on the next hit." +Each time \" q\" is pressed, the next function is executed. +Waiting more than 2 seconds between key presses switches back to +executing the first function on the next hit." (define-key keymap key (helm-make-multi-command functions delay))) ;;;###autoload @@ -90,8 +112,8 @@ Run each function in the FUNCTIONS list in turn when called within DELAY seconds (defun helm-run-multi-key-command (functions iterator delay) (let ((fn (lambda () - (cl-loop for count from 1 to (length functions) - collect count))) + (cl-loop for count from 1 to (length functions) + collect count))) next) (unless (and (symbol-value iterator) ;; Reset iterator when another key is pressed. @@ -108,7 +130,7 @@ Run each function in the FUNCTIONS list in turn when called within DELAY seconds (set iterator nil)))))) (helm-multi-key-defun helm-toggle-resplit-and-swap-windows - "Multi key command to re-split and swap helm window. + "Multi key command to re-split and swap Helm window. First call runs `helm-toggle-resplit-window', and second call within 1s runs `helm-swap-windows'." '(helm-toggle-resplit-window helm-swap-windows) 1) @@ -117,35 +139,34 @@ and second call within 1s runs `helm-swap-windows'." ;;;###autoload (defun helm-define-key-with-subkeys (map key subkey command &optional other-subkeys prompt exit-fn) - "Defines in MAP a KEY and SUBKEY to COMMAND. + "Define in MAP a KEY and SUBKEY to COMMAND. This allows typing KEY to call COMMAND the first time and type only SUBKEY on subsequent calls. -Arg MAP is the keymap to use, SUBKEY is the initial short key-binding to -call COMMAND. +Arg MAP is the keymap to use, SUBKEY is the initial short +key binding to call COMMAND. -Arg OTHER-SUBKEYS is an alist specifying other short key-bindings -to use once started e.g: +Arg OTHER-SUBKEYS is an alist specifying other short key bindings +to use once started, e.g.: (helm-define-key-with-subkeys global-map (kbd \"C-x v n\") ?n 'git-gutter:next-hunk '((?p . git-gutter:previous-hunk))\) - In this example, `C-x v n' will run `git-gutter:next-hunk' -subsequent \"n\"'s run this command again -and subsequent \"p\"'s run `git-gutter:previous-hunk'. +subsequent \"n\" will run this command again and subsequent \"p\" +will run `git-gutter:previous-hunk'. -If specified PROMPT can be displayed in minibuffer to -describe SUBKEY and OTHER-SUBKEYS. -Arg EXIT-FN specifies a function to run on exit. +If specified PROMPT can be displayed in minibuffer to describe +SUBKEY and OTHER-SUBKEYS. Arg EXIT-FN specifies a function to run +on exit. -For any other keys pressed, run their assigned command as defined +For any other key pressed, run their assigned command as defined in MAP and then exit the loop running EXIT-FN, if specified. -NOTE: SUBKEY and OTHER-SUBKEYS bindings support only char syntax and -vectors, so don't use strings to define them." +NOTE: SUBKEY and OTHER-SUBKEYS bindings support only char syntax +and vectors, so don't use strings to define them." (declare (indent 1)) (define-key map key (lambda () @@ -197,6 +218,8 @@ vectors, so don't use strings to define them." (define-key map (kbd "C-j") 'helm-execute-persistent-action) (define-key map (kbd "C-o") 'helm-next-source) (define-key map (kbd "M-o") 'helm-previous-source) + (define-key map (kbd "") 'helm-next-source) + (define-key map (kbd "") 'helm-previous-source) (define-key map (kbd "C-l") 'helm-recenter-top-bottom-other-window) (define-key map (kbd "M-C-l") 'helm-reposition-window-other-window) (define-key map (kbd "C-M-v") 'helm-scroll-other-window) @@ -207,8 +230,8 @@ vectors, so don't use strings to define them." (define-key map (kbd "") 'helm-scroll-other-window) (define-key map (kbd "") 'helm-scroll-other-window-down) (define-key map (kbd "C-@") 'helm-toggle-visible-mark) - (define-key map (kbd "C-SPC") 'helm-toggle-visible-mark) - (define-key map (kbd "M-SPC") 'helm-toggle-visible-mark) + (define-key map (kbd "C-SPC") 'helm-toggle-visible-mark-forward) + (define-key map (kbd "M-SPC") 'helm-toggle-visible-mark-backward) (define-key map (kbd "M-[") nil) (define-key map (kbd "M-(") 'helm-prev-visible-mark) (define-key map (kbd "M-)") 'helm-next-visible-mark) @@ -281,21 +304,21 @@ vectors, so don't use strings to define them." (defun helm-customize-group () "Jump to customization group of current source. -Default to `helm' when group is not defined in source." +Default to Helm group when group is not defined in source." (interactive) - (helm-run-after-exit 'helm-customize-group-1 (helm-attr 'group))) + (helm-run-after-exit 'helm-customize-group-1 (helm-get-attr 'group))) (put 'helm-customize-group 'helm-only t) (defun helm--action-at-nth-set-fn-1 (value &optional negative) (cl-loop for n from 1 to 9 - for key = (format value n) - for sym = (make-symbol (format "helm-execute-selection-action-at-nth-+%d" n)) - for fn = `(lambda () - (interactive) - (helm-execute-selection-action-at-nth ,(if negative (- n) n))) - do (progn - (defalias sym fn) - (define-key helm-map (kbd key) sym)))) + for key = (format value n) + for sym = (make-symbol (format "helm-execute-selection-action-at-nth-+%d" n)) + for fn = `(lambda () + (interactive) + (helm-execute-selection-action-at-nth ,(if negative (- n) n))) + do (progn + (defalias sym fn) + (define-key helm-map (kbd key) sym)))) (defun helm--action-at-nth-set-fn- (var val) (set var val) @@ -311,8 +334,8 @@ Default to `helm' when group is not defined in source." This is a format spec where %d will be replaced by the candidate number. -NOTE: `setq' have no effect until you restart emacs, use customize for -immediate effect." +NOTE: `setq' have no effect until you restart Emacs, use +customize for immediate effect." :group 'helm :type 'string :set #'helm--action-at-nth-set-fn-) @@ -323,22 +346,22 @@ immediate effect." This is a format spec where %d will be replaced by the candidate number. -NOTE: `setq' have no effect until you restart emacs, use customize for -immediate effect." +NOTE: `setq' have no effect until you restart Emacs, use +customize for immediate effect." :group 'helm :type 'string :set #'helm--action-at-nth-set-fn+) (defgroup helm nil - "Open helm." + "Open Helm." :prefix "helm-" :group 'convenience) (defcustom helm-completion-window-scroll-margin 5 - " `scroll-margin' to use for helm completion window. + "`scroll-margin' to use for Helm completion window. Set to 0 to disable. NOTE: This has no effect when `helm-display-source-at-screen-top' -id is non-`nil'." +id is non-nil." :group 'helm :type 'integer) @@ -350,7 +373,8 @@ id is non-`nil'." (defcustom helm-display-source-at-screen-top t "Display candidates at the top of screen. This happens with `helm-next-source' and `helm-previous-source'. -NOTE: When non-`nil' (default), disable `helm-completion-window-scroll-margin'." +NOTE: When non-nil (default), disable +`helm-completion-window-scroll-margin'." :group 'helm :type 'boolean) @@ -358,7 +382,7 @@ NOTE: When non-`nil' (default), disable `helm-completion-window-scroll-margin'." "Global limit for number of candidates displayed. When the pattern is empty, the number of candidates shown will be as set here instead of the entire list, which may be hundreds or -thousands. Since narrowing and filtering rapidly reduces +thousands. Since narrowing and filtering rapidly reduces available candidates, having a small list will keep the interface responsive. @@ -372,8 +396,8 @@ Set this value to nil for no limit." :type 'float) (defcustom helm-exit-idle-delay 0 - "Idle time before exiting minibuffer while helm is updating. -Has no affect when helm-buffer is up to date \(i.e exit without + "Idle time before exiting minibuffer while Helm is updating. +Has no affect when helm-buffer is up to date \(i.e. exit without delay in this condition\)." :group 'helm :type 'float) @@ -382,7 +406,7 @@ delay in this condition\)." (make-obsolete-variable 'helm-samewindow 'helm-full-frame "1.4.8.1") (defcustom helm-full-frame nil "Use current window for showing candidates. -If t, then Helm does not pop-up new window." +If t, then Helm does not pop-up a new window." :group 'helm :type 'boolean) @@ -397,14 +421,14 @@ If t, then Helm does not pop-up new window." (defcustom helm-save-configuration-functions '(set-window-configuration . current-window-configuration) "Functions used to restore or save configurations for frames and windows. -Specified as a pair of functions, where car is the restore function and cdr -is the save function. +Specified as a pair of functions, where car is the restore +function and cdr is the save function. To save and restore frame configuration, set this variable to '\(set-frame-configuration . current-frame-configuration\) NOTE: This may not work properly with own-frame minibuffer -settings. Older versions saves/restores frame configuration, but +settings. Older versions saves/restores frame configuration, but the default has changed now to avoid flickering." :group 'helm :type 'sexp) @@ -413,15 +437,15 @@ the default has changed now to avoid flickering." "Function used to display `helm-buffer'. Local value in `helm-buffer' will take precedence on this default -value. Commands that are in `helm-commands-using-frame' will have +value. Commands that are in `helm-commands-using-frame' will have `helm-buffer' displayed in frame, `helm-display-function' being ignored. -If no local value found and current command is not one of +If no local value is found and current command is not one of `helm-commands-using-frame' use this default value. -Function in charge of deciding which value use is +The function in charge of deciding which value use is `helm-resolve-display-function'. -To set it locally to `helm-buffer' in helm sources use +To set it locally to `helm-buffer' in Helm sources use `helm-set-local-variable' in init function or use :display-function slot in `helm' call." :group 'helm @@ -438,7 +462,7 @@ Use nil or t to turn off smart behavior and use Default is smart. NOTE: Case fold search has no effect when searching asynchronous -sources, which rely on customized features implemented directly +sources, which relies on customized features implemented directly into their execution process. See helm-grep.el for an example." :group 'helm :type '(choice (const :tag "Ignore case" t) @@ -474,46 +498,68 @@ the same window scheme as the previous session unless Must be one acceptable arg for `split-window' SIDE, that is `below', `above', `left' or `right'. -Other acceptable values are `same' which always display -`helm-buffer' in current window and `other' that display +Other acceptable values are `same' which always displays +`helm-buffer' in current window and `other' that displays `helm-buffer' below if only one window or in `other-window-for-scrolling' when available. -A nil value has same effect as `below'. -If `helm-full-frame' is non-`nil', it take precedence over this setting. +A nil value has same effect as `below'. If `helm-full-frame' is +non-nil, it take precedence over this setting. + +See also `helm-split-window-inside-p' and +`helm-always-two-windows' that take precedence over this. + +NOTE: this has no effect if +`helm-split-window-preferred-function' is not +`helm-split-window-default-fn' unless this new function can +handle this." + :group 'helm + :type 'symbol) + +(defcustom helm-split-window-other-side-when-one-window 'below + "The default side to display `helm-buffer' when (1) +`helm-split-window-default-side' is 'other and (2) +the current frame only has one window. Possible values +are acceptable args for `split-window' SIDE, that is `below', +`above', `left' or `right'. + +If `helm-full-frame' is non-nil, it takes precedence over this +setting. See also `helm-split-window-inside-p' and `helm-always-two-windows' that -take precedence over this. +takes precedence over this. -NOTE: this have no effect if `helm-split-window-preferred-function' is not -`helm-split-window-default-fn' unless this new function can handle this." +NOTE: this has no effect if +`helm-split-window-preferred-function' is not +`helm-split-window-default-fn' unless this new function can +handle this." :group 'helm :type 'symbol) (defcustom helm-display-buffer-default-height nil "Initial height of `helm-buffer', specified as an integer or a function. -The function should take one arg and the responsibility for -re-sizing the window; function's return value is ignored. -Note that this have no effect when the split is vertical. -See `display-buffer' for more info." +The function should take one arg and be responsible for re-sizing +the window; function's return value is ignored. Note that this +has no effect when the split is vertical. See `display-buffer' +for more info." :group 'helm :type '(choice integer function)) (defcustom helm-display-buffer-default-width nil "Initial width of `helm-buffer', specified as an integer or a function. -The function should take one arg and the responsibility for -re-sizing the window; function's return value is ignored. -Note that this have no effect when the split is horizontal. -See `display-buffer' for more info." +The function should take one arg and be responsible for re-sizing +the window; function's return value is ignored. Note that this +have no effect when the split is horizontal. See `display-buffer' +for more info." :group 'helm :type '(choice integer function)) (defvaralias 'helm-split-window-in-side-p 'helm-split-window-inside-p) (make-obsolete-variable 'helm-split-window-in-side-p 'helm-split-window-inside-p "2.8.6") (defcustom helm-split-window-inside-p nil - "Forces split inside selected window when non-`nil'. + "Force split inside selected window when non-nil. See also `helm-split-window-default-side'. NOTE: this has no effect if @@ -524,19 +570,20 @@ handle this." :type 'boolean) (defcustom helm-always-two-windows nil - "When non-`nil' helm uses two windows in this frame. + "When non-nil Helm uses two windows in this frame. I.e. `helm-buffer' in one window and `helm-current-buffer' in the other. -Note: this has no effect when `helm-split-window-inside-p' is non-`nil', -or when `helm-split-window-default-side' is set to 'same. +Note: this has no effect when `helm-split-window-inside-p' is +non-nil, or when `helm-split-window-default-side' is set to +'same. When `helm-autoresize-mode' is enabled, setting this to nil will have no effect. -Also when non-`nil' it overrides the effect of `helm-split-window-default-side' -set to `other'." +Also when non-nil it overrides the effect of +`helm-split-window-default-side' set to `other'." :group 'helm :type 'boolean) @@ -554,8 +601,8 @@ set to `other'." "Action functions to pass to `display-buffer'. See (info \"(elisp) Action Functions for Buffer Display\"). -Have no effect when `helm-always-two-windows' is non-nil and may -override other settings like `helm-split-window-inside-p'." +It has no effect when `helm-always-two-windows' is non-nil and +may override other settings like `helm-split-window-inside-p'." :group 'helm :type '(repeat symbol)) @@ -563,8 +610,8 @@ override other settings like `helm-split-window-inside-p'." "Additional alist to pass to `display-buffer' action. See (info \"(elisp) Action Alists for Buffer Display\"). -Have no effect when `helm-always-two-windows' is non-nil and may -override other settings like `helm-split-window-inside-p'. +It has no effect when `helm-always-two-windows' is non-nil and +may override other settings like `helm-split-window-inside-p'. Note that window-height and window-width have to be configured in `helm-display-buffer-height' and `helm-display-buffer-width'." :group 'helm @@ -580,27 +627,29 @@ Note that window-height and window-width have to be configured in helm-source-grep-ag helm-source-grep-git helm-source-grep) - "List of helm sources that need to use `helm--maybe-use-default-as-input'. + "List of Helm sources that need to use `helm-maybe-use-default-as-input'. When a source is a member of this list, default `thing-at-point' will be used as input." :group 'helm :type '(repeat (choice symbol))) (defcustom helm-delete-minibuffer-contents-from-point t - "When non-`nil', `helm-delete-minibuffer-contents' delete region from `point'. -Otherwise delete `minibuffer-contents'. -See documentation for `helm-delete-minibuffer-contents'." + "When non-nil, `helm-delete-minibuffer-contents' deletes region from `point'. +Otherwise it deletes `minibuffer-contents'. +See documentation for `helm-delete-minibuffer-contents'." :group 'helm :type 'boolean) (defcustom helm-follow-mode-persistent nil - "When non-`nil', save last state of `helm-follow-mode' for the next emacs sessions. + "When non-nil, save last state of `helm-follow-mode' for the next Emacs sessions. -Each time you turn on or off `helm-follow-mode', the current source name will be stored -or removed from `helm-source-names-using-follow'. +Each time you turn on or off `helm-follow-mode', the current +source name will be stored or removed from +`helm-source-names-using-follow'. -Note that this may be disabled in some places where it is unsafe to use -because persistent action is changing according to context." +Note that this may be disabled in some places where it is unsafe +to use because persistent action is changing according to +context." :group 'helm :type 'boolean) @@ -609,25 +658,25 @@ because persistent action is changing according to context." This list of source names will be used only when `helm-follow-mode-persistent' is non-nil. -You don't have to customize this yourself unless you really want and -know what you are doing, instead just set -`helm-follow-mode-persistent' to non-nil and as soon you turn on or -off `helm-follow-mode' (C-c C-f) in a source, helm will save or remove -source name in this variable." +You don't have to customize this yourself unless you really want +and know what you are doing, instead just set +`helm-follow-mode-persistent' to non-nil and as soon as you turn +on or off `helm-follow-mode' (C-c C-f) in a source, Helm will +save or remove source name in this variable." :group 'helm :type '(repeat (choice string))) (defcustom helm-prevent-escaping-from-minibuffer t - "Prevent escaping from minibuffer with `other-window' during the helm session." + "Prevent escaping from minibuffer with `other-window' during the Helm session." :group 'helm :type 'boolean) (defcustom helm-allow-mouse nil - "Allow mouse usage during the helm session when non-nil. + "Allow mouse usage during the Helm session when non-nil. -Note that this also allow moving out of minibuffer when clicking -outside of `helm-buffer', up to you to get back to helm by clicking -back in `helm-buffer' of minibuffer." +Note that this also allows moving out of minibuffer when clicking +outside of `helm-buffer', so it is up to you to get back to Helm +by clicking back in `helm-buffer' or minibuffer." :group 'helm :type 'boolean) @@ -648,26 +697,24 @@ This applies when using `helm-next/previous-line'." :type 'function) (defcustom helm-fuzzy-sort-fn 'helm-fuzzy-matching-default-sort-fn - "The sort transformer function used in fuzzy matching. -When nil, sorting is not done." + "The sort transformer function used in fuzzy matching." :group 'helm :type 'function) (defcustom helm-fuzzy-matching-highlight-fn 'helm-fuzzy-default-highlight-match - "The function to highlight fuzzy matches. -When nil, no highlighting is done." + "The function to highlight fuzzy matches." :group 'helm :type 'function) (defcustom helm-autoresize-max-height 40 - "Specifies maximum height and defaults to percent of helm window's frame height. + "Specify maximum height and defaults to percent of Helm window's frame height. See `fit-window-to-buffer' for more infos." :group 'helm :type 'integer) (defcustom helm-autoresize-min-height 10 - "Specifies minimum height and defaults to percent of helm window's frame height. + "Specify minimum height and defaults to percent of Helm window's frame height. If nil, `window-min-height' is used. See `fit-window-to-buffer' for details." @@ -675,12 +722,14 @@ See `fit-window-to-buffer' for details." :type 'integer) (defcustom helm-input-method-verbose-flag nil - "The default value for `input-method-verbose-flag' used in helm minibuffer. + "The default value for `input-method-verbose-flag' used in Helm minibuffer. It is nil by default, which does not turn off input method. Helm -updates and exits without interruption -- necessary for complex methods. +updates and exits without interruption -- necessary for complex +methods. If set to any other value as per `input-method-verbose-flag', -then use `C-\\' to disable the `current-input-method' to exit or update helm" +then use `C-\\' to disable the `current-input-method' to exit or +update Helm." :group 'helm :type '(radio :tag "A flag to control extra guidance for input methods in helm." (const :tag "Never provide guidance" nil) @@ -693,26 +742,28 @@ then use `C-\\' to disable the `current-input-method' to exit or update helm" :type 'boolean) (defcustom helm-inherit-input-method t - "Inherit `current-input-method' from `current-buffer' when non-`nil'. + "Inherit `current-input-method' from `current-buffer' when non-nil. The default is to enable this by default and then toggle `toggle-input-method'." :group 'helm :type 'boolean) (defcustom helm-echo-input-in-header-line nil - "Send current input in header-line when non-nil." + "Send current input to header-line when non-nil." :group 'helm :type 'boolean) (defcustom helm-header-line-space-before-prompt 'left-fringe "Specify the space before prompt in header-line. -This will be used when `helm-echo-input-in-header-line' is non-nil. +This will be used when `helm-echo-input-in-header-line' is +non-nil. -Value can be one of the symbols 'left-fringe or 'left-margin or an -integer specifying the number of spaces before prompt. -Note that on input longer that `window-width' the continuation string -will be shown on left side of window without taking care of this." +Value can be one of the symbols 'left-fringe or 'left-margin or +an integer specifying the number of spaces before prompt. Note +that on input longer that `window-width' the continuation string +will be shown on left side of window without taking care of +this." :group 'helm :type '(choice (symbol @@ -721,22 +772,25 @@ will be shown on left side of window without taking care of this." integer)) (defcustom helm-tramp-connection-min-time-diff 5 - "Value of `tramp-connection-min-time-diff' for helm remote processes. -If set to zero helm remote processes are not delayed. -Setting this to a value less than 5 or disabling it with a zero value -is risky, however on emacs versions starting at 24.5 it seems -it is now possible to disable it. -Anyway at any time in helm you can suspend your processes while typing -by hitting \\ `\\[helm-toggle-suspend-update]'. + "Value of `tramp-connection-min-time-diff' for Helm remote processes. +If set to zero Helm remote processes are not delayed. + +Setting this to a value less than 5 or disabling it with a zero +value is risky, however on Emacs versions starting at 24.5 it +seems it is now possible to disable it. + +Anyway at any time in Helm you can suspend your processes while +typing by hitting \\ `\\[helm-toggle-suspend-update]'. + Only async sources than use a sentinel calling `helm-process-deferred-sentinel-hook' are affected by this." :type 'integer :group 'helm) (defcustom helm-debug-root-directory nil - "When non-`nil', saves helm log messages to a file in this directory. -When `nil' log messages are saved to a buffer instead. -Log message are saved only when `helm-debug' is non-nil, so setting this + "When non-nil, save Helm log messages to a file in this directory. +When nil log messages are saved to a buffer instead. Log message +are saved only when `helm-debug' is non-nil, so setting this doesn't enable debugging by itself. See `helm-log-save-maybe' for more info." @@ -751,8 +805,9 @@ in same window. If left display the action buffer at the left of helm-buffer. If right or any other value, split at right. -Note that this may not fit well with some helm window configurations, -so it have only effect when `helm-always-two-windows' is non-nil." +Note that this may not fit well with some Helm window +configurations, so it have only effect when +`helm-always-two-windows' is non-nil." :group 'helm :type '(choice (const :tag "Split at left" left) @@ -765,11 +820,13 @@ so it have only effect when `helm-always-two-windows' is non-nil." :group 'helm) (defcustom helm-display-buffer-reuse-frame nil - "When non nil helm frame is not deleted and reused in next sessions. + "When non nil Helm frame is not deleted and reused in next sessions. -This was used to workaround a bug in emacs where frames where -popping up slowly, now that the bug have been fixed upstream probably -you don't want to use this anymore." +This was used to workaround a bug in Emacs where frames where +popping up slowly, now that the bug have been fixed upstream +\(emacs-27) probably you don't want to use this any more. On +emacs-26 set `x-wait-for-event-timeout' to nil to have your +frames popping up fast." :group 'helm :type 'boolean) @@ -779,42 +836,42 @@ you don't want to use this anymore." :type '(repeat symbol)) (defcustom helm-actions-inherit-frame-settings t - "Actions inherit helm frame settings of initial command when non nil." + "Actions inherit Helm frame settings of initial command when non nil." :group 'helm :type 'boolean) (defcustom helm-use-undecorated-frame-option t - "Display helm frame undecorated when non nil. + "Display Helm frame undecorated when non nil. -This option have no effect with emacs versions lower than 26." +This option has no effect with Emacs versions lower than 26." :group 'helm :type 'boolean) (defcustom helm-frame-background-color nil - "Background color for helm frames, a string. + "Background color for Helm frames, a string. Fallback to default face background when nil." :group 'helm :type 'string) (defcustom helm-frame-foreground-color nil - "Foreground color for helm frames, a string. + "Foreground color for Helm frames, a string. Fallback to default face foreground when nil" :group 'helm :type 'string) (defcustom helm-frame-alpha nil - "Alpha parameter for helm frames, an integer. + "Alpha parameter for Helm frames, an integer. Fallback to 100 when nil." :group 'helm :type 'integer) (defcustom helm-use-frame-when-more-than-two-windows nil - "Display helm buffer in frame when more than two windows." + "Display Helm buffer in frame when more than two windows." :group 'helm :type 'boolean) (defcustom helm-use-frame-when-dedicated-window nil - "Display helm buffer in frame when helm is started from a dedicated window." + "Display Helm buffer in frame when Helm is started from a dedicated window." :group 'helm :type 'boolean) @@ -825,8 +882,9 @@ Fallback to 100 when nil." :type 'function) (defcustom helm-truncate-lines nil - "The value of `truncate-lines' when helm startup. -You can toggle later `truncate-lines' with \\\\[helm-toggle-truncate-line]." + "The value of `truncate-lines' when Helm starts. +You can toggle later `truncate-lines' with +\\\\[helm-toggle-truncate-line]." :group 'helm :type 'boolean) @@ -834,95 +892,131 @@ You can toggle later `truncate-lines' with \\\\[helm-toggle-truncate-l ;; ;; (defgroup helm-faces nil - "Customize the appearance of helm." + "Customize the appearance of Helm." :prefix "helm-" :group 'faces :group 'helm) (defface helm-source-header - '((((background dark)) + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) :background "#22083397778B" :foreground "white" :weight bold :height 1.3 :family "Sans Serif") (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) :background "#abd7f0" :foreground "black" :weight bold :height 1.3 :family "Sans Serif")) - "Face for source header in the helm buffer." + "Face for source header in the Helm buffer." :group 'helm-faces) (defface helm-visible-mark - '((((min-colors 88) (background dark)) - (:background "green1" :foreground "black")) + `((((min-colors 88) (background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "green1" + :foreground "black") (((background dark)) - (:background "green" :foreground "black")) - (((background light)) :background "#d1f5ea") + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "green" + :foreground "black") + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "#d1f5ea") (((min-colors 88)) - (:background "green1")) - (t (:background "green"))) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "green1") + (t ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "green")) "Face for visible mark." :group 'helm-faces) (defface helm-header - '((t (:inherit header-line))) - "Face for header lines in the helm buffer." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit header-line)) + "Face for header lines in the Helm buffer." :group 'helm-faces) (defface helm-candidate-number - '((((background dark)) :background "Yellow" :foreground "black") - (((background light)) :background "#faffb5" :foreground "black")) + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "Yellow" :foreground "black") + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "#faffb5" :foreground "black")) "Face for candidate number in mode-line." :group 'helm-faces) (defface helm-candidate-number-suspended - '((t (:inherit helm-candidate-number :inverse-video t))) - "Face for candidate number in mode-line when helm is suspended." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit helm-candidate-number :inverse-video t)) + "Face for candidate number in mode-line when Helm is suspended." :group 'helm-faces) (defface helm-selection - '((((background dark)) :background "ForestGreen" + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "ForestGreen" :distant-foreground "black") - (((background light)) :background "#b5ffd1" + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :background "#b5ffd1" :distant-foreground "black")) - "Face for currently selected item in the helm buffer." + "Face for currently selected item in the Helm buffer." :group 'helm-faces) (defface helm-separator - '((((background dark)) :foreground "red") - (((background light)) :foreground "#ffbfb5")) + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red") + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "#ffbfb5")) "Face for multiline source separator." :group 'helm-faces) (defface helm-action - '((t (:underline t))) - "Face for action lines in the helm action buffer." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :underline t)) + "Face for action lines in the Helm action buffer." :group 'helm-faces) (defface helm-prefarg - '((((background dark)) :foreground "green") - (((background light)) :foreground "red")) + `((((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "green") + (((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "red")) "Face for showing prefix arg in mode-line." :group 'helm-faces) (defface helm-match - '((((background light)) :foreground "#b00000") - (((background dark)) :foreground "gold1")) + `((((background light)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "#b00000") + (((background dark)) + ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "gold1")) "Face used to highlight matches." :group 'helm-faces) (defface helm-header-line-left-margin - '((t (:foreground "black" :background "yellow"))) + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :foreground "black" :background "yellow")) "Face used to highlight helm-header sign in left-margin." :group 'helm-faces) (defface helm-minibuffer-prompt - '((t (:inherit minibuffer-prompt))) - "Face used for the minibuffer/headline prompt (such as Pattern:) in helm." + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit minibuffer-prompt)) + "Face used for the minibuffer/headline prompt (such as Pattern:) in Helm." :group 'helm-faces) (defface helm-eob-line - '((t (:inherit default))) - "Face for empty line at end of sources in the helm buffer. + `((t ,@(and (>= emacs-major-version 27) '(:extend t)) + :inherit default)) + "Face for empty line at end of sources in the Helm buffer. Allow specifying the height of this line." :group 'helm-faces) @@ -933,34 +1027,35 @@ Allow specifying the height of this line." "Overlay used to highlight the currently selected item.") (defvar helm-async-processes nil - "List of information about asynchronous processes managed by helm.") + "List of information about asynchronous processes managed by Helm.") (defvar helm-before-initialize-hook nil - "Runs before helm initialization. + "Runs before Helm initialization. This hook runs before init functions in `helm-sources', which is -before creation of `helm-buffer'. Set local variables for +before creation of `helm-buffer'. Set local variables for `helm-buffer' that need a value from `current-buffer' with `helm-set-local-variable'.") (defvar helm-after-initialize-hook nil - "Runs after helm initialization. + "Runs after Helm initialization. This hook runs after `helm-buffer' is created but not from -`helm-buffer'. The hook needs to specify in which buffer to run.") +`helm-buffer'. The hook needs to specify in which buffer to +run.") (defvaralias 'helm-update-hook 'helm-after-update-hook) (make-obsolete-variable 'helm-update-hook 'helm-after-update-hook "1.9.9") (defvar helm-after-update-hook nil - "Runs after updating the helm buffer with the new input pattern.") + "Runs after updating the Helm buffer with the new input pattern.") (defvar helm-before-update-hook nil - "Runs before updating the helm buffer with the new input pattern.") + "Runs before updating the Helm buffer with the new input pattern.") (defvar helm-cleanup-hook nil "Runs after exiting the minibuffer and before performing an action. -This hook runs even if helm exits the minibuffer abnormally (e.g. +This hook runs even if Helm exits the minibuffer abnormally (e.g. via `helm-keyboard-quit').") (defvar helm-select-action-hook nil @@ -968,7 +1063,7 @@ via `helm-keyboard-quit').") (defvar helm-before-action-hook nil "Runs before executing action. -Unlike `helm-cleanup-hook', this hook runs before helm closes the +Unlike `helm-cleanup-hook', this hook runs before Helm closes the minibuffer and also before performing an action.") (defvar helm-after-action-hook nil @@ -977,8 +1072,8 @@ minibuffer and also before performing an action.") (defvar helm-exit-minibuffer-hook nil "Runs just before exiting the minibuffer. -This hook runs when helm exits the minibuffer normally (e.g. via -candidate selection), but does NOT run if helm exits the +This hook runs when Helm exits the minibuffer normally (e.g., via +candidate selection), but does NOT run if Helm exits the minibuffer abnormally (e.g. via `helm-keyboard-quit').") (defvar helm-after-persistent-action-hook nil @@ -994,29 +1089,30 @@ minibuffer abnormally (e.g. via `helm-keyboard-quit').") "Runs after pre-selection in `helm-buffer'.") (defvar helm-window-configuration-hook nil - "Runs when switching to and from the action buffer.") + "Runs when switching to and from the action buffer. +Should run also at end of `helm-display-function'.") (defvar helm-execute-action-at-once-if-one nil - "When non--nil executes the default action and then exits if only one candidate. -If symbol 'current-source is given as value exit if only one candidate -in current source. -This variable accepts a function with no args that should returns a boolean -value or 'current-source.") + "When non-nil execute the default action and then exit if only one candidate. +If symbol 'current-source is given as value exit if only one +candidate in current source. This variable accepts a function +with no args that should returns a boolean value or +'current-source.") (defvar helm-quit-if-no-candidate nil - "When non-`nil', quits if there are no candidates. + "When non-nil, quit if there are no candidates. This variable accepts a function.") (defvar helm-debug-variables nil - "A list of helm variables that `helm-debug-output' displays. -If `nil', `helm-debug-output' includes only variables with -`helm-' prefixes.") + "A list of Helm variables that `helm-debug-output' displays. +If nil, `helm-debug-output' includes only variables with `helm-' +prefixes.") (defvar helm-debug-buffer "*Debug Helm Log*") (defvar helm-debug nil - "If non-`nil', write log message to `helm-debug-buffer'. -Default is `nil', which disables writing log messages because the + "If non-nil, write log message to `helm-debug-buffer'. +Default is nil, which disables writing log messages because the size of `helm-debug-buffer' grows quickly.") (defvar helm-mode-line-string "\ @@ -1027,14 +1123,14 @@ size of `helm-debug-buffer' grows quickly.") f1/f2/f-n:NthAct \ \\[helm-toggle-suspend-update]:Tog.suspend \ \\[helm-customize-group]:Conf" - "Help string displayed by helm in the mode-line. + "Help string displayed by Helm in the mode-line. It is either a string or a list of two string arguments where the first string is the name and the second string is displayed in -the mode-line. When `nil', uses default `mode-line-format'.") +the mode-line. When nil, it defaults to `mode-line-format'.") (defvar helm-minibuffer-set-up-hook nil "Hook that runs at minibuffer initialization. -A hook useful for modifying minibuffer settings in helm. +A hook useful for modifying minibuffer settings in Helm. An example that hides the minibuffer when using `helm-echo-input-in-header-line': @@ -1042,7 +1138,7 @@ An example that hides the minibuffer when using (add-hook 'helm-minibuffer-set-up-hook #'helm-hide-minibuffer-maybe) Note that we check `helm-echo-input-in-header-line' value -from `helm-buffer' which allow detecting possible local +from `helm-buffer' which allows detecting possible local value of this var.") (defvar helm-help-message @@ -1051,54 +1147,61 @@ value of this var.") To navigate in this Help buffer see [[Helm help][here]]. -Helm narrows down the list of candidates as you type a filter pattern see [[Matching in Helm][Matching in Helm]]. +Helm narrows down the list of candidates as you type a filter +pattern. See [[Matching in Helm][Matching in Helm]]. -Helm accepts multiple space-separated patterns, each pattern can be negated with \"!\". +Helm accepts multiple space-separated patterns, each pattern can +be negated with \"!\". -Helm also supports fuzzy matching in some places when specified, you will find -several variables to enable fuzzy matching in diverse [[Helm sources][sources]], -see [[https://github.com/emacs-helm/helm/wiki/Fuzzy-matching][fuzzy-matching]] in helm-wiki for more infos. +Helm also supports fuzzy matching in some places when specified, +you will find several variables to enable fuzzy matching in +diverse [[Helm sources][sources]], see [[https://github.com/emacs-helm/helm/wiki/Fuzzy-matching][fuzzy-matching]] in helm-wiki for more infos. Helm generally uses familiar Emacs keys to navigate the list. Here follow some of the less obvious bindings: -- `\\\\[helm-maybe-exit-minibuffer]' selects the candidate from the list, executes the default action -upon exiting the Helm session. +- `\\\\[helm-maybe-exit-minibuffer]' selects the +candidate from the list, executes the default action upon exiting +the Helm session. -- `\\\\[helm-execute-persistent-action]' executes the default action but without exiting the Helm session. -Not all sources support this. +- `\\\\[helm-execute-persistent-action]' executes the +default action but without exiting the Helm session. Not all +sources support this. -- `\\\\[helm-select-action]' displays a list of actions available on current candidate or all marked candidates. -The default binding is ordinarily used for completion, but that would be -redundant since Helm completes upon every character entered in the prompt. -See [[https://github.com/emacs-helm/helm/wiki#helm-completion-vs-emacs-completion][Helm wiki]]. +- `\\\\[helm-select-action]' displays a list of actions +available on current candidate or all marked candidates. The +default binding is ordinarily used for completion, but that +would be redundant since Helm completes upon every character +entered in the prompt. See [[https://github.com/emacs-helm/helm/wiki#helm-completion-vs-emacs-completion][Helm wiki]]. -Note: In addition to the default actions list, additional actions appear -depending of the type of the selected candidate(s). They are called filtered -actions. +Note: In addition to the default actions list, additional actions +appear depending on the type of the selected candidate(s). They +are called filtered actions. ** Helm sources -Helm uses what's called sources to provide different kinds of completions, each helm session -can handle one or more source. -A source is an alist object which is build from various classes, see [[Writing your own Helm sources][here]] -and [[https://github.com/emacs-helm/helm/wiki/Developing#creating-a-source][Helm wiki]] for more infos. +Helm uses what's called sources to provide different kinds of +completions. Each Helm session can handle one or more source. A +source is an alist object which is build from various classes, +see [[Writing your own Helm sources][here]] and +[[https://github.com/emacs-helm/helm/wiki/Developing#creating-a-source][Helm +wiki]] for more infos. *** Configure sources -You will find in helm sources already built and bound to a -variable called generally `helm-source-', in this case +You will find in Helm sources already built and bound to a +variable called generally `helm-source-'. In this case it is an alist and you can change the attributes (keys) values -using `helm-attrset' function in your config, of course you have -to ensure before calling `helm-attrset' that the file containing -source is loaded with e.g. `with-eval-after-load'. Of course you -can also completely redefine the source but this is generally not -elegant as it duplicate for its most part code already defined in -Helm. +using `helm-set-attr' function in your configuration. Of course +you have to ensure before calling `helm-set-attr' that the file +containing source is loaded, e.g. with `with-eval-after-load'. Of +course you can also completely redefine the source but this is +generally not elegant as it duplicate for its most part code +already defined in Helm. You will find also sources that are not built and even not bound -to any variables because they are rebuilded at each start of helm -session. In this case you can add a defmethod called +to any variables because they are rebuilded at each start of a +Helm session. In this case you can add a defmethod called `helm-setup-user-source' to your config: #+begin_src elisp @@ -1108,84 +1211,173 @@ session. In this case you can add a defmethod called #+end_src -See [[https://github.com/emacs-helm/helm/wiki/FAQ#why-is-a-customizable-helm-source-nil][here]] for more infos, -and for more complex examples of configuration [[https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/init-helm.el#L340][here]]. +See +[[https://github.com/emacs-helm/helm/wiki/FAQ#why-is-a-customizable-helm-source-nil][here]] +for more infos, and for more complex examples of configuration +[[https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/init-helm.el#L340][here]]. + +** Modify keybindings in Helm + +Helm main keymap is `helm-map', all keys bound in this map apply +to all Helm sources. However, most sources have their own keymap, +with each binding overriding its counterpart in `helm-map', you +can see all bindings in effect in the [[Commands][Commands]] +section (available only if the source has its own keymap and +documentation of course). ** Matching in Helm -All what you write in minibuffer is interpreted as a regexp or +All that you write in minibuffer is interpreted as a regexp or multiple regexps if separated by a space. This is true for most -sources unless developer of source have disabled it or have choosen to -use fuzzy matching. Even if a source have fuzzy matching enabled, -helm will switch to multi match as soon as it detect a space in -pattern, it may also switch to multi match as well if pattern starts -with a \"^\" beginning of line sign, in those cases each pattern -separated with space should be a regexp and not a fuzzy pattern. When -using multi match patterns, each pattern starting with \"!\" is -interpreted as a negation i.e. match everything but this. +sources unless the developer of the source has disabled it or +have choosen to use fuzzy matching. Even if a source has fuzzy +matching enabled, Helm will switch to multi match as soon as it +detects a space in the pattern. It may also switch to multi match +as well if pattern starts with a \"^\" beginning of line sign. In +those cases each pattern separated with space should be a regexp +and not a fuzzy pattern. When using multi match patterns, each +pattern starting with \"!\" is interpreted as a negation i.e. +match everything but this. + +*** Completion-styles + +Helm generally fetches its candidates with the :candidates +function up to `helm-candidate-number-limit' and then applies +match functions to these candidates according to `helm-pattern'. +But Helm allows matching candidates directly from the :candidates +function using its own `completion-styles'. +Helm provides 'helm completion style but also 'helm-flex +completion style for Emacs<27 that don't have 'flex completion +style, otherwise (emacs-27) 'flex completion style is used to +provide fuzzy aka flex completion. +By default, like in Emacs vanilla, all completion commands \(e.g., +`completion-at-point') using `completion-in-region' or +`completing-read' use `completion-styles'. +Some Helm native commands like `helm-M-x' do use +`completion-styles'. Any Helm sources can use `completion-styles' +by using :match-dynamic slot and building their :candidates +function with `helm-dynamic-completion'. + +Example: + +#+begin_src elisp + + (helm :sources (helm-build-sync-source \"test\" + :candidates (helm-dynamic-completion + '(foo bar baz foab) + 'symbolp) + :match-dynamic t) + :buffer \"*helm test*\") + +#+end_src + +By default Helm sets up `completion-styles' and always adds 'helm +to it. However the flex completion styles are not added. This is +up to the user if she wants to have such completion to enable +this. +As specified above use 'flex for emacs-27 and 'helm-flex for +emacs-26. Anyway, 'helm-flex is not provided in +`completion-styles-alist' if 'flex is present. + +Finally Helm provides two user variables to control +`completion-styles' usage: `helm-completion-style' and +`helm-completion-syles-alist'. Both variables are customizable. +The former allows retrieving previous Helm behavior if needed, by +setting it to `helm' or `helm-fuzzy', default being `emacs' which +allows dynamic completion and usage of `completion-styles'. The +second allows setting `helm-completion-style' per mode and also +specifying `completion-styles' per mode (see its docstring). Note +that these two variables take effect only in helm-mode i.e. in +all that uses `completion-read' or `completion-in-region', IOW all +helmized commands. File completion in `read-file-name' family +doesn't obey completion-styles and has its own file completion +implementation. Native Helm commands using `completion-styles' +doesn't obey `helm-completion-style' and +`helm-completion-syles-alist' (e.g., helm-M-x). + +Also for a better control of styles in native Helm sources (not +helmized by helm-mode) using :match-dynamic, +`helm-dynamic-completion' provides a STYLES argument that allows +specifying explicitely styles for this source. + +NOTE: Some old completion styles are not working fine with Helm +and are disabled by default in +`helm-blacklist-completion-styles'. They are anyway not useful in +Helm because 'helm style supersedes these styles. ** Helm mode -`helm-mode' toggles Helm completion in native Emacs functions, -so when you turn `helm-mode' on, commands like `switch-to-buffer' will use -Helm completion instead of the usual Emacs completion buffer. +`helm-mode' toggles Helm completion in native Emacs functions, so +when you turn `helm-mode' on, commands like `switch-to-buffer' +will use Helm completion instead of the usual Emacs completion +buffer. *** What gets or does not get \"helmized\" when `helm-mode' is enabled? -Helm provides generic completion on all Emacs functions using `completing-read', -`completion-in-region' and their derivatives, e.g. `read-file-name'. Helm -exposes a user variable to control which function to use for a specific Emacs -command: `helm-completing-read-handlers-alist'. If the function for a specific -command is nil, it turns off Helm completion. See the variable documentation -for more infos. +Helm provides generic completion on all Emacs functions using +`completing-read', `completion-in-region' and their derivatives, +e.g. `read-file-name'. Helm exposes a user variable to control +which function to use for a specific Emacs command: +`helm-completing-read-handlers-alist'. If the function for a +specific command is nil, it turns off Helm completion. See the +variable documentation for more infos. *** Helm functions vs helmized Emacs functions -While there are Helm functions that perform the same completion as other -helmized Emacs functions, e.g. `switch-to-buffer' and `helm-buffers-list', the -native Helm functions like `helm-buffers-list' can receive new features, the -allow marking candidates, they have several actions, etc. Whereas the helmized -Emacs functions only have Helm completion, one action and no more then Emacs can -provide for this function. This is the intended behavior. +While there are Helm functions that perform the same completion +as other helmized Emacs functions, e.g. `switch-to-buffer' and +`helm-buffers-list', the native Helm functions like +`helm-buffers-list' can receive new features that allow marking +candidates, have several actions, etc. Whereas the helmized Emacs +functions only have Helm completion, Emacs can provide no more +than one action for this function. This is the intended behavior. -Generally you are better off using the native Helm command -than the helmized Emacs equivalent. +Generally you are better off using the native Helm command than +the helmized Emacs equivalent. *** Completion behavior with Helm and completion-at-point -Helm is NOT completing dynamically, that's mean that when you are +Helm is NOT completing dynamically. That means that when you are completing some text at point, completion is done against this -text and subsequent characters you add AFTER this text, this -allow you to use matching methods provided by Helm, that is multi -matching or fuzzy matching (see [[Matching in Helm][Matching in Helm]]). +text and subsequent characters you add AFTER this text. This +allows you to use matching methods provided by Helm, that is multi +matching or fuzzy matching (see [[Matching in Helm][Matching in +Helm]]). Completion is not done dynamically (against `helm-pattern') because backend functions (i.e. `competion-at-point-functions') -are not aware of the Helm matching methods. +are not aware of Helm matching methods. By behaving like this, the benefit is that you can fully use Helm matching methods but you can't start a full completion against a -prefix different than the initial text you have at point, Helm -warn you against this by colorizing the initial input and send an -user-error message when trying to delete backward text beyond -this limit at first hit on DEL and on second hit on DEL within a -short delay (1s) quit Helm and delete-backward char in +prefix different than the initial text you have at point. Helm +warns you against this by colorizing the initial input and sends +a user-error message when trying to delete backward text beyond +this limit at first hit on DEL. A second hit on DEL within a +short delay (1s) quits Helm and delete-backward char in current-buffer. ** Helm help -\\[helm-documentation]: Show all helm documentations concatenated in one org file. +\\[helm-documentation]: Show all Helm documentations concatenated +in one org file. -From a Helm session, just hit \\\\[helm-help] to have the -documentation for the current source followed by the global Helm documentation. +From a Helm session, just hit \\\\[helm-help] to have +the documentation for the current source followed by the global +Helm documentation. -While in the help buffer, most of the Emacs regular keybindings +While in the help buffer, most of the Emacs regular key bindings are available; the most important ones are shown in minibuffer. -However due to the implementation restrictions, no regular Emacs -keymap is used (it runs in a loop when reading the help buffer) -they are hardcoded and not modifiable. +However, due to implementation restrictions, no regular Emacs +keymap is used (it runs in a loop when reading the help buffer). +Only simple bindings are available and they are defined in +`helm-help-hkmap', which is a simple alist of (key . function). +You can define or redefine bindings in help with +`helm-help-define-key' or by adding/removing entries directly in +`helm-help-hkmap'. +See `helm-help-hkmap' for restrictions on bindings and functions. -The hard-coded documentation bindings are: +The documentation of default bindings are: | Key | Alternative keys | Command | |-----------+------------------+---------------------| @@ -1206,6 +1398,7 @@ The hard-coded documentation bindings are: | M-> | | End of buffer | | M-< | | Beginning of buffer | | C- | | Toggle mark | +| C-M-SPACE | | Mark sexp | | RET | | Follow org link | | C-% | | Push org mark | | C-& | | Goto org mark-ring | @@ -1217,20 +1410,38 @@ The hard-coded documentation bindings are: ** Customize Helm Helm provides a lot of user variables for extensive customization. -From any Helm session, type \\\\[helm-customize-group] to jump to the current source `custom' group. -Helm also has a special group for faces you can access via `M-x customize-group RET helm-faces'. +From any Helm session, type \\\\[helm-customize-group] +to jump to the current source `custom' group. Helm also has a +special group for faces you can access via `M-x customize-group +RET helm-faces'. -Note: Some sources may not have their group set and default to the `helm' group. +Note: Some sources may not have their group set and default to +the `helm' group. ** Display Helm in windows and frames -You can display the helm completion buffer in many differents +You can display the Helm completion buffer in many different window configurations, see the custom interface to discover the different windows configurations available (See [[Customize Helm][Customize Helm]] to jump to custom interface). When using Emacs in a graphic display (i.e. not in a terminal) you can as -well display your helm buffers in separated frames globally for -all helm commands or separately for specific helm commands. -See [[https://github.com/emacs-helm/helm/wiki/frame][helm wiki]] for more infos. +well display your Helm buffers in separated frames globally for +all Helm commands or separately for specific Helm commands. +See `helm-display-function' and `helm-commands-using-frame'. +See also [[https://github.com/emacs-helm/helm/wiki/frame][helm wiki]] for more infos. + +There is a variable to allow reusing frame instead of deleting +and creating a new one at each session, see `helm-display-buffer-reuse-frame'. +Normally you don't have to use this, it have been made to workaround +slow frame popup in Emacs-26, to workaround this slowness in Emacs-26 use instead + +#+begin_src elisp + (when (= emacs-major-version 26) + (setq x-wait-for-event-timeout nil)) +#+end_src + +WARNING: +There is a package called posframe and also one called helm-posframe, +you DO NOT need these packages to display helm buffers in frames. ** Helm's basic operations and default key bindings @@ -1246,8 +1457,8 @@ See [[https://github.com/emacs-helm/helm/wiki/frame][helm wiki]] for more infos. | C-M-S-v | M-prior, C-M-y | Previous page (other-window) | | C-M-v | M-next | Next page (other-window) | | Tab | C-i | Show action list | -| M-o | | Previous source | -| C-o | | Next source | +| M-o | left | Previous source | +| C-o | right | Next source | | C-k | | Delete pattern (with prefix arg delete from point to end or all [2]) | | C-j | | Persistent action (Execute and keep Helm session) | @@ -1256,11 +1467,29 @@ See [[https://github.com/emacs-helm/helm/wiki/frame][helm wiki]] for more infos. \[2] Delete from point to end or all depending on the value of `helm-delete-minibuffer-contents-from-point'. +NOTE: Any of these bindings are from `helm-map' and may be +overriten by the map specific to the current source in use (each +source can have its own keymap). + +** The actions menu + +You can display the action menu in the same window +as helm candidates (default) or in a side window according to +`helm-show-action-window-other-window' value. + +When the action menu popup, the helm prompt is used to narrow +down this menu, no more candidates. + +When `helm-allow-mouse' is non nil, you can use as well +mouse-3 (right click) in the candidate zone to select actions +with the mouse once your candidate is selected. + ** Action transformers -You may be surprized to see you actions list changing depending of context, this -happen when a source have an action transformer function which check the current -candidate selectioned and add specific actions for this candidate. +You may be surprized to see your actions list changing depending +on the context. This happen when a source has an action +transformer function which checks the current selected candidate +and adds specific actions for this candidate. ** Shortcuts for n-th first actions @@ -1268,80 +1497,97 @@ f1-f12: Execute n-th action where n is 1 to 12. ** Shortcuts for executing the default action on the n-th candidate -Helm does not display line numbers by default, with Emacs-26+ -you can enable it permanently in all helm buffers with: +Helm does not display line numbers by default, with Emacs-26+ you +can enable it permanently in all helm buffers with: (add-hook 'helm-after-initialize-hook 'helm-init-relative-display-line-numbers) -You can also toggle line numbers with \\\\[helm-display-line-numbers-mode] in current helm buffer. +You can also toggle line numbers with +\\\\[helm-display-line-numbers-mode] in current Helm +buffer. -Of course when enabling `global-display-line-numbers-mode' helm buffers will have line numbers as well. -\(don't forget to customize `display-line-numbers-type' to relative). +Of course when enabling `global-display-line-numbers-mode' Helm +buffers will have line numbers as well. \(Don't forget to +customize `display-line-numbers-type' to relative). -In Emacs versions < to 26 you will have to use [[https://github.com/coldnew/linum-relative][linum-relative]] package -and `helm-linum-relative-mode'. +In Emacs versions < to 26 you will have to use +[[https://github.com/coldnew/linum-relative][linum-relative]] +package and `helm-linum-relative-mode'. Then when line numbers are enabled with one of the methods above the following keys are available([1]): -C-x : Execute default action on the n-th candidate before currently selected candidate. +C-x : Execute default action on the n-th candidate before +currently selected candidate. -C-c : Execute default action on the n-th candidate after current selected candidate. +C-c : Execute default action on the n-th candidate after +current selected candidate. -\"n\" is limited to 1-9. For larger jumps use other navigation keys. +\"n\" is limited to 1-9. For larger jumps use other navigation +keys. -\[1] Note that the keybindings are always available even if line numbers are not displayed, -they are just useless in this case. +\[1] Note that the key bindings are always available even if line +numbers are not displayed. They are just useless in this case. ** Mouse control in Helm -A basic support for the mouse is provided when the user sets `helm-allow-mouse' to non-nil. +A basic support for the mouse is provided when the user sets +`helm-allow-mouse' to non-nil. - mouse-1 selects the candidate. - mouse-2 executes the default action on selected candidate. - mouse-3 pops up the action menu. -Note: When mouse control is enabled in Helm, it also lets you click around and lose -the minibuffer focus: you'll have to click on the Helm buffer or the minibuffer -to retrieve control of your Helm session. +Note: When mouse control is enabled in Helm, it also lets you +click around and lose the minibuffer focus: you'll have to click +on the Helm buffer or the minibuffer to retrieve control of your +Helm session. ** Marked candidates -You can mark candidates to execute an action on all of them instead of the -current selected candidate only. (See bindings below.) Most Helm actions -operate on marked candidates unless candidate-marking is explicitely forbidden -for a specific source. +You can mark candidates to execute an action on all of them +instead of the current selected candidate only. (See bindings +below.) Most Helm actions operate on marked candidates unless +candidate-marking is explicitely forbidden for a specific source. -- To mark/unmark a candidate, use \\[helm-toggle-visible-mark]. (See bindings below.) -With a numeric prefix arg mark ARG candidates forward, if ARG is negative -mark ARG candidates backward. +- To mark/unmark a candidate, use +\\[helm-toggle-visible-mark]. (See bindings below.) With a +numeric prefix arg mark ARG candidates forward, if ARG is +negative mark ARG candidates backward. -- To mark all visible unmarked candidates at once in current source use \\[helm-mark-all]. -With a prefix argument, mark all candidates in all sources. +- To mark all visible unmarked candidates at once in current +source use \\[helm-mark-all]. With a prefix argument, mark all +candidates in all sources. -- To unmark all visible marked candidates at once use \\[helm-unmark-all]. +- To unmark all visible marked candidates at once use + \\[helm-unmark-all]. -- To mark/unmark all candidates at once use \\[helm-toggle-all-marks]. -With a prefix argument, mark/unmark all candidates in all sources. +- To mark/unmark all candidates at once use +\\[helm-toggle-all-marks]. With a prefix argument, mark/unmark +all candidates in all sources. -Note: When multiple candidates are selected across different sources, only the -candidates of the current source will be used when executing most actions (as -different sources can have different actions). Some actions support -multi-source marking however. +Note: When multiple candidates are selected across different +sources, only the candidates of the current source will be used +when executing most actions (as different sources can have +different actions). Some actions support multi-source marking +however. ** Follow candidates -When `helm-follow-mode' is on (\\\\[helm-follow-mode] to toggle it), -moving up and down the Helm session or updating the list of candidates will -automatically execute the persistent-action as specified for the current source. +When `helm-follow-mode' is on (\\\\[helm-follow-mode] +to toggle it), moving up and down Helm session or updating the +list of candidates will automatically execute the +persistent-action as specified for the current source. -If `helm-follow-mode-persistent' is non-nil, the state of the mode will be -restored for the following Helm sessions. +If `helm-follow-mode-persistent' is non-nil, the state of the +mode will be restored for the following Helm sessions. -If you just want to follow candidates occasionally without enabling -`helm-follow-mode', you can use \\\\[helm-follow-action-forward] or \\[helm-follow-action-backward] instead. -Conversely, when `helm-follow-mode' is enabled, those commands -go to previous/next line without executing the persistent action. +If you just want to follow candidates occasionally without +enabling `helm-follow-mode', you can use +\\\\[helm-follow-action-forward] or +\\[helm-follow-action-backward] instead. Conversely, when +`helm-follow-mode' is enabled, those commands go to previous/next +line without executing the persistent action. ** Frequently Used Commands @@ -1359,86 +1605,103 @@ go to previous/next line without executing the persistent action. ** Special yes, no or yes for all answers -You may be prompted in the minibuffer to answer by [y,n,!,q] in some places -for confirmation. +You may be prompted in the minibuffer to answer by [y,n,!,q] in +some places for confirmation. - y mean yes - no mean no - ! mean yes for all - q mean quit or abort current operation. -When using ! you will not be prompted anymore for the same thing in current operation -e.g. file deletion, file copy etc... +When using ! you will not be prompted for the same thing in +current operation any more, e.g. file deletion, file copy etc... ** Moving in `helm-buffer' -You can move in `helm-buffer' with the usual commands used in Emacs: -\(\\\\[helm-next-line], \\\\[helm-previous-line], etc. See above basic commands. -When `helm-buffer' contains more than one source, change source with \\\\[helm-next-source] and \\[helm-previous-source]. +You can move in `helm-buffer' with the usual commands used in +Emacs: \(\\\\[helm-next-line], +\\\\[helm-previous-line], etc. See above basic +commands. When `helm-buffer' contains more than one source, +change source with \\\\[helm-next-source] and +\\[helm-previous-source]. -Note: When reaching the end of a source, \\\\[helm-next-line] will *not* go to the next source when -variable `helm-move-to-line-cycle-in-source' is non-nil, so you will have to use \\\\[helm-next-source] -and \\[helm-previous-source]. +Note: When reaching the end of a source, +\\\\[helm-next-line] will *not* go to the next source +when variable `helm-move-to-line-cycle-in-source' is non-nil, so +you will have to use \\\\[helm-next-source] and +\\[helm-previous-source]. ** Resume previous session from current Helm session -You can use `C-c n' (`helm-run-cycle-resume') to cycle in resumables sources. -`C-c n' is a special key set with `helm-define-key-with-subkeys' which, after pressing it, allows you -to keep cycling with further `n'. +You can use `C-c n' (`helm-run-cycle-resume') to cycle in +resumables sources. `C-c n' is a special key set with +`helm-define-key-with-subkeys' which, after pressing it, allows +you to keep cycling with further `n'. -Tip: You can bound the same key in `global-map' to `helm-cycle-resume' - with `helm-define-key-with-subkeys' to let you transparently cycle - sessions, Helm fired up or not. - You can also bind the cycling commands to single key presses (e.g. `S-') this time - with a simple `define-key'. (Note that `S-' is not available in terminals.) +Tip: You can bound the same key in `global-map' to + `helm-cycle-resume' with `helm-define-key-with-subkeys' to + let you transparently cycle sessions, Helm fired up or not. + You can also bind the cycling commands to single key + presses (e.g., `S-') this time with a simple + `define-key'. (Note that `S-' is not available in + terminals.) -Note: `helm-define-key-with-subkeys' is available only once Helm is loaded. +Note: `helm-define-key-with-subkeys' is available only once Helm +is loaded. -You can also use \\\\[helm-resume-previous-session-after-quit] to resume -the previous session, or \\\\[helm-resume-list-buffers-after-quit] -to have completion on all resumable buffers. +You can also use +\\\\[helm-resume-previous-session-after-quit] to resume +the previous session, or +\\\\[helm-resume-list-buffers-after-quit] to have +completion on all resumable buffers. ** Global commands *** Resume Helm session from outside Helm -\\\\[helm-resume] revives the last `helm' session. Binding a key to -this command will greatly improve `helm' interactivity, e.g. when quitting Helm -accidentally. +\\\\[helm-resume] revives the last Helm session. +Binding a key to this command will greatly improve Helm +interactivity, e.g. when quitting Helm accidentally. -You can call \\\\[helm-resume] with a prefix argument to choose -\(with completion!) which session you'd like to resume. You can also cycle in -these sources with `helm-cycle-resume' (see above). +You can call \\\\[helm-resume] with a prefix argument +to choose \(with completion!) which session you'd like to resume. +You can also cycle in these sources with `helm-cycle-resume' (see +above). ** Debugging Helm -Helm exposes the special variable `helm-debug': setting it to non-nil -will enable Helm logging in a special outline-mode buffer. -Helm resets the variable to nil at the end of each session. +Helm exposes the special variable `helm-debug': setting it to +non-nil will enable Helm logging in a special outline-mode +buffer. Helm resets the variable to nil at the end of each +session. For convenience, \\\\[helm-enable-or-switch-to-debug] -allows you to turn on debugging for this session only. -To avoid accumulating log entries while you are typing patterns, you can use -\\\\[helm-toggle-suspend-update] to turn off updating. When you -are ready turn it on again to resume logging. +allows you to turn on debugging for this session only. To avoid +accumulating log entries while you are typing patterns, you can +use \\\\[helm-toggle-suspend-update] to turn off +updating. When you are ready turn it on again to resume logging. -Once you exit your Helm session you can access the debug buffer with -`helm-debug-open-last-log'. It is possible to save logs to dated files when -`helm-debug-root-directory' is set to a valid directory. +Once you exit your Helm session you can access the debug buffer +with `helm-debug-open-last-log'. It is possible to save logs to +dated files when `helm-debug-root-directory' is set to a valid +directory. -Note: Be aware that Helm log buffers grow really fast, so use `helm-debug' only -when needed. +Note: Be aware that Helm log buffers grow really fast, so use +`helm-debug' only when needed. ** Writing your own Helm sources -Writing simple sources for your own usage is easy. When calling the `helm' -function, the sources are added the :sources slot which can be a symbol or a -list of sources. Sources can be built with different EIEIO classes depending -what you want to do. To simplify this, several `helm-build-*' macros are -provided. Below, simple examples to start with. +Writing simple sources for your own usage is easy. When calling +the `helm' function, the sources are added the :sources slot +which can be a symbol or a list of sources. Sources can be built +with different EIEIO classes depending on what you want to do. To +simplify this, several `helm-build-*' macros are provided. Below +there are simple examples to start with. -We will not go further here, see [[https://github.com/emacs-helm/helm/wiki/Developing][Helm wiki]] and the source -code for more information and more complex examples. +We will not go further here, see +[[https://github.com/emacs-helm/helm/wiki/Developing][Helm wiki]] +and the source code for more information and more complex +examples. #+begin_src elisp @@ -1466,15 +1729,18 @@ It also accepts function or variable symbol.") (defvar helm-autoresize-mode) ;; Undefined in `helm-default-display-buffer'. (defvar helm-async-outer-limit-hook nil - "A hook that run in async sources when process output comes out of `candidate-number-limit'. + "A hook that runs in async sources when process output comes out of `candidate-number-limit'. Should be set locally to `helm-buffer' with `helm-set-local-variable'.") (defvar helm-quit-hook nil - "A hook that run when quitting helm.") + "A hook that runs when quitting Helm.") (defvar helm-resume-after-hook nil - "A hook that run after resuming a helm session. -The hook should take one arg SOURCES.") + "A hook that runs after resuming a Helm session. +The hook should takes one arg SOURCES.") + +(defvar helm-help-buffer-name "*Helm Help*" + "The name of helm help buffer.") ;;; Internal Variables ;; @@ -1483,8 +1749,8 @@ The hook should take one arg SOURCES.") "A list of source names to be displayed. Other sources won't appear in the search results. If nil, no filtering is done. -Don't set this directly, use `helm-set-source-filter' during helm session -to modify it.") +Don't set this directly, use `helm-set-source-filter' during a +Helm session to modify it.") (defvar helm-current-prefix-arg nil "Record `current-prefix-arg' when exiting minibuffer.") (defvar helm-saved-action nil @@ -1494,17 +1760,17 @@ to modify it.") (defvar helm-in-persistent-action nil "Flag whether in persistent-action or not.") (defvar helm-last-buffer nil - "`helm-buffer' of previously `helm' session.") + "`helm-buffer' of a previous Helm session.") (defvar helm-saved-selection nil "Value of the currently selected object when the action list is shown.") (defvar helm-sources nil "[INTERNAL] Value of current sources in use, a list of alists. -The list of sources (symbols or alists) is normalized to alists in -`helm-initialize'.") +The list of sources (symbols or alists) is normalized to alists +in `helm-initialize'.") (defvar helm-buffer-file-name nil - "Variable `buffer-file-name' when `helm' is invoked.") + "Variable `buffer-file-name' when Helm is invoked.") (defvar helm-candidate-cache (make-hash-table :test 'equal) - "Holds the available candidate within a single helm invocation.") + "Holds the available candidate within a single Helm invocation.") (defvar helm--candidate-buffer-alist nil) (defvar helm-input "" "The input typed in the candidates panel.") @@ -1515,7 +1781,7 @@ The list of sources (symbols or alists) is normalized to alists in (defvar helm-tick-hash (make-hash-table :test 'equal)) (defvar helm-issued-errors nil) (defvar helm--last-log-file nil - "The name of the log file of the last helm session.") + "The name of the log file of the last Helm session.") (defvar helm--local-variables nil) (defvar helm-split-window-state nil) (defvar helm--window-side-state nil) @@ -1529,22 +1795,22 @@ The list of sources (symbols or alists) is normalized to alists in (defvar helm--force-updating-p nil "[INTERNAL] Don't use this in your programs.") (defvar helm-exit-status 0 - "Flag to inform if helm did exit or quit. -0 means helm did exit when executing an action. -1 means helm did quit with \\[keyboard-quit] -Knowing this exit-status could help restore a window config when helm aborts -in some special circumstances. -See `helm-exit-minibuffer' and `helm-keyboard-quit'.") + "Flag to inform if Helm did exit or quit. +0 means Helm did exit when executing an action. +1 means Helm did quit with \\[keyboard-quit] +Knowing this exit-status could help restore a window config when +Helm aborts in some special circumstances. See +`helm-exit-minibuffer' and `helm-keyboard-quit'.") (defvar helm-minibuffer-confirm-state nil) (defvar helm-quit nil) (defvar helm-buffers nil "Helm buffers listed in order of most recently used.") (defvar helm-current-position nil - "Cons of \(point . window-start\) when `helm' is invoked. + "Cons of \(point . window-start\) when Helm is invoked. `helm-current-buffer' uses this to restore position after `helm-keyboard-quit'") (defvar helm-last-frame-or-window-configuration nil - "Used to store window or frame configuration at helm start.") + "Used to store window or frame configuration at Helm start.") (defvar helm-onewindow-p nil) (defvar helm-types nil) (defvar helm--mode-line-string-real nil) ; The string to display in mode-line. @@ -1557,7 +1823,7 @@ See `helm-exit-minibuffer' and `helm-keyboard-quit'.") (defvar helm--reading-passwd-or-string nil) (defvar helm--in-update nil) (defvar helm--in-fuzzy nil) -(defvar helm--maybe-use-default-as-input nil +(defvar helm-maybe-use-default-as-input nil "Flag to notify the use of use-default-as-input. Use only in let-bindings. Use :default arg of `helm' as input to update display. @@ -1572,44 +1838,45 @@ precedence on :default.") Sources generated by `helm-mode' don't need to be added here because they are automatically added. -You should not modify this yourself unless you know what you are doing.") +You should not modify this yourself unless you know what you are +doing.") (defvar helm--completing-file-name nil "Non nil when `helm-read-file-name' is running. Used for `helm-file-completion-source-p'.") ;; Same as `ffap-url-regexp' but keep it here to ensure `ffap-url-regexp' is not nil. (defvar helm--url-regexp "\\`\\(news\\(post\\)?:\\|mailto:\\|file:\\|\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://\\)") (defvar helm--ignore-errors nil - "Flag to prevent helm popping up errors in candidates functions. -Should be set in candidates functions if needed, will be restored -at end of session.") + "Flag to prevent Helm popping up errors in candidates functions. +Should be set in candidates functions if needed, and will be +restored at end of session.") (defvar helm--action-prompt "Select action: ") (defvar helm--cycle-resume-iterator nil) (defvar helm--buffer-in-new-frame-p nil) (defvar helm-initial-frame nil - "[INTERNAL] The selected frame before starting helm. + "[INTERNAL] The selected frame before starting Helm. Helm use this internally to know in which frame it started, don't modify this yourself.") (defvar helm-popup-frame nil - "The frame where helm is displayed. + "The frame where Helm is displayed. -This is only used when helm is using +This is only used when Helm is using `helm-display-buffer-in-own-frame' as `helm-display-function' and `helm-display-buffer-reuse-frame' is non nil.") (defvar helm--nested nil) (defconst helm--frame-default-attributes '(width height tool-bar-lines left top - title undecorated vertical-scroll-bars - visibility fullscreen menu-bar-lines undecorated - alpha foreground-color background-color) + title undecorated vertical-scroll-bars + visibility fullscreen menu-bar-lines undecorated + alpha foreground-color background-color) "Frame parameters to save in `helm--last-frame-parameters'.") (defvar helm--last-frame-parameters nil "Frame parameters to save for later resuming. Local to `helm-buffer'.") (defvar helm--executing-helm-action nil "Non nil when action is triggering a new helm-session. -This may be let bounded in other places to notify the display function -to reuse the same frame parameters as the previous helm session just -like resume would do.") +This may be let bounded in other places to notify the display +function to reuse the same frame parameters as the previous Helm +session just like resume would do.") (defvar helm--current-buffer-narrowed nil) (defvar helm--suspend-update-interactive-flag nil) (defvar helm-persistent-action-window-buffer nil @@ -1620,7 +1887,7 @@ window handling a buffer, it is this one we store.") ;; Utility: logging (defun helm-log (format-string &rest args) - "Log message `helm-debug' is non-`nil'. + "Log message `helm-debug' is non-nil. Messages are written to the `helm-debug-buffer' buffer. Argument FORMAT-STRING is a string to use with `format'. @@ -1641,7 +1908,7 @@ Use optional arguments ARGS like in `format'." (apply #'format (cons format-string args))))))))) (defun helm-log-run-hook (hook) - "Run HOOK like `run-hooks' but write these actions to helm log buffer." + "Run HOOK like `run-hooks' but write these actions to Helm log buffer." (helm-log "Executing %s with value = %S" hook (symbol-value hook)) (helm-log "Executing %s with global value = %S" hook (default-value hook)) (run-hooks hook) @@ -1668,7 +1935,7 @@ Use optional arguments ARGS like in `format'." (defun helm-log-error (&rest args) "Accumulate error messages into `helm-issued-errors'. ARGS are args given to `format'. -e.g (helm-log-error \"Error %s: %s\" (car err) (cdr err))." +E.g. (helm-log-error \"Error %s: %s\" (car err) (cdr err))." (apply 'helm-log (concat "ERROR: " (car args)) (cdr args)) (let ((msg (apply 'format args))) (unless (member msg helm-issued-errors) @@ -1677,7 +1944,8 @@ e.g (helm-log-error \"Error %s: %s\" (car err) (cdr err))." (defun helm-log-save-maybe () "Save log buffer when `helm-debug-root-directory' is non nil. Create `helm-debug-root-directory' directory if necessary. -Messages are logged to a file named with todays date and time in this directory." +Messages are logged to a file named with today's date and time in +this directory." (when (and (stringp helm-debug-root-directory) (not (file-directory-p helm-debug-root-directory))) (make-directory helm-debug-root-directory t)) @@ -1705,7 +1973,7 @@ End:") ;;;###autoload (defun helm-debug-open-last-log () - "Open helm log file or buffer of last helm session." + "Open Helm log file or buffer of last Helm session." (interactive) (if helm--last-log-file (progn @@ -1768,7 +2036,7 @@ End:") `(with-helm-temp-hook 'helm-after-update-hook ,@body)) (defmacro with-helm-alive-p (&rest body) - "Return error when BODY run outside helm context." + "Return error when BODY run outside Helm context." (declare (indent 0) (debug t)) `(progn (if helm-alive-p @@ -1776,7 +2044,7 @@ End:") (error "Running helm command outside of context")))) (defmacro with-helm-in-frame (&rest body) - "Execute helm function in BODY displaying `helm-buffer' in separate frame." + "Execute Helm function in BODY displaying `helm-buffer' in separate frame." (declare (debug t) (indent 0)) `(progn (helm-set-local-variable @@ -1785,20 +2053,21 @@ End:") ;;; helm-attributes ;; -(defun helm-attr (attribute-name &optional source compute) +(defun helm-get-attr (attribute-name &optional source compute) "Get the value of ATTRIBUTE-NAME of SRC. If SRC is omitted, use current source. If COMPUTE is non-`nil' compute value of ATTRIBUTE-NAME with -`helm-interpret-value'. COMPUTE can have also 'ignorefn as value, in -this case `helm-interpret-value' will return a function as value -unchanged, but will eval a symbol which is bound. - -You can use `setf' to modify value of ATTRIBUTE-NAME unless COMPUTE is -specified, if attribute ATTRIBUTE-NAME is not found in SOURCE `setf' -will create new attribute ATTRIBUTE-NAME with specified value. -You can also use `helm-attrset' to modify ATTRIBUTE-NAME." +`helm-interpret-value'. COMPUTE can have also 'ignorefn as value, +in this case `helm-interpret-value' will return a function as +value unchanged, but will eval a symbol which is bound. + +You can use `setf' to modify value of ATTRIBUTE-NAME unless +COMPUTE is specified, if attribute ATTRIBUTE-NAME is not found in +SOURCE `setf' will create new attribute ATTRIBUTE-NAME with +specified value. You can also use `helm-set-attr' to modify +ATTRIBUTE-NAME." (declare (gv-setter (lambda (val) `(let* ((src (or ,source (helm-get-current-source))) @@ -1817,32 +2086,38 @@ You can also use `helm-attrset' to modify ATTRIBUTE-NAME." (helm-interpret-value (cdr it) src compute) (cdr it))))) -(cl-defun helm-attrset (attribute-name value +(defalias 'helm-attr 'helm-get-attr) +(make-obsolete 'helm-attr 'helm-get-attr "3.7.0") + +(cl-defun helm-set-attr (attribute-name value &optional (src (helm-get-current-source))) "Set the value of ATTRIBUTE-NAME of source SRC to VALUE. -If ATTRIBUTE-NAME doesn't exists in source it is created with value VALUE.. -If SRC is omitted, use current source. -If operation succeed, return value, otherwise nil. +If ATTRIBUTE-NAME doesn't exists in source it is created with +value VALUE. If SRC is omitted, use current source. If operation +succeed, return value, otherwise nil. -Note that `setf' on `helm-attr' can be used instead of this function." - (setf (helm-attr attribute-name src) value)) +Using this function is same as using `setf' on `helm-get-attr'." + (setf (helm-get-attr attribute-name src) value)) + +(defalias 'helm-attrset 'helm-set-attr) +(make-obsolete 'helm-attrset 'helm-set-attr "3.7.0") (defun helm-add-action-to-source (name fn source &optional index) "Add new action NAME linked to function FN to SOURCE. -Function FN should be a valid function that takes one arg i.e candidate, -argument NAME is a string that will appear in action menu -and SOURCE should be an existing helm source already loaded. +Function FN should be a valid function that takes one arg i.e. +candidate, argument NAME is a string that will appear in action +menu and SOURCE should be an existing helm source already loaded. If INDEX is specified, action is added to the action list at INDEX, otherwise added at end. This allows users to add specific actions to an existing source without modifying source code." - (let ((actions (helm-attr 'action source 'ignorefn)) + (let ((actions (helm-get-attr 'action source 'ignorefn)) (new-action (list (cons name fn)))) (when (functionp actions) (setq actions (list (cons "Default action" actions)))) - (helm-attrset 'action + (helm-set-attr 'action (if index (helm-append-at-nth actions new-action index) (append actions new-action)) @@ -1850,39 +2125,42 @@ without modifying source code." (defun helm-delete-action-from-source (action-or-name source) "Delete ACTION-OR-NAME from SOURCE. -ACTION-OR-NAME can either be the name of action or the symbol function -associated to name." - (let* ((actions (helm-attr 'action source 'ignorefn)) +ACTION-OR-NAME can either be the name of action or the symbol +function associated to name." + (let* ((actions (helm-get-attr 'action source 'ignorefn)) (del-action (if (symbolp action-or-name) (rassoc action-or-name actions) (assoc action-or-name actions)))) - (helm-attrset 'action (delete del-action actions) source))) + (helm-set-attr 'action (delete del-action actions) source))) (cl-defun helm-add-action-to-source-if (name fn source predicate &optional (index 4) test-only) "Add new action NAME linked to function FN to SOURCE. -Action NAME will be available when the current candidate matches PREDICATE. +Action NAME will be available when the current candidate matches +PREDICATE. This function adds an entry in the `action-transformer' attribute of SOURCE (or creates one if not found). Function PREDICATE must take one candidate as arg. -Function FN should be a valid function that takes one arg i.e. candidate, -argument NAME is a string that will appear in action menu -and SOURCE should be an existing helm source already loaded. +Function FN should be a valid function that takes one arg i.e. +candidate, argument NAME is a string that will appear in action +menu and SOURCE should be an existing Helm source already loaded. If INDEX is specified, action is added in action list at INDEX. -Value of INDEX should be always >=1, default to 4. -This allow user to add a specific `action-transformer' -to an existing source without modifying source code. -E.g -Add the action \"Byte compile file async\" linked to -function 'async-byte-compile-file to source `helm-source-find-files' -only when predicate helm-ff-candidates-lisp-p return non-`nil': +Value of INDEX should be always >=1, default to 4. This allows +user to add a specific `action-transformer' to an existing source +without modifying source code. + +E.g. + +Add the action \"Byte compile file async\" linked to function +'async-byte-compile-file to source `helm-source-find-files' only +when predicate helm-ff-candidates-lisp-p returns non-nil: \(helm-add-action-to-source-if \"Byte compile file async\" 'async-byte-compile-file helm-source-find-files 'helm-ff-candidates-lisp-p\)." - (let* ((actions (helm-attr 'action source 'ignorefn)) - (action-transformers (helm-attr 'action-transformer source)) + (let* ((actions (helm-get-attr 'action source 'ignorefn)) + (action-transformers (helm-get-attr 'action-transformer source)) (new-action (list (cons name fn))) (transformer (lambda (actions candidate) (cond ((funcall predicate candidate) @@ -1890,12 +2168,12 @@ only when predicate helm-ff-candidates-lisp-p return non-`nil': actions new-action index)) (t actions))))) (when (functionp actions) - (helm-attrset 'action (list (cons "Default action" actions)) source)) + (helm-set-attr 'action (list (cons "Default action" actions)) source)) (when (or (symbolp action-transformers) (functionp action-transformers)) (setq action-transformers (list action-transformers))) (if test-only ; debug (delq nil (append (list transformer) action-transformers)) - (helm-attrset 'action-transformer + (helm-set-attr 'action-transformer (helm-fast-remove-dups (delq nil (append (list transformer) action-transformers)) :test 'equal) @@ -1907,12 +2185,12 @@ only when predicate helm-ff-candidates-lisp-p return non-`nil': (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 dynamically. 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: +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 dynamically. 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: @@ -1940,7 +2218,7 @@ existing Helm function names." (helm-log "helm-source-filter = %S" helm-source-filter) ;; Use force-update to run init/update functions. (helm-update (and (stringp cur-disp-sel) - (regexp-quote cur-disp-sel)))))) + (regexp-quote cur-disp-sel)))))) (defun helm--normalize-filter-sources (sources) (cl-loop for s in sources collect @@ -1951,8 +2229,8 @@ existing Helm function names." (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'." +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-sources (helm-get-sources sources)) (helm-log "helm-sources = %S" helm-sources)) @@ -1962,8 +2240,8 @@ If NO-UPDATE is non-`nil', skip executing `helm-update'." (defun helm-get-selection (&optional buffer force-display-part source) "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 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 (or buffer helm-buffer)) @@ -2006,10 +2284,10 @@ It is a function symbol (sole action) or list of (action-display . function)." (unless (helm-empty-buffer-p (helm-buffer-get)) (let ((src (helm-get-current-source))) - (helm-aif (helm-attr 'action-transformer) + (helm-aif (helm-get-attr 'action-transformer) (helm-apply-functions-from-source (or source src) it - (helm-attr 'action nil 'ignorefn) + (helm-get-attr 'action nil 'ignorefn) ;; Check if the first given transformer ;; returns the same set of actions for each ;; candidate in marked candidates. @@ -2021,8 +2299,8 @@ of (action-display . function)." for c in marked always (equal (funcall act nil c) acts)) (car (helm-marked-candidates)) - (helm-get-selection nil nil src))) - (helm-attr 'action nil 'ignorefn))))) + (helm-get-selection nil nil src))) + (helm-get-attr 'action nil 'ignorefn))))) (defun helm-get-current-source () "Return the source for the current selection. @@ -2045,9 +2323,9 @@ Return nil when `helm-buffer' is empty." source))))))))) (defun helm-buffer-is-modified (buffer) - "Return non-`nil' when BUFFER is modified since `helm' was invoked." + "Return non-nil when BUFFER is modified since Helm was invoked." (let* ((buf (get-buffer buffer)) - (key (concat (buffer-name buf) "/" (helm-attr 'name))) + (key (concat (buffer-name buf) "/" (helm-get-attr 'name))) (source-tick (or (gethash key helm-tick-hash) 0)) (buffer-tick (buffer-chars-modified-tick buf)) (modifiedp (/= source-tick buffer-tick))) @@ -2057,18 +2335,18 @@ Return nil when `helm-buffer' is empty." modifiedp)) (defun helm-current-buffer-is-modified () - "Check if `helm-current-buffer' is modified since `helm' was invoked." + "Check if `helm-current-buffer' is modified since Helm was invoked." (helm-buffer-is-modified helm-current-buffer)) (defun helm-run-after-exit (function &rest args) - "Execute FUNCTION with ARGS after exiting `helm'. + "Execute FUNCTION with ARGS after exiting Helm. The action is to call FUNCTION with arguments ARGS. Unlike `helm-exit-and-execute-action', this can be used -to call non--actions functions with any ARGS or no ARGS at all. +to call non-actions functions with any ARGS or no ARGS at all. -Use this on commands invoked from key-bindings, but not -on action functions invoked as action from the action menu, -i.e. functions called with RET." +Use this on commands invoked from key bindings, but not on action +functions invoked as action from the action menu, i.e. functions +called with RET." (helm-kill-async-processes) (helm-log "function = %S" function) (helm-log "args = %S" args) @@ -2077,13 +2355,13 @@ i.e. functions called with RET." (apply function args)))) (defun helm-exit-and-execute-action (action) - "Exit current helm session and execute ACTION. -Argument ACTION is a function called with one arg (candidate) -and part of the actions of current source. + "Exit current Helm session and execute ACTION. +Argument ACTION is a function called with one arg (candidate) and +part of the actions of current source. -Use this on commands invoked from key-bindings, but not +Use this on commands invoked from key bindings, but not on action functions invoked as action from the action menu, -i.e functions called with RET." +i.e. functions called with RET." ;; If ACTION is not an action available in source 'action attribute, ;; return an error. This allow to remove unneeded actions from ;; source that inherit actions from type, note that ACTION have to @@ -2092,8 +2370,10 @@ i.e functions called with RET." (let ((actions (helm-get-actions-from-current-source))) (when actions (cl-assert (or (eq action actions) - ;; Compiled lambda + ;; Compiled lambdas (byte-code-function-p action) + ;; Natively compiled (libgccjit) + (helm-subr-native-elisp-p action) ;; Lambdas (and (listp action) (functionp action)) ;; One of current actions. @@ -2121,8 +2401,8 @@ i.e functions called with RET." ;; If no helm based action run within 0.5 seconds, the next helm ;; session will have to resolve again those variable values. (run-with-idle-timer 0.5 nil - (lambda () (helm-set-local-variable 'helm-display-function nil - 'helm--last-frame-parameters nil)))) + (lambda () (helm-set-local-variable 'helm-display-function nil + 'helm--last-frame-parameters nil)))) (helm-exit-minibuffer)) (defun helm--get-frame-parameters (&optional frame) @@ -2161,7 +2441,7 @@ Otherwise, return VALUE itself." Use this to set local vars before calling helm. When used from an init or update function -(i.e when `helm-force-update' is running) the variables are set +\(i.e. when `helm-force-update' is running) the variables are set using `make-local-variable' within the `helm-buffer'. Usage: helm-set-local-variable ([VAR VALUE]...) @@ -2173,10 +2453,10 @@ IOW Don't use VALUE of previous VAR to set the VALUE of next VAR. (with-helm-buffer (cl-loop for i on args by #'cddr do (set (make-local-variable (car i)) (cadr i)))) - (setq helm--local-variables - (append (cl-loop for i on args by #'cddr - collect (cons (car i) (cadr i))) - helm--local-variables)))) + (setq helm--local-variables + (append (cl-loop for i on args by #'cddr + collect (cons (car i) (cadr i))) + helm--local-variables)))) (defun helm--set-local-variables-internal () (cl-loop for (var . val) in helm--local-variables @@ -2222,19 +2502,20 @@ was deleted and the candidates list not updated." (defun helm-apply-functions-from-source (source functions &rest args) "From SOURCE apply FUNCTIONS on ARGS. -This function is used to process filter functions, when filter is a -\`filtered-candidate-transformer', we pass to ARGS candidates+source -whereas when the filter is `candidate-transformer' we pass to ARGS -candidates only. -This function is used also to process functions called with no args, -e.g. init functions, in this case it is called without ARGS. +This function is used to process filter functions. When filter is +a \`filtered-candidate-transformer', we pass to ARGS +candidates+source whereas when the filter is +`candidate-transformer' we pass to ARGS candidates only. +This function is also used to process functions called with no +args, e.g. init functions. In this case it is called without +ARGS. See `helm-process-filtered-candidate-transformer' \`helm-compute-attr-in-sources' and \`helm-process-candidate-transformer'. -Arg FUNCTIONS is either a symbol or a list of functions, each function being -applied on ARGS and called on the result of the precedent function. -Return the result of last function call." +Arg FUNCTIONS is either a symbol or a list of functions, each +function being applied on ARGS and called on the result of the +precedent function. Return the result of last function call." (let ((helm--source-name (assoc-default 'name source)) (helm-current-source source) (funs (if (functionp functions) (list functions) functions))) @@ -2279,36 +2560,36 @@ Return the result of last function call." (defun helm-get-candidate-number (&optional in-current-source) "Return candidates number in `helm-buffer'. -If IN-CURRENT-SOURCE is provided return number of candidates of current source -only." +If IN-CURRENT-SOURCE is provided return the number of candidates +of current source only." (with-helm-buffer (if (or (helm-empty-buffer-p) (helm-empty-source-p)) 0 - (save-excursion - (helm-aif (and in-current-source (helm-get-previous-header-pos)) - (goto-char it) - (goto-char (point-min))) - (forward-line 1) - (if (helm-pos-multiline-p) - (cl-loop with count-multi = 1 - 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 (cl-incf count-multi) - finally return count-multi) - (cl-loop with ln = 0 - while (not (if in-current-source - (or (helm-pos-header-line-p) (eobp)) - (eobp))) - ;; Don't count empty lines maybe added by popup (#1370). - unless (or (eq (point-at-bol) (point-at-eol)) - (helm-pos-header-line-p)) - do (cl-incf ln) - do (forward-line 1) finally return ln)))))) + (save-excursion + (helm-aif (and in-current-source (helm-get-previous-header-pos)) + (goto-char it) + (goto-char (point-min))) + (forward-line 1) + (if (helm-pos-multiline-p) + (cl-loop with count-multi = 1 + 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 (cl-incf count-multi) + finally return count-multi) + (cl-loop with ln = 0 + while (not (if in-current-source + (or (helm-pos-header-line-p) (eobp)) + (eobp))) + ;; Don't count empty lines maybe added by popup (#1370). + unless (or (eq (point-at-bol) (point-at-eol)) + (helm-pos-header-line-p)) + do (cl-incf ln) + do (forward-line 1) finally return ln)))))) (defmacro with-helm-quittable (&rest body) "If an error occurs in execution of BODY, safely quit helm." @@ -2327,7 +2608,7 @@ only." ;; `:allow-nest' is not in this list because it is treated before. (defconst helm-argument-keys '(:sources :input :prompt :resume - :preselect :buffer :keymap :default :history)) + :preselect :buffer :keymap :default :history)) ;;;###autoload (defun helm (&rest plist) @@ -2420,9 +2701,9 @@ the list items, starting with the first. If nil, `thing-at-point' is used. -If `helm--maybe-use-default-as-input' is non-`nil', display is -updated using this value, unless :input is specified, in which -case that value is used instead. +If `helm-maybe-use-default-as-input' is non-nil, display is +updated using this value if this value matches, otherwise it is +ignored. If :input is specified, it takes precedence on :default. *** :history @@ -2444,7 +2725,7 @@ session. The `helm-' prefix can be omitted. For example, :buffer \"*helm buffers*\" :candidate-number-limit 10\) -starts a Helm session with the variable +Starts a Helm session with the variable `helm-candidate-number-limit' set to 10. ** Backward compatibility @@ -2492,9 +2773,9 @@ However, the use of non-keyword args is deprecated. (apply fn plist))))) ; [1] fn == helm-internal. (defun helm--alive-p () - "[Internal] Check if `helm' is alive. -An `helm' session is considered alive if `helm-alive-p' value is -non-`nil', the `helm-buffer' is visible, and cursor is in the + "[INTERNAL] Check if `helm' is alive. +An Helm session is considered alive if `helm-alive-p' value is +non-nil, the `helm-buffer' is visible, and cursor is in the minibuffer." (and helm-alive-p (get-buffer-window (helm-buffer-get) 'visible) @@ -2504,11 +2785,11 @@ minibuffer." (defun helm-parse-keys (keys) "Parse the KEYS arguments of `helm'. Return only those keys not in `helm-argument-keys', prefix them -with \"helm\", and then convert them to an alist. This allows +with \"helm\", and then convert them to an alist. This allows adding arguments that are not part of `helm-argument-keys', but -are valid helm variables nevertheless. For -example, :candidate-number-limit is bound to -`helm-candidate-number-limit' in the source. +are valid helm variables nevertheless. For example, +:candidate-number-limit is bound to `helm-candidate-number-limit' +in the source. (helm-parse-keys '(:sources ((name . \"test\") (candidates . (a b c))) @@ -2526,13 +2807,17 @@ example, :candidate-number-limit is bound to ;;; 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'." + sources input + prompt resume + preselect buffer + keymap default history) + "The internal Helm function called by `helm'. +For SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT and +HISTORY args see `helm'." + (cl-assert (or (stringp input) + (null input)) + nil "Error in %S buffer: Initial input should be a string or nil" + buffer) (unless helm--nested (setq helm-initial-frame (selected-frame))) ;; Activate the advices. ;; Advices will be available only in >=emacs-24.4, but @@ -2544,69 +2829,70 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'." :around #'helm--suspend-read-passwd) ;; Ensure linum-mode is disabled in Helm buffers to preserve ;; performances (Issue #1894). - (advice-add 'linum-on :override #'helm--advice-linum-on)) + (advice-add 'linum-on :override #'helm--advice-linum-on '((depth . 100)))) (helm-log (concat "[Start session] " (make-string 41 ?+))) - (helm-log "any-prompt = %S" any-prompt) - (helm-log "any-preselect = %S" any-preselect) - (helm-log "any-buffer = %S" any-buffer) - (helm-log "any-keymap = %S" any-keymap) - (helm-log "any-default = %S" any-default) - (helm-log "any-history = %S" any-history) - (setq helm--prompt (or any-prompt "pattern: ")) + (helm-log "prompt = %S" prompt) + (helm-log "preselect = %S" preselect) + (helm-log "buffer = %S" buffer) + (helm-log "keymap = %S" keymap) + (helm-log "default = %S" default) + (helm-log "history = %S" history) + (setq helm--prompt (or prompt "pattern: ")) (let ((non-essential t) ;; Prevent mouse jumping to the upper-right ;; hand corner of the frame (#1538). mouse-autoselect-window focus-follows-mouse mode-line-in-non-selected-windows + minibuffer-completion-confirm (input-method-verbose-flag helm-input-method-verbose-flag) - (helm--maybe-use-default-as-input - (and (null any-input) - (or helm--maybe-use-default-as-input ; it is let-bounded so use it. - (cl-loop for s in (helm-normalize-sources any-sources) + (helm-maybe-use-default-as-input + (and (null input) + (or helm-maybe-use-default-as-input ; it is let-bounded so use it. + (cl-loop for s in (helm-normalize-sources sources) thereis (memq s helm-sources-using-default-as-input)))))) (unwind-protect - (condition-case-unless-debug _v - (let ( ;; `helm--source-name' is non-`nil' - ;; when `helm' is invoked by action, reset it. - helm--source-name - helm-current-source - helm-in-persistent-action - helm-quit - (helm-buffer (or any-buffer helm-buffer))) - (helm-initialize - any-resume any-input any-default any-sources) - ;; We don't display helm-buffer here to avoid popping - ;; up a window or a frame when exiting immediately when - ;; only one candidate (this avoid having the helm frame - ;; flashing), lets first compute candidates and if more - ;; than one display helm-buffer (this is done later in - ;; helm-read-pattern-maybe). - (unless helm-execute-action-at-once-if-one - (helm-display-buffer helm-buffer any-resume) - (select-window (helm-window))) - ;; We are now in helm-buffer. - (unless helm-allow-mouse - (helm--remap-mouse-mode 1)) ; Disable mouse bindings. - (add-hook 'post-command-hook 'helm--maybe-update-keymap) - ;; Add also to update hook otherwise keymap is not updated - ;; until a key is hitted (Issue #1670). - (add-hook 'helm-after-update-hook 'helm--maybe-update-keymap) - (add-hook 'post-command-hook 'helm--update-header-line) - (helm-log "show prompt") - (unwind-protect - (helm-read-pattern-maybe - any-prompt any-input any-preselect - any-resume any-keymap any-default any-history) - (helm-cleanup)) - (prog1 - (unless helm-quit (helm-execute-selection-action)) - (helm-log (concat "[End session] " (make-string 41 ?-))))) - (quit - (helm-restore-position-on-quit) - (helm-log-run-hook 'helm-quit-hook) - (helm-log (concat "[End session (quit)] " (make-string 34 ?-))) - nil)) + (condition-case-unless-debug _v + (let ( ;; `helm--source-name' is non-`nil' + ;; when `helm' is invoked by action, reset it. + helm--source-name + helm-current-source + helm-in-persistent-action + helm-quit + (helm-buffer (or buffer helm-buffer))) + (helm-initialize + resume input default sources) + ;; We don't display helm-buffer here to avoid popping + ;; up a window or a frame when exiting immediately when + ;; only one candidate (this avoid having the helm frame + ;; flashing), lets first compute candidates and if more + ;; than one display helm-buffer (this is done later in + ;; helm-read-from-minibuffer). + (unless helm-execute-action-at-once-if-one + (helm-display-buffer helm-buffer resume) + (select-window (helm-window))) + ;; We are now in helm-buffer. + (unless helm-allow-mouse + (helm--remap-mouse-mode 1)) ; Disable mouse bindings. + (add-hook 'post-command-hook 'helm--maybe-update-keymap) + ;; Add also to update hook otherwise keymap is not updated + ;; until a key is hitted (Issue #1670). + (add-hook 'helm-after-update-hook 'helm--maybe-update-keymap) + (add-hook 'post-command-hook 'helm--update-header-line) + (helm-log "show prompt") + (unwind-protect + (helm-read-from-minibuffer + prompt input preselect + resume keymap default history) + (helm-cleanup)) + (prog1 + (unless helm-quit (helm-execute-selection-action)) + (helm-log (concat "[End session] " (make-string 41 ?-))))) + (quit + (helm-restore-position-on-quit) + (helm-log-run-hook 'helm-quit-hook) + (helm-log (concat "[End session (quit)] " (make-string 34 ?-))) + nil)) (when (fboundp 'advice-remove) (advice-remove 'tramp-read-passwd #'helm--suspend-read-passwd) (advice-remove 'ange-ftp-get-passwd #'helm--suspend-read-passwd) @@ -2635,42 +2921,42 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'." ;; ;; (defun helm-resume (arg) - "Resume a previous `helm' session. -Call with a prefix arg to choose among existing helm -buffers (sessions). When calling from lisp, specify a buffer-name -as a string with ARG." + "Resume a previous Helm session. +Call with a prefix arg to choose among existing Helm +buffers (sessions). When calling from Lisp, specify a +`buffer-name' as a string with ARG." (interactive "P") - (let (any-buffer + (let (buffer cur-dir narrow-pos (helm-full-frame (default-value 'helm-full-frame)) sources) (if arg (if (and (stringp arg) (bufferp (get-buffer arg))) - (setq any-buffer arg) - (setq any-buffer (helm-resume-select-buffer))) - (setq any-buffer helm-last-buffer)) - (cl-assert any-buffer nil + (setq buffer arg) + (setq buffer (helm-resume-select-buffer))) + (setq buffer helm-last-buffer)) + (cl-assert buffer nil "helm-resume: No helm buffers found to resume") (setq sources (buffer-local-value - 'helm-sources (get-buffer any-buffer))) + 'helm-sources (get-buffer buffer))) ;; Reset `cursor-type' to nil as it have been set to t ;; when quitting previous session. - (with-current-buffer any-buffer (setq cursor-type nil)) + (with-current-buffer buffer (setq cursor-type nil)) (setq helm-full-frame (buffer-local-value - 'helm-full-frame (get-buffer any-buffer))) + 'helm-full-frame (get-buffer buffer))) (setq cur-dir (buffer-local-value - 'default-directory (get-buffer any-buffer))) + 'default-directory (get-buffer buffer))) (setq helm-saved-selection nil helm-saved-action nil) (unless (buffer-live-p helm-current-buffer) ;; `helm-current-buffer' may have been killed. (setq helm-current-buffer (current-buffer))) - (helm-aif (with-current-buffer any-buffer + (helm-aif (with-current-buffer buffer helm--current-buffer-narrowed) - (progn - (set-buffer (car it)) - (setq narrow-pos (cdr it)))) + (progn + (set-buffer (car it)) + (setq narrow-pos (cdr it)))) ;; This happen when calling C-x b within helm. (helm-aif (get-buffer-window helm-marked-buffer-name 'visible) (progn (delete-window it) (kill-buffer helm-marked-buffer-name))) @@ -2679,27 +2965,27 @@ as a string with ARG." ;; Restart with same `default-directory' value this session ;; was initially started with. (with-helm-default-directory cur-dir - (unwind-protect - (helm - :sources sources - :input (buffer-local-value 'helm-input-local (get-buffer any-buffer)) - :prompt (buffer-local-value 'helm--prompt (get-buffer any-buffer)) - :resume t - :buffer any-buffer) - (run-hook-with-args 'helm-resume-after-hook sources)))))) + (unwind-protect + (helm + :sources sources + :input (buffer-local-value 'helm-input-local (get-buffer buffer)) + :prompt (buffer-local-value 'helm--prompt (get-buffer buffer)) + :resume t + :buffer buffer) + (run-hook-with-args 'helm-resume-after-hook sources)))))) (defun helm-resume-previous-session-after-quit () - "Resume previous helm session within a running helm." + "Resume previous Helm session within a running Helm." (interactive) (with-helm-alive-p - (let ((arg (if (null (member helm-buffer helm-buffers)) 0 1))) + (let ((arg (if (null (member helm-buffer helm-buffers)) 0 1))) (if (> (length helm-buffers) arg) (helm-run-after-exit (lambda () (helm-resume (nth arg helm-buffers)))) (message "No previous helm sessions available for resuming!"))))) (put 'helm-resume-previous-session-after-quit 'helm-only t) (defun helm-resume-list-buffers-after-quit () - "List resumable helm buffers within running helm." + "List Helm buffers that can be resumed within a running Helm." (interactive) (with-helm-alive-p (if (> (length helm-buffers) 0) @@ -2707,16 +2993,16 @@ as a string with ARG." (message "No previous helm sessions available for resuming!")))) (put 'helm-resume-list-buffers-after-quit 'helm-only t) -(defun helm-resume-p (any-resume) - "Whether current helm session is resumed or not." - (eq any-resume t)) +(defun helm-resume-p (resume) + "Whether current Helm session is resumed or not." + (eq resume t)) (defun helm-resume-select-buffer () "Select an `helm-buffer' in `helm-buffers' list to resume a helm session. Return nil if no `helm-buffer' found." (when helm-buffers (or (helm :sources (helm-build-sync-source "Resume helm buffer" - :candidates helm-buffers) + :candidates helm-buffers) :resume 'noresume :buffer "*helm resume*") (keyboard-quit)))) @@ -2751,7 +3037,7 @@ Return nil if no `helm-buffer' found." (helm-iter-next helm--cycle-resume-iterator)))))) (defun helm-run-cycle-resume () - "Same as `helm-cycle-resume' but intended to be called only from helm." + "Same as `helm-cycle-resume' but intended to be called only from Helm." (interactive) (when (cdr helm-buffers) ; only one session registered. ;; Setup a new iterator only on first hit on @@ -2770,16 +3056,16 @@ Return nil if no `helm-buffer' found." ;;;###autoload -(defun helm-other-buffer (any-sources any-buffer) - "Simplified `helm' interface with other `helm-buffer'. -Call `helm' only with ANY-SOURCES and ANY-BUFFER as args." - (helm :sources any-sources :buffer any-buffer)) +(defun helm-other-buffer (sources buffer) + "Simplified Helm interface with other `helm-buffer'. +Call `helm' only with SOURCES and BUFFER as args." + (helm :sources sources :buffer buffer)) ;;; Nested sessions ;; ;; (defun helm--nest (&rest same-as-helm) - "[internal]Allows calling `helm' within a running helm session. + "[INTERNAL] Allow calling `helm' within a running Helm session. Arguments SAME-AS-HELM are the same as `helm'. @@ -2828,16 +3114,12 @@ Don't use this directly, use instead `helm' with the keyword (setq helm-current-buffer orig-helm-current-buffer) (setq helm-onewindow-p orig-one-window-p) ;; Be sure advices, hooks, and local modes keep running. - (if (fboundp 'advice-add) - (progn - (advice-add 'tramp-read-passwd - :around #'helm--suspend-read-passwd) - (advice-add 'ange-ftp-get-passwd - :around #'helm--suspend-read-passwd) - (advice-add 'epa-passphrase-callback-function - :around #'helm--suspend-read-passwd)) - (ad-activate 'tramp-read-passwd) - (ad-activate 'ange-ftp-get-passwd)) + (advice-add 'tramp-read-passwd + :around #'helm--suspend-read-passwd) + (advice-add 'ange-ftp-get-passwd + :around #'helm--suspend-read-passwd) + (advice-add 'epa-passphrase-callback-function + :around #'helm--suspend-read-passwd) (unless helm-allow-mouse (helm--remap-mouse-mode 1)) (unless (cl-loop for h in post-command-hook @@ -2918,11 +3200,13 @@ frame configuration as per `helm-save-configuration-functions'." "Default function to split windows before displaying `helm-buffer'. It is used as default value for -`helm-split-window-preferred-function' which is then the let-bounded -value of `split-window-preferred-function' in `helm-display-buffer'. -When `helm-display-function' which default to -`helm-default-display-buffer' is called from `helm-display-buffer' the -value of `split-window-preferred-function' will be used by `display-buffer'." +`helm-split-window-preferred-function' which is then the +let-bounded value of `split-window-preferred-function' in +`helm-display-buffer'. When `helm-display-function' which default +to `helm-default-display-buffer' is called from +`helm-display-buffer' the value of +`split-window-preferred-function' will be used by +`display-buffer'." (let* (split-width-threshold (win (if (and (fboundp 'window-in-direction) ;; Don't try to split when starting in a minibuffer @@ -2931,8 +3215,10 @@ value of `split-window-preferred-function' will be used by `display-buffer'." (if (or (one-window-p t) helm-split-window-inside-p) (split-window - (selected-window) nil (if (eq helm-split-window-default-side 'other) - 'below helm-split-window-default-side)) + (selected-window) nil + (if (eq helm-split-window-default-side 'other) + helm-split-window-other-side-when-one-window + helm-split-window-default-side)) ;; If more than one window reuse one of them. (cl-case helm-split-window-default-side (left (or (helm-window-in-direction 'left) @@ -2948,30 +3234,39 @@ value of `split-window-preferred-function' will be used by `display-buffer'." (helm-window-in-direction 'right) (selected-window))) (same (selected-window)) - (other (other-window-for-scrolling)) + (other (or (helm-other-window-for-scrolling) + (selected-window))) (t (or (window-next-sibling) (selected-window))))) (split-window-sensibly window)))) (setq helm-persistent-action-window-buffer (window-buffer win)) win)) (defun helm-window-in-direction (direction) - "Same as `window-in-direction' but check if window is dedicated." + "Same as `window-in-direction' but check if window is dedicated. +Return nil when window is dedicated." (helm-aif (window-in-direction direction) (and (not (window-dedicated-p it)) it))) +(defun helm-other-window-for-scrolling () + "Same as `other-window-for-scrolling' but check if window is dedicated. +Returns nil when window is dedicated." + (helm-aif (other-window-for-scrolling) + (and (not (window-dedicated-p it)) it))) + ;;; Display helm buffer ;; ;; (defun helm-resolve-display-function (com) - "Decide which display function use according to `helm-commands-using-frame'. + "Decide which display function to use according to `helm-commands-using-frame'. -The `helm-display-function' buffer local value takes precedence on -`helm-commands-using-frame'. +The `helm-display-function' buffer local value takes precedence +on `helm-commands-using-frame'. If `helm-initial-frame' has no minibuffer, use `helm-display-buffer-in-own-frame' function. Fallback to global value of `helm-display-function' when no local -value found and current command is not in `helm-commands-using-frame'." +value found and current command is not in +`helm-commands-using-frame'." (or (with-helm-buffer helm-display-function) (and (or (memq com helm-commands-using-frame) (and helm-use-frame-when-dedicated-window @@ -2988,7 +3283,7 @@ value found and current command is not in `helm-commands-using-frame'." "Display BUFFER. The function used to display `helm-buffer' by calling -`helm-display-function' which split window with +`helm-display-function' which splits window with `helm-split-window-preferred-function'." (let ((split-window-preferred-function helm-split-window-preferred-function) @@ -3026,7 +3321,7 @@ Arg ENABLE is the value of `no-other-window' window property." (defun helm-default-display-buffer (buffer &optional _resume) "Default function to display `helm-buffer' BUFFER. -It is the default value of `helm-display-function' +It is the default value of `helm-display-function'. It uses `switch-to-buffer' or `display-buffer' depending on the value of `helm-full-frame' or `helm-split-window-default-side'." (let (pop-up-frames @@ -3054,15 +3349,18 @@ value of `helm-full-frame' or `helm-split-window-default-side'." (window-width . ,helm-display-buffer-default-width))))) (helm-log-run-hook 'helm-window-configuration-hook)))) +;; Shut up byte-compiler in emacs-26 +(defvar tab-bar-mode) + (defun helm-display-buffer-in-own-frame (buffer &optional resume) - "Display helm buffer BUFFER in a separate frame. + "Display Helm buffer BUFFER in a separate frame. Function suitable for `helm-display-function', -`helm-completion-in-region-display-function' -and/or `helm-show-completion-default-display-function'. +`helm-completion-in-region-display-function' and/or +`helm-show-completion-default-display-function'. -See `helm-display-buffer-height' and `helm-display-buffer-width' to -configure frame size. +See `helm-display-buffer-height' and `helm-display-buffer-width' +to configure frame size. Note that this feature is available only with emacs-25+." (cl-assert (and (fboundp 'window-absolute-pixel-edges) @@ -3077,44 +3375,46 @@ Note that this feature is available only with emacs-25+." (frame-info (frame-geometry)) (prmt-size (length helm--prompt)) (line-height (frame-char-height)) + tab-bar-mode (default-frame-alist - (if resume - (buffer-local-value 'helm--last-frame-parameters - (get-buffer buffer)) - `((width . ,helm-display-buffer-width) - (height . ,helm-display-buffer-height) - (tool-bar-lines . 0) - (left . ,(- (car pos) - (* (frame-char-width) - (if (< (- (point) (point-at-bol)) prmt-size) - (- (point) (point-at-bol)) - prmt-size)))) - ;; Try to put frame at the best possible place. - ;; Frame should be below point if enough - ;; place, otherwise above point and - ;; current line should not be hidden - ;; by helm frame. - (top . ,(if (> (cdr pos) half-screen-size) - ;; Above point - (- (cdr pos) - ;; add 2 lines to make sure there is always a gap - (* (+ helm-display-buffer-height 2) line-height) - ;; account for title bar height too - (cddr (assq 'title-bar-size frame-info))) - ;; Below point - (+ (cdr pos) line-height))) - (title . "Helm") - (undecorated . ,helm-use-undecorated-frame-option) - (background-color . ,(or helm-frame-background-color - (face-attribute 'default :background))) - (foreground-color . ,(or helm-frame-foreground-color - (face-attribute 'default :foreground))) - (alpha . ,(or helm-frame-alpha 100)) - (vertical-scroll-bars . nil) - (menu-bar-lines . 0) - (fullscreen . nil) - (visibility . ,(null helm-display-buffer-reuse-frame)) - (minibuffer . t)))) + (if resume + (buffer-local-value 'helm--last-frame-parameters + (get-buffer buffer)) + `((width . ,helm-display-buffer-width) + (height . ,helm-display-buffer-height) + (tool-bar-lines . 0) + (left . ,(- (car pos) + (* (frame-char-width) + (if (< (- (point) (point-at-bol)) prmt-size) + (- (point) (point-at-bol)) + prmt-size)))) + ;; Try to put frame at the best possible place. + ;; Frame should be below point if enough + ;; place, otherwise above point and + ;; current line should not be hidden + ;; by helm frame. + (top . ,(if (> (cdr pos) half-screen-size) + ;; Above point + (- (cdr pos) + ;; add 2 lines to make sure there is always a gap + (* (+ helm-display-buffer-height 2) line-height) + ;; account for title bar height too + (cddr (assq 'title-bar-size frame-info))) + ;; Below point + (+ (cdr pos) line-height))) + (title . "Helm") + (undecorated . ,helm-use-undecorated-frame-option) + (background-color . ,(or helm-frame-background-color + (face-attribute 'default :background))) + (foreground-color . ,(or helm-frame-foreground-color + (face-attribute 'default :foreground))) + (alpha . ,(or helm-frame-alpha 100)) + (font . ,(assoc-default 'font (frame-parameters))) + (vertical-scroll-bars . nil) + (menu-bar-lines . 0) + (fullscreen . nil) + (visibility . ,(null helm-display-buffer-reuse-frame)) + (minibuffer . t)))) display-buffer-alist) ;; Display minibuffer above or below only in initial session, ;; not on a session triggered by action, this way if user have @@ -3143,12 +3443,16 @@ Note that this feature is available only with emacs-25+." (defun helm-display-buffer-popup-frame (buffer frame-alist) (if helm-display-buffer-reuse-frame (let* ((x (cdr (assoc 'left frame-alist))) - (y (cdr (assoc 'top frame-alist)))) + (y (cdr (assoc 'top frame-alist))) + (width (cdr (assoc 'width frame-alist))) + (height (cdr (assoc 'height frame-alist)))) (unless (and helm-popup-frame (frame-live-p helm-popup-frame)) (setq helm-popup-frame (make-frame frame-alist))) (select-frame helm-popup-frame) (set-frame-position helm-popup-frame x y) + (set-frame-width helm-popup-frame width) + (set-frame-height helm-popup-frame height) (switch-to-buffer buffer) (select-frame-set-input-focus helm-popup-frame t)) ;; If user have changed `helm-display-buffer-reuse-frame' to nil @@ -3172,51 +3476,51 @@ Note that this feature is available only with emacs-25+." ;; (defun helm-get-sources (sources) "Transform each element of SOURCES in alist. -Returns the resulting list." +Return the resulting list." (when sources (mapcar (lambda (source) (if (listp source) source (symbol-value source))) (helm-normalize-sources sources)))) -(defun helm-initialize (any-resume any-input any-default any-sources) - "Start initialization of `helm' session. -For ANY-RESUME ANY-INPUT ANY-DEFAULT and ANY-SOURCES See `helm'." - (helm-log "start initialization: any-resume=%S any-input=%S" - any-resume any-input) +(defun helm-initialize (resume input default sources) + "Start initialization of Helm session. +For RESUME INPUT DEFAULT and SOURCES see `helm'." + (helm-log "start initialization: resume=%S input=%S" + resume input) (helm-frame-or-window-configuration 'save) - (let ((sources (helm-get-sources any-sources))) + (let ((sources-list (helm-get-sources sources))) (setq helm--in-fuzzy - (cl-loop for s in sources + (cl-loop for s in sources-list for matchfns = (helm-match-functions s) for searchfns = (helm-search-functions s) when (or (memq 'helm-fuzzy-match matchfns) (memq 'helm-fuzzy-search searchfns)) return t)) - (helm-log "sources = %S" sources) - (helm-set-local-variable 'helm-sources sources) + (helm-log "sources-list = %S" sources-list) + (helm-set-local-variable 'helm-sources sources-list) ;; Once `helm-buffer' is created `helm-sources' will be a local ;; variable which value is a list of alists. (helm-current-position 'save) - (if (helm-resume-p any-resume) + (if (helm-resume-p resume) (helm-initialize-overlays (helm-buffer-get)) - (helm-initial-setup any-default sources)) + (helm-initial-setup default sources-list)) (setq helm-alive-p t) - (unless (eq any-resume 'noresume) + (unless (eq resume 'noresume) (helm--push-and-remove-dups helm-buffer 'helm-buffers) (setq helm-last-buffer helm-buffer)) - (when any-input - (setq helm-input any-input - helm-pattern any-input) + (when input + (setq helm-input input + helm-pattern input) (helm--fuzzy-match-maybe-set-pattern)) ;; If a `resume' attribute is present `helm-compute-attr-in-sources' ;; will run its function. - (when (helm-resume-p any-resume) + (when (helm-resume-p resume) (helm-compute-attr-in-sources 'resume)) (helm-log "end initialization"))) (defun helm-initialize-overlays (buffer) - "Initialize helm overlays in BUFFER." + "Initialize Helm overlays in BUFFER." (helm-log "overlay setup") (if helm-selection-overlay ;; make sure the overlay belongs to the helm buffer if @@ -3229,49 +3533,8 @@ For ANY-RESUME ANY-INPUT ANY-DEFAULT and ANY-SOURCES See `helm'." (overlay-put helm-selection-overlay 'face 'helm-selection) (overlay-put helm-selection-overlay 'priority 1))) -(defun helm-restore-position-on-quit () - "Restore position in `helm-current-buffer' when quitting." - (helm-current-position 'restore)) - -(defun helm--push-and-remove-dups (elm sym) - "Move ELM of SYM value on top and set SYM to this new value." - (set sym (cons elm (delete elm (symbol-value sym))))) - -(defun helm--current-buffer () - "[internal] Return `current-buffer' BEFORE `helm-buffer' is initialized. -Note that it returns the minibuffer in use after helm has started -and is intended for `helm-initial-setup'. To get the buffer where -helm was started, use `helm-current-buffer' instead." - (if (minibuffer-window-active-p (minibuffer-window)) - ;; If minibuffer is active be sure to use it's buffer - ;; as `helm-current-buffer', this allow to use helm - ;; from an already active minibuffer (M-: etc...) - (window-buffer (active-minibuffer-window)) - ;; Fix Issue #456 - ;; Use this instead of `current-buffer' to ensure - ;; helm session started in helm-mode from a completing-read - ;; Use really the buffer where we started and not the one - ;; where the completing-read is wrapped. i.e - ;; (with-current-buffer SOME-OTHER-BUFFER (completing-read [...]) - (window-buffer (with-selected-window (minibuffer-window) - (minibuffer-selected-window))))) - -(defun helm--run-init-hooks (hook sources) - "Run after and before init hooks local to source. -See :after-init-hook and :before-init-hook in `helm-source'." - (cl-loop with sname = (cl-ecase hook - (before-init-hook "h-before-init-hook") - (after-init-hook "h-after-init-hook")) - with h = (cl-gensym sname) - for s in sources - for hv = (assoc-default hook s) - if (and hv (not (symbolp hv))) - do (set h hv) - and do (helm-log-run-hook h) - else do (helm-log-run-hook hv))) - -(defun helm-initial-setup (any-default sources) - "Initialize helm settings and set up the helm buffer." +(defun helm-initial-setup (default sources) + "Initialize Helm settings and set up the Helm buffer." ;; Run global hook. (helm-log-run-hook 'helm-before-initialize-hook) ;; Run local source hook. @@ -3308,9 +3571,9 @@ See :after-init-hook and :before-init-hook in `helm-source'." (or helm-split-window-default-side 'below))) ;; Call the init function for sources where appropriate (helm-compute-attr-in-sources 'init sources) - (setq helm-pattern (or (and helm--maybe-use-default-as-input - (or (if (listp any-default) - (car any-default) any-default) + (setq helm-pattern (or (and helm-maybe-use-default-as-input + (or (if (listp default) + (car default) default) (with-helm-current-buffer (thing-at-point 'symbol)))) "")) @@ -3323,10 +3586,51 @@ See :after-init-hook and :before-init-hook in `helm-source'." ;; Run local source hook. (helm--run-init-hooks 'after-init-hook sources)) +(defun helm--run-init-hooks (hook sources) + "Run after and before init hooks local to source. +See :after-init-hook and :before-init-hook in `helm-source'." + (cl-loop with sname = (cl-ecase hook + (before-init-hook "h-before-init-hook") + (after-init-hook "h-after-init-hook")) + with h = (cl-gensym sname) + for s in sources + for hv = (assoc-default hook s) + if (and hv (not (symbolp hv))) + do (set h hv) + and do (helm-log-run-hook h) + else do (helm-log-run-hook hv))) + +(defun helm-restore-position-on-quit () + "Restore position in `helm-current-buffer' when quitting." + (helm-current-position 'restore)) + +(defun helm--push-and-remove-dups (elm sym) + "Move ELM of SYM value on top and set SYM to this new value." + (set sym (cons elm (delete elm (symbol-value sym))))) + +(defun helm--current-buffer () + "[INTERNAL] Return `current-buffer' BEFORE `helm-buffer' is initialized. +Note that it returns the minibuffer in use after Helm has started +and is intended for `helm-initial-setup'. To get the buffer where +Helm was started, use `helm-current-buffer' instead." + (if (minibuffer-window-active-p (minibuffer-window)) + ;; If minibuffer is active be sure to use it's buffer + ;; as `helm-current-buffer', this allow to use helm + ;; from an already active minibuffer (M-: etc...) + (window-buffer (active-minibuffer-window)) + ;; Fix Issue #456 + ;; Use this instead of `current-buffer' to ensure + ;; helm session started in helm-mode from a completing-read + ;; Use really the buffer where we started and not the one + ;; where the completing-read is wrapped. i.e + ;; (with-current-buffer SOME-OTHER-BUFFER (completing-read [...]) + (window-buffer (with-selected-window (minibuffer-window) + (minibuffer-selected-window))))) + (define-derived-mode helm-major-mode - fundamental-mode "Hmm" - "[Internal] Provide major-mode name in helm buffers. -Unuseful when used outside helm, don't use it.") + fundamental-mode "Hmm" + "[INTERNAL] Provide major-mode name in Helm buffers. +Unuseful when used outside Helm, don't use it.") (put 'helm-major-mode 'mode-class 'special) (put 'helm-major-mode 'helm-only t) @@ -3364,9 +3668,9 @@ Unuseful when used outside helm, don't use it.") (get-buffer helm-buffer))) (define-minor-mode helm--minor-mode - "[INTERNAL] Enable keymap in helm minibuffer. -Since this mode has no effect when run outside of helm context, -please don't use it outside helm. + "[INTERNAL] Enable keymap in Helm minibuffer. +Since this mode has no effect when run outside of Helm context, +please don't use it outside of Helm. \\{helm-map}" :group 'helm @@ -3376,23 +3680,23 @@ please don't use it outside helm. (defun helm--reset-default-pattern () (setq helm-pattern "") - (setq helm--maybe-use-default-as-input nil)) + (setq helm-maybe-use-default-as-input nil)) -(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 ANY-DEFAULT ANY-HISTORY, See `helm'." +(defun helm-read-from-minibuffer (prompt + input preselect resume + keymap default history) + "Read pattern with prompt PROMPT and initial input INPUT. +For PRESELECT RESUME KEYMAP DEFAULT HISTORY, see `helm'." (with-helm-buffer - (if (and (helm-resume-p any-resume) - ;; When no source, helm-buffer is empty - ;; or contain non--candidate lines (e.g grep exit status) - (helm-get-current-source)) - (helm-mark-current-line t) - (helm-update any-preselect)) + (if (and (helm-resume-p resume) + ;; When no source, helm-buffer is empty + ;; or contain non--candidate lines (e.g grep exit status) + (helm-get-current-source)) + (helm-mark-current-line t) + (helm-update preselect)) (let* ((src (helm-get-current-source)) (src-keymap (assoc-default 'keymap src)) - (hist (or (and any-history (symbolp any-history) any-history) + (hist (or (and history (symbolp history) history) ;; Needed for resuming. (assoc-default 'history src))) (timer nil) @@ -3407,15 +3711,15 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." (helm-log "helm-execute-action-at-once-if-one = %S" helm-execute-action-at-once-if-one) (helm-log "helm-quit-if-no-candidate = %S" helm-quit-if-no-candidate) - (when (and src (helm-resume-p any-resume)) + (when (and src (helm-resume-p resume)) (helm-display-mode-line src)) ;; Reset `helm-pattern' and update ;; display if no result found with precedent value of `helm-pattern' ;; unless `helm-quit-if-no-candidate' is non-`nil', in this case ;; Don't force update with an empty pattern. - ;; Reset also `helm--maybe-use-default-as-input' as this checking + ;; Reset also `helm-maybe-use-default-as-input' as this checking ;; happen only on startup. - (when helm--maybe-use-default-as-input + (when helm-maybe-use-default-as-input ;; Store value of `default' temporarily here waiting next update ;; to allow actions like helm-moccur-action matching pattern ;; at the place it jump to. @@ -3430,7 +3734,7 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." ;; when we start with an empty pattern. (and (helm-empty-buffer-p) (null helm-quit-if-no-candidate) - (helm-force-update))) + (helm-force-update preselect))) ;; Handle `helm-execute-action-at-once-if-one' and ;; `helm-quit-if-no-candidate' now. (cond ((and (if (functionp helm-execute-action-at-once-if-one) @@ -3446,11 +3750,11 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." (and (functionp helm-quit-if-no-candidate) (funcall helm-quit-if-no-candidate))) (t ; Enter now minibuffer and wait for input. - (let ((tap (or any-default + (let ((tap (or default (with-helm-current-buffer (thing-at-point 'symbol))))) (when helm-execute-action-at-once-if-one - (helm-display-buffer helm-buffer any-resume) + (helm-display-buffer helm-buffer resume) (select-window (helm-window))) (unwind-protect (minibuffer-with-setup-hook @@ -3460,10 +3764,10 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." ;; Now override the global value of `helm-map' with ;; the local one which is in this order: ;; - The keymap of current source. - ;; - The value passed in ANY-KEYMAP + ;; - The value passed in KEYMAP ;; - Or fallback to the global value of helm-map. (helm--maybe-update-keymap - (or src-keymap any-keymap helm-map)) + (or src-keymap keymap helm-map)) (helm-log-run-hook 'helm-minibuffer-set-up-hook) (setq timer (run-with-idle-timer @@ -3481,17 +3785,17 @@ For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." (helm-print-error-messages)))))) ;; minibuffer has already been filled here. (helm--update-header-line)) - (read-from-minibuffer (propertize (or any-prompt "pattern: ") + (read-from-minibuffer (propertize (or prompt "pattern: ") 'face 'helm-minibuffer-prompt) - any-input helm-map + input helm-map nil hist tap helm-inherit-input-method)) (when timer (cancel-timer timer) (setq timer nil))))))))) (defun helm-toggle-suspend-update () "Enable or disable display update in helm. -This can be useful for example for quietly writing a complex regexp -without helm constantly updating." +This can be useful for example for quietly writing a complex +regexp without Helm constantly updating." (interactive) (helm-suspend-update (not helm-suspend-update-flag) t) (setq helm--suspend-update-interactive-flag @@ -3535,24 +3839,24 @@ Update is reenabled when idle 1s." (put 'helm-delete-backward-no-update 'helm-only t) (defun helm--suspend-read-passwd (old--fn &rest args) - "Suspend helm while reading password. -This is used to advice `tramp-read-passwd', `ange-ftp-get-passwd' and -`epa-passphrase-callback-function'." + "Suspend Helm while reading password. +This is used to advice `tramp-read-passwd', `ange-ftp-get-passwd' +and `epa-passphrase-callback-function'." ;; Suspend update when prompting for a tramp password. (setq helm-suspend-update-flag t) (setq overriding-terminal-local-map nil) (setq helm--reading-passwd-or-string t) (unwind-protect - ;; No need to suspend timer in emacs-24.4 - ;; it is fixed upstream. - (apply old--fn args) + ;; No need to suspend timer in emacs-24.4 + ;; it is fixed upstream. + (apply old--fn args) (setq helm--reading-passwd-or-string nil) (setq helm-suspend-update-flag nil))) (defun helm--maybe-update-keymap (&optional map) "Handle different keymaps in multiples sources. -Overrides `helm-map' with the local map of current source. If no +Overrides `helm-map' with the local map of current source. If no map is found in current source, does nothing (keeps previous map)." (with-helm-buffer @@ -3582,10 +3886,10 @@ map)." map)) (define-minor-mode helm--remap-mouse-mode - "[INTERNAL] Prevent escaping helm minibuffer with mouse clicks. + "[INTERNAL] Prevent escaping helm minibuffer with mouse clicks. Do nothing when used outside of helm context. -WARNING: Do not use this mode yourself, it is internal to helm." +WARNING: Do not use this mode yourself, it is internal to Helm." :group 'helm :global t :keymap helm--remap-mouse-mode-map @@ -3596,11 +3900,14 @@ WARNING: Do not use this mode yourself, it is internal to helm." ;; Clean up (defun helm-cleanup () - "Clean up the mess when helm exit or quit." + "Clean up the mess when Helm exit or quit." (helm-log "start cleanup") (with-current-buffer helm-buffer (let ((frame (selected-frame))) (setq cursor-type t) + ;; Ensure restoring default-value of mode-line to allow user + ;; using the mouse when helm is inactive (issues #1517,#2377). + (setq mode-line-format (default-value 'mode-line-format)) (remove-hook 'post-command-hook 'helm--maybe-update-keymap) (remove-hook 'post-command-hook 'helm--update-header-line) ;; Be sure we call cleanup functions from helm-buffer. @@ -3689,7 +3996,7 @@ WARNING: Do not use this mode yourself, it is internal to helm." "Retrieve and return the list of candidates from SOURCE." (let* ((candidate-fn (assoc-default 'candidates source)) (candidate-proc (assoc-default 'candidates-process source)) - ;; See comment in helm-get-cached-candidates (Issue 2113). + ;; See comment in helm-get-cached-candidates (Issue #2113). (inhibit-quit candidate-proc) cfn-error (notify-error @@ -3754,7 +4061,7 @@ Cache the candidates if there is no cached value yet." (candidate-cache (gethash name helm-candidate-cache)) ;; Bind inhibit-quit to ensure function terminate in case of ;; quit from helm-while-no-input and processes are added to - ;; helm-async-processes for further deletion (Issue 2113). + ;; helm-async-processes for further deletion (Issue #2113). (inhibit-quit (assoc-default 'candidates-process source))) (helm-aif candidate-cache (prog1 it (helm-log "Use cached candidates")) @@ -3792,17 +4099,17 @@ Cache the candidates if there is no cached value yet." `(helm-aif (assoc-default 'filter-one-by-one ,source) (let ((real (if (consp ,candidate) (cdr ,candidate) - ,candidate))) + ,candidate))) (if (and (listp it) (not (functionp it))) ;; Don't treat lambda's as list. (cl-loop for f in it do (setq ,candidate (funcall f real)) finally return ,candidate) - (setq ,candidate (funcall it real)))) + (setq ,candidate (funcall it real)))) ,candidate)) (defun helm--initialize-one-by-one-candidates (candidates source) - "Process the CANDIDATES with the `filter-one-by-one' function in SOURCE. + "Process CANDIDATES with the `filter-one-by-one' function in SOURCE. Return CANDIDATES unchanged when pattern is not empty." (helm-aif (and (string= helm-pattern "") (assoc-default 'filter-one-by-one source)) @@ -3813,8 +4120,9 @@ Return CANDIDATES unchanged when pattern is not empty." (defun helm-process-filtered-candidate-transformer-maybe (candidates source process-p) "Execute `filtered-candidate-transformer' function(s) on CANDIDATES in SOURCE. -When PROCESS-P is non-`nil' execute `filtered-candidate-transformer' -functions if some, otherwise return CANDIDATES." +When PROCESS-P is non-nil execute +`filtered-candidate-transformer' functions if some, otherwise +return CANDIDATES." (if process-p ;; When no filter return CANDIDATES unmodified. (helm-process-filtered-candidate-transformer candidates source) @@ -3836,7 +4144,7 @@ functions if some, otherwise return CANDIDATES." (defun helm-transform-candidates (candidates source &optional process-p) "Transform CANDIDATES from SOURCE according to candidate transformers. -When PROCESS-P is non-`nil' executes the +When PROCESS-P is non-nil executes the `filtered-candidate-transformer' functions, otherwise processes `candidate-transformer' functions only, `filtered-candidate-transformer' functions being processed later, @@ -3857,7 +4165,7 @@ maybe filtered CANDIDATES." "Apply candidate-number-limit attribute value. This overrides `helm-candidate-number-limit' variable. -e.g: +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) @@ -3900,7 +4208,7 @@ Default function to match candidates according to `helm-pattern'." (when helm--in-fuzzy (let ((fun (if (string-match "\\`\\^" helm-pattern) #'identity - #'helm--mapconcat-pattern))) + #'helm--mapconcat-pattern))) (clrhash helm--fuzzy-regexp-cache) ;; FIXME: Splitted part are not handled here, ;; I must compute them in `helm-search-match-part' @@ -3910,14 +4218,14 @@ Default function to match candidates according to `helm-pattern'." (if (> (length helm-pattern) 1) (list (regexp-quote (substring helm-pattern 1 2)) (funcall fun (substring helm-pattern 1))) - '("" "")) + '("" "")) helm--fuzzy-regexp-cache) - (puthash 'helm-pattern - (if (> (length helm-pattern) 0) - (list (regexp-quote (substring helm-pattern 0 1)) - (funcall fun helm-pattern)) - '("" "")) - helm--fuzzy-regexp-cache))))) + (puthash 'helm-pattern + (if (> (length helm-pattern) 0) + (list (regexp-quote (substring helm-pattern 0 1)) + (funcall fun helm-pattern)) + '("" "")) + helm--fuzzy-regexp-cache))))) (defun helm-fuzzy-match (candidate) "Check if `helm-pattern' fuzzy matches CANDIDATE. @@ -3969,11 +4277,12 @@ This function is used with sources built with `helm-source-sync'." Score is calculated for contiguous matches found with PATTERN. Score is 100 (maximum) if PATTERN is fully matched in CANDIDATE. One point bonus is added to score when PATTERN prefix matches -CANDIDATE. Contiguous matches get a coefficient of 2." +CANDIDATE. Contiguous matches get a coefficient of 2." (let* ((cand (if (stringp candidate) candidate (helm-stringify candidate))) (pat-lookup (helm--collect-pairs-in-string pattern)) (str-lookup (helm--collect-pairs-in-string cand)) + (inter (cl-nintersection pat-lookup str-lookup :test 'equal)) ;; Prefix (bonus (cond ((or (equal (car pat-lookup) (car str-lookup)) (equal (caar pat-lookup) (caar str-lookup))) @@ -3999,16 +4308,14 @@ CANDIDATE. Contiguous matches get a coefficient of 2." ;; That's mean that "wiaaaki" will not take precedence ;; on "aaawiki" when matching on "wiki" even if "wiaaaki" ;; starts by "wi". - (* (length (cl-nintersection - pat-lookup str-lookup :test 'equal)) - 2))))) + (* (length inter) 2))))) (defun helm-fuzzy-matching-default-sort-fn-1 (candidates &optional use-real basename preserve-tie-order) "The transformer for sorting candidates in fuzzy matching. It sorts on the display part by default. -Sorts CANDIDATES by their scores as calculated by -`helm-score-candidate-for-pattern'. Set USE-REAL to non-`nil' to +It sorts CANDIDATES by their scores as calculated by +`helm-score-candidate-for-pattern'. Set USE-REAL to non-nil to sort on the real part. If BASENAME is non-nil assume we are completing filenames and sort on basename of candidates. If PRESERVE-TIE-ORDER is nil, ties in scores are sorted by length of @@ -4062,7 +4369,7 @@ The default function, `helm-fuzzy-matching-default-sort-fn', sorts ties by length, shortest first. This function may be more useful when the order of the candidates is meaningful, e.g. with `recentf-list'." - (helm-fuzzy-matching-default-sort-fn-1 candidates nil t)) + (helm-fuzzy-matching-default-sort-fn-1 candidates nil nil t)) (defun helm--maybe-get-migemo-pattern (pattern) (or (and helm-migemo-mode @@ -4087,7 +4394,9 @@ to the matching method in use." (count 0) beg-str end-str) ;; Extract all parts of display keeping original properties. - (when (and mp (string-match (regexp-quote mp) display)) + (when (and mp (ignore-errors + ;; Avoid error when candidate is a huge line. + (string-match (regexp-quote mp) display))) (setq beg-str (substring display 0 (match-beginning 0)) end-str (substring display (match-end 0) (length display)) mp (substring display (match-beginning 0) (match-end 0)))) @@ -4109,7 +4418,7 @@ to the matching method in use." with patterns = (if multi-match (mapcar #'helm--maybe-get-migemo-pattern (helm-mm-split-pattern helm-pattern)) - (split-string helm-pattern "" t)) + (split-string helm-pattern "" t)) for p in patterns ;; Multi matches (regexps patterns). if multi-match do @@ -4134,9 +4443,59 @@ to the matching method in use." (defun helm-fuzzy-highlight-matches (candidates _source) "The filtered-candidate-transformer function to highlight fuzzy matches. See `helm-fuzzy-default-highlight-match'." + (cl-assert helm-fuzzy-matching-highlight-fn nil "Wrong type argument functionp: nil") (cl-loop for c in candidates collect (funcall helm-fuzzy-matching-highlight-fn c))) + +;;; helm-flex style +;; +;; Provide the emacs-27 flex style for emacs<27. +;; Reuse the flex scoring algorithm of flex style in emacs-27. +(defun helm-flex--style-score (str regexp) + "Score STR candidate according to PATTERN. + +REGEXP should be generated from a pattern which is a list like +\'(point \"f\" any \"o\" any \"b\" any) for \"fob\" as pattern. +Such pattern is build with +`helm-completion--flex-transform-pattern' function. + +Function extracted from `completion-pcm--hilit-commonality' in +emacs-27 to provide such scoring in emacs<27." + ;; Don't modify the string itself. + (setq str (copy-sequence str)) + (unless (string-match regexp str) + (error "Internal error: %s does not match %s" regexp str)) + (let* ((md (match-data)) + (start (pop md)) + (len (length str)) + (score-numerator 0) + (score-denominator 0) + (last-b 0) + (update-score + (lambda (a b) + "Update score variables given match range (A B)." + (setq score-numerator (+ score-numerator (- b a))) + (unless (or (= a last-b) + (zerop last-b) + (= a (length str))) + (setq score-denominator (+ score-denominator + 1 + (expt (- a last-b 1) + (/ 1.0 3))))) + (setq last-b b)))) + (funcall update-score start start) + (setq md (cdr md)) + (while md + (funcall update-score start (pop md)) + (setq start (pop md))) + (funcall update-score len len) + (unless (zerop (length str)) + (put-text-property + 0 1 'completion-score + (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + str) + ;;; Matching candidates ;; @@ -4153,12 +4512,6 @@ See `helm-fuzzy-default-highlight-match'." (if (and (listp searchfns) (not (functionp searchfns))) searchfns (list searchfns)))) -(defun helm-take-first-elements (seq n) - "Return the first N elements of SEQ if SEQ is longer than N. -It is used for narrowing list of candidates to the -`helm-candidate-number-limit'." - (if (> (length seq) n) (cl-subseq seq 0 n) seq)) - (defun helm-match-from-candidates (cands matchfns match-part-fn limit source) (when cands ; nil in async sources. (condition-case-unless-debug err @@ -4171,8 +4524,12 @@ It is used for narrowing list of candidates to the when (< count limit) nconc (cl-loop for c in cands for dup = (gethash c hash) + for disp = (helm-candidate-get-display c) while (< count limit) - for target = (helm-candidate-get-display c) + for target = (if (helm-get-attr 'match-on-real source) + (or (cdr-safe c) + (get-text-property 0 'helm-realvalue disp)) + disp) for prop-part = (get-text-property 0 'match-part target) for part = (and match-part-fn (or prop-part @@ -4224,10 +4581,11 @@ It is used for narrowing list of candidates to the ;; the candidates being processed directly in `helm-output-filter' ;; process-filter. (helm-process-filtered-candidate-transformer - ;; Using in-buffer method or helm-pattern is empty - ;; in this case compute all candidates. + ;; When using in-buffer method or helm-pattern is empty or + ;; using dynamic completion always compute all candidates. (if (or (equal helm-pattern "") - (helm--candidates-in-buffer-p matchfns)) + (assq 'match-dynamic source) + (helm--candidates-in-buffer-p source)) ;; Compute all candidates up to LIMIT. ;; one-by-one are computed here only for sources that ;; display a list of candidates even with an empty @@ -4236,16 +4594,16 @@ It is used for narrowing list of candidates to the (helm-take-first-elements (helm-get-cached-candidates source) limit) source) - ;; Compute candidates according to pattern with their match - ;; fns. - ;; one-by-one filtered candidates are computed during the - ;; execution of next loop in `helm-match-from-candidates'. - (helm-match-from-candidates - (helm-get-cached-candidates source) matchfns matchpartfn limit source)) + ;; Compute candidates according to pattern with their match + ;; fns. + ;; one-by-one filtered candidates are computed during the + ;; execution of next loop in `helm-match-from-candidates'. + (helm-match-from-candidates + (helm-get-cached-candidates source) matchfns matchpartfn limit source)) source)))) -(defun helm--candidates-in-buffer-p (matchfns) - (equal matchfns '(identity))) +(defun helm--candidates-in-buffer-p (source) + (assq 'search source)) (defun helm-render-source (source matches) "Display MATCHES from SOURCE according to its settings." @@ -4280,13 +4638,14 @@ It is used for narrowing list of candidates to the (helm-while-no-input ,@body)))) (defun helm--collect-matches (src-list) - "Returns a list of matches for each source in SRC-LIST. - -The resulting value is a list of lists, e.g ((a b c) (c d) (e f)) or -\(nil nil nil) for three sources when no matches found, however this -function can be interrupted by new input and in this case returns a -plain `nil' i.e not (nil), in this case `helm-update' is not rendering -the source, keeping previous candidates in display." + "Return a list of matches for each source in SRC-LIST. + +The resulting value is a list of lists, e.g. ((a b c) (c d) (e +f)) or \(nil nil nil) for three sources when no matches found, +however this function can be interrupted by new input and in this +case returns a plain nil i.e. not (nil), in this case +`helm-update' is not rendering the source, keeping previous +candidates in display." (let ((matches (helm--maybe-use-while-no-input (cl-loop for src in src-list collect (helm-compute-matches src))))) @@ -4297,21 +4656,23 @@ the source, keeping previous candidates in display." ;; ;; (cl-defun helm-set-case-fold-search (&optional (pattern helm-pattern)) - "Used to set the value of `case-fold-search' in helm. + "Used to set the value of `case-fold-search' in Helm. Return t or nil depending on the value of `helm-case-fold-search' and `helm-pattern'." - (let ((helm-case-fold-search - (helm-aif (assq 'case-fold-search (helm-get-current-source)) - (cdr it) - helm-case-fold-search)) - ;; Only parse basename for filenames - ;; to avoid setting case sensitivity - ;; when expanded directories contains upcase - ;; characters. - (bn-or-pattern (if (string-match "[~/]*" pattern) - (helm-basename pattern) - pattern))) - (helm-set-case-fold-search-1 bn-or-pattern))) + (if helm-alive-p + (let ((helm-case-fold-search + (helm-aif (assq 'case-fold-search (helm-get-current-source)) + (cdr it) + helm-case-fold-search)) + ;; Only parse basename for filenames + ;; to avoid setting case sensitivity + ;; when expanded directories contains upcase + ;; characters. + (bn-or-pattern (if (string-match "[~/]*" pattern) + (helm-basename pattern) + pattern))) + (helm-set-case-fold-search-1 bn-or-pattern)) + case-fold-search)) (defun helm-set-case-fold-search-1 (pattern) (cl-case helm-case-fold-search @@ -4347,33 +4708,33 @@ without recomputing them, it should be a list of lists." (with-current-buffer (helm-buffer-get) (set (make-local-variable 'helm-input-local) helm-pattern) (unwind-protect - (let (sources matches) - ;; Collect sources ready to be updated. - (setq sources - (cl-loop for src in helm-sources - when (helm-update-source-p src) - collect src)) - ;; When no sources to update erase buffer - ;; to avoid duplication of header and candidates - ;; when next chunk of update will arrive, - ;; otherwise the buffer is erased AFTER [1] the results - ;; are computed. - (unless sources (erase-buffer)) - ;; Compute matches without rendering the sources. - ;; This prevent the helm-buffer flickering when constantly - ;; updating. - (helm-log "Matches: %S" - (setq matches (or candidates (helm--collect-matches sources)))) - ;; If computing matches finished and is not interrupted - ;; erase the helm-buffer and render results (Fix #1157). - (when matches ;; nil only when interrupted by helm-while-no-input. - (erase-buffer) ; [1] - (cl-loop for src in sources - for mtc in matches - do (helm-render-source src mtc)) - ;; Move to first line only when there is matches - ;; to avoid cursor moving upside down (issue #1703). - (helm--update-move-first-line))) + (let (sources matches) + ;; Collect sources ready to be updated. + (setq sources + (cl-loop for src in helm-sources + when (helm-update-source-p src) + collect src)) + ;; When no sources to update erase buffer + ;; to avoid duplication of header and candidates + ;; when next chunk of update will arrive, + ;; otherwise the buffer is erased AFTER [1] the results + ;; are computed. + (unless sources (erase-buffer)) + ;; Compute matches without rendering the sources. + ;; This prevent the helm-buffer flickering when constantly + ;; updating. + (helm-log "Matches: %S" + (setq matches (or candidates (helm--collect-matches sources)))) + ;; If computing matches finished and is not interrupted + ;; erase the helm-buffer and render results (Fix #1157). + (when matches ;; nil only when interrupted by helm-while-no-input. + (erase-buffer) ; [1] + (cl-loop for src in sources + for mtc in matches + do (helm-render-source src mtc)) + ;; Move to first line only when there is matches + ;; to avoid cursor moving upside down (issue #1703). + (helm--update-move-first-line))) ;; When there is only one async source, update mode-line and run ;; `helm-after-update-hook' in `helm-output-filter--post-process', ;; when there is more than one source, update mode-line and run @@ -4435,8 +4796,8 @@ pattern has changed. Selection is preserved to current candidate if it still exists after update or moved to PRESELECT, if specified. -The helm-window is recentered at the end when RECENTER is `t' -which is the default, RECENTER can be also a number in this case it is +The helm-window is re-centered at the end when RECENTER is t which +is the default. RECENTER can be also a number in this case it is passed as argument to `recenter'." (with-helm-buffer (let* ((source (helm-get-current-source)) @@ -4460,7 +4821,7 @@ passed as argument to `recenter'." "Reinit SOURCE by calling its update and init functions." ;; When using a specific buffer as cache, don't kill it. (helm-aif (and (null (bufferp (assoc-default - (helm-attr 'name source) + (helm-get-attr 'name source) helm--candidate-buffer-alist))) (helm-apply-functions-from-source source 'helm-candidate-buffer)) @@ -4473,19 +4834,21 @@ passed as argument to `recenter'." (defun helm-redisplay-buffer () "Redisplay candidates in `helm-buffer'. -Candidates are not recomputed, only redisplayed after modifying the -whole list of candidates in each source with functions found in -`redisplay' attribute of current source. Note that candidates are -redisplayed with their display part with all properties included only. -This function is used in async sources to transform the whole list of -candidates from the sentinel functions (i.e when all candidates have -been computed) because other filters like `candidate-transformer' are -modifying only each chunk of candidates from process-filter as they -come in and not the whole list. Use this for e.g sorting the whole -list of async candidates once computed. -Note: To ensure redisplay is done in async sources after helm -reached `candidate-number-limit' you will have also to redisplay your -candidates from `helm-async-outer-limit-hook'." +Candidates are not recomputed, only redisplayed after modifying +the whole list of candidates in each source with functions found +in `redisplay' attribute of current source. Note that candidates +are redisplayed with their display part with all properties +included only. This function is used in async sources to +transform the whole list of candidates from the sentinel +functions (i.e. when all candidates have been computed) because +other filters like `candidate-transformer' are modifying only +each chunk of candidates from `process-filter' as they come in +and not the whole list. Use this for e.g. sorting the whole list +of async candidates once computed. + +Note: To ensure redisplay is done in async sources after Helm +reached `candidate-number-limit' you will have also to redisplay +your candidates from `helm-async-outer-limit-hook'." (with-helm-buffer (let ((get-cands (lambda (source) (let ((fns (assoc-default 'redisplay source)) @@ -4513,7 +4876,7 @@ candidates from `helm-async-outer-limit-hook'." (when (save-excursion (helm-move--end-of-source) (forward-line 1) (eobp)) - (cl-return nil)) + (cl-return nil)) (helm-next-source)) (nreverse sources))))) (goto-char (point-min)) @@ -4524,7 +4887,7 @@ candidates from `helm-async-outer-limit-hook'." (when (cl-loop for src in sources thereis (string= name (assoc-default 'name src))) - (funcall get-cands s))))))) + (funcall get-cands s))))))) (defun helm-remove-candidate-cache (source) "Remove SOURCE from `helm-candidate-cache'." @@ -4532,10 +4895,10 @@ candidates from `helm-async-outer-limit-hook'." (defun helm-insert-match (match insert-function &optional num source) "Insert MATCH into `helm-buffer' with INSERT-FUNCTION. -If MATCH is a cons cell then insert the car as display with -the cdr stored as real value in a `helm-realvalue' text property. -Args NUM and SOURCE are also stored as text property when specified as -respectively `helm-cand-num' and `helm-cur-source'." +If MATCH is a cons cell then insert the car as display with the +cdr stored as real value in a `helm-realvalue' text property. +Args NUM and SOURCE are also stored as text property when +specified as respectively `helm-cand-num' and `helm-cur-source'." (let ((start (point-at-bol (point))) (dispvalue (helm-candidate-get-display match)) (realvalue (cdr-safe match)) @@ -4558,15 +4921,15 @@ respectively `helm-cand-num' and `helm-cur-source'." (when map (define-key map [mouse-1] 'helm-mouse-select-candidate) (define-key map [mouse-2] 'ignore) - (define-key map [mouse-3] 'helm-select-action) + (define-key map [mouse-3] 'helm-menu-select-action) (add-text-properties start end `(mouse-face highlight - keymap ,map - help-echo ,(pcase (get-text-property start 'help-echo) - ((and it (pred stringp)) - (concat it "\nmouse-1: select candidate\nmouse-3: menu actions")) - (_ "mouse-1: select candidate\nmouse-3: menu actions"))))) + keymap ,map + help-echo ,(pcase (get-text-property start 'help-echo) + ((and it (pred stringp)) + (concat it "\nmouse-1: select candidate\nmouse-3: menu actions")) + (_ "mouse-1: select candidate\nmouse-3: menu actions"))))) (when num (put-text-property start end 'helm-cand-num num)) (when source @@ -4605,18 +4968,18 @@ respectively `helm-cand-num' and `helm-cur-source'." (let* ((window (posn-window (event-end event))) (pos (posn-point (event-end event)))) (unwind-protect - (with-current-buffer (window-buffer window) - (if (and (helm-action-window) - (eql window (get-buffer-window helm-buffer))) - (user-error "selection in helm-window not available while selecting action") - (helm--mouse-reset-selection-help-echo) - (goto-char pos) - (when (helm-pos-multiline-p) - (goto-char (or (helm-get-previous-candidate-separator-pos) - (helm-get-previous-header-pos))) - (forward-line 1))) - (helm-mark-current-line) - (helm-follow-execute-persistent-action-maybe)) + (with-current-buffer (window-buffer window) + (if (and (helm-action-window) + (eql window (get-buffer-window helm-buffer))) + (user-error "selection in helm-window not available while selecting action") + (helm--mouse-reset-selection-help-echo) + (goto-char pos) + (when (helm-pos-multiline-p) + (goto-char (or (helm-get-previous-candidate-separator-pos) + (helm-get-previous-header-pos))) + (forward-line 1))) + (helm-mark-current-line) + (helm-follow-execute-persistent-action-maybe)) (select-window (minibuffer-window)) (set-buffer (window-buffer window))))) (put 'helm-mouse-select-candidate 'helm-only t) @@ -4633,8 +4996,8 @@ if SOURCE has header-name attribute." (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 value then display -this additional info after the source name by overlay." +If DISPLAY-STRING is non-nil and a string value then display this +additional info after the source name by overlay." (unless (bobp) (let ((start (point))) (insert (propertize "\n" 'face 'helm-eob-line)) @@ -4648,28 +5011,28 @@ this additional info after the source name by overlay." 'display display-string)) (insert "\n") (add-text-properties start (point) '(face helm-source-header - ;; Disable line numbers on - ;; source headers. - display-line-numbers-disable t)))) + ;; Disable line numbers on + ;; source headers. + display-line-numbers-disable t)))) (defun helm-insert-candidate-separator () - "Insert separator of candidates into the helm buffer." + "Insert separator of candidates into the Helm buffer." (insert (propertize helm-candidate-separator 'face 'helm-separator)) (put-text-property (point-at-bol) (point-at-eol) 'helm-candidate-separator t) (insert "\n")) (defun helm-init-relative-display-line-numbers () - "Enable `display-line-numbers' for helm buffers. + "Enable `display-line-numbers' for Helm buffers. This is intended to be added to `helm-after-initialize-hook'. -This will work only in Emacs-26+, i.e. Emacs -versions that have `display-line-numbers-mode'." +This will work only in Emacs-26+, i.e. Emacs versions that have +`display-line-numbers-mode'." (when (boundp 'display-line-numbers) (with-helm-buffer (setq display-line-numbers 'relative)))) (define-minor-mode helm-display-line-numbers-mode - "Toggle display of line numbers in current helm buffer." + "Toggle display of line numbers in current Helm buffer." :group 'helm (with-helm-alive-p (cl-assert (boundp 'display-line-numbers) nil @@ -4686,7 +5049,7 @@ versions that have `display-line-numbers-mode'." ;;; Async process ;; (defun helm-output-filter (process output-string) - "The `process-filter' function for helm async sources." + "The `process-filter' function for Helm async sources." (with-helm-quittable (helm-output-filter-1 (assoc process helm-async-processes) output-string))) @@ -4721,9 +5084,9 @@ versions that have `display-line-numbers-mode'." (1+ (cdr (assq 'item-count source))) source) (put-text-property start (point) 'helm-multiline t)) - (helm-insert-match candidate 'insert-before-markers - (1+ (cdr (assq 'item-count source))) - source)) + (helm-insert-match candidate 'insert-before-markers + (1+ (cdr (assq 'item-count source))) + source)) (cl-incf (cdr (assq 'item-count source))) (when (>= (assoc-default 'item-count source) limit) (helm-kill-async-process process) @@ -4817,15 +5180,15 @@ function." ;; is split, so jump to this position before executing action. (helm-current-position 'restore) (unwind-protect - (prog1 (helm-execute-selection-action-1) - (helm-log-run-hook 'helm-after-action-hook)) + (prog1 (helm-execute-selection-action-1) + (helm-log-run-hook 'helm-after-action-hook)) (setq helm--executing-helm-action nil))) (defun helm-execute-selection-action-1 (&optional selection action preserve-saved-action) "Execute ACTION on current SELECTION. -If PRESERVE-SAVED-ACTION is non-`nil', then save the action." +If PRESERVE-SAVED-ACTION is non-nil, then save the action." (helm-log "executing action") (setq action (helm-get-default-action (or action @@ -4869,7 +5232,7 @@ Coerce source with coerce function." (defun helm-select-action () "Select an action for the currently selected candidate. -If action buffer is selected, back to the helm buffer." +If action buffer is selected, back to the Helm buffer." (interactive) (with-helm-alive-p (let ((src (helm-get-current-source))) @@ -4892,26 +5255,50 @@ If action buffer is selected, back to the helm buffer." (if (functionp actions) (message "Sole action: %s" (if (or (consp actions) - (byte-code-function-p actions)) + (byte-code-function-p actions) + (helm-subr-native-elisp-p actions)) "Anonymous" actions)) - (helm-show-action-buffer actions) - ;; Be sure the minibuffer is entirely deleted (#907). - (helm--delete-minibuffer-contents-from "") - (helm--set-action-prompt) - (helm-check-minibuffer-input)))) + (helm-show-action-buffer actions) + ;; Be sure the minibuffer is entirely deleted (#907). + (helm--delete-minibuffer-contents-from "") + (helm--set-action-prompt) + (helm-check-minibuffer-input)))) (t (message "No Actions available"))) (helm-display-mode-line (helm-get-current-source)) (run-hooks 'helm-window-configuration-hook)))))) (put 'helm-select-action 'helm-only t) +(defun helm-menu-select-action (_event) + "Popup action menu from mouse-3." + (interactive "e") + (if (get-buffer-window helm-action-buffer 'visible) + (helm-select-action) + (let ((src (helm-get-current-source))) + (helm-aif (helm-get-actions-from-current-source src) + (progn + (setq helm-saved-current-source src) + (if (functionp it) + (message "Sole action: %s" + (if (or (consp it) + (byte-code-function-p it) + (helm-subr-native-elisp-p it)) + "Anonymous" it)) + (setq helm-saved-action + (x-popup-menu + t (list "Available Actions" + (cons "" it)))) + (helm-maybe-exit-minibuffer)) + (message "No Actions available")))))) +(put 'helm-menu-select-action 'helm-only t) + (defun helm--set-action-prompt (&optional restore) (with-selected-window (minibuffer-window) (let ((inhibit-read-only t) (props '(face minibuffer-prompt - field t - read-only t - rear-nonsticky t - front-sticky t)) + field t + read-only t + rear-nonsticky t + front-sticky t)) (prt (if restore helm--prompt helm--action-prompt))) (erase-buffer) (insert (apply #'propertize prt props))))) @@ -4924,7 +5311,7 @@ If action buffer is selected, back to the helm buffer." (set-window-buffer (if (helm--show-action-window-other-window-p) (split-window (get-buffer-window helm-buffer) nil helm-show-action-window-other-window) - (get-buffer-window helm-buffer)) + (get-buffer-window helm-buffer)) helm-action-buffer) (set (make-local-variable 'helm-sources) (list @@ -4937,17 +5324,17 @@ If action buffer is selected, back to the helm buffer." :candidates actions :mode-line '("Action(s)" "\\\\[helm-select-action]:BackToCands RET/f1/f2/fn:NthAct") :candidate-transformer - (lambda (candidates) - (cl-loop for (i . j) in candidates - for count from 1 - collect - (cons (concat (cond ((> count 12) - " ") - ((< count 10) - (format "[f%s] " count)) - (t (format "[f%s] " count))) - (propertize i 'face 'helm-action)) - j))) + (lambda (candidates) + (cl-loop for (i . j) in candidates + for count from 1 + collect + (cons (concat (cond ((> count 12) + " ") + ((< count 10) + (format "[f%s] " count)) + (t (format "[f%s] " count))) + (propertize i 'face 'helm-action)) + j))) :candidate-number-limit nil))) (set (make-local-variable 'helm-source-filter) nil) (set (make-local-variable 'helm-selection-overlay) nil) @@ -4958,7 +5345,7 @@ If action buffer is selected, back to the helm buffer." (defun helm-display-source-at-screen-top-maybe (unit) "Display source at the top of screen when UNIT value is 'source. -Returns nil for any other value of UNIT." +Return nil for any other value of UNIT." (when (and helm-display-source-at-screen-top (eq unit 'source)) (set-window-start (selected-window) (save-excursion (forward-line -1) (point))))) @@ -4966,8 +5353,8 @@ Returns nil for any other value of UNIT." (defun helm-skip-noncandidate-line (direction) "Skip source header or candidates separator when going in DIRECTION. DIRECTION is either 'next or 'previous. -Same as `helm-skip-header-and-separator-line' but ensure -point is moved to the right place when at bob or eob." +Same as `helm-skip-header-and-separator-line' but ensure point is +moved to the right place when at bob or eob." (helm-skip-header-and-separator-line direction) (and (bobp) (forward-line 1)) ; Skip first header. (and (eobp) (forward-line -1))) ; Avoid last empty line. @@ -4986,7 +5373,7 @@ DIRECTION is either 'next or 'previous." -1 1))))) (defun helm-display-mode-line (source &optional force) - "Set up mode line and header line for `helm-buffer'. + "Set up mode-line and header-line for `helm-buffer'. SOURCE is a Helm source object. @@ -5013,25 +5400,25 @@ mode and header lines." (setq mode-line-format `(:propertize (" " mode-line-buffer-identification " " - (:eval (format "L%-3d" (helm-candidate-number-at-point))) - ,follow - " " - (:eval ,(and marked - (propertize - (format "M%d" (length marked)) - 'face 'helm-visible-mark))) - (:eval (when ,helm--mode-line-display-prefarg - (let ((arg (prefix-numeric-value - (or prefix-arg current-prefix-arg)))) - (unless (= arg 1) - (propertize (format " [prefarg:%s]" arg) - 'face 'helm-prefarg))))) - " " - (:eval (with-helm-buffer - (helm-show-candidate-number - (car-safe helm-mode-line-string)))) - " " helm--mode-line-string-real " " - (:eval (make-string (window-width) ? ))) + (:eval (format "L%-3d" (helm-candidate-number-at-point))) + ,follow + " " + (:eval ,(and marked + (propertize + (format "M%d" (length marked)) + 'face 'helm-visible-mark))) + (:eval (when ,helm--mode-line-display-prefarg + (let ((arg (prefix-numeric-value + (or prefix-arg current-prefix-arg)))) + (unless (= arg 1) + (propertize (format " [prefarg:%s]" arg) + 'face 'helm-prefarg))))) + " " + (:eval (with-helm-buffer + (helm-show-candidate-number + (car-safe helm-mode-line-string)))) + " " helm--mode-line-string-real " " + (:eval (make-string (window-width) ? ))) keymap (keymap (mode-line keymap (mouse-1 . ignore) (down-mouse-1 . ignore) @@ -5045,8 +5432,8 @@ mode and header lines." 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))) + helm-mode-line-string))) + (setq mode-line-format (default-value 'mode-line-format))) ;; Setup header-line. (cond (helm-echo-input-in-header-line (setq force t) @@ -5078,13 +5465,13 @@ mode and header lines." ,helm--action-prompt)) cont) `(space :width ,helm-header-line-space-before-prompt) - (propertize - "->" - 'face 'helm-header-line-left-margin)))) + (propertize + "->" + 'face 'helm-header-line-left-margin)))) (pos (- (point) beg))) ;; Increment pos each time we find a "%" up to current-pos (#1648). (cl-loop for c across (buffer-substring-no-properties beg (point)) - when (eql c ?%) do (cl-incf pos)) + when (eql c ?%) do (cl-incf pos)) ;; Increment pos when cursor is on a "%" to make it visible in header-line ;; i.e "%%|" and not "%|%" (#1649). (when (eql (char-after) ?%) (setq pos (1+ pos))) @@ -5106,7 +5493,7 @@ mode and header lines." header-line-format)) (defun helm-exchange-minibuffer-and-header-line () - "Display minibuffer in header-line and vice versa for current helm session. + "Display minibuffer in header-line and vice versa for current Helm session. This is a toggle command." (interactive) @@ -5136,7 +5523,7 @@ It has no effect if `helm-echo-input-in-header-line' is nil." (let ((ov (make-overlay (point-min) (point-max) nil nil t))) (overlay-put ov 'window (selected-window)) (helm-aif (and helm-display-header-line - (helm-attr 'persistent-help)) + (helm-get-attr 'persistent-help)) (progn (overlay-put ov 'display (truncate-string-to-width @@ -5152,8 +5539,8 @@ It has no effect if `helm-echo-input-in-header-line' is nil." (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." +You can specify NAME of candidates e.g. \"Buffers\" otherwise it +is \"Candidate\(s\)\" by default." (when helm-alive-p (unless (helm-empty-source-p) ;; Build a fixed width string when candidate-number < 1000 @@ -5166,7 +5553,7 @@ it is \"Candidate\(s\)\" by default." cand-name)) 'face (if helm-suspend-update-flag 'helm-candidate-number-suspended - 'helm-candidate-number)))))) + 'helm-candidate-number)))))) (cl-defun helm-move-selection-common (&key where direction (follow t)) "Move the selection marker to a new position. @@ -5194,7 +5581,8 @@ Key arg DIRECTION can be one of: (previous 'helm-move--previous-source-fn) (next 'helm-move--next-source-fn) (t (lambda () ; A source is passed as DIRECTION arg. - (helm-move--goto-source-fn direction)))))))) + (helm-move--goto-source-fn direction))))))) + source) (unless (or (helm-empty-buffer-p (helm-buffer-get)) (not (helm-window))) (with-helm-window @@ -5210,8 +5598,9 @@ Key arg DIRECTION can be one of: (helm-mark-current-line) (when follow (helm-follow-execute-persistent-action-maybe)) - (helm-display-mode-line (helm-get-current-source)) - (helm-log-run-hook 'helm-move-selection-after-hook))))) + (helm-display-mode-line (setq source (helm-get-current-source))) + (helm-log-run-hook 'helm-move-selection-after-hook) + (helm--set-minibuffer-completion-confirm source))))) (defun helm-move--beginning-of-multiline-candidate () (let ((header-pos (helm-get-previous-header-pos)) @@ -5220,7 +5609,7 @@ Key arg DIRECTION can be one of: (goto-char (if (or (null separator-pos) (< separator-pos header-pos)) header-pos - separator-pos)) + separator-pos)) (forward-line 1)))) (defun helm-move--previous-multi-line-fn () @@ -5313,19 +5702,19 @@ Key arg DIRECTION can be one of: (goto-char (point-min)) (let ((name (if (stringp source-or-name) source-or-name - (assoc-default 'name source-or-name)))) + (assoc-default 'name source-or-name)))) (if (or (null name) (string= name "")) (forward-line 1) - (condition-case err - (while (not (string= name (helm-current-line-contents))) - (goto-char (helm-get-next-header-pos))) - (error (helm-log "%S" err)))))) + (condition-case err + (while (not (string= name (helm-current-line-contents))) + (goto-char (helm-get-next-header-pos))) + (error (helm-log "%S" err)))))) (defun helm-candidate-number-at-point () (if helm-alive-p (with-helm-buffer (or (get-text-property (point) 'helm-cand-num) 1)) - (or (get-text-property (point) 'helm-cand-num) 1))) + (or (get-text-property (point) 'helm-cand-num) 1))) (defun helm--next-or-previous-line (direction &optional arg) ;; Be sure to not use this in non--interactives calls. @@ -5336,16 +5725,17 @@ Key arg DIRECTION can be one of: with cand-num = (helm-get-candidate-number t) with iter = (min arg (if (eq direction 'next) (- cand-num pos) - (min arg (1- pos)))) + (min arg (1- pos)))) for count from 1 while (<= count iter) do (helm-move-selection-common :where 'line :direction direction)) - (helm-move-selection-common :where 'line :direction direction)))) + (helm-move-selection-common :where 'line :direction direction)))) (defun helm-previous-line (&optional arg) "Move selection to the ARG previous line(s). -Same behavior as `helm-next-line' when called with a numeric prefix arg." +Same behavior as `helm-next-line' when called with a numeric +prefix arg." (interactive "p") (with-helm-alive-p (helm--next-or-previous-line 'previous arg))) @@ -5406,10 +5796,21 @@ next source)." (defun helm-goto-source (&optional source-or-name) "Move the selection to the source named SOURCE-OR-NAME. -If SOURCE-OR-NAME is empty string or nil go to the first candidate of -first source." +If SOURCE-OR-NAME is empty string or nil go to the first +candidate of first source." (helm-move-selection-common :where 'source :direction source-or-name)) +(defvar helm-follow-action-white-list-commands + '(helm-ff-decrease-image-size-persistent + helm-ff-increase-image-size-persistent + helm-ff-rotate-left-persistent + helm-ff-rotate-right-persistent) + "Allow `helm-follow-action-forward/backward' switching to next file +when one of these commands is the `last-command'. + +For example when browsing files with `C-` and rotate the current file, +hitting `C-` again will not switch to next file but kill its buffer.") + (defun helm--follow-action (arg) (let ((helm--temp-follow-flag t) ; Needed in HFF. (in-follow-mode (helm-follow-mode-p))) @@ -5418,14 +5819,15 @@ first source." (when (or (eq last-command 'helm-follow-action-forward) (eq last-command 'helm-follow-action-backward) (eq last-command 'helm-execute-persistent-action) + (memq last-command helm-follow-action-white-list-commands) in-follow-mode) (if (> arg 0) (helm-move-selection-common :where 'line :direction 'next :follow nil) - (helm-move-selection-common :where 'line - :direction 'previous - :follow nil))) + (helm-move-selection-common :where 'line + :direction 'previous + :follow nil))) (unless in-follow-mode (helm-execute-persistent-action)))) @@ -5446,8 +5848,8 @@ first source." When RESUMEP is non nil move overlay to `helm-selection-point'. When NOMOUSE is specified do not set mouse bindings. -Note that selection is unrelated to visible marks used for marking -candidates." +Note that selection is unrelated to visible marks used for +marking candidates." (with-helm-buffer (when resumep (goto-char helm-selection-point)) @@ -5469,11 +5871,11 @@ candidates." (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 minibuffer confirm message and exit on next hit. -If `minibuffer-completion-confirm' value is t, -don't exit and send message 'no match'." +It is similar to `minibuffer-complete-and-exit' adapted to Helm. +If `minibuffer-completion-confirm' value is 'confirm, send +minibuffer confirm message and exit on next hit. If +`minibuffer-completion-confirm' value is t, don't exit and send +message 'no match'." (interactive) (with-helm-alive-p (if (and (helm--updating-p) @@ -5484,47 +5886,58 @@ don't exit and send message 'no match'." (let* ((src (helm-get-current-source)) (empty-buffer-p (with-current-buffer helm-buffer (eq (point-min) (point-max)))) - (sel (helm-get-selection nil nil src)) (unknown (and (not empty-buffer-p) - (string= (get-text-property - 0 'display - (helm-get-selection nil 'withprop src)) - "[?]")))) + (helm-aif (get-text-property + 0 'display + (helm-get-selection nil 'withprop src)) + (when (stringp it) + (string-match-p "\\`\\[\\?\\]" it)))))) (cond ((and (or empty-buffer-p unknown) - (eq minibuffer-completion-confirm 'confirm)) + (memq minibuffer-completion-confirm + '(confirm confirm-after-completion))) (setq helm-minibuffer-confirm-state 'confirm) (setq minibuffer-completion-confirm nil) (minibuffer-message " [confirm]")) - ((and (or empty-buffer-p - (unless (if minibuffer-completing-file-name - (and minibuffer-completion-predicate - (funcall minibuffer-completion-predicate sel)) - (and (stringp sel) - ;; SEL may be a cons cell when helm-comp-read - ;; is called directly with a collection composed - ;; of (display . real) and real is a cons cell. - (try-completion sel minibuffer-completion-table - minibuffer-completion-predicate))) - unknown)) + ;; When require-match is strict (i.e. `t'), buffer + ;; should be either empty or in read-file-name have an + ;; unknown candidate ([?] prefix), if it's not the case + ;; fix it in helm-mode but not here. + ((and (or empty-buffer-p unknown) (eq minibuffer-completion-confirm t)) (minibuffer-message " [No match]")) + (empty-buffer-p + ;; This is used when helm-buffer is totally empty, + ;; i.e. the [?] have not been added because must-match + ;; is used from outside helm-comp-read i.e. from a helm + ;; source built with :must-match. + (setq helm-saved-selection helm-pattern + helm-saved-action (helm-get-default-action + (assoc-default + 'action + (car (with-helm-buffer helm-sources)))) + helm-minibuffer-confirm-state nil) + (helm-exit-minibuffer)) (t (setq helm-minibuffer-confirm-state nil) (helm-exit-minibuffer))))))) (put 'helm-confirm-and-exit-minibuffer 'helm-only t) -(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))) +(add-hook 'helm-after-update-hook 'helm-confirm-and-exit-hook) + +(defun helm--set-minibuffer-completion-confirm (src) + (with-helm-buffer + (helm-aif (helm-get-attr 'must-match src) + (setq minibuffer-completion-confirm it)))) (defun helm-read-string (prompt &optional initial-input history - default-value inherit-input-method) + default-value inherit-input-method) "Same as `read-string' but for reading string from a helm session." (let ((helm--reading-passwd-or-string t)) (read-string @@ -5547,7 +5960,7 @@ don't exit and send message 'no match'." (message "[Display not ready]") (sit-for 0.5) (message nil) (helm-update)) - (helm-exit-minibuffer)))) + (helm-exit-minibuffer)))) (put 'helm-maybe-exit-minibuffer 'helm-only t) (defun helm-exit-minibuffer () @@ -5613,7 +6026,7 @@ If action buffer is displayed, kill it." ;; ;; (defun helm-debug-output () - "Show all helm-related variables at this time." + "Show all Helm-related variables at this time." (interactive) (with-helm-alive-p (helm-help-internal " *Helm Debug*" 'helm-debug-output-function))) @@ -5638,9 +6051,9 @@ to a list of forms.\n\n") (if helm-debug (helm-run-after-exit #'helm-debug-open-last-log) - (setq helm-debug t) - (with-helm-buffer (setq truncate-lines nil)) - (message "Debugging enabled")))) + (setq helm-debug t) + (with-helm-buffer (setq truncate-lines nil)) + (message "Debugging enabled")))) (put 'helm-enable-or-switch-to-debug 'helm-only t) @@ -5649,8 +6062,8 @@ to a list of forms.\n\n") "Remove tick entry from `helm-tick-hash' and remove buffer from `helm-buffers' when killing a buffer." (cl-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)) + if (string-match (format "^%s/" (regexp-quote (buffer-name))) key) + do (remhash key helm-tick-hash)) (setq helm-buffers (remove (buffer-name) helm-buffers))) (add-hook 'kill-buffer-hook 'helm-kill-buffer-hook) @@ -5664,7 +6077,7 @@ CANDIDATE-OR-REGEXP can be a: - Nullary function, which moves to a candidate When CANDIDATE-OR-REGEXP is a cons cell, tries moving to first -element of the cons cell, then the second, and so on. This allows +element of the cons cell, then the second, and so on. This allows selection of duplicate candidates after the first. Optional argument SOURCE is a Helm source object." @@ -5672,19 +6085,19 @@ Optional argument SOURCE is a Helm source object." (when candidate-or-regexp (if source (helm-goto-source source) - (goto-char (point-min)) - (forward-line 1)) + (goto-char (point-min)) + (forward-line 1)) (if (functionp candidate-or-regexp) (funcall candidate-or-regexp) - (let ((start (point)) mp) - (helm-awhile (if (consp candidate-or-regexp) - (and (re-search-forward (car candidate-or-regexp) nil t) - (re-search-forward (cdr candidate-or-regexp) nil t)) - (re-search-forward candidate-or-regexp nil t)) - ;; If search fall on an header line continue loop - ;; until it match or fail (Issue #1509). - (unless (helm-pos-header-line-p) (cl-return (setq mp it)))) - (goto-char (or mp start))))) + (let ((start (point)) mp) + (helm-awhile (if (consp candidate-or-regexp) + (and (re-search-forward (car candidate-or-regexp) nil t) + (re-search-forward (cdr candidate-or-regexp) nil t)) + (re-search-forward candidate-or-regexp nil t)) + ;; If search fall on an header line continue loop + ;; until it match or fail (Issue #1509). + (unless (helm-pos-header-line-p) (cl-return (setq mp it)))) + (goto-char (or mp start))))) (forward-line 0) ; Avoid scrolling right on long lines. (when (helm-pos-multiline-p) (helm-move--beginning-of-multiline-candidate)) @@ -5723,17 +6136,17 @@ Optional argument SOURCE is a Helm source object." (save-excursion (if (and (helm-pos-multiline-p) (null at-point)) (null (helm-get-next-candidate-separator-pos)) - (forward-line (if at-point 0 n)) - (or (eq (point-at-bol) (point-at-eol)) - (helm-pos-header-line-p) - (if (< n 0) (bobp) (eobp)))))) + (forward-line (if at-point 0 n)) + (or (eq (point-at-bol) (point-at-eol)) + (helm-pos-header-line-p) + (if (< n 0) (bobp) (eobp)))))) (defun helm-end-of-source-p (&optional at-point) - "Return non-`nil' if we are at eob or end of source." + "Return non-nil if we are at EOB or end of source." (helm-end-of-source-1 1 at-point)) (defun helm-beginning-of-source-p (&optional at-point) - "Return non-`nil' if we are at bob or beginning of source." + "Return non-nil if we are at BOB or beginning of source." (helm-end-of-source-1 -1 at-point)) (defun helm--edit-current-selection-internal (func) @@ -5768,15 +6181,15 @@ Used generally to modify current selection." ;; minibuffer is not empty, delete contents from end ;; of FROM-STR and update. (helm-set-pattern from-str) - ;; minibuffer is already empty, force update. - (helm-force-update)))) + ;; minibuffer is already empty, force update. + (helm-force-update)))) (defun helm-delete-minibuffer-contents (&optional arg) "Delete minibuffer contents. -When `helm-delete-minibuffer-contents-from-point' is non-`nil', +When `helm-delete-minibuffer-contents-from-point' is non-nil, delete minibuffer contents from point instead of deleting all. -Giving a prefix arg reverses this behavior. -When at the end of minibuffer, deletes all." +With a prefix arg reverse this behaviour. When at the end of +minibuffer, delete all." (interactive "P") (let ((str (if helm-delete-minibuffer-contents-from-point (if (or arg (eobp)) @@ -5791,13 +6204,14 @@ When at the end of minibuffer, deletes all." (defun helm-candidates-in-buffer (&optional source) "The top level function used to store candidates with `helm-source-in-buffer'. -Candidates are stored in a buffer generated internally -by `helm-candidate-buffer' function. -Each candidate must be placed in one line. +Candidates are stored in a buffer generated internally by +`helm-candidate-buffer' function. Each candidate must be placed +in one line. -The buffer is created and fed in the init attribute function of helm. +The buffer is created and fed in the init attribute function of +Helm. -e.g: +E.g.: (helm-build-in-buffer-source \"test\" :init (lambda () @@ -5809,14 +6223,13 @@ A shortcut can be used to simplify: (helm-build-in-buffer-source \"test\" :data '(foo foa fob bar baz)) -By default, `helm' makes candidates by evaluating the -candidates function, then narrows them by `string-match' for each -candidate. +By default, Helm makes candidates by evaluating the candidates +function, then narrows them by `string-match' for each candidate. -But this is slow for large number of candidates. The new way is -to store all candidates in a buffer and then narrow -with `re-search-forward'. Search function is customizable by search -attribute. The important point is that buffer processing is MUCH +But this is slow for large number of candidates. The new way is +to store all candidates in a buffer and then narrow with +`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 @@ -5832,20 +6245,21 @@ Class `helm-source-in-buffer' is implemented with three attributes: (volatile) (match identity) -The volatile attribute is needed because `helm-candidates-in-buffer' -creates candidates dynamically and need to be called every -time `helm-pattern' changes. +The volatile attribute is needed because +`helm-candidates-in-buffer' creates candidates dynamically and +need to be called every time `helm-pattern' changes. -Because `helm-candidates-in-buffer' plays the role of `match' attribute -function, specifying `(match identity)' makes the source slightly faster. +Because `helm-candidates-in-buffer' plays the role of `match' +attribute function, specifying `(match identity)' makes the +source slightly faster. -However if source contains `match-part' attribute, match is computed only -on part of candidate returned by the call of function provided by this attribute. -The function should have one arg, candidate, and return only -a specific part of candidate. +However if source contains `match-part' attribute, match is +computed only on part of candidate returned by the call of +function provided by this attribute. The function should have one +arg, candidate, and return only a specific part of candidate. -To customize `helm-candidates-in-buffer' behavior, -use `search', `get-line' and `match-part' attributes." +To customize `helm-candidates-in-buffer' behaviour, use `search', +`get-line' and `match-part' attributes." (let ((src (or source (helm-get-current-source)))) (helm-candidates-in-buffer-1 (helm-candidate-buffer) @@ -5855,7 +6269,7 @@ use `search', `get-line' and `match-part' attributes." (or (assoc-default 'search src) '(helm-candidates-in-buffer-search-default-fn)) (helm-candidate-number-limit src) - (helm-attr 'match-part) + (helm-get-attr 'match-part) src))) (defun helm-candidates-in-buffer-search-default-fn (pattern) @@ -5865,8 +6279,8 @@ use `search', `get-line' and `match-part' attributes." (invalid-regexp nil))) (defun helm-candidates-in-buffer-1 (buffer pattern get-line-fn - search-fns limit - match-part-fn source) + search-fns limit + match-part-fn source) "Return the list of candidates inserted in BUFFER matching PATTERN." ;; buffer == nil when candidates buffer does not exist. (when buffer @@ -5883,7 +6297,7 @@ use `search', `get-line' and `match-part' attributes." (defun helm-search-from-candidate-buffer (pattern get-line-fn search-fns - limit start-point match-part-fn source) + limit start-point match-part-fn source) (let ((inhibit-read-only t)) (helm--search-from-candidate-buffer-1 (lambda () @@ -5921,7 +6335,7 @@ use `search', `get-line' and `match-part' attributes." for cand = (apply get-line-fn (if (and pos-lst (listp pos-lst)) pos-lst - (list (point-at-bol) (point-at-eol)))) + (list (point-at-bol) (point-at-eol)))) when (and match-part-fn (not (get-text-property 0 'match-part cand))) do (setq cand @@ -5949,10 +6363,10 @@ use `search', `get-line' and `match-part' attributes." (defun helm-search-match-part (candidate pattern) "Match PATTERN only on match-part property value of CANDIDATE. -Because `helm-search-match-part' maybe called even if unspecified -in source (negation or fuzzy), the part to match fallback to the whole -candidate even if match-part haven't been computed by match-part-fn -and stored in the match-part property." +Because `helm-search-match-part' may be called even if +unspecified in source (negation or fuzzy), the part to match +falls back to the whole candidate even if match-part hasn't been +computed by match-part-fn and stored in the match-part property." (let ((part (or (get-text-property 0 'match-part candidate) candidate)) (fuzzy-regexp (cadr (gethash 'helm-pattern helm--fuzzy-regexp-cache))) @@ -5962,14 +6376,14 @@ and stored in the match-part property." (cl-loop for i in (helm-mm-split-pattern pattern) always (if (string-match "\\`!" i) (not (funcall matchfn (substring i 1) part)) - (funcall matchfn i part))) - (if (string-match "\\`!" pattern) - (if helm--in-fuzzy - ;; Fuzzy regexp have already been - ;; computed with substring 1. - (not (string-match fuzzy-regexp part)) - (not (funcall matchfn (substring pattern 1) part))) - (funcall matchfn (if helm--in-fuzzy fuzzy-regexp pattern) part))))) + (funcall matchfn i part))) + (if (string-match "\\`!" pattern) + (if helm--in-fuzzy + ;; Fuzzy regexp have already been + ;; computed with substring 1. + (not (string-match fuzzy-regexp part)) + (not (funcall matchfn (substring pattern 1) part))) + (funcall matchfn (if helm--in-fuzzy fuzzy-regexp pattern) part))))) (defun helm-initial-candidates-from-candidate-buffer (get-line-fn limit) (delq nil (cl-loop for i from 1 to limit @@ -5990,7 +6404,7 @@ and stored in the match-part property." (goto-char (point-max)) (insert "\n") (unwind-protect - (funcall search-fn) + (funcall search-fn) (goto-char (point-min)) (delete-char 1) (goto-char (1- (point-max))) @@ -6002,17 +6416,17 @@ and stored in the match-part property." This is used to initialize a buffer for storing candidates for a candidates-in-buffer source, candidates will be searched in this -buffer and displayed in `helm-buffer'. -This should be used only in init functions, don't relay on this in -other places unless you know what you are doing. +buffer and displayed in `helm-buffer'. This should be used only +in init functions, don't relay on this in other places unless you +know what you are doing. -This function is still in public API only for backward compatibility, -you should use instead `helm-init-candidates-in-buffer' for -initializing your sources. +This function is still in public API only for backward +compatibility, you should use instead +`helm-init-candidates-in-buffer' for initializing your sources. -Internally, this function is called without argument and returns the -buffer corresponding to current source i.e `helm--source-name' which -is available in only some places. +Internally, this function is called without argument and returns +the buffer corresponding to current source i.e. +`helm--source-name' which is available in only some places. Acceptable values of BUFFER-SPEC: @@ -6021,15 +6435,18 @@ Acceptable values of BUFFER-SPEC: named \" *helm candidates:SOURCE*\". This is used by `helm-init-candidates-in-buffer' and it is the most common usage of BUFFER-SPEC. - The buffer will be killed and recreated at each new helm-session. + The buffer will be killed and recreated at each new + helm-session. - local (a symbol) Create a new local candidates buffer, named \" *helm candidates:SOURCE*HELM-CURRENT-BUFFER\". - You may want to use this when you want to have a different buffer - each time source is used from a different `helm-current-buffer'. - The buffer is erased and refilled at each new session but not killed. - You probably don't want to use this value for BUFFER-SPEC. + You may want to use this when you want to have a different + buffer each time source is used from a different + `helm-current-buffer'. + The buffer is erased and refilled at each new session but not + killed. You probably don't want to use this value for + BUFFER-SPEC. - nil (omit) Only return the candidates buffer of current source if found. @@ -6037,18 +6454,18 @@ Acceptable values of BUFFER-SPEC: - A buffer Register a buffer as a candidates buffer. The buffer needs to exists, it is not created. - This allow you to use the buffer as a cache, it is faster because - the buffer is already drawn, but be careful when using this as you - may mangle your buffer depending what you write in your init(s) - function, IOW don't modify the contents of the buffer in init(s) - function but in a transformer. + This allow you to use the buffer as a cache, it is faster + because the buffer is already drawn, but be careful when using + this as you may mangle your buffer depending on what you write + in your init(s) function, IOW don't modify the contents of the + buffer in init(s) function but in a transformer. The buffer is not erased nor deleted. Generally it is safer to use a copy of buffer inserted in a global or local buffer. -If for some reasons a global buffer and a local buffer exist and are -belonging to the same source, the local buffer takes precedence on the -global one and is used instead. +If for some reasons a global buffer and a local buffer exist and +are belonging to the same source, the local buffer takes +precedence on the global one and is used instead. When forcing update only the global and local buffers are killed before running again the init function." @@ -6099,17 +6516,17 @@ before running again the init function." (defun helm-init-candidates-in-buffer (buffer-spec data) "Register BUFFER-SPEC with DATA for a helm candidates-in-buffer session. -Arg BUFFER-SPEC can be a buffer-name (stringp), a buffer-spec object -\(bufferp), or a symbol, either 'local or 'global which is passed to -`helm-candidate-buffer'. +Arg BUFFER-SPEC can be a `buffer-name' (stringp), a buffer-spec +object \(bufferp), or a symbol, either 'local or 'global which is +passed to `helm-candidate-buffer'. The most common usage of BUFFER-SPEC is 'global. Arg DATA can be either a list or a plain string. Returns the resulting buffer. Use this in your init function to register a buffer for a -`helm-source-in-buffer' session and feed it with DATA. -You probably don't want to bother with this and use the :data slot +`helm-source-in-buffer' session and feed it with DATA. You +probably don't want to bother with this and use the :data slot when initializing a source with `helm-source-in-buffer' class." (declare (indent 1)) (let ((caching (and (or (stringp buffer-spec) @@ -6147,38 +6564,38 @@ when initializing a source with `helm-source-in-buffer' class." (when helm-prevent-escaping-from-minibuffer (helm-prevent-switching-other-window :enabled nil)) (unwind-protect - (with-helm-window - (cond ((or helm-full-frame (one-window-p t)) - (user-error "Attempt to resplit a single window")) - ((helm-action-window) - (user-error "Can't resplit while selecting actions")) - (t - (let ((before-height (window-height))) - (delete-window) - (set-window-buffer - (select-window - (if (= (window-height) before-height) ; initial split was horizontal. - ;; Split window vertically with `helm-buffer' placed - ;; on the good side according to actual value of - ;; `helm-split-window-default-side'. - (prog1 - (cond ((or (eq helm-split-window-default-side 'above) - (eq helm-split-window-default-side 'left)) - (split-window - (selected-window) nil 'above)) - (t (split-window-vertically))) - (setq helm-split-window-state 'vertical)) - ;; Split window vertically, same comment as above. - (setq helm-split-window-state 'horizontal) - (cond ((or (eq helm-split-window-default-side 'left) - (eq helm-split-window-default-side 'above)) - (split-window (selected-window) nil 'left)) - (t (split-window-horizontally))))) - helm-buffer)))) - (setq helm--window-side-state (helm--get-window-side-state))) + (with-helm-window + (cond ((or helm-full-frame (one-window-p t)) + (user-error "Attempt to resplit a single window")) + ((helm-action-window) + (user-error "Can't resplit while selecting actions")) + (t + (let ((before-height (window-height))) + (delete-window) + (set-window-buffer + (select-window + (if (= (window-height) before-height) ; initial split was horizontal. + ;; Split window vertically with `helm-buffer' placed + ;; on the good side according to actual value of + ;; `helm-split-window-default-side'. + (prog1 + (cond ((or (eq helm-split-window-default-side 'above) + (eq helm-split-window-default-side 'left)) + (split-window + (selected-window) nil 'above)) + (t (split-window-vertically))) + (setq helm-split-window-state 'vertical)) + ;; Split window vertically, same comment as above. + (setq helm-split-window-state 'horizontal) + (cond ((or (eq helm-split-window-default-side 'left) + (eq helm-split-window-default-side 'above)) + (split-window (selected-window) nil 'left)) + (t (split-window-horizontally))))) + helm-buffer)))) + (setq helm--window-side-state (helm--get-window-side-state))) (when helm-prevent-escaping-from-minibuffer (helm-prevent-switching-other-window :enabled t)))) - (error "current window configuration not suitable for splitting")))) + (error "current window configuration not suitable for splitting")))) (put 'helm-toggle-resplit-window 'helm-only t) ;; Utility: Resize helm window. @@ -6205,7 +6622,7 @@ If N is positive enlarge, if negative narrow." (put 'helm-enlarge-window 'helm-only t) (defun helm-toggle-full-frame (&optional arg) - "Toggle helm-buffer full-frame view." + "Toggle `helm-buffer' full-frame view." (interactive "p") (cl-assert (null (helm-action-window)) nil "Unable to toggle full frame from action window") @@ -6273,7 +6690,7 @@ If N is positive enlarge, if negative narrow." (set-window-start w1 s2 t) (set-window-start w2 s1 t)) (setq helm--window-side-state (helm--get-window-side-state))))) - (error "current window configuration not suitable for splitting")))) + (error "current window configuration not suitable for splitting")))) (put 'helm-swap-windows 'helm-only t) (defun helm--get-window-side-state () @@ -6281,11 +6698,11 @@ If N is positive enlarge, if negative narrow." Possible values are 'left 'right 'below or 'above." (let ((side-list '(left right below above))) (cl-loop for side in side-list - thereis (and (equal (helm-window) - (window-in-direction - side (get-buffer-window helm-current-buffer t) - t)) - side)))) + thereis (and (equal (helm-window) + (window-in-direction + side (get-buffer-window helm-current-buffer t) + t)) + side)))) (defun helm-replace-buffer-in-window (window buffer1 buffer2) "Replace BUFFER1 by BUFFER2 in WINDOW registering BUFFER1." @@ -6305,7 +6722,7 @@ Possible values are 'left 'right 'below or 'above." n (if (get-buffer-window helm-action-buffer 'visible) (assoc-default 'candidates src) - (helm-get-actions-from-current-source src)))) + (helm-get-actions-from-current-source src)))) (helm-maybe-exit-minibuffer))) (defun helm-get-nth-action (n action) @@ -6324,7 +6741,7 @@ Possible values are 'left 'right 'below or 'above." (let ((prefarg current-prefix-arg)) (if (>= linum 0) (helm-next-line linum) - (helm-previous-line (lognot (1- linum)))) + (helm-previous-line (lognot (1- linum)))) (setq current-prefix-arg prefarg) (helm-exit-minibuffer))) @@ -6336,18 +6753,18 @@ Possible values are 'left 'right 'below or 'above." (cl-defun helm-execute-persistent-action (&optional attr split) "Perform the associated action ATTR without quitting helm. -Arg ATTR default will be `persistent-action' or `persistent-action-if' -if unspecified depending on what's found in source, but it can be -anything else. +Arg ATTR default will be `persistent-action' or +`persistent-action-if' if unspecified depending on what's found +in source, but it can be anything else. In this case you have to add this new attribute to your source. -See `persistent-action' and `persistent-action-if' slot documentation -in `helm-source'. - -When `helm-full-frame' is non-`nil', and -`helm-buffer' is displayed in only one window, the helm window is -split to display `helm-select-persistent-action-window' in other -window to maintain visibility. The argument SPLIT can be used to -force splitting inconditionally, it is unused actually." +See `persistent-action' and `persistent-action-if' slot +documentation in `helm-source'. + +When `helm-full-frame' is non-nil, and `helm-buffer' is displayed +in only one window, the helm window is split to display +`helm-select-persistent-action-window' in other window to +maintain visibility. The argument SPLIT can be used to force +splitting inconditionally, it is unused actually." (interactive) (with-helm-alive-p (let ((source (helm-get-current-source))) @@ -6408,10 +6825,10 @@ force splitting inconditionally, it is unused actually." (cl-defun helm-persistent-action-display-window (&key split) "Return the window that will be used for persistent action. -If SPLIT is `t' window is split in persistent action, if it has the -special symbol `never' don't split, if it is `nil' normally don't -split but this may happen in case of dedicated-windows or unsuitable -window to display persistent action buffer." +If SPLIT is t window is split in persistent action, if it has the +special symbol `never' don't split, if it is nil normally don't +split but this may happen in case of dedicated-windows or +unsuitable window to display persistent action buffer." (with-helm-window (let (prev-win cur-win) (setq helm-persistent-action-display-window @@ -6519,7 +6936,7 @@ Meaning of prefix ARG is the same as in `reposition-window'." (defun helm-make-visible-mark (&optional src selection) (let* ((source (or src (helm-get-current-source))) (sel (or selection (helm-get-selection - nil (helm-attr 'marked-with-props source) + nil (helm-get-attr 'marked-with-props source) source))) (selection-end (if (helm-pos-multiline-p) ;; Stays within source @@ -6539,7 +6956,7 @@ Meaning of prefix ARG is the same as in `reposition-window'." (push (cons source sel) helm-marked-candidates))) (defun helm-toggle-visible-mark (arg) - "Toggle helm visible mark at point ARG times. + "Toggle Helm visible mark at point ARG times. If ARG is negative toggle backward." (interactive "p") (with-helm-alive-p @@ -6563,98 +6980,105 @@ If ARG is negative toggle backward." (funcall (cdr next-fns)))))))))) (put 'helm-toggle-visible-mark 'helm-only t) +(defun helm-toggle-visible-mark-forward () + (interactive) + (helm-toggle-visible-mark 1)) + +(defun helm-toggle-visible-mark-backward () + (interactive) + (helm-toggle-visible-mark -1)) + (defun helm-file-completion-source-p (&optional source) - "Return non-`nil' if current source is a file completion source." + "Return non-nil if current source is a file completion source." (or helm--completing-file-name ; helm-read-file-name (let ((cur-source (cdr (assq 'name - (or source (helm-get-current-source)))))) + (or source (helm-get-current-source)))))) (cl-loop for i in helm--file-completion-sources thereis (string= cur-source i))))) (defun helm-mark-all (&optional all) "Mark all visible unmarked candidates in current source. -With a prefix arg mark all visible unmarked candidates in all sources." +With a prefix arg mark all visible unmarked candidates in all +sources." (interactive "P") (with-helm-alive-p (with-helm-window ; Using `with-helm-buffer' for some unknow reasons infloop. (if (null all) (helm-mark-all-1 t) - (let ((pos (point))) - (goto-char (point-min)) - (helm-awhile (helm-get-next-header-pos) - (goto-char it) - (forward-line 1) - (helm-mark-current-line) - (helm-mark-all-1)) - ;; `save-excursion' seems confused if used in addition of - ;; the one used in `helm-mark-all-1', so save POS and back - ;; to it when loop is finished. - (goto-char pos) + (let ((pos (point))) + (goto-char (point-min)) + (helm-awhile (helm-get-next-header-pos) + (goto-char it) + (forward-line 1) (helm-mark-current-line) - (helm-display-mode-line (helm-get-current-source) t)))))) + (helm-mark-all-1)) + ;; `save-excursion' seems confused if used in addition of + ;; the one used in `helm-mark-all-1', so save POS and back + ;; to it when loop is finished. + (goto-char pos) + (helm-mark-current-line) + (helm-display-mode-line (helm-get-current-source) t)))))) (put 'helm-mark-all 'helm-only t) (defun helm-mark-all-1 (&optional ensure-beg-of-source) "Mark all visible unmarked candidates in current source. Need to be wrapped in `with-helm-window'. -Arg ENSURE-BEG-OF-SOURCE ensure we are at beginning of source when -starting to mark candidates, if handled elsewhere before starting it -is not needed." +Arg ENSURE-BEG-OF-SOURCE ensure we are at beginning of source +when starting to mark candidates, if handled elsewhere before +starting it is not needed." (let* ((src (helm-get-current-source)) (follow (if (helm-follow-mode-p src) 1 -1)) (nomark (assq 'nomark src)) (src-name (assoc-default 'name src)) (filecomp-p (or (helm-file-completion-source-p src) - (string= src-name "Files from Current Directory"))) - (remote-p (and filecomp-p (file-remote-p helm-pattern)))) + (string= src-name "Files from Current Directory")))) ;; Note that `cl-letf' prevents edebug working properly. (cl-letf (((symbol-function 'message) #'ignore)) (helm-follow-mode -1) (unwind-protect - (if nomark - (message "Marking not allowed in this source") - (save-excursion - (when ensure-beg-of-source - (goto-char (helm-get-previous-header-pos)) - (forward-line 1)) - (let* ((next-head (helm-get-next-header-pos)) - (end (and next-head - (save-excursion - (goto-char next-head) - (forward-line -1) - (point)))) - (maxpoint (or end (point-max)))) - (while (< (point) maxpoint) - (helm-mark-current-line) - (let* ((prefix (get-text-property (point-at-bol) 'display)) - (cand (helm-get-selection - nil (helm-attr 'marked-with-props src) - src)) - (bn (and filecomp-p (helm-basename cand)))) - ;; Don't mark possibles directories ending with . or .. - ;; autosave files/links and non--existent files. - (unless - (or (helm-this-visible-mark) - (string= prefix "[?]") ; doesn't match - (and filecomp-p - (or - ;; autosave files - (string-match-p "^[.]?#.*#?$" bn) - ;; dot files - (member bn '("." "..")) - ;; We need to test here when not using - ;; a transformer that put a prefix tag - ;; before candidate. - ;; (i.e no [?] prefix on tramp). - (and remote-p (not (file-exists-p cand)))))) - (helm-make-visible-mark src cand))) - (when (helm-pos-multiline-p) - (goto-char - (or (helm-get-next-candidate-separator-pos) - (point-max)))) - (forward-line 1)))) - (helm-mark-current-line)) + (if nomark + (user-error "Marking not allowed in this source") + (save-excursion + (when ensure-beg-of-source + (goto-char (helm-get-previous-header-pos)) + (forward-line 1)) + (let* ((next-head (helm-get-next-header-pos)) + (end (and next-head + (save-excursion + (goto-char next-head) + (forward-line -1) + (point)))) + (maxpoint (or end (point-max)))) + (while (< (point) maxpoint) + (helm-mark-current-line) + (let* ((prefix (get-text-property (point-at-bol) 'display)) + (cand (helm-get-selection + nil (helm-get-attr 'marked-with-props src) + src)) + (bn (and filecomp-p (helm-basename cand)))) + ;; Don't mark possibles directories ending with . or .. + ;; autosave files/links and non--existent files. + (unless + (or (helm-this-visible-mark) + ;; Non existing files in HFF and + ;; RFN. Display may be an image. See + ;; https://github.com/yyoncho/helm-treemacs-icons/issues/5 + ;; and also issue #2296. + (equal prefix "[?]") + (and filecomp-p + (or + ;; autosave files + (string-match-p "\\`[.]?#.*#?\\'" bn) + ;; dot files + (member bn '("." ".."))))) + (helm-make-visible-mark src cand))) + (when (helm-pos-multiline-p) + (goto-char + (or (helm-get-next-candidate-separator-pos) + (point-max)))) + (forward-line 1)))) + (helm-mark-current-line)) (helm-follow-mode follow))))) (defun helm-unmark-all () @@ -6672,8 +7096,9 @@ is not needed." (defun helm-toggle-all-marks (&optional all) "Toggle all marks. -Mark all visible candidates of current source or unmark all candidates -visible or invisible in all sources of current helm session. +Mark all visible candidates of current source or unmark all +candidates visible or invisible in all sources of current Helm +session. With a prefix argument mark all candidates in all sources." (interactive "P") @@ -6682,7 +7107,7 @@ With a prefix argument mark all candidates in all sources." (if (and (>= (length marked) 1) (with-helm-window helm-visible-mark-overlays)) (helm-unmark-all) - (helm-mark-all all))))) + (helm-mark-all all))))) (put 'helm-toggle-all-marks 'helm-only t) (defun helm--compute-marked (real source &optional wildcard) @@ -6692,7 +7117,7 @@ With a prefix argument mark all candidates in all sources." (helm-file-expand-wildcards coerced t) (error nil))))) - ;; Avoid returning a not expanded wilcard fname. + ;; Avoid returning a not expanded wildcard fname. ;; e.g assuming "/tmp" doesn't contain "*.el" ;; return nil when coerced is "/tmp/*.el". (unless (or wilds (null wildcard) @@ -6707,8 +7132,8 @@ With a prefix argument mark all candidates in all sources." "Return marked candidates of current source, if any. Otherwise return one element list consisting of the current -selection. When key WITH-WILDCARD is specified, expand it. -When ALL-SOURCES key value is non-nil returns marked candidates of all +selection. When key WITH-WILDCARD is specified, expand it. When +ALL-SOURCES key value is non-nil returns marked candidates of all sources." (with-current-buffer helm-buffer (let* ((current-src (helm-get-current-source)) @@ -6724,7 +7149,7 @@ sources." sel) (unless candidates (setq sel (helm-get-selection - nil (helm-attr 'marked-with-props + nil (helm-get-attr 'marked-with-props current-src) current-src)) (setq candidates @@ -6774,33 +7199,33 @@ sources." ;; Issue (#706). (and (equal (overlay-get o 'real) real) (move-overlay o beg end)) - (and (equal o-str (buffer-substring beg end)) - (move-overlay o beg end)))))))))) + (and (equal o-str (buffer-substring beg end)) + (move-overlay o beg end)))))))))) (add-hook 'helm-after-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))) - (nth (1- (length points)) points)) - ((< (car (last points)) curpos) - (if prev (car (last points)) (nth 0 points))) - ((and (not prev) (>= curpos (car (last points)))) - (nth 0 points)) - (t - (nth (if prev - (cl-loop for pt in points + ;; rule out special cases. + ((null points) curpos) + ((and prev (<= curpos (car points))) + (nth (1- (length points)) points)) + ((< (car (last points)) curpos) + (if prev (car (last points)) (nth 0 points))) + ((and (not prev) (>= curpos (car (last points)))) + (nth 0 points)) + (t + (nth (if prev + (cl-loop for pt in points + for i from 0 + if (<= curpos pt) return (1- i)) + (cl-loop for pt in points for i from 0 - if (<= curpos pt) return (1- i)) - (cl-loop for pt in points - for i from 0 - if (< curpos pt) return i)) - points)))) + 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." + "Move next Helm visible mark. +If PREV is non-nil move to precedent." (interactive) (with-helm-alive-p (with-helm-window @@ -6834,8 +7259,8 @@ With a prefix arg set to real value of current selection." (defun helm-kill-selection-and-quit (arg) "Store display value of current selection to kill ring. With a prefix arg use real value of current selection. -Display value is shown in `helm-buffer' and real value -is used to perform actions." +Display value is shown in `helm-buffer' and real value is used to +perform actions." (interactive "P") (with-helm-alive-p (helm-run-after-exit @@ -6869,30 +7294,36 @@ display values." ;; (defvar helm-follow-input-idle-delay nil "`helm-follow-mode' will execute its persistent action after this delay. -Note that if the `follow-delay' attr is present in source, -it will take precedence over this.") +Note that if the `follow-delay' attr is present in source, it +will take precedence over this.") (defun helm-follow-mode (&optional arg) "Execute persistent action every time the cursor is moved. -This mode is source local, i.e It apply on current source only. +This mode is source local, i.e. It applies on current source only. \\ This mode can be enabled or disabled interactively at anytime during a helm session with \\[helm-follow-mode]. -When enabling interactively `helm-follow-mode' in a source, you can keep it enabled -for next emacs sessions by setting `helm-follow-mode-persistent' to a non-nil value. +When enabling interactively `helm-follow-mode' in a source, you +can keep it enabled for next Emacs sessions by setting +`helm-follow-mode-persistent' to a non-nil value. -When `helm-follow-mode' is called with a prefix arg and `helm-follow-mode-persistent' -is non-nil `helm-follow-mode' will be persistent only for this emacs session, -but not for next emacs sessions, i.e the current source will not be saved -to `helm-source-names-using-follow'. -A prefix arg with `helm-follow-mode' already enabled will have no effect. +When `helm-follow-mode' is called with a prefix arg and +`helm-follow-mode-persistent' is non-nil `helm-follow-mode' will +be persistent only for this Emacs session, but not for the next +Emacs sessions, i.e. the current source will not be saved to +`helm-source-names-using-follow'. -Note that you can use instead of this mode the commands `helm-follow-action-forward' -and `helm-follow-action-backward' at anytime in all helm sessions. +A prefix arg with `helm-follow-mode' already enabled will have no +effect. -They are bound by default to \\[helm-follow-action-forward] and \\[helm-follow-action-backward]." +Note that you can use instead of this mode the commands +`helm-follow-action-forward' and `helm-follow-action-backward' at +anytime in all Helm sessions. + +They are bound by default to \\[helm-follow-action-forward] and +\\[helm-follow-action-backward]." (interactive (list (helm-aif (and current-prefix-arg (prefix-numeric-value current-prefix-arg)) (unless (helm-follow-mode-p) it)))) @@ -6909,39 +7340,40 @@ They are bound by default to \\[helm-follow-action-forward] and \\[helm-follow-a (progn (if (eq (cdr fol-attr) 'never) (message "helm-follow-mode not allowed in this source") - ;; Make follow attr persistent for this emacs session. - (helm-follow-mode-set-source - (if (or enabled (and (numberp arg) (< arg 0))) -1 1) - src) - ;; When arg is nil assume the call is interactive. - ;; However if user call helm-follow-mode with a prefix arg, - ;; the call will be considered non--interactive and - ;; src-name will NOT be saved to helm-source-names-using-follow. - ;; When called from lisp (non--interactive) src-name - ;; will never be saved. - (when (and helm-follow-mode-persistent (null arg)) - (if (null enabled) - (unless (member name helm-source-names-using-follow) - (push name helm-source-names-using-follow) - (customize-save-variable 'helm-source-names-using-follow - helm-source-names-using-follow)) - (when (member name helm-source-names-using-follow) - (setq helm-source-names-using-follow - (delete name helm-source-names-using-follow)) - (customize-save-variable 'helm-source-names-using-follow - helm-source-names-using-follow)))) - (message "helm-follow-mode is %s" - (if (helm-follow-mode-p src) - "enabled" "disabled")) - (helm-display-mode-line src t))) - (message "Not enough candidates for helm-follow-mode")))))) + ;; Make follow attr persistent for this emacs session. + (helm-follow-mode-set-source + (if (or enabled (and (numberp arg) (< arg 0))) -1 1) + src) + ;; When arg is nil assume the call is interactive. + ;; However if user call helm-follow-mode with a prefix arg, + ;; the call will be considered non--interactive and + ;; src-name will NOT be saved to helm-source-names-using-follow. + ;; When called from lisp (non--interactive) src-name + ;; will never be saved. + (when (and helm-follow-mode-persistent (null arg)) + (if (null enabled) + (unless (member name helm-source-names-using-follow) + (push name helm-source-names-using-follow) + (customize-save-variable 'helm-source-names-using-follow + helm-source-names-using-follow)) + (when (member name helm-source-names-using-follow) + (setq helm-source-names-using-follow + (delete name helm-source-names-using-follow)) + (customize-save-variable 'helm-source-names-using-follow + helm-source-names-using-follow)))) + (message "helm-follow-mode is %s" + (if (helm-follow-mode-p src) + "enabled" "disabled")) + (helm-display-mode-line src t))) + (message "Not enough candidates for helm-follow-mode")))))) (put 'helm-follow-mode 'helm-only t) (defun helm-follow-execute-persistent-action-maybe (&optional delay) "Execute persistent action in mode `helm-follow-mode'. -This happen after: DELAY or the 'follow-attr value of current source -or `helm-follow-input-idle-delay' or `helm-input-idle-delay' secs." +This happen after: DELAY or the 'follow-attr value of current +source or `helm-follow-input-idle-delay' or +`helm-input-idle-delay' secs." (let* ((src (helm-get-current-source)) (at (or delay (assoc-default 'follow-delay src) @@ -6964,11 +7396,11 @@ or `helm-follow-input-idle-delay' or `helm-input-idle-delay' secs." (defun helm-follow-mode-p (&optional source) (with-helm-buffer - (eq (helm-attr 'follow (or source (helm-get-current-source))) 1))) + (eq (helm-get-attr 'follow (or source (helm-get-current-source))) 1))) (defun helm-follow-mode-set-source (value &optional source) (with-helm-buffer - (helm-attrset 'follow value (or source (helm-get-current-source))))) + (helm-set-attr 'follow value (or source (helm-get-current-source))))) ;;; Auto-resize mode ;; @@ -6984,11 +7416,10 @@ or `helm-follow-input-idle-delay' or `helm-input-idle-delay' secs." 100))))) (define-minor-mode helm-autoresize-mode - "Auto resize helm window when enabled. + "Auto resize helm window when enabled. Helm window is re-sized according to `helm-autoresize-max-height' -and `helm-autoresize-min-height'. Note that when this mode is -enabled, helm behaves as if `helm-always-two-windows' is -enabled. +and `helm-autoresize-min-height'. Note that when this mode is +enabled, Helm behaves as if `helm-always-two-windows' is enabled. See `fit-window-to-buffer' for more infos." :group 'helm @@ -6996,17 +7427,18 @@ See `fit-window-to-buffer' for more infos." (if helm-autoresize-mode (progn (add-hook 'helm-after-update-hook 'helm--autoresize-hook) (add-hook 'helm-window-configuration-hook 'helm--autoresize-hook)) - (remove-hook 'helm-after-update-hook 'helm--autoresize-hook) - (remove-hook 'helm-window-configuration-hook 'helm--autoresize-hook))) + (remove-hook 'helm-after-update-hook 'helm--autoresize-hook) + (remove-hook 'helm-window-configuration-hook 'helm--autoresize-hook))) (defun helm-help () - "Generate helm's help according to `help-message' attribute. - -If `helm-buffer' is empty, provide completions on `helm-sources' to -choose its local documentation. -If source doesn't have any `help-message' attribute, a generic message -explaining this is added instead. -The global `helm-help-message' is always added after this local help." + "Generate Helm's help according to `help-message' attribute. + +If `helm-buffer' is empty, provide completions on `helm-sources' +to choose its local documentation. +If source doesn't have any `help-message' attribute, a generic +message explaining this is added instead. +The global `helm-help-message' is always added after this local +help." (interactive) (require 'helm-mode) ; for helm-comp-read. (with-helm-alive-p @@ -7015,12 +7447,12 @@ The global `helm-help-message' is always added after this local help." "Help for: " (cl-loop for src in (with-helm-buffer helm-sources) collect `(,(assoc-default 'name src) . - ,src)) + ,src)) :allow-nest t :exec-when-only-one t)))) (save-selected-window (helm-help-internal - "*Helm Help*" + helm-help-buffer-name (lambda () (helm-aif (assoc-default 'help-message source) (insert (substitute-command-keys diff --git a/elpa/helm-org-20191101.715/helm-org-pkg.el b/elpa/helm-org-20191101.715/helm-org-pkg.el deleted file mode 100644 index d31e66b2..00000000 --- a/elpa/helm-org-20191101.715/helm-org-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "helm-org" "20191101.715" "Helm for org headlines and keywords completion" '((helm "3.3") (emacs "24.4")) :commit "c55512511251c4da8480eabcc4fffd303728b855" :authors '(("Thierry Volpiatto" . "thierry.volpiatto@gmail.com")) :maintainer '("Thierry Volpiatto" . "thierry.volpiatto@gmail.com") :url "https://github.com/emacs-helm/helm-org") diff --git a/elpa/helm-org-20191101.715/helm-org-autoloads.el b/elpa/helm-org-20200311.633/helm-org-autoloads.el similarity index 92% rename from elpa/helm-org-20191101.715/helm-org-autoloads.el rename to elpa/helm-org-20200311.633/helm-org-autoloads.el index e57a5e48..44aff9db 100644 --- a/elpa/helm-org-20191101.715/helm-org-autoloads.el +++ b/elpa/helm-org-20200311.633/helm-org-autoloads.el @@ -16,22 +16,20 @@ (autoload 'helm-org-agenda-files-headings "helm-org" "\ Preconfigured helm for org files headings. -\(fn)" t nil) +\(fn &optional ARG)" t nil) (autoload 'helm-org-in-buffer-headings "helm-org" "\ Preconfigured helm for org buffer headings. -\(fn)" t nil) +\(fn &optional ARG)" t nil) (autoload 'helm-org-parent-headings "helm-org" "\ Preconfigured helm for org headings that are parents of the current heading. -\(fn)" t nil) +\(fn &optional ARG)" t nil) (autoload 'helm-org-capture-templates "helm-org" "\ -Preconfigured helm for org templates. - -\(fn)" t nil) +Preconfigured helm for org templates." t nil) (autoload 'helm-org-completing-read-tags "helm-org" "\ Completing read function for Org tags. diff --git a/elpa/helm-org-20200311.633/helm-org-pkg.el b/elpa/helm-org-20200311.633/helm-org-pkg.el new file mode 100644 index 00000000..037a54fe --- /dev/null +++ b/elpa/helm-org-20200311.633/helm-org-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from /Users/andreas/.emacs.d/elpa/helm-org-20200311.633/helm-org.el -*- no-byte-compile: t -*- +(define-package "helm-org" "20200311.633" "Helm for org headlines and keywords completion" '((helm "3.3") (emacs "24.4")) :commit "b7a18dfc17e8b933956d61d68c435eee03a96c24" :authors '(("Thierry Volpiatto" . "thierry.volpiatto@gmail.com")) :maintainer '("Thierry Volpiatto" . "thierry.volpiatto@gmail.com") :url "https://github.com/emacs-helm/helm-org") diff --git a/elpa/helm-org-20191101.715/helm-org.el b/elpa/helm-org-20200311.633/helm-org.el similarity index 57% rename from elpa/helm-org-20191101.715/helm-org.el rename to elpa/helm-org-20200311.633/helm-org.el index ea761335..8b0ff3bf 100644 --- a/elpa/helm-org-20191101.715/helm-org.el +++ b/elpa/helm-org-20200311.633/helm-org.el @@ -4,7 +4,8 @@ ;; Author: Thierry Volpiatto ;; URL: https://github.com/emacs-helm/helm-org -;; Package-Version: 20191101.715 +;; Package-Version: 20200311.633 +;; Package-Commit: b7a18dfc17e8b933956d61d68c435eee03a96c24 ;; Package-Requires: ((helm "3.3") (emacs "24.4")) ;; Version: 1.0 @@ -34,6 +35,12 @@ (defvar helm-completing-read-handlers-alist) +;; Internals +(defvar helm-org--headers-cache nil) +(defvar helm-org--buffer-tick nil) +(defvar helm-org--force-refresh nil + "[INTERNAL] Force refreshing caches when non nil.") + ;; Menu ;;;###autoload (progn @@ -61,28 +68,34 @@ This reflect fontification in `helm-buffer' when non--nil. NOTE: This will be slow on large org buffers." :group 'helm-org - :type 'boolean) + :type 'boolean + :set (lambda (var value) + (set var value) + (setq helm-org--force-refresh t))) (defcustom helm-org-format-outline-path nil "Show all org level as path." :group 'helm-org - :type 'boolean) - -(defcustom helm-org-show-filename nil - "Show org filenames in `helm-org-agenda-files-headings' when non--nil. -Note this have no effect in `helm-org-in-buffer-headings'." - :group 'helm-org - :type 'boolean) + :type 'boolean + :set (lambda (var value) + (set var value) + (setq helm-org--force-refresh t))) (defcustom helm-org-headings-min-depth 1 "Minimum depth of org headings to start with." :group 'helm-org - :type 'integer) + :type 'integer + :set (lambda (var value) + (set var value) + (setq helm-org--force-refresh t))) (defcustom helm-org-headings-max-depth 8 "Go down to this maximum depth of org headings." :group 'helm-org - :type 'integer) + :type 'integer + :set (lambda (var value) + (set var value) + (setq helm-org--force-refresh t))) (defcustom helm-org-headings-actions '(("Go to heading" . helm-org-goto-marker) @@ -103,6 +116,11 @@ Note this have no effect in `helm-org-in-buffer-headings'." :type 'boolean :group 'helm-org) +(defcustom helm-org-completion-styles '(helm) + "A list of styles suitable for `completion-styles'." + :group 'helm-org + :type '(repeat symbol)) + ;;; Help ;; @@ -111,6 +129,11 @@ Note this have no effect in `helm-org-in-buffer-headings'." ** Tips +*** Matching and completion-styles + +In addition of multi matching like in all other helm commands, helm-org obey `completion-styles' +which allow having flex aka fuzzy matching, see [[Completion-styles][Completion-styles]]. + *** Refiling You can refile one or more headings at a time. @@ -203,97 +226,38 @@ Note: [1] A separator can be a comma, a colon i.e. [,:] or a space. map) "Keymap for `helm-source-org-headings-for-files'.") -(defclass helm-org-headings-class (helm-source-sync) - ((parents - :initarg :parents - :initform nil - :custom boolean) - (match :initform - (lambda (candidate) - (string-match - helm-pattern - (helm-aif (get-text-property 0 'helm-real-display candidate) - it - candidate)))) - (help-message :initform 'helm-org-headings-help-message) - (action :initform 'helm-org-headings-actions) - (keymap :initform 'helm-org-headings-map) - (group :initform 'helm-org))) - -(defmethod helm--setup-source :after ((source helm-org-headings-class)) - (let ((parents (slot-value source 'parents))) - (setf (slot-value source 'candidate-transformer) - (lambda (candidates) - (let ((cands (helm-org-get-candidates candidates parents))) - (if parents (nreverse cands) cands)))))) - -(defun helm-source-org-headings-for-files (filenames &optional parents) - "Build source for org headings in files FILENAMES. -When PARENTS is specified, bild source for heading that are parents of -current heading." - (helm-make-source "Org Headings" 'helm-org-headings-class - :filtered-candidate-transformer 'helm-org-startup-visibility - :parents parents - :candidates filenames)) - -(defun helm-org-startup-visibility (candidates _source) - "Indent headings and hide leading stars displayed in the helm buffer. -If `org-startup-indented' and `org-hide-leading-stars' are nil, do -nothing to CANDIDATES." - (cl-loop for i in candidates - collect - ;; Transformation is not needed if these variables are t. - (if (or helm-org-show-filename helm-org-format-outline-path) - (cons - (car i) (cdr i)) - (cons - (if helm-org-headings-fontify - (when (string-match "^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)" (car i)) - (replace-match "\\1\\2\\3" t nil (car i))) - (when (string-match "^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)" (car i)) - (let ((foreground (org-find-invisible-foreground))) - (with-helm-current-buffer - (cond - ;; org-startup-indented is t, and org-hide-leading-stars is t - ;; Or: #+STARTUP: indent hidestars - ((and org-startup-indented org-hide-leading-stars) - (with-helm-buffer - (require 'org-indent) - (org-indent-mode 1) - (replace-match - (format "%s\\2\\3" - (propertize (replace-match "\\1" t nil (car i)) - 'face `(:foreground ,foreground))) - t nil (car i)))) - ;; org-startup-indented is nil, org-hide-leading-stars is t - ;; Or: #+STARTUP: noindent hidestars - ((and (not org-startup-indented) org-hide-leading-stars) - (with-helm-buffer - (replace-match - (format "%s\\2\\3" - (propertize (replace-match "\\1" t nil (car i)) - 'face `(:foreground ,foreground))) - t nil (car i)))) - ;; org-startup-indented is nil, and org-hide-leading-stars is nil - ;; Or: #+STARTUP: noindent showstars - (t - (with-helm-buffer - (replace-match "\\1\\2\\3" t nil (car i))))))))) - (cdr i))))) - -(defun helm-org-get-candidates (filenames &optional parents) - "Get org headings for file FILENAMES. -Get PARENTS of heading when specified." - (apply #'append - (mapcar (lambda (filename) - (helm-org--get-candidates-in-file - filename - helm-org-headings-fontify - (or parents (null helm-org-show-filename)) - parents)) - filenames))) - -(defun helm-org--get-candidates-in-file (filename &optional fontify nofname parents) +(defun helm-org-build-sources (filenames &optional parents force-refresh) + (unwind-protect + (cl-loop for file in filenames + for name = (if (bufferp file) + (buffer-name file) + (helm-basename file)) + collect + (helm-build-sync-source (format "Org headings (%s)" name) + :candidates (helm-dynamic-completion + (helm-org--get-candidates-in-file + file + helm-org-headings-fontify + t + parents (or force-refresh + helm-org--force-refresh)) + 'stringp + nil '(metadata (display-sort-function + . + (lambda (candidates) + (sort candidates + #'helm-generic-sort-fn)))) + nil helm-org-completion-styles) + :match-dynamic t + :filtered-candidate-transformer + #'helm-org-indent-headings + :action 'helm-org-headings-actions + :help-message 'helm-org-headings-help-message + :keymap helm-org-headings-map + :group 'helm-org)) + (setq helm-org--force-refresh nil))) + +(defun helm-org--get-candidates-in-file (filename &optional fontify nofname parents force-refresh) "Get candidates for org FILENAME. Fontify each heading when FONTIFY is specified. Don't show filename when NOFNAME. @@ -301,60 +265,113 @@ Get PARENTS as well when specified." (with-current-buffer (pcase filename ((pred bufferp) filename) ((pred stringp) (find-file-noselect filename t))) - (let ((match-fn (if fontify - #'match-string - #'match-string-no-properties)) - (search-fn (lambda () - (re-search-forward - org-complex-heading-regexp nil t))) - (file (unless (or (bufferp filename) nofname) - (concat (helm-basename filename) ":")))) - (when parents - (add-function :around (var search-fn) - (lambda (old-fn &rest args) - (when (org-up-heading-safe) - (apply old-fn args))))) - (save-excursion - (save-restriction - (unless (and (bufferp filename) - (buffer-base-buffer filename)) - ;; Only widen direct buffers, not indirect ones. - (widen)) - (unless parents (goto-char (point-min))) - ;; clear cache for new version of org-get-outline-path - (and (boundp 'org-outline-path-cache) - (setq org-outline-path-cache nil)) - (cl-loop with width = (window-width (helm-window)) - while (funcall search-fn) - for beg = (point-at-bol) - for end = (point-at-eol) - when (and fontify - (null (text-property-any - beg end 'fontified t))) - do (jit-lock-fontify-now beg end) - for level = (length (match-string-no-properties 1)) - for heading = (funcall match-fn 4) - if (and (>= level helm-org-headings-min-depth) - (<= level helm-org-headings-max-depth)) - collect `(,(propertize - (if helm-org-format-outline-path - (org-format-outline-path - ;; org-get-outline-path changed in signature and behaviour since org's - ;; commit 105a4466971. Let's fall-back to the new version in case - ;; of wrong-number-of-arguments error. - (condition-case nil - (append (apply #'org-get-outline-path - (unless parents - (list t level heading))) - (list heading)) - (wrong-number-of-arguments - (org-get-outline-path t t))) - width file) - (if file - (concat file (funcall match-fn 0)) - (funcall match-fn 0))) - 'helm-real-display heading) - . ,(point-marker)))))))) + (let ((tick (buffer-chars-modified-tick))) + (if (and helm-org--buffer-tick + (= tick helm-org--buffer-tick) + (null force-refresh)) + helm-org--headers-cache + (message "Refreshing cache in `%s'..." (buffer-name)) + (set (make-local-variable 'helm-org--buffer-tick) tick) + (prog1 + (set (make-local-variable 'helm-org--headers-cache) + (let ((match-fn (if fontify + #'match-string + #'match-string-no-properties)) + (search-fn (lambda () + (re-search-forward + org-complex-heading-regexp nil t))) + (file (unless (or (bufferp filename) nofname) + (concat (helm-basename filename) ":")))) + (when parents + (add-function :around (var search-fn) + (lambda (old-fn &rest args) + (when (org-up-heading-safe) + (apply old-fn args))))) + (save-excursion + (save-restriction + (unless (and (bufferp filename) + (buffer-base-buffer filename)) + ;; Only widen direct buffers, not indirect ones. + (widen)) + (unless parents (goto-char (point-min))) + ;; clear cache for new version of org-get-outline-path + (and (boundp 'org-outline-path-cache) + (setq org-outline-path-cache nil)) + (cl-loop with width = (window-width (helm-window)) + while (funcall search-fn) + for beg = (point-at-bol) + for end = (point-at-eol) + when (and fontify + (null (text-property-any + beg end 'fontified t))) + do (jit-lock-fontify-now beg end) + for level = (length (match-string-no-properties 1)) + for heading = (funcall match-fn 4) + if (and (>= level helm-org-headings-min-depth) + (<= level helm-org-headings-max-depth)) + collect (propertize + (if helm-org-format-outline-path + (org-format-outline-path + ;; org-get-outline-path changed in signature and behaviour since org's + ;; commit 105a4466971. Let's fall-back to the new version in case + ;; of wrong-number-of-arguments error. + (condition-case nil + (append (apply #'org-get-outline-path + (unless parents + (list t level heading))) + (list heading)) + (wrong-number-of-arguments + (org-get-outline-path t t))) + width file) + (if file + (concat file (funcall match-fn 0)) + (funcall match-fn 0))) + 'helm-real-display heading + 'helm-realvalue (point-marker))))))) + (message "Refreshing cache in `%s' done" (buffer-name))))))) + +(defun helm-org-indent-headings (candidates _source) + "Indent headings and hide leading stars displayed in the helm buffer. +If `org-startup-indented' and `org-hide-leading-stars' are nil, do +nothing to CANDIDATES." + (cl-loop for disp in candidates collect + (helm-org-indent-headings-1 disp))) + +(defun helm-org-indent-headings-1 (candidate) + (if helm-org-headings-fontify + (if (string-match "^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)" candidate) + (replace-match "\\1\\2\\3" t nil candidate) + candidate) + (if (string-match "^\\(\\**\\)\\(\\* \\)\\(.*\n?\\)" candidate) + (let ((foreground (org-find-invisible-foreground))) + (with-helm-current-buffer + (cond + ;; org-startup-indented is t, and org-hide-leading-stars is t + ;; Or: #+STARTUP: indent hidestars + ((and org-startup-indented org-hide-leading-stars) + (with-helm-buffer + (require 'org-indent) + (org-indent-mode 1) + (replace-match + (format "%s\\2\\3" + (propertize (replace-match "\\1" t nil candidate) + 'face `(:foreground ,foreground))) + t nil candidate))) + ;; org-startup-indented is nil, org-hide-leading-stars is t + ;; Or: #+STARTUP: noindent hidestars + ((and (not org-startup-indented) org-hide-leading-stars) + (with-helm-buffer + (replace-match + (format "%s\\2\\3" + (propertize (replace-match "\\1" t nil candidate) + 'face `(:foreground ,foreground))) + t nil candidate))) + ;; org-startup-indented is nil, and org-hide-leading-stars is nil + ;; Or: #+STARTUP: noindent showstars + (t + (with-helm-buffer + (replace-match "\\1\\2\\3" t nil candidate)))))) + candidate))) (defun helm-org-insert-link-to-heading-at-marker (marker) "Insert link to heading at MARKER position." @@ -381,7 +398,12 @@ will be refiled." (let* ((victims (with-helm-buffer (helm-marked-candidates))) (buffer (marker-buffer marker)) (filename (buffer-file-name buffer)) - (rfloc (list nil filename nil marker))) + ;; get the heading we refile to so org doesn't + ;; output 'Refile to "nil" in file ...' + (heading (with-current-buffer buffer + (org-with-point-at marker + (org-get-heading :no-tags :no-todo :no-priority :no-comment)))) + (rfloc (list heading filename nil marker))) (when (and (= 1 (length victims)) (equal (helm-get-selection) (car victims))) ;; No candidates are marked; we are refiling the entry at point @@ -411,46 +433,43 @@ will be refiled." (put 'helm-org-run-refile-heading-to 'helm-only t) ;;;###autoload -(defun helm-org-agenda-files-headings () +(defun helm-org-agenda-files-headings (&optional arg) "Preconfigured helm for org files headings." - (interactive) + (interactive "P") (let ((autosaves (cl-loop for f in (org-agenda-files) when (file-exists-p (expand-file-name (concat "#" (helm-basename f) "#") (helm-basedir f))) - collect (helm-basename f)))) + collect (helm-basename f))) + (files (org-agenda-files))) (when (or (null autosaves) helm-org-ignore-autosaves (y-or-n-p (format "%s have auto save data, continue? " (mapconcat #'identity autosaves ", ")))) - (helm :sources (helm-source-org-headings-for-files (org-agenda-files)) - :candidate-number-limit 99999 + (helm :sources (helm-org-build-sources files nil arg) :truncate-lines helm-org-truncate-lines :buffer "*helm org headings*")))) ;;;###autoload -(defun helm-org-in-buffer-headings () +(defun helm-org-in-buffer-headings (&optional arg) "Preconfigured helm for org buffer headings." - (interactive) - (let (helm-org-show-filename) - (helm :sources (helm-source-org-headings-for-files - (list (current-buffer))) - :candidate-number-limit 99999 + (interactive "P") + (let ((files (list (current-buffer)))) + (helm :sources (helm-org-build-sources files nil arg) :preselect (helm-org-in-buffer-preselect) :truncate-lines helm-org-truncate-lines :buffer "*helm org inbuffer*"))) ;;;###autoload -(defun helm-org-parent-headings () +(defun helm-org-parent-headings (&optional arg) "Preconfigured helm for org headings that are parents of the current heading." - (interactive) + (interactive "P") ;; Use a large max-depth to ensure all parents are displayed. (let ((helm-org-headings-min-depth 1) - (helm-org-headings-max-depth 50)) - (helm :sources (helm-source-org-headings-for-files - (list (current-buffer)) t) - :candidate-number-limit 99999 + (helm-org-headings-max-depth 50) + (files (list (current-buffer)))) + (helm :sources (helm-org-build-sources files t arg) :truncate-lines helm-org-truncate-lines :buffer "*helm org parent headings*"))) @@ -459,7 +478,6 @@ will be refiled." "Preconfigured helm for org templates." (interactive) (helm :sources (helm-source-org-capture-templates) - :candidate-number-limit 99999 :truncate-lines helm-org-truncate-lines :buffer "*helm org capture templates*")) diff --git a/elpa/helm-projectile-20190731.1538/helm-projectile-pkg.el b/elpa/helm-projectile-20190731.1538/helm-projectile-pkg.el deleted file mode 100644 index c17919b8..00000000 --- a/elpa/helm-projectile-20190731.1538/helm-projectile-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "helm-projectile" "20190731.1538" "Helm integration for Projectile" '((helm "1.9.9") (projectile "0.14.0") (cl-lib "0.3")) :commit "5328b74dddcee8d1913803ca8167868831a07463" :keywords '("project" "convenience") :authors '(("Bozhidar Batsov")) :maintainer '("Bozhidar Batsov") :url "https://github.com/bbatsov/helm-projectile") diff --git a/elpa/helm-projectile-20190731.1538/helm-projectile-autoloads.el b/elpa/helm-projectile-20201217.908/helm-projectile-autoloads.el similarity index 79% rename from elpa/helm-projectile-20190731.1538/helm-projectile-autoloads.el rename to elpa/helm-projectile-20201217.908/helm-projectile-autoloads.el index 1e9b287f..3e4338c5 100644 --- a/elpa/helm-projectile-20190731.1538/helm-projectile-autoloads.el +++ b/elpa/helm-projectile-20201217.908/helm-projectile-autoloads.el @@ -1,10 +1,13 @@ ;;; helm-projectile-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + -;;;### (autoloads nil "helm-projectile" "helm-projectile.el" (23994 -;;;;;; 46466 834972 289000)) +;;;### (autoloads nil "helm-projectile" "helm-projectile.el" (0 0 +;;;;;; 0 0)) ;;; Generated autoloads from helm-projectile.el (defvar helm-projectile-fuzzy-match t "\ @@ -14,9 +17,7 @@ This needs to be set before loading helm-projectile.el.") (custom-autoload 'helm-projectile-fuzzy-match "helm-projectile" t) (autoload 'helm-projectile-find-file-dwim "helm-projectile" "\ -Find file at point based on context. - -\(fn)" t nil) +Find file at point based on context." t nil) (autoload 'helm-projectile-find-other-file "helm-projectile" "\ Switch between files with the same name but different extensions using Helm. @@ -26,14 +27,10 @@ Other file extensions can be customized with the variable `projectile-other-file \(fn &optional FLEX-MATCHING)" t nil) (autoload 'helm-projectile-on "helm-projectile" "\ -Turn on `helm-projectile' key bindings. - -\(fn)" t nil) +Turn on `helm-projectile' key bindings." t nil) (autoload 'helm-projectile-off "helm-projectile" "\ -Turn off `helm-projectile' key bindings. - -\(fn)" t nil) +Turn off `helm-projectile' key bindings." t nil) (autoload 'helm-projectile-grep "helm-projectile" "\ Helm version of `projectile-grep'. @@ -52,9 +49,7 @@ Helm version of `projectile-ag'. \(fn &optional OPTIONS)" t nil) (autoload 'helm-projectile-rg "helm-projectile" "\ -Projectile version of `helm-rg'. - -\(fn)" t nil) +Projectile version of `helm-rg'." t nil) (autoload 'helm-projectile-toggle "helm-projectile" "\ Toggle Helm version of Projectile commands. @@ -71,11 +66,14 @@ If invoked outside of a project, displays a list of known projects to jump. (eval-after-load 'projectile '(progn (define-key projectile-command-map (kbd "h") #'helm-projectile))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-projectile" '("helm-"))) + ;;;*** ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; helm-projectile-autoloads.el ends here diff --git a/elpa/helm-projectile-20201217.908/helm-projectile-pkg.el b/elpa/helm-projectile-20201217.908/helm-projectile-pkg.el new file mode 100644 index 00000000..2094cd43 --- /dev/null +++ b/elpa/helm-projectile-20201217.908/helm-projectile-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from /Users/andreas/.emacs.d/elpa/helm-projectile-20201217.908/helm-projectile.el -*- no-byte-compile: t -*- +(define-package "helm-projectile" "20201217.908" "Helm integration for Projectile" '((helm "1.9.9") (projectile "2.2.0") (cl-lib "0.3")) :commit "58123f14c392021714fc5d23b9f95c7f95ce07f1" :authors '(("Bozhidar Batsov")) :maintainer '("Bozhidar Batsov") :keywords '("project" "convenience") :url "https://github.com/bbatsov/helm-projectile") diff --git a/elpa/helm-projectile-20190731.1538/helm-projectile.el b/elpa/helm-projectile-20201217.908/helm-projectile.el similarity index 96% rename from elpa/helm-projectile-20190731.1538/helm-projectile.el rename to elpa/helm-projectile-20201217.908/helm-projectile.el index c97c363a..3e9c02de 100644 --- a/elpa/helm-projectile-20190731.1538/helm-projectile.el +++ b/elpa/helm-projectile-20201217.908/helm-projectile.el @@ -1,14 +1,15 @@ ;;; helm-projectile.el --- Helm integration for Projectile -*- lexical-binding: t; -*- -;; Copyright (C) 2011-2016 Bozhidar Batsov +;; Copyright (C) 2011-2020 Bozhidar Batsov ;; Author: Bozhidar Batsov ;; URL: https://github.com/bbatsov/helm-projectile -;; Package-Version: 20190731.1538 +;; Package-Version: 20201217.908 +;; Package-Commit: 58123f14c392021714fc5d23b9f95c7f95ce07f1 ;; Created: 2011-31-07 ;; Keywords: project, convenience -;; Version: 0.14.0 -;; Package-Requires: ((helm "1.9.9") (projectile "0.14.0") (cl-lib "0.3")) +;; Version: 1.1.0-snapshot +;; Package-Requires: ((helm "1.9.9") (projectile "2.2.0") (cl-lib "0.3")) ;; This file is NOT part of GNU Emacs. @@ -51,7 +52,7 @@ (require 'helm-files) (declare-function eshell "eshell") -(declare-function helm-do-ag "helm-ag") +(declare-function helm-do-ag "ext:helm-ag") (declare-function dired-get-filename "dired") (defvar helm-ag-base-command) @@ -187,7 +188,7 @@ It is there because Helm requires it." (message "(No removal performed)") (progn (mapc (lambda (p) - (delete p projectile-known-projects)) + (setq projectile-known-projects (delete p projectile-known-projects))) projects) (projectile-save-known-projects)) (message "%s projects(s) removed" len))))) @@ -198,7 +199,7 @@ It is there because Helm requires it." (helm-projectile-define-key map (kbd "C-d") #'dired (kbd "M-g") #'helm-projectile-vc - (kbd "M-e") #'helm-projectile-switch-to-eshell + (kbd "M-e") #'helm-projectile-switch-to-shell (kbd "C-s") #'helm-projectile-grep (kbd "M-c") #'helm-projectile-compile-project (kbd "M-t") #'helm-projectile-test-project @@ -214,7 +215,7 @@ It is there because Helm requires it." (projectile-switch-project-by-name project))) "Open Dired in project's directory `C-d'" #'dired "Open project root in vc-dir or magit `M-g'" #'helm-projectile-vc - "Switch to Eshell `M-e'" #'helm-projectile-switch-to-eshell + "Switch to Eshell `M-e'" #'helm-projectile-switch-to-shell "Grep in projects `C-s'" #'helm-projectile-grep "Compile project `M-c'. With C-u, new compile command" #'helm-projectile-compile-project "Remove project(s) from project list `M-D'" #'helm-projectile-remove-known-project) @@ -239,7 +240,7 @@ It is there because Helm requires it." (kbd "M-o") #'(lambda (project) (let ((projectile-completion-system 'helm)) (projectile-switch-project-by-name project))) - (kbd "M-e") #'helm-projectile-switch-to-eshell + (kbd "M-e") #'helm-projectile-switch-to-shell (kbd "C-s") #'helm-projectile-grep (kbd "M-c") #'helm-projectile-compile-project (kbd "M-t") #'helm-projectile-test-project @@ -260,7 +261,7 @@ It is there because Helm requires it." (let ((projectile-completion-system 'helm)) (projectile-switch-project-by-name project)))) ("Open Dired in project's directory `C-d'" . dired) - ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) + ("Switch to Eshell `M-e'" . helm-projectile-switch-to-shell) ("Grep in projects `C-s'" . helm-projectile-grep) ("Compile project `M-c'. With C-u, new compile command" . helm-projectile-compile-project))) @@ -321,11 +322,12 @@ Previews the contents of a file in a temporary buffer." (let* ((helm-ff-default-directory (file-name-directory candidate))) (helm-ff-etags-select candidate))) -(defun helm-projectile-switch-to-eshell (dir) +(defun helm-projectile-switch-to-shell (dir) + "Within DIR, switch to a shell corresponding to `helm-ff-preferred-shell-mode'." (interactive) (let* ((projectile-require-project-root nil) (helm-ff-default-directory (file-name-directory (projectile-expand-root dir)))) - (helm-ff-switch-to-eshell dir))) + (helm-ff-switch-to-shell dir))) (defun helm-projectile-files-in-current-dired-buffer () "Return a list of files (only) in the current dired buffer." @@ -468,7 +470,7 @@ CANDIDATE is the selected file. Used when no file is explicitly marked." (helm-projectile-define-key map (kbd "C-c f") #'helm-projectile-dired-files-new-action (kbd "C-c a") #'helm-projectile-dired-files-add-action - (kbd "M-e") #'helm-projectile-switch-to-eshell + (kbd "M-e") #'helm-projectile-switch-to-shell (kbd "M-.") #'helm-projectile-ff-etags-select-action (kbd "M-!") #'helm-projectile-find-files-eshell-command-on-file-action) (define-key map (kbd "") #'helm-previous-source) @@ -488,7 +490,7 @@ CANDIDATE is the selected file. Used when no file is explicitly marked." 'helm-ff-find-sh-command 'helm-ff-cache-add-file ;; Substitute these actions - '(helm-ff-switch-to-eshell . helm-projectile-switch-to-eshell) + '(helm-ff-switch-to-shell . helm-projectile-switch-to-shell) '(helm-ff-etags-select . helm-projectile-ff-etags-select-action) '(helm-find-files-eshell-command-on-file . helm-projectile-find-files-eshell-command-on-file-action) @@ -639,7 +641,7 @@ Meant to be added to `helm-cleanup-hook', from which it removes (kbd "") #'helm-previous-source (kbd "") #'helm-next-source (kbd "C-c o") #'helm-projectile-dired-find-dir-other-window - (kbd "M-e") #'helm-projectile-switch-to-eshell + (kbd "M-e") #'helm-projectile-switch-to-shell (kbd "C-c f") #'helm-projectile-dired-files-new-action (kbd "C-c a") #'helm-projectile-dired-files-add-action (kbd "C-s") #'helm-projectile-grep) @@ -648,7 +650,7 @@ Meant to be added to `helm-cleanup-hook', from which it removes :mode-line helm-read-file-name-mode-line-string :action '(("Open Dired" . helm-projectile-dired-find-dir) ("Open Dired in other window `C-c o'" . helm-projectile-dired-find-dir) - ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) + ("Switch to Eshell `M-e'" . helm-projectile-switch-to-shell) ("Grep in projects `C-s'" . helm-projectile-grep) ("Create Dired buffer from files `C-c f'" . helm-projectile-dired-files-new-action) ("Add files to Dired buffer `C-c a'" . helm-projectile-dired-files-add-action))) @@ -709,6 +711,23 @@ Meant to be added to `helm-cleanup-hook', from which it removes '(helm-source-projectile-dired-files-list helm-source-projectile-directories-list)) +(defcustom helm-projectile-git-grep-command + "git --no-pager grep --no-color -n%c -e %p -- %f" + "Command to execute when performing `helm-grep' inside a projectile git project. +See documentation of `helm-grep-default-command' for the format." + :type 'string + :group 'helm-projectile + ) + +(defcustom helm-projectile-grep-command + "grep -a -r %e -n%cH -e %p %f ." + "Command to execute when performing `helm-grep' outside a projectile git project. +See documentation of `helm-grep-default-command' for the format." + :type 'string + :group 'helm-projectile + ) + + (defcustom helm-projectile-sources-list '(helm-source-projectile-buffers-list helm-source-projectile-files-list @@ -853,8 +872,8 @@ If it is nil, or ack/ack-grep not found then use default grep command." (helm-grep-default-command (if use-ack-p (concat ack-executable " -H --no-group --no-color " ack-ignored-pattern " %p %f") (if (and projectile-use-git-grep (eq (projectile-project-vcs) 'git)) - "git --no-pager grep --no-color -n%c -e %p -- %f" - "grep -a -r %e -n%cH -e %p %f ."))) + helm-projectile-git-grep-command + helm-projectile-grep-command))) (helm-grep-default-recurse-command helm-grep-default-command)) (setq helm-source-grep @@ -960,7 +979,8 @@ DIR is the project root, if not set then current directory is used" ;; Declare/define these to satisfy the byte compiler (defvar helm-rg-prepend-file-name-line-at-top-of-matches) (defvar helm-rg-include-file-on-every-match-line) -(declare-function helm-rg "helm-rg") +(declare-function helm-rg "ext:helm-rg") +(declare-function helm-rg--get-thing-at-pt "ext:helm-rg") (defun helm-projectile-rg--region-selection () (when helm-projectile-set-input-automatically @@ -976,9 +996,9 @@ DIR is the project root, if not set then current directory is used" (if (projectile-project-p) (let ((helm-rg-prepend-file-name-line-at-top-of-matches nil) (helm-rg-include-file-on-every-match-line t)) - (helm-rg (helm-projectile-rg--region-selection) - nil - (list (projectile-project-root)))) + (let ((default-directory (projectile-project-root))) + (helm-rg (helm-projectile-rg--region-selection) + nil))) (error "You're not in a project")) (when (yes-or-no-p "`helm-rg' is not installed. Install? ") (condition-case nil diff --git a/elpa/helm-swoop-20200121.1859/helm-swoop-pkg.el b/elpa/helm-swoop-20200121.1859/helm-swoop-pkg.el deleted file mode 100644 index 0a82d8b3..00000000 --- a/elpa/helm-swoop-20200121.1859/helm-swoop-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "helm-swoop" "20200121.1859" "Efficiently hopping squeezed lines powered by helm interface" '((emacs "24.4") (helm "3.2")) :commit "9324d8c196ab2a86fde7142f159e081b87a4d277" :keywords '("convenience" "helm" "swoop" "inner" "buffer" "search") :authors '(("Shingo Fukuyama - http://fukuyama.co")) :maintainer '("Shingo Fukuyama - http://fukuyama.co") :url "https://github.com/emacsorphanage/helm-swoop") diff --git a/elpa/helm-swoop-20200121.1859/helm-swoop-autoloads.el b/elpa/helm-swoop-20200814.448/helm-swoop-autoloads.el similarity index 70% rename from elpa/helm-swoop-20200121.1859/helm-swoop-autoloads.el rename to elpa/helm-swoop-20200814.448/helm-swoop-autoloads.el index 3c34a232..586e9d86 100644 --- a/elpa/helm-swoop-20200121.1859/helm-swoop-autoloads.el +++ b/elpa/helm-swoop-20200814.448/helm-swoop-autoloads.el @@ -11,24 +11,22 @@ (autoload 'helm-swoop-back-to-last-point "helm-swoop" "\ Go back to last position where `helm-swoop' was called. -If $CANSEL is non-nil, store `helm-swoop-last-point'. +If CANCEL is non-nil, store `helm-swoop-last-point'. -\(fn &optional $CANCEL)" t nil) +\(fn &optional CANCEL)" t nil) (autoload 'helm-swoop "helm-swoop" "\ List the all lines to another buffer, which is able to squeeze by any words you input. At the same time, the original buffer's cursor is jumping line to line according to moving up and down the list. -\(fn &key $QUERY $SOURCE ($MULTILINE current-prefix-arg))" t nil) +\(fn &key QUERY SOURCE (MULTILINE current-prefix-arg))" t nil) (autoload 'helm-swoop-from-isearch "helm-swoop" "\ -Invoke `helm-swoop' from isearch. - -\(fn)" t nil) +Invoke `helm-swoop' from isearch." t nil) (autoload 'helm-multi-swoop "helm-swoop" "\ -Multi swoop for $QUERY in $BUFLIST. +Multi swoop for QUERY in BUFLIST. Usage: \\[execute-extended-command] helm-multi-swoop @@ -39,44 +37,38 @@ Usage: If you have done helm-multi-swoop before, you can skip select buffers step. Last selected buffers will be applied to helm-multi-swoop. -\(fn &optional $QUERY $BUFLIST)" t nil) +\(fn &optional QUERY BUFLIST)" t nil) (autoload 'helm-multi-swoop-all "helm-swoop" "\ -Apply all buffers to helm-multi-swoop for $QUERY. +Apply all buffers to helm-multi-swoop for QUERY. -\(fn &optional $QUERY)" t nil) +\(fn &optional QUERY)" t nil) (autoload 'helm-multi-swoop-org "helm-swoop" "\ -Applie all `org-mode' buffers to helm-multi-swoop for $QUERY. +Applie all `org-mode' buffers to helm-multi-swoop for QUERY. -\(fn &optional $QUERY)" t nil) +\(fn &optional QUERY)" t nil) (autoload 'helm-multi-swoop-current-mode "helm-swoop" "\ -Applie all buffers of the same mode as the current buffer to helm-multi-swoop for $QUERY. +Applie all buffers of the same mode as the current buffer to helm-multi-swoop for QUERY. -\(fn &optional $QUERY)" t nil) +\(fn &optional QUERY)" t nil) (autoload 'helm-multi-swoop-projectile "helm-swoop" "\ -Apply all opened buffers of the current project to helm-multi-swoop for $QUERY. +Apply all opened buffers of the current project to helm-multi-swoop for QUERY. -\(fn &optional $QUERY)" t nil) +\(fn &optional QUERY)" t nil) (autoload 'helm-swoop-without-pre-input "helm-swoop" "\ -Start helm-swoop without pre input query. - -\(fn)" t nil) +Start helm-swoop without pre input query." t nil) (autoload 'helm-swoop-symble-pre-input "helm-swoop" "\ -Start helm-swoop without pre input query. - -\(fn)" t nil) +Start helm-swoop without pre input query." t nil) (autoload 'helm-multi-swoop-edit "helm-swoop" "\ -Multi swoop edit. - -\(fn)" t nil) +Multi swoop edit." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-swoop" '("helm-" "get-buffers-matching-mode"))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "helm-swoop" '("get-buffers-matching-mode" "helm-"))) ;;;*** diff --git a/elpa/helm-swoop-20200814.448/helm-swoop-pkg.el b/elpa/helm-swoop-20200814.448/helm-swoop-pkg.el new file mode 100644 index 00000000..05eaf6cb --- /dev/null +++ b/elpa/helm-swoop-20200814.448/helm-swoop-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from /Users/andreas/.emacs.d/elpa/helm-swoop-20200814.448/helm-swoop.el -*- no-byte-compile: t -*- +(define-package "helm-swoop" "20200814.448" "Efficiently hopping squeezed lines powered by helm interface" '((emacs "25.1") (helm "3.6")) :commit "1f7d3cf0d742b199e4ce13fcb8b19c977a44611e" :authors '(("Shingo Fukuyama - http://fukuyama.co")) :maintainer '("Shingo Fukuyama - http://fukuyama.co") :keywords '("convenience" "helm" "swoop" "inner" "buffer" "search") :url "https://github.com/emacsorphanage/helm-swoop") diff --git a/elpa/helm-swoop-20200121.1859/helm-swoop.el b/elpa/helm-swoop-20200814.448/helm-swoop.el similarity index 60% rename from elpa/helm-swoop-20200121.1859/helm-swoop.el rename to elpa/helm-swoop-20200814.448/helm-swoop.el index 6cca3be6..6984190e 100644 --- a/elpa/helm-swoop-20200121.1859/helm-swoop.el +++ b/elpa/helm-swoop-20200814.448/helm-swoop.el @@ -3,13 +3,14 @@ ;; Copyright (C) 2019 Emacsorphanage Community ;; Copyright (C) 2013-2018 Shingo Fukuyama -;; Version: 2.0.0 -;; Package-Version: 20200121.1859 +;; Version: 3.0.0 +;; Package-Version: 20200814.448 +;; Package-Commit: 1f7d3cf0d742b199e4ce13fcb8b19c977a44611e ;; Author: Shingo Fukuyama - http://fukuyama.co ;; URL: https://github.com/emacsorphanage/helm-swoop ;; Created: Oct 24 2013 ;; Keywords: convenience, helm, swoop, inner, buffer, search -;; Package-Requires: ((emacs "24.4") (helm "3.2")) +;; Package-Requires: ((emacs "25.1") (helm "3.6")) ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -96,10 +97,10 @@ (require 'helm-utils) (require 'helm-grep) -(declare-function migemo-search-pattern-get "migemo") -(declare-function migemo-forward "migemo") -(declare-function projectile-buffers-with-file-or-process "projectile") -(declare-function projectile-project-buffers "projectile") +(declare-function migemo-search-pattern-get "ext:migemo") +(declare-function migemo-forward "ext:migemo") +(declare-function projectile-buffers-with-file-or-process "ext:projectile") +(declare-function projectile-project-buffers "ext:projectile") (defvar projectile-buffers-filter-function) ;;; @ helm-swoop ---------------------------------------------- @@ -150,13 +151,13 @@ :group 'helm-swoop :type 'integer) (defvar helm-swoop-split-window-function - (lambda ($buf &rest _$args) + (lambda (buf &rest _args) (if helm-swoop-split-with-multiple-windows (funcall helm-swoop-split-direction) (when (one-window-p) (funcall helm-swoop-split-direction))) (other-window 1) - (switch-to-buffer $buf)) + (switch-to-buffer buf)) "Change the way to split window only when `helm-swoop' is calling.") (defcustom helm-swoop-after-goto-line-action-hook nil @@ -224,13 +225,12 @@ If value is symbol `always', always do fontify." map)) (defvar helm-swoop-map - (let (($map (make-sparse-keymap))) - (set-keymap-parent $map helm-swoop--basic-map) - (define-key $map (kbd "C-c C-e") 'helm-swoop-edit) - (define-key $map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop) - (define-key $map (kbd "C-w") 'helm-swoop-yank-thing-at-point) - (define-key $map (kbd "^") 'helm-swoop-caret-match) - $map) + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-swoop--basic-map) + (define-key map (kbd "C-c C-e") 'helm-swoop-edit) + (define-key map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop) + (define-key map (kbd "C-w") 'helm-swoop-yank-thing-at-point) + map) "Keymap for helm-swoop.") (defvar helm-multi-swoop--basic-map @@ -251,10 +251,10 @@ If value is symbol `always', always do fontify." map)) (defvar helm-multi-swoop-map - (let (($map (make-sparse-keymap))) - (set-keymap-parent $map helm-multi-swoop--basic-map) - (define-key $map (kbd "C-c C-e") 'helm-multi-swoop-edit) - $map)) + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-multi-swoop--basic-map) + (define-key map (kbd "C-c C-e") 'helm-multi-swoop-edit) + map)) (defvar helm-c-source-swoop-match-functions '(helm-mm-exact-match @@ -336,72 +336,72 @@ If value is symbol `always', always do fontify." "This function can pre-input keywords when helm-swoop invoked." :group 'helm-swoop :type 'function) -(defun helm-swoop-pre-input-optimize ($query) - "Return $QUERY processed by `regexp-quote'." - (when $query (regexp-quote $query))) +(defun helm-swoop-pre-input-optimize (query) + "Return QUERY processed by `regexp-quote'." + (when query (regexp-quote query))) -(defsubst helm-swoop--goto-line ($line) - "Go to $LINE concider narrowing." +(defsubst helm-swoop--goto-line (line) + "Go to LINE concider narrowing." (goto-char (point-min)) - (forward-line (1- $line))) + (forward-line (1- line))) (defsubst helm-swoop--recenter () "Recenter." (recenter (/ (window-height) 2))) -(defsubst helm-swoop--delete-overlay ($identity &optional $beg $end) - "Delete overlay if $IDENTITY has in $BEG to $END." - (overlay-recenter (or $end (point-max))) - (mapc (lambda ($o) - (if (overlay-get $o $identity) - (delete-overlay $o))) - (overlays-in (or $beg (point-min)) (or $end (point-max))))) +(defsubst helm-swoop--delete-overlay (identity &optional beg end) + "Delete overlay if IDENTITY has in BEG to END." + (overlay-recenter (or end (point-max))) + (mapc (lambda (ov) + (if (overlay-get ov identity) + (delete-overlay ov))) + (overlays-in (or beg (point-min)) (or end (point-max))))) (defsubst helm-swoop--get-string-at-line () "Get line string with no properties." (buffer-substring-no-properties (point-at-bol) (point-at-eol))) -(defun helm-swoop--buffer-substring ($point-min $point-max) - "Get buffer substring $POINT-MIN to $POINT-MAX." +(defun helm-swoop--buffer-substring (beg end) + "Get buffer substring BEG to END." (if helm-swoop-speed-or-color - (let (($content (buffer-substring $point-min $point-max))) - (propertize $content 'read-only nil)) - (buffer-substring-no-properties $point-min $point-max))) + (let ((content (buffer-substring beg end))) + (propertize content 'read-only nil)) + (buffer-substring-no-properties beg end))) ;;;###autoload -(defun helm-swoop-back-to-last-point (&optional $cancel) +(defun helm-swoop-back-to-last-point (&optional cancel) "Go back to last position where `helm-swoop' was called. -If $CANSEL is non-nil, store `helm-swoop-last-point'." +If CANCEL is non-nil, store `helm-swoop-last-point'." (interactive) (if helm-swoop-last-point - (let (($po (point))) + (let ((po (point))) (switch-to-buffer (cdr helm-swoop-last-point)) (goto-char (car helm-swoop-last-point)) - (unless $cancel + (unless cancel (setq helm-swoop-last-point - (cons $po (buffer-name (current-buffer)))))))) - -(defun helm-swoop--split-lines-by ($string $regexp $step) - "Return $STRING processed by `split-string' by $step for multiline." - (or $step (setq $step 1)) - (let (($from1 0) ;; last match point - ($from2 0) ;; last substring point - $list - ($i 1)) ;; from line 1 - (while (string-match $regexp $string $from1) - (setq $i (1+ $i)) - (if (eq 0 (% $i $step)) + (cons po (buffer-name (current-buffer)))))))) + +(defun helm-swoop--split-lines-by (string regexp step) + "Return STRING processed by `split-string' with REGEXP by STEP for multiline." + (or step (setq step 1)) + (let ((from1 0) ;; last match point + (from2 0) ;; last substring point + list + (i 1)) ;; from line 1 + (while (string-match regexp string from1) + (setq i (1+ i)) + (if (eq 0 (% i step)) (progn - (setq $list (cons (substring $string $from2 (match-beginning 0)) - $list)) - (setq $from2 (match-end 0)) - (setq $from1 (match-end 0))) - (setq $from1 (match-end 0)))) - (setq $list (cons (substring $string $from2) $list)) - (nreverse $list))) - -(defun helm-swoop--target-line-overlay-move (&optional $buf) - "Add color to the target line in $BUF." + (setq list (cons (substring string from2 (match-beginning 0)) + list)) + (setq from2 (match-end 0)) + (setq from1 (match-end 0))) + (setq from1 (match-end 0)))) + (setq list (cons (substring string from2) list)) + (nreverse list))) + +(defun helm-swoop--target-line-overlay-move (&optional buf) + "Add color to the target line in BUF." (move-overlay helm-swoop-line-overlay (progn @@ -414,7 +414,7 @@ If $CANSEL is non-nil, store `helm-swoop-last-point'." (or (re-search-forward "\n" nil t helm-swoop-last-prefix-number) ;; For the end of buffer error (point-max))) - $buf) + buf) (helm-swoop--unveil-invisible-overlay)) (defun helm-swoop--validate-regexp (regexp) @@ -425,35 +425,35 @@ If $CANSEL is non-nil, store `helm-swoop-last-point'." t) (invalid-regexp nil))) -(defun helm-swoop--target-word-overlay ($identity &optional $threshold) - "Target ward overlay to $IDENTITY with $THRESHOLD." +(defun helm-swoop--target-word-overlay (identity &optional threshold) + "Target ward overlay to IDENTITY with THRESHOLD." (interactive) (save-excursion - (let (($pat (split-string helm-pattern " ")) - ($threshold (or $threshold 2)) - $o) - (mapc (lambda ($wd) - (when (and (helm-swoop--validate-regexp $wd) (< $threshold (length $wd))) + (let ((pattern (split-string helm-pattern " ")) + (threshold (or threshold 2)) + ov) + (mapc (lambda (wd) + (when (and (helm-swoop--validate-regexp wd) (< threshold (length wd))) (goto-char (point-min)) ;; Optional require migemo.el (if (and (featurep 'migemo) helm-migemo-mode) - (setq $wd (migemo-search-pattern-get $wd))) + (setq wd (migemo-search-pattern-get wd))) ;; For caret begging match - (if (string-match "^\\^\\[0\\-9\\]\\+\\.\\(.+\\)" $wd) - (setq $wd (concat "^" (match-string 1 $wd)))) + (if (string-match "^\\^\\[0\\-9\\]\\+\\.\\(.+\\)" wd) + (setq wd (concat "^" (match-string 1 wd)))) (overlay-recenter (point-max)) - (while (and (not (eobp)) (re-search-forward $wd nil t)) + (while (and (not (eobp)) (re-search-forward wd nil t)) (if (= (match-beginning 0) (match-end 0)) (forward-char 1) - (setq $o (make-overlay (match-beginning 0) (match-end 0))) - (overlay-put $o 'face 'helm-swoop-target-word-face) - (overlay-put $o $identity t))))) - $pat)))) + (setq ov (make-overlay (match-beginning 0) (match-end 0))) + (overlay-put ov 'face 'helm-swoop-target-word-face) + (overlay-put ov identity t))))) + pattern)))) (defun helm-swoop--restore-unveiled-overlay () "Restore unveiled overlay." (when helm-swoop-invisible-targets - (mapc (lambda ($ov) (overlay-put (car $ov) 'invisible (cdr $ov))) + (mapc (lambda (ov) (overlay-put (car ov) 'invisible (cdr ov))) helm-swoop-invisible-targets) (setq helm-swoop-invisible-targets nil))) @@ -461,12 +461,12 @@ If $CANSEL is non-nil, store `helm-swoop-last-point'." "Show hidden text temporarily to view it during helm-swoop. This function needs to call after latest helm-swoop-line-overlay set." (helm-swoop--restore-unveiled-overlay) - (mapc (lambda ($ov) - (let (($type (overlay-get $ov 'invisible))) - (when $type - (overlay-put $ov 'invisible nil) + (mapc (lambda (ov) + (let ((type (overlay-get ov 'invisible))) + (when type + (overlay-put ov 'invisible nil) (setq helm-swoop-invisible-targets - (cons (cons $ov $type) helm-swoop-invisible-targets))))) + (cons (cons ov type) helm-swoop-invisible-targets))))) (overlays-in (overlay-start helm-swoop-line-overlay) (overlay-end helm-swoop-line-overlay)))) @@ -475,76 +475,76 @@ This function needs to call after latest helm-swoop-line-overlay set." (defun helm-swoop--move-line-action () "Move line action." (with-helm-window - (let* (($key (helm-swoop--get-string-at-line)) - ($num (when (string-match "^[0-9]+" $key) - (string-to-number (match-string 0 $key))))) + (let* ((key (helm-swoop--get-string-at-line)) + (num (when (string-match "^[0-9]+" key) + (string-to-number (match-string 0 key))))) ;; Synchronizing line position - (when (and $key $num) + (when (and key num) (with-selected-window helm-swoop-synchronizing-window - (helm-swoop--goto-line $num) + (helm-swoop--goto-line num) (with-current-buffer helm-swoop-target-buffer (delete-overlay helm-swoop-line-overlay) (helm-swoop--target-line-overlay-move)) (helm-swoop--recenter)) (setq helm-swoop-last-line-info - (cons helm-swoop-target-buffer $num)))))) - -(defun helm-swoop--nearest-line ($target $list) - "Return the nearest number of $TARGET out of $LIST." - (when (and $target $list) - (let ($result) - (cl-labels ((filter ($fn $elem $list) - (let ($r) - (mapc (lambda ($e) - (if (funcall $fn $elem $e) - (setq $r (cons $e $r)))) - $list) $r))) - (if (eq 1 (length $list)) - (setq $result (car $list)) - (let* (($lts (filter '> $target $list)) - ($gts (filter '< $target $list)) - ($lt (if $lts (apply 'max $lts))) - ($gt (if $gts (apply 'min $gts))) - ($ltg (if $lt (- $target $lt))) - ($gtg (if $gt (- $gt $target)))) - (setq $result - (cond ((memq $target $list) $target) - ((and (not $lt) (not $gt)) nil) - ((not $gtg) $lt) - ((not $ltg) $gt) - ((eq $ltg $gtg) $gt) - ((< $ltg $gtg) $lt) - ((> $ltg $gtg) $gt) + (cons helm-swoop-target-buffer num)))))) + +(defun helm-swoop--nearest-line (target list) + "Return the nearest number of TARGET out of LIST." + (when (and target list) + (let (res) + (cl-labels ((filter (fn elm list) + (let (r) + (mapc (lambda (e) + (if (funcall fn elm e) + (setq r (cons e r)))) + list) r))) + (if (eq 1 (length list)) + (setq res (car list)) + (let* ((lts (filter '> target list)) + (gts (filter '< target list)) + (lt (if lts (apply 'max lts))) + (gt (if gts (apply 'min gts))) + (ltg (if lt (- target lt))) + (gtg (if gt (- gt target)))) + (setq res + (cond ((memq target list) target) + ((and (not lt) (not gt)) nil) + ((not gtg) lt) + ((not ltg) gt) + ((eq ltg gtg) gt) + ((< ltg gtg) lt) + ((> ltg gtg) gt) (t 1)))))) - $result))) + res))) (defun helm-swoop--keep-nearest-position () "Keep nearest position." (with-helm-window - (let (($p (point-min)) $list $bound - $nearest-line $target-point - ($buf (rx-to-string (buffer-name (car helm-swoop-last-line-info)) t))) + (let ((p (point-min)) + (buf (rx-to-string (buffer-name (car helm-swoop-last-line-info)) t)) + list bound nearest-line target-point) (save-excursion - (goto-char $p) - (while (if $p (setq $p (re-search-forward (concat "^" $buf "$") nil t))) + (goto-char p) + (while (if p (setq p (re-search-forward (concat "^" buf "$") nil t))) (when (get-text-property (point-at-bol) 'helm-header) (forward-char 1) - (setq $bound (next-single-property-change (point) 'helm-header)) - (while (re-search-forward "^[0-9]+" $bound t) - (setq $list (cons - (string-to-number (match-string 0)) - $list))) - (setq $nearest-line (helm-swoop--nearest-line - (cdr helm-swoop-last-line-info) - $list)) - (goto-char $p) + (setq bound (next-single-property-change (point) 'helm-header)) + (while (re-search-forward "^[0-9]+" bound t) + (setq list (cons + (string-to-number (match-string 0)) + list))) + (setq nearest-line (helm-swoop--nearest-line + (cdr helm-swoop-last-line-info) + list)) + (goto-char p) (re-search-forward (concat "^" - (number-to-string $nearest-line) - "\\s-") $bound t) - (setq $target-point (point)) - (setq $p nil)))) - (when $target-point - (goto-char $target-point) + (number-to-string nearest-line) + "\\s-") bound t) + (setq target-point (point)) + (setq p nil)))) + (when target-point + (goto-char target-point) (helm-mark-current-line) (if (equal helm-swoop-buffer (buffer-name (current-buffer))) (helm-swoop--move-line-action) @@ -561,72 +561,74 @@ This function needs to call after latest helm-swoop-line-overlay set." (helm-swoop--delete-overlay 'target-buffer) (helm-swoop--target-word-overlay 'target-buffer helm-swoop-min-overlay-length))))) -(defun helm-swoop-flash-word ($match-beg $match-end) - "Flash ward in $MATCH-BEG to $MATCH-END." +(defun helm-swoop-flash-word (match-beg match-end) + "Flash ward in MATCH-BEG to MATCH-END." (interactive) (unwind-protect - (let (($o (make-overlay $match-beg $match-end))) - (when $o - (overlay-put $o 'face 'helm-swoop-target-word-face) - (overlay-put $o 'helm-swoop-overlay-word-frash t))) + (let ((ov (make-overlay match-beg match-end))) + (when ov + (overlay-put ov 'face 'helm-swoop-target-word-face) + (overlay-put ov 'helm-swoop-overlay-word-frash t))) (run-with-idle-timer 0.6 nil (lambda () (helm-swoop--delete-overlay 'helm-swoop-overlay-word-frash))))) ;; core ------------------------------------------------ +(defun helm-swoop--match-part (candidate) + "Extract the proper part of CANDIDATE." + (replace-regexp-in-string (rx bol (+? digit) " ") "" candidate)) + (defun helm-swoop--maybe-fontify! () "Ensure the entired buffer is highlighted." - (let ((fontify-safe? - (not (or (derived-mode-p 'magit-mode) - (bound-and-true-p magit-blame-mode) - (memq major-mode helm-swoop-font-lock-exclude) - (not (derived-mode-p 'prog-mode)))))) + (let ((fontify-safe-p (not (or (derived-mode-p 'magit-mode) + (bound-and-true-p magit-blame-mode) + (memq major-mode helm-swoop-font-lock-exclude) + (not (derived-mode-p 'prog-mode)))))) (when (and helm-swoop-speed-or-color font-lock-mode - fontify-safe? + fontify-safe-p (or (eq 'always helm-swoop-fontify-buffer-size-limit) (< (buffer-size) helm-swoop-fontify-buffer-size-limit))) (if (fboundp 'font-lock-ensure) (font-lock-ensure) (with-no-warnings (font-lock-fontify-buffer)))))) -(defun helm-swoop--get-content ($buffer &optional $linum) - "Get the whole content in $BUFFER and add line number at the head. -If $LINUM is number, lines are separated by $LINUM." - (let (($buf (get-buffer $buffer))) - (when $buf - (with-current-buffer $buf +(defun helm-swoop--get-content (buffer &optional linum) + "Get the whole content in BUFFER and add line number at the head. +If LINUM is number, lines are separated by LINUM." + (let ((buf (get-buffer buffer))) + (when buf + (with-current-buffer buf (helm-swoop--maybe-fontify!) - (let (($bufstr (helm-swoop--buffer-substring (point-min) (point-max)))) + (let ((bufstr (helm-swoop--buffer-substring (point-min) (point-max)))) (with-temp-buffer - (insert $bufstr) + (insert bufstr) (goto-char (point-min)) - (let (($i 1)) - (insert (format "%s " $i)) + (let ((i 1)) + (insert (format "%s " i)) (while (re-search-forward "\n" nil t) - (setq $i (1+ $i)) + (setq i (1+ i)) (if helm-swoop-use-line-number-face - (insert (propertize (format "%s" $i) 'font-lock-face 'helm-swoop-line-number-face) " ") - (insert (format "%s " $i)))) + (insert (propertize (format "%s" i) 'font-lock-face 'helm-swoop-line-number-face) " ") + (insert (format "%s " i)))) ;; Delete empty lines - (unless $linum + (unless linum (goto-char (point-min)) (while (re-search-forward "^[0-9]+\\s-*$" nil t) (replace-match "")))) (helm-swoop--buffer-substring (point-min) (point-max)))))))) -(defun helm-swoop--goto-line-action ($line) - "Goto $LINE action." +(defun helm-swoop--goto-line-action (line &optional other-window) + "Goto LINE action. If OTHER-WINDOW is non-nil, a new window will be open." (run-hooks 'helm-swoop-before-goto-line-action-hook) + (when other-window + (switch-to-buffer-other-window (current-buffer))) (helm-swoop--goto-line - (when (string-match "^[0-9]+" $line) - (string-to-number (match-string 0 $line)))) - (let (($regex - (mapconcat 'identity - (split-string helm-pattern " ") - "\\|"))) - (when (or (and (featurep 'migemo) helm-migemo-mode (migemo-forward $regex nil t)) - (re-search-forward $regex nil t)) + (when (string-match "^[0-9]+" line) + (string-to-number (match-string 0 line)))) + (let ((regex (mapconcat 'identity (split-string helm-pattern " ") "\\|"))) + (when (or (and (featurep 'migemo) helm-migemo-mode (migemo-forward regex nil t)) + (re-search-forward regex nil t)) (funcall helm-swoop-flash-region-function (match-beginning 0) (match-end 0)) (goto-char (match-beginning 0)) @@ -650,36 +652,39 @@ If $LINUM is number, lines are separated by $LINUM." "[\\\\[helm-swoop-edit]] Edit mode, \ [\\\\[helm-multi-swoop-all-from-helm-swoop]] apply all buffers")) (action . (("Go to Line" . helm-swoop--goto-line-action) - ("Edit" . helm-swoop--edit))) + ("Edit" . helm-swoop--edit) + ("Go to Line in Other Window" . (lambda (line) (helm-swoop--goto-line-action line t))))) ,(if (and helm-swoop-last-prefix-number (> helm-swoop-last-prefix-number 1)) '(multiline)) (match . ,(helm-swoop-match-functions)) + (match-part . ,#'helm-swoop--match-part) ;; (search . ,(helm-swoop-search-functions)) )) -(defun helm-c-source-multi-swoop ($buf $func $action $multiline) - "C source multi swoop in $BUF for $FUNC, $ACTION, $MULTILINE." - `((name . ,$buf) - (candidates . ,(funcall $func)) - (action . ,$action) - (header-line . ,(concat $buf +(defun helm-c-source-multi-swoop (buf func action multiline) + "C source multi swoop in BUF for FUNC, ACTION, MULTILINE." + `((name . ,buf) + (candidates . ,(funcall func)) + (action . ,action) + (header-line . ,(concat buf (substitute-command-keys " [\\\\[helm-multi-swoop-edit]] Edit mode"))) (keymap . ,helm-multi-swoop-map) (requires-pattern . 2) - ,(if (and $multiline - (> $multiline 1)) + ,(if (and multiline + (> multiline 1)) '(multiline)) (match . ,(helm-swoop-match-functions)) + (match-part . ,#'helm-swoop--match-part) ;; (search . ,(helm-swoop-search-functions)) )) -(defun helm-swoop--set-prefix ($multiline) - "Set prefix $MULTILINE." +(defun helm-swoop--set-prefix (multiline) + "Set prefix MULTILINE." ;; Enable scrolling margin (setq helm-swoop-last-prefix-number - (or $multiline 1))) ;; $multiline is for resume + (or multiline 1))) ;; multiline is for resume ;; Delete cache when buffer is saved or file changes on disk (defun helm-swoop--clear-cache () @@ -714,17 +719,17 @@ If $LINUM is number, lines are separated by $LINUM." (remove-hook 'helm-after-update-hook 'helm-swoop--pattern-match) (remove-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position) (setq helm-swoop-last-query helm-swoop-pattern) - (mapc (lambda ($ov) - (when (or (eq 'helm-swoop-target-line-face (overlay-get $ov 'face)) + (mapc (lambda (ov) + (when (or (eq 'helm-swoop-target-line-face (overlay-get ov 'face)) (eq 'helm-swoop-target-line-block-face - (overlay-get $ov 'face))) - (delete-overlay $ov))) + (overlay-get ov 'face))) + (delete-overlay ov))) (overlays-in (point-min) (point-max))) (helm-swoop--delete-overlay 'target-buffer) (deactivate-mark t)) ;;;###autoload -(cl-defun helm-swoop (&key $query $source ($multiline current-prefix-arg)) +(cl-defun helm-swoop (&key query source (multiline current-prefix-arg)) "List the all lines to another buffer, which is able to squeeze by any words you input. At the same time, the original buffer's cursor is jumping line to line according to moving up and down the list." @@ -736,7 +741,7 @@ If $LINUM is number, lines are separated by $LINUM." (unless (boundp 'helm-swoop-last-query) (set (make-local-variable 'helm-swoop-last-query) "")) (setq helm-swoop-target-buffer (current-buffer)) - (helm-swoop--set-prefix (prefix-numeric-value $multiline)) + (helm-swoop--set-prefix (prefix-numeric-value multiline)) ;; Overlay (setq helm-swoop-line-overlay (make-overlay (point) (point))) (overlay-put helm-swoop-line-overlay @@ -753,20 +758,20 @@ If $LINUM is number, lines are separated by $LINUM." ;; For synchronizing line position (add-hook 'helm-after-update-hook 'helm-swoop--pattern-match) (add-hook 'helm-after-update-hook 'helm-swoop--keep-nearest-position t) - (cond ($query + (cond (query (if (string-match - "\\(\\^\\[0\\-9\\]\\+\\.\\)\\(.*\\)" $query) - $query ;; NEED FIX #1 to appear as a "^" - $query)) + "\\(\\^\\[0\\-9\\]\\+\\.\\)\\(.*\\)" query) + query ;; NEED FIX #1 to appear as a "^" + query)) (mark-active - (let (($st (buffer-substring-no-properties - (region-beginning) (region-end)))) - (if (string-match "\n" $st) + (let ((st (buffer-substring-no-properties + (region-beginning) (region-end)))) + (if (string-match "\n" st) (message "Multi line region is not allowed") - (setq $query (helm-swoop-pre-input-optimize $st))))) - ((setq $query (helm-swoop-pre-input-optimize - (funcall helm-swoop-pre-input-function)))) - (t (setq $query ""))) + (setq query (helm-swoop-pre-input-optimize st))))) + ((setq query (helm-swoop-pre-input-optimize + (funcall helm-swoop-pre-input-function)))) + (t (setq query ""))) ;; First behavior (helm-swoop--recenter) (move-beginning-of-line 1) @@ -776,10 +781,10 @@ If $LINUM is number, lines are separated by $LINUM." (helm-display-source-at-screen-top nil) (helm-completion-window-scroll-margin 5)) (helm :sources - (or $source + (or source (helm-c-source-swoop)) :buffer helm-swoop-buffer - :input $query + :input query :prompt helm-swoop-prompt :preselect ;; Get current line has content or else near one @@ -799,12 +804,12 @@ If $LINUM is number, lines are separated by $LINUM." (defun helm-swoop-from-isearch () "Invoke `helm-swoop' from isearch." (interactive) - (let (($query (if isearch-regexp - isearch-string - (regexp-quote isearch-string)))) + (let ((query (if isearch-regexp + isearch-string + (regexp-quote isearch-string)))) (let (search-nonincremental-instead) (isearch-exit)) - (helm-swoop :$query $query))) + (helm-swoop :query query))) ;; When doing isearch, hand the word over to helm-swoop (define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch) @@ -813,9 +818,9 @@ If $LINUM is number, lines are separated by $LINUM." "Invoke `helm-swoop' from evil isearch." (interactive) (if (string-match "\\(isearch-\\|evil.*search\\)" (symbol-name real-last-command)) - (helm-swoop :$query (if isearch-regexp - isearch-string - (regexp-quote isearch-string))) + (helm-swoop :query (if isearch-regexp + isearch-string + (regexp-quote isearch-string))) (helm-swoop))) ;; When doing evil-search, hand the word over to helm-swoop ;; (define-key evil-motion-state-map (kbd "M-i") 'helm-swoop-from-evil-search) @@ -824,17 +829,17 @@ If $LINUM is number, lines are separated by $LINUM." (defun helm-swoop-yank-thing-at-point () "Insert string at which the point helm-swoop started." (interactive) - (let ($amend $buf) + (let (amend buf) (with-selected-window helm-swoop-synchronizing-window - (setq $buf (get-buffer (cdr helm-swoop-last-point))) - (when $buf - (with-current-buffer $buf + (setq buf (get-buffer (cdr helm-swoop-last-point))) + (when buf + (with-current-buffer buf (save-excursion (goto-char (car helm-swoop-last-point)) - (setq $amend (thing-at-point 'symbol)))))) - (when $amend + (setq amend (thing-at-point 'symbol)))))) + (when amend (with-selected-window (minibuffer-window) - (insert $amend))))) + (insert amend))))) ;; For helm-resume ------------------------ (defadvice helm-resume-select-buffer @@ -847,8 +852,8 @@ If $LINUM is number, lines are separated by $LINUM." ad-do-it)) (when (and (equal ad-return-value helm-swoop-buffer) (boundp 'helm-swoop-last-query)) - (helm-swoop :$query helm-swoop-last-query - :$multiline helm-swoop-last-prefix-number) + (helm-swoop :query helm-swoop-last-query + :multiline helm-swoop-last-prefix-number) (setq ad-return-value nil))) (defadvice helm-resume (around helm-swoop-resume activate) @@ -856,66 +861,29 @@ If $LINUM is number, lines are separated by $LINUM." (if (equal helm-last-buffer helm-swoop-buffer) (if (boundp 'helm-swoop-last-query) (if (not (ad-get-arg 0)) - (helm-swoop :$query helm-swoop-last-query - :$multiline helm-swoop-last-prefix-number)) + (helm-swoop :query helm-swoop-last-query + :multiline helm-swoop-last-prefix-number)) ;; Temporary apply second last buffer (let ((helm-last-buffer (cadr helm-buffers))) ad-do-it)) ad-do-it)) -;; For caret beginning-match ----------------------------- -(defun helm-swoop--caret-match-delete ($o $aft $beg $end &optional $len) - "Caret match delete for $O, $AFT in $BEG to $END and $LEN." - (if $aft - (- $end $beg $len) ;; Unused argument? To avoid byte compile error - (delete-region (overlay-start $o) (1- (overlay-end $o))))) - -(defun helm-swoop-caret-match (&optional _$resume) - "Caret match." - (interactive) - (let* (($prompt helm-swoop-prompt) ;; Accept change of the variable - ($line-number-regexp "^[0-9]+.") - ($prompt-regexp - (funcall `(lambda () - (rx bol ,$prompt)))) - ($prompt-regexp-with-line-number - (funcall `(lambda () - (rx bol ,$prompt (group ,$line-number-regexp))))) - ($disguise-caret - (lambda () - (save-excursion - (re-search-backward $prompt-regexp-with-line-number nil t) - (let (($o (make-overlay (match-beginning 1) (match-end 1)))) - (overlay-put $o 'face 'helm-swoop-target-word-face) - (overlay-put $o 'modification-hooks '(helm-swoop--caret-match-delete)) - (overlay-put $o 'display "^") - (overlay-put $o 'evaporate t)))))) - (if (and (minibufferp) - (string-match $prompt-regexp - (buffer-substring-no-properties - (point-min) (point-max))) - (eq (point) (+ 1 (length helm-swoop-prompt)))) - (progn - (insert $line-number-regexp) - (funcall $disguise-caret)) - (insert "^")))) - ;;; @ helm-swoop-edit ----------------------------------------- (defvar helm-swoop-edit-target-buffer) (defvar helm-swoop-edit-buffer "*Helm Swoop Edit*") (defvar helm-swoop-edit-map - (let (($map (make-sparse-keymap))) - (define-key $map (kbd "C-x C-s") 'helm-swoop--edit-complete) - (define-key $map (kbd "C-c C-g") 'helm-swoop--edit-cancel) - (define-key $map (kbd "C-c C-q C-k") 'helm-swoop--edit-delete-all-lines) - $map)) - -(defun helm-swoop--clear-edit-buffer ($prop) - "Clear edit buffer with $PROP." + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-x C-s") 'helm-swoop--edit-complete) + (define-key map (kbd "C-c C-g") 'helm-swoop--edit-cancel) + (define-key map (kbd "C-c C-q C-k") 'helm-swoop--edit-delete-all-lines) + map)) + +(defun helm-swoop--clear-edit-buffer (prop) + "Clear edit buffer with PROP." (let ((inhibit-read-only t)) - (mapc (lambda ($ov) - (when (overlay-get $ov $prop) - (delete-overlay $ov))) + (mapc (lambda (ov) + (when (overlay-get ov prop) + (delete-overlay ov))) (overlays-in (point-min) (point-max))) (set-text-properties (point-min) (point-max) nil) (goto-char (point-min)) @@ -924,10 +892,10 @@ If $LINUM is number, lines are separated by $LINUM." (defun helm-swoop--collect-edited-lines () "Create a list of edited lines with each its own line number." (interactive) - (let ($list) + (let (res) (goto-char (point-min)) (while (re-search-forward "^\\([0-9]+\\)\s" nil t) - (setq $list + (setq res (cons (cons (string-to-number (match-string 1)) (buffer-substring-no-properties (point) @@ -937,11 +905,11 @@ If $LINUM is number, lines are separated by $LINUM." (1- (match-beginning 0)) (goto-char (point-max)) (re-search-backward "\n" nil t))))) - $list))) - $list)) + res))) + res)) -(defun helm-swoop--edit ($candidate) - "This function will only be called from `helm-swoop-edit' with $CANDIDATE." +(defun helm-swoop--edit (candidate) + "This function will only be called from `helm-swoop-edit' with CANDIDATE." (interactive) (setq helm-swoop-edit-target-buffer helm-swoop-target-buffer) (delete-overlay helm-swoop-line-overlay) @@ -949,25 +917,25 @@ If $LINUM is number, lines are separated by $LINUM." (with-current-buffer (get-buffer-create helm-swoop-edit-buffer) (helm-swoop--clear-edit-buffer 'helm-swoop-edit) - (let (($bufstr "")) + (let ((bufstr "")) ;; Get target line number to edit (with-current-buffer helm-swoop-buffer ;; Use selected line by [C-SPC] or [M-SPC] - (mapc (lambda ($ov) - (when (eq 'helm-visible-mark (overlay-get $ov 'face)) - (setq $bufstr (concat (buffer-substring-no-properties - (overlay-start $ov) (overlay-end $ov)) - $bufstr)))) + (mapc (lambda (ov) + (when (eq 'helm-visible-mark (overlay-get ov 'face)) + (setq bufstr (concat (buffer-substring-no-properties + (overlay-start ov) (overlay-end ov)) + bufstr)))) (overlays-in (point-min) (point-max))) - (if (equal "" $bufstr) + (if (equal "" bufstr) ;; Not found selected line - (setq $bufstr (buffer-substring-no-properties - (point-min) (point-max))) + (setq bufstr (buffer-substring-no-properties + (point-min) (point-max))) ;; Attach title - (setq $bufstr (concat "Helm Swoop\n" $bufstr)))) + (setq bufstr (concat "Helm Swoop\n" bufstr)))) ;; Set for edit buffer - (insert $bufstr) + (insert bufstr) (add-text-properties (point-min) (point-max) '(read-only t rear-nonsticky t front-sticky t)) @@ -975,10 +943,10 @@ If $LINUM is number, lines are separated by $LINUM." (let ((inhibit-read-only t)) ;; Title and explanation (goto-char (point-min)) - (let (($o (make-overlay (point) (point-at-eol)))) - (overlay-put $o 'helm-swoop-edit t) - (overlay-put $o 'face 'font-lock-function-name-face) - (overlay-put $o 'after-string + (let ((ov (make-overlay (point) (point-at-eol)))) + (overlay-put ov 'helm-swoop-edit t) + (overlay-put ov 'face 'font-lock-function-name-face) + (overlay-put ov 'after-string (propertize (substitute-command-keys (concat @@ -988,44 +956,44 @@ If $LINUM is number, lines are separated by $LINUM." 'face 'helm-bookmark-addressbook))) ;; Line number and editable area (while (re-search-forward "^\\([0-9]+\s\\)\\(.*\\)$" nil t) - (let* (($bol1 (match-beginning 1)) - ($eol1 (match-end 1)) - ($bol2 (match-beginning 2)) - ($eol2 (match-end 2))) + (let* ((bol1 (match-beginning 1)) + (eol1 (match-end 1)) + (bol2 (match-beginning 2)) + (eol2 (match-end 2))) ;; Line number - (add-text-properties $bol1 $eol1 + (add-text-properties bol1 eol1 '(face font-lock-function-name-face intangible t)) ;; Editable area - (remove-text-properties $bol2 $eol2 '(read-only t)) + (remove-text-properties bol2 eol2 '(read-only t)) ;; For line tail - (set-text-properties $eol2 (or (1+ $eol2) (point-max)) + (set-text-properties eol2 (or (1+ eol2) (point-max)) '(read-only t rear-nonsticky t)))) (helm-swoop--target-word-overlay 'edit-buffer 0)))) (other-window 1) (switch-to-buffer helm-swoop-edit-buffer) (goto-char (point-min)) - (if (string-match "^[0-9]+" $candidate) + (if (string-match "^[0-9]+" candidate) (re-search-forward - (concat "^" (match-string 0 $candidate)) nil t)) + (concat "^" (match-string 0 candidate)) nil t)) (use-local-map helm-swoop-edit-map)) (defun helm-swoop--edit-complete () "Apply change and kill temporary edit buffer." (interactive) - (let (($list (helm-swoop--collect-edited-lines))) + (let ((lines (helm-swoop--collect-edited-lines))) (with-current-buffer helm-swoop-edit-target-buffer ;; Replace from the end of buffer (save-excursion - (mapc (lambda ($cell) - (let (($k (car $cell)) - ($v (cdr $cell))) + (mapc (lambda (cell) + (let ((k (car cell)) + (v (cdr cell))) (goto-char (point-min)) - (delete-region (point-at-bol $k) (point-at-eol $k)) - (goto-char (point-at-bol $k)) - (insert $v))) - $list))) + (delete-region (point-at-bol k) (point-at-eol k)) + (goto-char (point-at-bol k)) + (insert v))) + lines))) (select-window helm-swoop-synchronizing-window) (kill-buffer (get-buffer helm-swoop-edit-buffer))) (message "Successfully helm-swoop-edit applied to original buffer")) @@ -1033,18 +1001,18 @@ If $LINUM is number, lines are separated by $LINUM." (defun helm-swoop--edit-delete-all-lines () "Apply change and kill temporary edit buffer." (interactive) - (let (($list (helm-swoop--collect-edited-lines))) + (let ((lines (helm-swoop--collect-edited-lines))) (with-current-buffer helm-swoop-edit-target-buffer ;; Replace from the end of buffer (save-excursion - (mapc (lambda ($cell) - (let (($k (car $cell))) + (mapc (lambda (cell) + (let ((k (car cell))) (goto-char (point-min)) - (delete-region (point-at-bol $k) - (if (eq (point-at-eol $k) (point-max)) - (point-at-eol $k) - (1+ (point-at-eol $k)))))) - $list))) + (delete-region (point-at-bol k) + (if (eq (point-at-eol k) (point-max)) + (point-at-eol k) + (1+ (point-at-eol k)))))) + lines))) (select-window helm-swoop-synchronizing-window) (kill-buffer (get-buffer helm-swoop-edit-buffer))) (message "Successfully helm-swoop-edit applied to original buffer")) @@ -1076,12 +1044,12 @@ If $LINUM is number, lines are separated by $LINUM." (defvar helm-multi-swoop-move-line-action-last-buffer nil) (defvar helm-multi-swoop-buffers-map - (let (($map (make-sparse-keymap))) - (set-keymap-parent $map helm-map) - (define-key $map (kbd "RET") + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "RET") (lambda () (interactive) (helm-exit-and-execute-action 'helm-multi-swoop--exec))) - (delq nil $map))) + (delq nil map))) (defvar helm-multi-swoop-projectile-buffers-filter #'projectile-buffers-with-file-or-process) @@ -1090,50 +1058,46 @@ If $LINUM is number, lines are separated by $LINUM." (defun helm-multi-swoop--move-line-action () "Move line action." (with-helm-window - (let* (($key (buffer-substring (point-at-bol) (point-at-eol))) - ($num (when (string-match "^[0-9]+" $key) - (string-to-number (match-string 0 $key)))) - ($source (helm-get-current-source)) - ($buf (let (($name (assoc-default 'name $source))) - (when $name (get-buffer $name))))) - (when $buf + (let* ((key (buffer-substring (point-at-bol) (point-at-eol))) + (num (when (string-match "^[0-9]+" key) + (string-to-number (match-string 0 key)))) + (source (helm-get-current-source)) + (buf (let ((name (assoc-default 'name source))) + (when name (get-buffer name))))) + (when buf ;; Synchronizing line position (with-selected-window helm-swoop-synchronizing-window - (with-current-buffer $buf - (when (not (eq $buf helm-multi-swoop-move-line-action-last-buffer)) - (set-window-buffer nil $buf) + (with-current-buffer buf + (when (not (eq buf helm-multi-swoop-move-line-action-last-buffer)) + (set-window-buffer nil buf) (helm-swoop--pattern-match)) - (helm-swoop--goto-line $num) - (helm-swoop--target-line-overlay-move $buf) + (helm-swoop--goto-line num) + (helm-swoop--target-line-overlay-move buf) (helm-swoop--recenter)) - (setq helm-multi-swoop-move-line-action-last-buffer $buf)) - (setq helm-swoop-last-line-info (cons $buf $num)))))) + (setq helm-multi-swoop-move-line-action-last-buffer buf)) + (setq helm-swoop-last-line-info (cons buf num)))))) (defun helm-multi-swoop--get-marked-buffers () "Get marked buffers." - (let ($list - ($buf (get-buffer helm-multi-swoop-buffer-list))) - (when $buf - (with-current-buffer (get-buffer helm-multi-swoop-buffer-list) - (mapc (lambda ($ov) - (when (eq 'helm-visible-mark (overlay-get $ov 'face)) - (setq $list (cons - (let (($word (buffer-substring-no-properties - (overlay-start $ov) (overlay-end $ov)))) - (mapc (lambda ($r) - (setq $word (replace-regexp-in-string - (car $r) (cdr $r) $word))) - (list '("\\`[ \t\n\r]+" . "") - '("[ \t\n\r]+\\'" . ""))) - $word) - $list)))) - (overlays-in (point-min) (point-max)))) - (delete "" $list)))) + (let ((buf (get-buffer helm-multi-swoop-buffer-list)) + lst) + (when (buffer-live-p buf) + (with-current-buffer buf + (dolist (ov (cl-delete-if-not + (lambda (o) + (eq 'helm-visible-mark (overlay-get o 'face))) + (overlays-in (point-min) (point-max)))) + (let ((word (string-trim + (buffer-substring-no-properties + (overlay-start ov) (overlay-end ov))))) + (unless (string-empty-p word) + (push word lst))))) + (nreverse (sort lst #'string<))))) ;; core -------------------------------------------------------- -(cl-defun helm-multi-swoop--exec (ignored &key $query $buflist $func $action) - "Multi swoop exec with IGNORED $QUERY $BUFLIST $FUNC $ACTION." +(cl-defun helm-multi-swoop--exec (ignored &key query buflist func action) + "Multi swoop exec with IGNORED QUERY BUFLIST FUNC ACTION." (interactive) (setq helm-swoop-synchronizing-window (selected-window)) (setq helm-swoop-last-point @@ -1144,35 +1108,34 @@ If $LINUM is number, lines are separated by $LINUM." (unless (get-buffer helm-multi-swoop-buffer-list) (get-buffer-create helm-multi-swoop-buffer-list)) (helm-swoop--set-prefix (prefix-numeric-value current-prefix-arg)) - (let (($buffs (or $buflist - (helm-multi-swoop--get-marked-buffers) - `(,(buffer-name helm-swoop-target-buffer)) - (error "No buffer selected"))) - $contents - $preserve-position - ($prefix-arg (prefix-numeric-value - (or current-prefix-arg helm-swoop-last-prefix-number 1)))) - (helm-swoop--set-prefix $prefix-arg) - (setq helm-multi-swoop-last-selected-buffers $buffs) + (let ((buffs (or buflist + (helm-multi-swoop--get-marked-buffers) + `(,(buffer-name helm-swoop-target-buffer)) + (error "No buffer selected"))) + (prefix-arg (prefix-numeric-value + (or current-prefix-arg helm-swoop-last-prefix-number 1))) + contents preserve-position) + (helm-swoop--set-prefix prefix-arg) + (setq helm-multi-swoop-last-selected-buffers buffs) ;; Create buffer sources - (mapc (lambda ($buf) - (when (get-buffer $buf) - (with-current-buffer (get-buffer $buf) - (let* (($func - (or $func + (mapc (lambda (buf) + (when (get-buffer buf) + (with-current-buffer (get-buffer buf) + (let* ((func + (or func (lambda () (helm-swoop--split-lines-by - (helm-swoop--get-content $buf t) - "\n" $prefix-arg)))) - ($action - (or $action + (helm-swoop--get-content buf t) + "\n" prefix-arg)))) + (action + (or action `(("Go to Line" - . (lambda ($line) - (switch-to-buffer ,$buf) + . (lambda (line) + (switch-to-buffer ,buf) (helm-swoop--goto-line - (when (string-match "^[0-9]+" $line) + (when (string-match "^[0-9]+" line) (string-to-number - (match-string 0 $line)))) + (match-string 0 line)))) (when (re-search-forward (mapconcat 'identity (split-string @@ -1183,14 +1146,14 @@ If $LINUM is number, lines are separated by $LINUM." (goto-char (match-beginning 0))) (helm-swoop--recenter))) ("Edit" . helm-multi-swoop--edit))))) - (setq $preserve-position - (cons (cons $buf (point)) $preserve-position)) + (setq preserve-position + (cons (cons buf (point)) preserve-position)) (setq - $contents + contents (cons - (helm-c-source-multi-swoop $buf $func $action $prefix-arg) - $contents)))))) - $buffs) + (helm-c-source-multi-swoop buf func action prefix-arg) + contents)))))) + buffs) (unwind-protect (progn (add-hook 'helm-after-update-hook 'helm-swoop--pattern-match) @@ -1204,9 +1167,9 @@ If $LINUM is number, lines are separated by $LINUM." (let ((helm-display-function helm-swoop-split-window-function) (helm-display-source-at-screen-top nil) (helm-completion-window-scroll-margin 5)) - (helm :sources $contents + (helm :sources contents :buffer helm-multi-swoop-buffer - :input (or $query helm-multi-swoop-query "") + :input (or query helm-multi-swoop-query "") :prompt helm-swoop-prompt :candidate-number-limit helm-multi-swoop-candidate-number-limit @@ -1226,35 +1189,33 @@ If $LINUM is number, lines are separated by $LINUM." (helm-swoop--restore-unveiled-overlay) (setq helm-multi-swoop-query nil) (setq helm-multi-swoop-all-from-helm-swoop-last-point nil) - (mapc (lambda ($buf) - (let (($current-buffer (buffer-name (current-buffer)))) - (with-current-buffer (car $buf) + (mapc (lambda (buf) + (let ((current-buf (buffer-name (current-buffer)))) + (with-current-buffer (car buf) ;; Delete overlay (delete-overlay helm-swoop-line-overlay) (helm-swoop--delete-overlay 'target-buffer) ;; Restore each buffer's position - (unless (equal (car $buf) $current-buffer) - (goto-char (cdr $buf)))))) - $preserve-position))))) + (unless (equal (car buf) current-buf) + (goto-char (cdr buf)))))) + preserve-position))))) (defun helm-multi-swoop--get-buffer-list () "Get buffer list." - (let ($buflist1 $buflist2) + (let (buflist1 buflist2) ;; eliminate buffers start with whitespace and dired buffers - (mapc (lambda ($buf) - (setq $buf (buffer-name $buf)) - (unless (string-match "^\\s-" $buf) - (unless (eq 'dired-mode (with-current-buffer $buf major-mode)) - (setq $buflist1 (cons $buf $buflist1))))) + (mapc (lambda (buf) + (setq buf (buffer-name buf)) + (unless (string-match "^\\s-" buf) + (unless (eq 'dired-mode (with-current-buffer buf major-mode)) + (setq buflist1 (cons buf buflist1))))) (buffer-list)) ;; eliminate buffers match pattern - (mapc (lambda ($buf) - (unless (string-match - helm-multi-swoop-ignore-buffers-match - $buf) - (setq $buflist2 (cons $buf $buflist2)))) - $buflist1) - $buflist2)) + (mapc (lambda (buf) + (unless (string-match helm-multi-swoop-ignore-buffers-match buf) + (setq buflist2 (cons buf buflist2)))) + buflist1) + buflist2)) (defun helm-c-source-helm-multi-swoop-buffers () "Show buffer list to select." @@ -1266,25 +1227,25 @@ If $LINUM is number, lines are separated by $LINUM." ;; (search . ,(helm-swoop-search-functions)) )) -(defun helm-multi-swoop--get-query ($query) - "Get query from $QUERY." - (cond ($query - (setq helm-multi-swoop-query $query)) +(defun helm-multi-swoop--get-query (query) + "Get query from QUERY." + (cond (query + (setq helm-multi-swoop-query query)) (mark-active - (let (($st (buffer-substring-no-properties - (region-beginning) (region-end)))) - (if (string-match "\n" $st) + (let ((st (buffer-substring-no-properties + (region-beginning) (region-end)))) + (if (string-match "\n" st) (message "Multi line region is not allowed") (setq helm-multi-swoop-query - (helm-swoop-pre-input-optimize $st))))) + (helm-swoop-pre-input-optimize st))))) ((setq helm-multi-swoop-query (helm-swoop-pre-input-optimize (funcall helm-swoop-pre-input-function)))) (t (setq helm-multi-swoop-query "")))) ;;;###autoload -(defun helm-multi-swoop (&optional $query $buflist) - "Multi swoop for $QUERY in $BUFLIST. +(defun helm-multi-swoop (&optional query buflist) + "Multi swoop for QUERY in BUFLIST. Usage: \\[execute-extended-command] helm-multi-swoop @@ -1295,80 +1256,80 @@ Usage: If you have done helm-multi-swoop before, you can skip select buffers step. Last selected buffers will be applied to helm-multi-swoop." (interactive) - (setq helm-multi-swoop-query (helm-multi-swoop--get-query $query)) + (setq helm-multi-swoop-query (helm-multi-swoop--get-query query)) (if (equal current-prefix-arg '(4)) (helm-multi-swoop--exec nil - :$query helm-multi-swoop-query - :$buflist $buflist) - (if $buflist + :query helm-multi-swoop-query + :buflist buflist) + (if buflist (helm-multi-swoop--exec nil - :$query $query - :$buflist $buflist) + :query query + :buflist buflist) (helm :sources (helm-c-source-helm-multi-swoop-buffers) :buffer helm-multi-swoop-buffer-list :prompt "Mark any buffers by [C-SPC] or [M-SPC]: ")))) ;;;###autoload -(defun helm-multi-swoop-all (&optional $query) - "Apply all buffers to helm-multi-swoop for $QUERY." +(defun helm-multi-swoop-all (&optional query) + "Apply all buffers to helm-multi-swoop for QUERY." (interactive) - (setq helm-multi-swoop-query (helm-multi-swoop--get-query $query)) + (setq helm-multi-swoop-query (helm-multi-swoop--get-query query)) (helm-multi-swoop--exec nil - :$query helm-multi-swoop-query - :$buflist (helm-multi-swoop--get-buffer-list))) - -(defun get-buffers-matching-mode ($mode) - "Return a list of buffers where their `major-mode' is equal to $MODE." - (let ($buffer-mode-matches) - (mapc (lambda ($buf) - (when (get-buffer $buf) - (with-current-buffer (get-buffer $buf) - (if (eq $mode major-mode) - (add-to-list '$buffer-mode-matches (buffer-name $buf)))))) + :query helm-multi-swoop-query + :buflist (helm-multi-swoop--get-buffer-list))) + +(defun get-buffers-matching-mode (mode) + "Return a list of buffers where their `major-mode' is equal to MODE." + (let (buffer-mode-matches) + (mapc (lambda (buf) + (when (get-buffer buf) + (with-current-buffer (get-buffer buf) + (if (eq mode major-mode) + (add-to-list 'buffer-mode-matches (buffer-name buf)))))) (buffer-list)) - $buffer-mode-matches)) + buffer-mode-matches)) -(defun helm-multi-swoop-by-mode ($mode &optional $query) - "Apply all buffers whose mode is $MODE to helm-multi-swoop for $QUERY." - (setq helm-multi-swoop-query (helm-multi-swoop--get-query $query)) - (if (get-buffers-matching-mode $mode) +(defun helm-multi-swoop-by-mode (mode &optional query) + "Apply all buffers whose mode is MODE to helm-multi-swoop for QUERY." + (setq helm-multi-swoop-query (helm-multi-swoop--get-query query)) + (if (get-buffers-matching-mode mode) (helm-multi-swoop--exec nil - :$query helm-multi-swoop-query - :$buflist (get-buffers-matching-mode $mode)) + :query helm-multi-swoop-query + :buflist (get-buffers-matching-mode mode)) (message "there are no buffers in that mode right now"))) ;;;###autoload -(defun helm-multi-swoop-org (&optional $query) - "Applie all `org-mode' buffers to helm-multi-swoop for $QUERY." +(defun helm-multi-swoop-org (&optional query) + "Applie all `org-mode' buffers to helm-multi-swoop for QUERY." (interactive) - (helm-multi-swoop-by-mode 'org-mode $query)) + (helm-multi-swoop-by-mode 'org-mode query)) ;;;###autoload -(defun helm-multi-swoop-current-mode (&optional $query) - "Applie all buffers of the same mode as the current buffer to helm-multi-swoop for $QUERY." +(defun helm-multi-swoop-current-mode (&optional query) + "Applie all buffers of the same mode as the current buffer to helm-multi-swoop for QUERY." (interactive) - (helm-multi-swoop-by-mode major-mode $query)) + (helm-multi-swoop-by-mode major-mode query)) ;;;###autoload -(defun helm-multi-swoop-projectile (&optional $query) - "Apply all opened buffers of the current project to helm-multi-swoop for $QUERY." +(defun helm-multi-swoop-projectile (&optional query) + "Apply all opened buffers of the current project to helm-multi-swoop for QUERY." (interactive) - (setq helm-multi-swoop-query (helm-multi-swoop--get-query $query)) + (setq helm-multi-swoop-query (helm-multi-swoop--get-query query)) (if (require 'projectile nil 'noerror) ;; set filter function that is used in projectile-project-buffers (let ((projectile-buffers-filter-function helm-multi-swoop-projectile-buffers-filter)) (helm-multi-swoop--exec nil - :$query helm-multi-swoop-query - :$buflist (mapcar #'buffer-name - (projectile-project-buffers)))) + :query helm-multi-swoop-query + :buflist (mapcar #'buffer-name + (projectile-project-buffers)))) (error "Package 'projectile' is not available"))) -(defun helm-swoop--wrap-function-with-pre-input-function ($target-func $pre-input-func) - "Wrap function with pre input function for $TARGET-FUNC and $PRE-INPUT-FUNC." - (let ((helm-swoop-pre-input-function $pre-input-func)) - (funcall $target-func))) +(defun helm-swoop--wrap-function-with-pre-input-function (target-fn pre-input-fn) + "Wrap function with pre input function for TARGET-FN and PRE-INPUT-FN." + (let ((helm-swoop-pre-input-function pre-input-fn)) + (funcall target-fn))) ;;;###autoload (defun helm-swoop-without-pre-input () @@ -1389,12 +1350,12 @@ Last selected buffers will be applied to helm-multi-swoop." (defun helm-multi-swoop-all-from-isearch () "Invoke `helm-multi-swoop-all' from isearch." (interactive) - (let (($query (if isearch-regexp - isearch-string - (regexp-quote isearch-string)))) + (let ((query (if isearch-regexp + isearch-string + (regexp-quote isearch-string)))) (let (search-nonincremental-instead) (isearch-exit)) - (helm-multi-swoop-all $query))) + (helm-multi-swoop-all query))) ;; When doing isearch, hand the word over to helm-swoop ;; (define-key isearch-mode-map (kbd "C-x M-i") 'helm-multi-swoop-all-from-isearch) @@ -1404,8 +1365,8 @@ Last selected buffers will be applied to helm-multi-swoop." (helm-swoop--restore) (delete-overlay helm-swoop-line-overlay) (setq helm-multi-swoop-all-from-helm-swoop-last-point helm-swoop-last-point) - (let (($query helm-pattern)) - (run-with-timer 0 nil (lambda () (helm-multi-swoop-all $query)))) + (let ((query helm-pattern)) + (run-with-timer 0 nil (lambda () (helm-multi-swoop-all query)))) (helm-exit-minibuffer)) (defun helm-multi-swoop-current-mode-from-helm-swoop () @@ -1414,21 +1375,21 @@ Last selected buffers will be applied to helm-multi-swoop." (helm-swoop--restore) (delete-overlay helm-swoop-line-overlay) (setq helm-multi-swoop-all-from-helm-swoop-last-point helm-swoop-last-point) - (let (($query helm-pattern)) - (run-with-timer 0 nil (lambda () (helm-multi-swoop-current-mode $query)))) + (let ((query helm-pattern)) + (run-with-timer 0 nil (lambda () (helm-multi-swoop-current-mode query)))) (helm-exit-minibuffer)) ;; (define-key helm-swoop-map (kbd "M-m") 'helm-multi-swoop-current-mode-from-helm-swoop) (defadvice helm-resume (around helm-multi-swoop-resume activate) "Resume if the last used helm buffer is *Helm Swoop*." (if (equal helm-last-buffer helm-multi-swoop-buffer) - (if (boundp 'helm-multi-swoop-last-query) (if (not (ad-get-arg 0)) (helm-multi-swoop helm-multi-swoop-last-query helm-multi-swoop-last-selected-buffers)) ;; Temporary apply second last buffer - (let ((helm-last-buffer (cadr helm-buffers))) ad-do-it)) + (let ((helm-last-buffer (cadr helm-buffers))) + ad-do-it)) ad-do-it)) ;;; @ helm-multi-swoop-edit ----------------------------------- @@ -1437,58 +1398,59 @@ Last selected buffers will be applied to helm-multi-swoop." (defvar helm-multi-swoop-edit-buffer "*Helm Multi Swoop Edit*") (defvar helm-multi-swoop-edit-map - (let (($map (make-sparse-keymap))) - (define-key $map (kbd "C-x C-s") 'helm-multi-swoop--edit-complete) - (define-key $map (kbd "C-c C-g") 'helm-multi-swoop--edit-cancel) - (define-key $map (kbd "C-c C-q C-k") 'helm-multi-swoop--edit-delete-all-lines) - $map)) - -(defun helm-multi-swoop--edit ($candidate) - "This function will only be called from `helm-swoop-edit' for $CANDIDATE." + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-x C-s") 'helm-multi-swoop--edit-complete) + (define-key map (kbd "C-c C-g") 'helm-multi-swoop--edit-cancel) + (define-key map (kbd "C-c C-q C-k") 'helm-multi-swoop--edit-delete-all-lines) + map)) + +(defun helm-multi-swoop--edit (candidate) + "This function will only be called from `helm-swoop-edit' for CANDIDATE." (interactive) (delete-overlay helm-swoop-line-overlay) (helm-swoop--delete-overlay 'target-buffer) (with-current-buffer (get-buffer-create helm-multi-swoop-edit-buffer) (helm-swoop--clear-edit-buffer 'helm-multi-swoop-edit) - (let (($bufstr "") - ($mark nil) - ($buf (get-buffer helm-multi-swoop-buffer))) + (let ((bufstr "") + (buf (get-buffer helm-multi-swoop-buffer)) + mark) ;; Get target line number to edit - (when $buf - (with-current-buffer $buf + (when buf + (with-current-buffer buf ;; Set overlay to helm-source-header for editing marked lines (save-excursion (goto-char (point-min)) - (let (($beg (point)) $end) + (let ((beg (point)) + end) (overlay-recenter (point-max)) - (while (setq $beg (text-property-any $beg (point-max) - 'face 'helm-source-header)) - (setq $end (next-single-property-change $beg 'face)) - (overlay-put (make-overlay $beg $end) 'source-header t) - (setq $beg $end) - (goto-char $end)))) + (while (setq beg (text-property-any beg (point-max) + 'face 'helm-source-header)) + (setq end (next-single-property-change beg 'face)) + (overlay-put (make-overlay beg end) 'source-header t) + (setq beg end) + (goto-char end)))) ;; Use selected line by [C-SPC] or [M-SPC] - (mapc (lambda ($ov) - (when (overlay-get $ov 'source-header) - (setq $bufstr (concat (buffer-substring - (overlay-start $ov) (overlay-end $ov)) - $bufstr))) - (when (eq 'helm-visible-mark (overlay-get $ov 'face)) - (let (($str (buffer-substring (overlay-start $ov) (overlay-end $ov)))) - (unless (equal "" $str) (setq $mark t)) - (setq $bufstr (concat (buffer-substring - (overlay-start $ov) (overlay-end $ov)) - $bufstr))))) + (mapc (lambda (ov) + (when (overlay-get ov 'source-header) + (setq bufstr (concat (buffer-substring + (overlay-start ov) (overlay-end ov)) + bufstr))) + (when (eq 'helm-visible-mark (overlay-get ov 'face)) + (let ((str (buffer-substring (overlay-start ov) (overlay-end ov)))) + (unless (equal "" str) (setq mark t)) + (setq bufstr (concat (buffer-substring + (overlay-start ov) (overlay-end ov)) + bufstr))))) (overlays-in (point-min) (point-max))) - (if $mark - (progn (setq $bufstr (concat "Helm Multi Swoop\n" $bufstr)) - (setq $mark nil)) - (setq $bufstr (concat "Helm Multi Swoop\n" - (buffer-substring - (point-min) (point-max))))))) + (if mark + (progn (setq bufstr (concat "Helm Multi Swoop\n" bufstr)) + (setq mark nil)) + (setq bufstr (concat "Helm Multi Swoop\n" + (buffer-substring + (point-min) (point-max))))))) ;; Set for edit buffer - (insert $bufstr) + (insert bufstr) (add-text-properties (point-min) (point-max) '(read-only t rear-nonsticky t front-sticky t)) @@ -1496,10 +1458,10 @@ Last selected buffers will be applied to helm-multi-swoop." (let ((inhibit-read-only t)) ;; Title and explanation (goto-char (point-min)) - (let (($o (make-overlay (point) (point-at-eol)))) - (overlay-put $o 'helm-multi-swoop-edit t) - (overlay-put $o 'face 'font-lock-function-name-face) - (overlay-put $o 'after-string + (let ((ov (make-overlay (point) (point-at-eol)))) + (overlay-put ov 'helm-multi-swoop-edit t) + (overlay-put ov 'face 'font-lock-function-name-face) + (overlay-put ov 'after-string (propertize (substitute-command-keys (concat @@ -1509,67 +1471,66 @@ Last selected buffers will be applied to helm-multi-swoop." 'face 'helm-bookmark-addressbook))) ;; Line number and editable area (while (re-search-forward "^\\([0-9]+\s\\)\\(.*\\)$" nil t) - (let* (($bol1 (match-beginning 1)) - ($eol1 (match-end 1)) - ($bol2 (match-beginning 2)) - ($eol2 (match-end 2))) + (let* ((bol1 (match-beginning 1)) + (eol1 (match-end 1)) + (bol2 (match-beginning 2)) + (eol2 (match-end 2))) ;; Line number - (add-text-properties $bol1 $eol1 + (add-text-properties bol1 eol1 '(face font-lock-function-name-face intangible t)) ;; Editable area - (remove-text-properties $bol2 $eol2 '(read-only t)) - ;; (add-text-properties $bol2 $eol2 '(font-lock-face helm-match)) + (remove-text-properties bol2 eol2 '(read-only t)) + ;; (add-text-properties bol2 eol2 '(font-lock-face helm-match)) ;; For line tail - (set-text-properties $eol2 (or (1+ $eol2) (point-max)) + (set-text-properties eol2 (or (1+ eol2) (point-max)) '(read-only t rear-nonsticky t)))) (helm-swoop--target-word-overlay 'edit-buffer 0)))) (other-window 1) (switch-to-buffer helm-multi-swoop-edit-buffer) (goto-char (point-min)) - (if (string-match "^[0-9]+" $candidate) + (if (string-match "^[0-9]+" candidate) (re-search-forward - (concat "^" (match-string 0 $candidate)) nil t)) + (concat "^" (match-string 0 candidate)) nil t)) (use-local-map helm-multi-swoop-edit-map)) -(defun helm-multi-swoop--separate-text-property-into-list ($property) - "Separete text property into list for $PROPERTY." +(defun helm-multi-swoop--separate-text-property-into-list (prop) + "Separete text property into list for PROP." (interactive) - (let ($list $end) + (let (list end) (save-excursion (goto-char (point-min)) - (while (setq $end (next-single-property-change (point) $property)) + (while (setq end (next-single-property-change (point) prop)) ;; Must eliminate last return because of unexpected edit result - (setq $list (cons - (let (($str (buffer-substring-no-properties (point) $end))) - (if (string-match "\n\n\\'" $str) - (replace-regexp-in-string "\n\\'" "" $str) - $str)) - $list)) - (goto-char $end)) - (setq $list (cons (buffer-substring-no-properties (point) (point-max)) - $list))) - (nreverse $list))) + (setq list (cons + (let ((str (buffer-substring-no-properties (point) end))) + (if (string-match "\n\n\\'" str) + (replace-regexp-in-string "\n\\'" "" str) + str)) + list)) + (goto-char end)) + (setq list (cons (buffer-substring-no-properties (point) (point-max)) + list))) + (nreverse list))) (defun helm-multi-swoop--collect-edited-lines () "Create a list of edited lines with each its own line number." (interactive) - (let* (($list - (helm-multi-swoop--separate-text-property-into-list 'helm-header)) - ($length (length $list)) - ($i 1) ;; 0th $list is header - $pairs) - (while (<= $i $length) - (let ($contents) + (let* ((list (helm-multi-swoop--separate-text-property-into-list 'helm-header)) + (length (length list)) + (i 1) ;; 0th list is header + pairs) + (while (<= i length) + (let (contents) ;; Make ((number . line) (number . line) (number . line) ...) (with-temp-buffer - (insert (format "%s" (nth (1+ $i) $list))) + (insert (format "%s" (nth (1+ i) list))) (goto-char (point-min)) (while (re-search-forward "^\\([0-9]+\\)\s" nil t) - (setq $contents + (setq contents (cons (cons (string-to-number (match-string 1)) (buffer-substring-no-properties (point) @@ -1579,66 +1540,66 @@ Last selected buffers will be applied to helm-multi-swoop." (1- (match-beginning 0)) (goto-char (point-max)) (re-search-backward "\n" nil t))))) - $contents)))) + contents)))) ;; Make ((buffer-name (number . line) (number . line) ...) ;; (buffer-name (number . line) (number . line) ...) ...) - (setq $pairs (cons (cons (nth $i $list) $contents) $pairs))) - (setq $i (+ $i 2))) - (delete '(nil) $pairs))) + (setq pairs (cons (cons (nth i list) contents) pairs))) + (setq i (+ i 2))) + (delete '(nil) pairs))) (defun helm-multi-swoop--edit-complete () "Delete all extracted lines, and apply change to buffers and kill temporary edit buffer." (interactive) - (let (($list (helm-multi-swoop--collect-edited-lines)) - $read-only) - (mapc (lambda ($x) - (with-current-buffer (car $x) + (let ((lines (helm-multi-swoop--collect-edited-lines)) + read-only) + (mapc (lambda (elm) + (with-current-buffer (car elm) (unless buffer-read-only (save-excursion - (mapc (lambda ($cell) - (let (($k (car $cell)) - ($v (cdr $cell))) + (mapc (lambda (cell) + (let ((k (car cell)) + (v (cdr cell))) (goto-char (point-min)) - (delete-region (point-at-bol $k) (point-at-eol $k)) - (goto-char (point-at-bol $k)) - (insert $v))) - (cdr $x)))) + (delete-region (point-at-bol k) (point-at-eol k)) + (goto-char (point-at-bol k)) + (insert v))) + (cdr elm)))) (if helm-multi-swoop-edit-save (if buffer-read-only - (setq $read-only t) + (setq read-only t) (save-buffer))))) - $list) + lines) (select-window helm-swoop-synchronizing-window) (kill-buffer (get-buffer helm-multi-swoop-edit-buffer)) - (if $read-only + (if read-only (message "Couldn't save some buffers because of read-only") (message "Successfully helm-multi-swoop-edit applied to original buffer")))) (defun helm-multi-swoop--edit-delete-all-lines () "Delete all extracted lines, and apply change to buffers and kill temporary edit buffer." (interactive) - (let (($list (helm-multi-swoop--collect-edited-lines)) - $read-only) - (mapc (lambda ($x) - (with-current-buffer (car $x) + (let ((lines (helm-multi-swoop--collect-edited-lines)) + read-only) + (mapc (lambda (elm) + (with-current-buffer (car elm) (unless buffer-read-only (save-excursion - (mapc (lambda ($cell) - (let (($k (car $cell))) + (mapc (lambda (cell) + (let ((k (car cell))) (goto-char (point-min)) - (delete-region (point-at-bol $k) - (if (eq (point-at-eol $k) (point-max)) - (point-at-eol $k) - (1+ (point-at-eol $k)))))) - (cdr $x)))) + (delete-region (point-at-bol k) + (if (eq (point-at-eol k) (point-max)) + (point-at-eol k) + (1+ (point-at-eol k)))))) + (cdr elm)))) (if helm-multi-swoop-edit-save (if buffer-read-only - (setq $read-only t) + (setq read-only t) (save-buffer))))) - $list) + lines) (select-window helm-swoop-synchronizing-window) (kill-buffer (get-buffer helm-multi-swoop-edit-buffer)) - (if $read-only + (if read-only (message "Couldn't save some buffers because of read-only") (message "Successfully helm-multi-swoop-edit applied to original buffer")))) @@ -1657,73 +1618,73 @@ Last selected buffers will be applied to helm-multi-swoop." ;;; @ helm-swoop-same-face-at-point ----------------------------------- -(defsubst helm-swoop--get-at-face (&optional $point) - "Get at face at $POINT." - (or $point (setq $point (point))) - (let (($face (or (get-char-property $point 'read-face-name) - (get-char-property $point 'face)))) - $face)) +(defsubst helm-swoop--get-at-face (&optional point) + "Get at face at POINT." + (or point (setq point (point))) + (let ((face (or (get-char-property point 'read-face-name) + (get-char-property point 'face)))) + face)) -(defun helm-swoop--cull-face-include-line ($face) - "Cull face include line for $FACE." - (let (($list) ($po (point-min))) +(defun helm-swoop--cull-face-include-line (face) + "Cull face include line for FACE." + (let ((po (point-min)) res) (save-excursion - (while (setq $po (next-single-property-change $po 'face)) - (when (equal $face (helm-swoop--get-at-face $po)) - (goto-char $po) - (setq $list (cons (format "%s %s" - (line-number-at-pos $po) - (buffer-substring (point-at-bol) (point-at-eol))) - $list)) - (let (($ov (make-overlay $po (or (next-single-property-change $po 'face) - (point-max))))) - (overlay-put $ov 'face 'helm-swoop-target-word-face) - (overlay-put $ov 'target-buffer 'helm-swoop-target-word-face))))) - (nreverse (delete-dups $list)))) - -(defun helm-swoop-same-face-at-point (&optional $face) - "Same face at point for $FACE." + (while (setq po (next-single-property-change po 'face)) + (when (equal face (helm-swoop--get-at-face po)) + (goto-char po) + (setq res (cons (format "%s %s" + (line-number-at-pos po) + (buffer-substring (point-at-bol) (point-at-eol))) + res)) + (let ((ov (make-overlay po (or (next-single-property-change po 'face) + (point-max))))) + (overlay-put ov 'face 'helm-swoop-target-word-face) + (overlay-put ov 'target-buffer 'helm-swoop-target-word-face))))) + (nreverse (delete-dups res)))) + +(defun helm-swoop-same-face-at-point (&optional face) + "Same face at point for FACE." (interactive) - (or $face (setq $face (helm-swoop--get-at-face))) - (helm-swoop :$query "" - :$source + (or face (setq face (helm-swoop--get-at-face))) + (helm-swoop :query "" + :source `((name . "helm-swoop-same-face-at-point") - (candidates . ,(helm-swoop--cull-face-include-line $face)) - (header-line . ,(format "%s" $face)) + (candidates . ,(helm-swoop--cull-face-include-line face)) + (header-line . ,(format "%s" face)) (action . (("Go to Line" - . (lambda ($line) + . (lambda (line) (helm-swoop--goto-line - (when (string-match "^[0-9]+" $line) - (string-to-number (match-string 0 $line)))) - (let (($po (point)) - ($poe (point-at-eol))) - (while (<= (setq $po (next-single-property-change $po 'face)) $poe) - (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face $po)) - (goto-char $po)))) + (when (string-match "^[0-9]+" line) + (string-to-number (match-string 0 line)))) + (let ((po (point)) + (poe (point-at-eol))) + (while (<= (setq po (next-single-property-change po 'face)) poe) + (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face po)) + (goto-char po)))) (helm-swoop--recenter))) ("Edit" . helm-swoop--edit)))))) -(defun helm-multi-swoop-same-face-at-point (&optional $face) - "Same face at point for $FACE." +(defun helm-multi-swoop-same-face-at-point (&optional face) + "Same face at point for FACE." (interactive) - (or $face (setq $face (helm-swoop--get-at-face))) + (or face (setq face (helm-swoop--get-at-face))) (helm-multi-swoop--exec nil - :$query "" - :$func (lambda () (helm-swoop--cull-face-include-line $face)) - :$action (lambda ($line) - (switch-to-buffer (assoc-default 'name (helm-get-current-source))) - (helm-swoop--goto-line - (when (string-match "^[0-9]+" $line) - (string-to-number (match-string 0 $line)))) - (let (($po (point)) - ($poe (point-at-eol))) - (while (<= (setq $po (next-single-property-change $po 'face)) $poe) - (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face $po)) - (goto-char $po)))) - (helm-swoop--recenter)) - :$buflist (helm-multi-swoop--get-buffer-list))) + :query "" + :func (lambda () (helm-swoop--cull-face-include-line face)) + :action (lambda (line) + (switch-to-buffer (assoc-default 'name (helm-get-current-source))) + (helm-swoop--goto-line + (when (string-match "^[0-9]+" line) + (string-to-number (match-string 0 line)))) + (let ((po (point)) + (poe (point-at-eol))) + (while (<= (setq po (next-single-property-change po 'face)) poe) + (when (eq 'helm-swoop-target-word-face (helm-swoop--get-at-face po)) + (goto-char po)))) + (helm-swoop--recenter)) + :buflist (helm-multi-swoop--get-buffer-list))) (provide 'helm-swoop) -- 2.47.3