make actions and transformer functions "public"
avoid `--' in the function name
This commit is contained in:
parent
c83216eba4
commit
fe524f7fcd
1 changed files with 50 additions and 50 deletions
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
;;; counsel-projectile-find-file
|
;;; counsel-projectile-find-file
|
||||||
|
|
||||||
(defun counsel-projectile--find-file-action (file &optional other-window)
|
(defun counsel-projectile-action-find-file (file &optional other-window)
|
||||||
"Find FILE and run `projectile-find-file-hook'."
|
"Find FILE and run `projectile-find-file-hook'."
|
||||||
(funcall (if other-window
|
(funcall (if other-window
|
||||||
'find-file-other-window
|
'find-file-other-window
|
||||||
|
|
@ -73,12 +73,12 @@
|
||||||
(projectile-expand-root file))
|
(projectile-expand-root file))
|
||||||
(run-hooks 'projectile-find-file-hook))
|
(run-hooks 'projectile-find-file-hook))
|
||||||
|
|
||||||
(defun counsel-projectile--find-file-other-window-action (file)
|
(defun counsel-projectile-action-find-file-other-window (file)
|
||||||
"Find FILE in another window and run
|
"Find FILE in another window and run
|
||||||
`projectile-find-file-hook'."
|
`projectile-find-file-hook'."
|
||||||
(counsel-projectile--find-file-action file t))
|
(counsel-projectile-action-find-file file t))
|
||||||
|
|
||||||
(defun counsel-projectile--find-file-transformer (name)
|
(defun counsel-projectile-find-file-transformer (name)
|
||||||
"Transform non-visited file names with `ivy-virtual' face."
|
"Transform non-visited file names with `ivy-virtual' face."
|
||||||
(if (not (get-file-buffer (expand-file-name name (projectile-project-root))))
|
(if (not (get-file-buffer (expand-file-name name (projectile-project-root))))
|
||||||
(propertize name 'face 'ivy-virtual)
|
(propertize name 'face 'ivy-virtual)
|
||||||
|
|
@ -97,17 +97,17 @@ invalidates the cache first."
|
||||||
:matcher #'counsel--find-file-matcher
|
:matcher #'counsel--find-file-matcher
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:action #'counsel-projectile--find-file-action
|
:action #'counsel-projectile-action-find-file
|
||||||
:caller 'counsel-projectile-find-file))
|
:caller 'counsel-projectile-find-file))
|
||||||
|
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile-find-file
|
'counsel-projectile-find-file
|
||||||
'(("j" counsel-projectile--find-file-other-window-action
|
'(("j" counsel-projectile-action-find-file-other-window
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
(ivy-set-display-transformer
|
(ivy-set-display-transformer
|
||||||
'counsel-projectile-find-file
|
'counsel-projectile-find-file
|
||||||
'counsel-projectile--find-file-transformer)
|
'counsel-projectile-find-file-transformer)
|
||||||
|
|
||||||
;;; counsel-projectile-find-dir
|
;;; counsel-projectile-find-dir
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ invalidates the cache first."
|
||||||
(append '("./") (projectile-current-project-dirs))
|
(append '("./") (projectile-current-project-dirs))
|
||||||
(projectile-current-project-dirs)))
|
(projectile-current-project-dirs)))
|
||||||
|
|
||||||
(defun counsel-projectile--find-dir-action (dir &optional other-window)
|
(defun counsel-projectile-action-find-dir (dir &optional other-window)
|
||||||
"Visit DIR with dired and run `projectile-find-dir-hook'."
|
"Visit DIR with dired and run `projectile-find-dir-hook'."
|
||||||
(funcall (if other-window
|
(funcall (if other-window
|
||||||
'dired-other-window
|
'dired-other-window
|
||||||
|
|
@ -125,10 +125,10 @@ invalidates the cache first."
|
||||||
(projectile-expand-root dir))
|
(projectile-expand-root dir))
|
||||||
(run-hooks 'projectile-find-dir-hook))
|
(run-hooks 'projectile-find-dir-hook))
|
||||||
|
|
||||||
(defun counsel-projectile--find-dir-other-window-action (dir)
|
(defun counsel-projectile-action-find-dir-other-window (dir)
|
||||||
"Visit DIR with dired in another window and run
|
"Visit DIR with dired in another window and run
|
||||||
`projectile-find-dir-hook'."
|
`projectile-find-dir-hook'."
|
||||||
(counsel-projectile--find-dir-action dir t))
|
(counsel-projectile-action-find-dir dir t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun counsel-projectile-find-dir (&optional arg)
|
(defun counsel-projectile-find-dir (&optional arg)
|
||||||
|
|
@ -141,12 +141,12 @@ With a prefix ARG invalidates the cache first."
|
||||||
(counsel-projectile--dir-list)
|
(counsel-projectile--dir-list)
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:action #'counsel-projectile--find-dir-action
|
:action #'counsel-projectile-action-find-dir
|
||||||
:caller 'counsel-projectile-find-dir))
|
:caller 'counsel-projectile-find-dir))
|
||||||
|
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile-find-dir
|
'counsel-projectile-find-dir
|
||||||
'(("j" counsel-projectile--find-dir-other-window-action
|
'(("j" counsel-projectile-action-find-dir-other-window
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
;;; counsel-projectile-switch-to-buffer
|
;;; counsel-projectile-switch-to-buffer
|
||||||
|
|
@ -161,7 +161,7 @@ names as in `ivy--buffer-list'."
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(member (car x) buffer-names)))))
|
(member (car x) buffer-names)))))
|
||||||
|
|
||||||
(defun counsel-projectile--switch-buffer-action (buffer &optional other-window)
|
(defun counsel-projectile-action-switch-buffer (buffer &optional other-window)
|
||||||
"Switch to BUFFER.
|
"Switch to BUFFER.
|
||||||
|
|
||||||
BUFFER may be a string or nil."
|
BUFFER may be a string or nil."
|
||||||
|
|
@ -173,11 +173,11 @@ BUFFER may be a string or nil."
|
||||||
(t
|
(t
|
||||||
(switch-to-buffer buffer nil 'force-same-window))))
|
(switch-to-buffer buffer nil 'force-same-window))))
|
||||||
|
|
||||||
(defun counsel-projectile--switch-buffer-other-window-action (buffer)
|
(defun counsel-projectile-action-switch-buffer-other-window (buffer)
|
||||||
"Switch to BUFFER in other window.
|
"Switch to BUFFER in other window.
|
||||||
|
|
||||||
BUFFER may be a string or nil."
|
BUFFER may be a string or nil."
|
||||||
(counsel-projectile--switch-buffer-action buffer t))
|
(counsel-projectile-action-switch-buffer buffer t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun counsel-projectile-switch-to-buffer ()
|
(defun counsel-projectile-switch-to-buffer ()
|
||||||
|
|
@ -188,7 +188,7 @@ BUFFER may be a string or nil."
|
||||||
:matcher #'ivy--switch-buffer-matcher
|
:matcher #'ivy--switch-buffer-matcher
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:action #'counsel-projectile--switch-buffer-action
|
:action #'counsel-projectile-action-switch-buffer
|
||||||
:caller 'counsel-projectile-switch-to-buffer))
|
:caller 'counsel-projectile-switch-to-buffer))
|
||||||
|
|
||||||
(ivy-set-display-transformer
|
(ivy-set-display-transformer
|
||||||
|
|
@ -197,7 +197,7 @@ BUFFER may be a string or nil."
|
||||||
|
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile-switch-to-buffer
|
'counsel-projectile-switch-to-buffer
|
||||||
'(("j" counsel-projectile--switch-buffer-other-window-action
|
'(("j" counsel-projectile-action-switch-buffer-other-window
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
;;; counsel-projectile-ag
|
;;; counsel-projectile-ag
|
||||||
|
|
@ -304,7 +304,7 @@ action."
|
||||||
(with-current-buffer " *counsel-projectile*"
|
(with-current-buffer " *counsel-projectile*"
|
||||||
(run-hooks 'projectile-after-switch-project-hook)))
|
(run-hooks 'projectile-after-switch-project-hook)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--find-file-action (project)
|
(defun counsel-projectile-switch-project-action-find-file (project)
|
||||||
"Action for `counsel-projectile-switch-project' to find a
|
"Action for `counsel-projectile-switch-project' to find a
|
||||||
PROJECT file."
|
PROJECT file."
|
||||||
(let ((projectile-switch-project-action
|
(let ((projectile-switch-project-action
|
||||||
|
|
@ -312,7 +312,7 @@ PROJECT file."
|
||||||
(counsel-projectile-find-file ivy-current-prefix-arg))))
|
(counsel-projectile-find-file ivy-current-prefix-arg))))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--find-file-manually-action (project)
|
(defun counsel-projectile-switch-project-action-find-file-manually (project)
|
||||||
"Action for `counsel-projectile-switch-project' to find a
|
"Action for `counsel-projectile-switch-project' to find a
|
||||||
PROJECT file manually."
|
PROJECT file manually."
|
||||||
(let ((projectile-switch-project-action
|
(let ((projectile-switch-project-action
|
||||||
|
|
@ -320,7 +320,7 @@ PROJECT file manually."
|
||||||
(counsel-find-file project))))
|
(counsel-find-file project))))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--find-dir-action (project)
|
(defun counsel-projectile-switch-project-action-find-dir (project)
|
||||||
"Action for `counsel-projectile-switch-project' to find a
|
"Action for `counsel-projectile-switch-project' to find a
|
||||||
PROJECT directory."
|
PROJECT directory."
|
||||||
(let ((projectile-switch-project-action
|
(let ((projectile-switch-project-action
|
||||||
|
|
@ -328,25 +328,25 @@ PROJECT directory."
|
||||||
(counsel-projectile-find-dir ivy-current-prefix-arg))))
|
(counsel-projectile-find-dir ivy-current-prefix-arg))))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--switch-to-buffer-action (project)
|
(defun counsel-projectile-switch-project-action-switch-to-buffer (project)
|
||||||
"Action for `counsel-projectile-switch-project' to switch to a
|
"Action for `counsel-projectile-switch-project' to switch to a
|
||||||
PROJECT buffer."
|
PROJECT buffer."
|
||||||
(let ((projectile-switch-project-action 'counsel-projectile-switch-to-buffer))
|
(let ((projectile-switch-project-action 'counsel-projectile-switch-to-buffer))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--save-all-buffers-axtion (project)
|
(defun counsel-projectile-switch-project-action-save-all-buffers (project)
|
||||||
"Action for `counsel-projectile-switch-project' to save all
|
"Action for `counsel-projectile-switch-project' to save all
|
||||||
PROJECT buffers."
|
PROJECT buffers."
|
||||||
(let ((projectile-switch-project-action 'projectile-save-project-buffers))
|
(let ((projectile-switch-project-action 'projectile-save-project-buffers))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--kill-buffers-action (project)
|
(defun counsel-projectile-switch-project-action-kill-buffers (project)
|
||||||
"Action for `counsel-projectile-switch-project' to kill all
|
"Action for `counsel-projectile-switch-project' to kill all
|
||||||
PROJECT buffers."
|
PROJECT buffers."
|
||||||
(let ((projectile-switch-project-action 'projectile-kill-buffers))
|
(let ((projectile-switch-project-action 'projectile-kill-buffers))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--remove-known-project-action (project)
|
(defun counsel-projectile-switch-project-action-remove-known-project (project)
|
||||||
"Action for `counsel-projectile-switch-project' to remove
|
"Action for `counsel-projectile-switch-project' to remove
|
||||||
PROJECT from the list of known projects."
|
PROJECT from the list of known projects."
|
||||||
(projectile-remove-known-project project)
|
(projectile-remove-known-project project)
|
||||||
|
|
@ -354,31 +354,31 @@ PROJECT from the list of known projects."
|
||||||
(delete dir ivy--all-candidates))
|
(delete dir ivy--all-candidates))
|
||||||
(ivy--reset-state ivy-last))
|
(ivy--reset-state ivy-last))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--edit-dir-locals-action (project)
|
(defun counsel-projectile-switch-project-action-edit-dir-locals (project)
|
||||||
"Action for `counsel-projectile-switch-project' to edit
|
"Action for `counsel-projectile-switch-project' to edit
|
||||||
PROJECT's dir-locals."
|
PROJECT's dir-locals."
|
||||||
(let ((projectile-switch-project-action 'projectile-edit-dir-locals))
|
(let ((projectile-switch-project-action 'projectile-edit-dir-locals))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--vc-action (project)
|
(defun counsel-projectile-switch-project-action-vc (project)
|
||||||
"Action for `counsel-projectile-switch-project' to open PROJECT
|
"Action for `counsel-projectile-switch-project' to open PROJECT
|
||||||
in vc-dir / magit / monky."
|
in vc-dir / magit / monky."
|
||||||
(let ((projectile-switch-project-action 'projectile-vc))
|
(let ((projectile-switch-project-action 'projectile-vc))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--run-eshell-action (project)
|
(defun counsel-projectile-switch-project-action-run-eshell (project)
|
||||||
"Action for `counsel-projectile-switch-project' to start
|
"Action for `counsel-projectile-switch-project' to start
|
||||||
`eshell' from PROJECT's root."
|
`eshell' from PROJECT's root."
|
||||||
(let ((projectile-switch-project-action 'projectile-run-eshell))
|
(let ((projectile-switch-project-action 'projectile-run-eshell))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--ag-action (project)
|
(defun counsel-projectile-switch-project-action-ag (project)
|
||||||
"Action for `counsel-projectile-switch-project' to search
|
"Action for `counsel-projectile-switch-project' to search
|
||||||
PROJECT with `ag'."
|
PROJECT with `ag'."
|
||||||
(let ((projectile-switch-project-action 'counsel-projectile-ag))
|
(let ((projectile-switch-project-action 'counsel-projectile-ag))
|
||||||
(counsel-projectile-switch-project-by-name project)))
|
(counsel-projectile-switch-project-by-name project)))
|
||||||
|
|
||||||
(defun counsel-projectile-switch-project--rg-action (project)
|
(defun counsel-projectile-switch-project-action-rg (project)
|
||||||
"Action for `counsel-projectile-switch-project' to search
|
"Action for `counsel-projectile-switch-project' to search
|
||||||
PROJECT with `rg'."
|
PROJECT with `rg'."
|
||||||
(let ((projectile-switch-project-action 'counsel-projectile-rg))
|
(let ((projectile-switch-project-action 'counsel-projectile-rg))
|
||||||
|
|
@ -400,29 +400,29 @@ Invokes the command referenced by
|
||||||
:caller 'counsel-projectile-switch-project))
|
:caller 'counsel-projectile-switch-project))
|
||||||
|
|
||||||
(defvar counsel-projectile-switch-project-actions
|
(defvar counsel-projectile-switch-project-actions
|
||||||
'(("f" counsel-projectile-switch-project--find-file-action
|
'(("f" counsel-projectile-switch-project-action-find-file
|
||||||
"find file")
|
"find file")
|
||||||
("F" counsel-projectile-switch-project--find-file-manually-action
|
("F" counsel-projectile-switch-project-action-find-file-manually
|
||||||
"find file manually")
|
"find file manually")
|
||||||
("d" counsel-projectile-switch-project--find-dir-action
|
("d" counsel-projectile-switch-project-action-find-dir
|
||||||
"find directory")
|
"find directory")
|
||||||
("b" counsel-projectile-switch-project--switch-to-buffer-action
|
("b" counsel-projectile-switch-project-action-switch-to-buffer
|
||||||
"switch to buffer")
|
"switch to buffer")
|
||||||
("s" counsel-projectile-switch-project--save-all-buffers-axtion
|
("s" counsel-projectile-switch-project-action-save-all-buffers
|
||||||
"save all buffers")
|
"save all buffers")
|
||||||
("k" counsel-projectile-switch-project--kill-buffers-action
|
("k" counsel-projectile-switch-project-action-kill-buffers
|
||||||
"kill all buffers")
|
"kill all buffers")
|
||||||
("r" counsel-projectile-switch-project--remove-known-project-action
|
("r" counsel-projectile-switch-project-action-remove-known-project
|
||||||
"remove from known projects")
|
"remove from known projects")
|
||||||
("l" counsel-projectile-switch-project--edit-dir-locals-action
|
("l" counsel-projectile-switch-project-action-edit-dir-locals
|
||||||
"edit dir-locals")
|
"edit dir-locals")
|
||||||
("g" counsel-projectile-switch-project--vc-action
|
("g" counsel-projectile-switch-project-action-vc
|
||||||
"open in vc-dir / magit / monky")
|
"open in vc-dir / magit / monky")
|
||||||
("e" counsel-projectile-switch-project--run-eshell-action
|
("e" counsel-projectile-switch-project-action-run-eshell
|
||||||
"start eshell")
|
"start eshell")
|
||||||
("a" counsel-projectile-switch-project--ag-action
|
("a" counsel-projectile-switch-project-action-ag
|
||||||
"search with ag")
|
"search with ag")
|
||||||
("R" counsel-projectile-switch-project--rg-action
|
("R" counsel-projectile-switch-project-action-rg
|
||||||
"search with rg"))
|
"search with rg"))
|
||||||
"List of actions for `counsel-projecile-switch-project'. If
|
"List of actions for `counsel-projecile-switch-project'. If
|
||||||
you modify this variable after loading counsel-projectile, then
|
you modify this variable after loading counsel-projectile, then
|
||||||
|
|
@ -457,7 +457,7 @@ already being visited by a buffer."
|
||||||
(add-text-properties 0 1 '(type file) file))
|
(add-text-properties 0 1 '(type file) file))
|
||||||
(counsel-projectile--unvisited-file-list))))
|
(counsel-projectile--unvisited-file-list))))
|
||||||
|
|
||||||
(defun counsel-projectile--transformer (str)
|
(defun counsel-projectile-transformer (str)
|
||||||
"Fontifies modified, file-visiting buffers.
|
"Fontifies modified, file-visiting buffers.
|
||||||
|
|
||||||
Relies on `ivy-switch-buffer-transformer'."
|
Relies on `ivy-switch-buffer-transformer'."
|
||||||
|
|
@ -481,18 +481,18 @@ Relies on `ivy--switch-buffer-matcher` and
|
||||||
(append (ivy--switch-buffer-matcher regexp buffers)
|
(append (ivy--switch-buffer-matcher regexp buffers)
|
||||||
(counsel--find-file-matcher regexp files))))
|
(counsel--find-file-matcher regexp files))))
|
||||||
|
|
||||||
(defun counsel-projectile--action (name &optional other-window)
|
(defun counsel-projectile-action (name &optional other-window)
|
||||||
"Switch to buffer or find file named NAME."
|
"Switch to buffer or find file named NAME."
|
||||||
(let ((type (get-text-property 0 'type name)))
|
(let ((type (get-text-property 0 'type name)))
|
||||||
(cond
|
(cond
|
||||||
((eq type 'file)
|
((eq type 'file)
|
||||||
(counsel-projectile--find-file-action name other-window))
|
(counsel-projectile-action-find-file name other-window))
|
||||||
((eq type 'buffer)
|
((eq type 'buffer)
|
||||||
(counsel-projectile--switch-buffer-action name other-window)))))
|
(counsel-projectile-action-switch-buffer name other-window)))))
|
||||||
|
|
||||||
(defun counsel-projectile--other-window-action (name)
|
(defun counsel-projectile-action-other-window (name)
|
||||||
"Switch to buffer or find file named NAME in another window."
|
"Switch to buffer or find file named NAME in another window."
|
||||||
(counsel-projectile--action name t))
|
(counsel-projectile-action name t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun counsel-projectile (&optional arg)
|
(defun counsel-projectile (&optional arg)
|
||||||
|
|
@ -508,16 +508,16 @@ With a prefix ARG invalidates the cache first."
|
||||||
:matcher #'counsel-projectile--matcher
|
:matcher #'counsel-projectile--matcher
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:action #'counsel-projectile--action
|
:action #'counsel-projectile-action
|
||||||
:caller 'counsel-projectile)))
|
:caller 'counsel-projectile)))
|
||||||
|
|
||||||
(ivy-set-display-transformer
|
(ivy-set-display-transformer
|
||||||
'counsel-projectile
|
'counsel-projectile
|
||||||
'counsel-projectile--transformer)
|
'counsel-projectile-transformer)
|
||||||
|
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile
|
'counsel-projectile
|
||||||
'(("j" counsel-projectile--other-window-action
|
'(("j" counsel-projectile-action-other-window
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
;;; key bindings
|
;;; key bindings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue