add actions to open project file externally or as root
This commit is contained in:
parent
162cdc2655
commit
e200bce2ff
1 changed files with 33 additions and 3 deletions
|
|
@ -228,7 +228,11 @@ The format is the same as in `org-capture-templates-contexts'."
|
||||||
|
|
||||||
(defcustom counsel-projectile-find-file-actions
|
(defcustom counsel-projectile-find-file-actions
|
||||||
'(("j" counsel-projectile-find-file-action-other-window
|
'(("j" counsel-projectile-find-file-action-other-window
|
||||||
"other window"))
|
"other window")
|
||||||
|
("x" counsel-projectile-find-file-action-extern
|
||||||
|
"open externally")
|
||||||
|
("r" counsel-projectile-find-file-action-root
|
||||||
|
"open as root"))
|
||||||
"List of actions for `counsel-projecile-find-file'.
|
"List of actions for `counsel-projecile-find-file'.
|
||||||
|
|
||||||
Each action is made of:
|
Each action is made of:
|
||||||
|
|
@ -288,7 +292,7 @@ afterwards to apply your changes."
|
||||||
|
|
||||||
(defcustom counsel-projectile-switch-to-buffer-actions
|
(defcustom counsel-projectile-switch-to-buffer-actions
|
||||||
'(("j" switch-to-buffer-other-window
|
'(("j" switch-to-buffer-other-window
|
||||||
"other window"))
|
"other window"))
|
||||||
"List of actions for `counsel-projecile-switch-to-buffer'.
|
"List of actions for `counsel-projecile-switch-to-buffer'.
|
||||||
|
|
||||||
Each action is made of:
|
Each action is made of:
|
||||||
|
|
@ -374,7 +378,11 @@ afterwards to apply your changes."
|
||||||
|
|
||||||
(defcustom counsel-projectile-actions
|
(defcustom counsel-projectile-actions
|
||||||
'(("j" counsel-projectile-action-other-window
|
'(("j" counsel-projectile-action-other-window
|
||||||
"other window"))
|
"other window")
|
||||||
|
("x" counsel-projectile-action-file-extern
|
||||||
|
"open file externally")
|
||||||
|
("r" counsel-projectile-action-file-root
|
||||||
|
"open file as root"))
|
||||||
"List of actions for `counsel-projecile'.
|
"List of actions for `counsel-projecile'.
|
||||||
|
|
||||||
Each action is made of:
|
Each action is made of:
|
||||||
|
|
@ -436,6 +444,16 @@ afterwards to apply your changes."
|
||||||
(find-file-other-window (projectile-expand-root file))
|
(find-file-other-window (projectile-expand-root file))
|
||||||
(run-hooks 'projectile-find-file-hook))
|
(run-hooks 'projectile-find-file-hook))
|
||||||
|
|
||||||
|
(defun counsel-projectile-find-file-action-extern (file)
|
||||||
|
"Find FILE externally and run `projectile-find-file-hook'."
|
||||||
|
(counsel-find-file-extern (projectile-expand-root file))
|
||||||
|
(run-hooks 'projectile-find-file-hook))
|
||||||
|
|
||||||
|
(defun counsel-projectile-find-file-action-root (file)
|
||||||
|
"Find FILE as root and run `projectile-find-file-hook'."
|
||||||
|
(counsel-find-file-as-root (projectile-expand-root file))
|
||||||
|
(run-hooks 'projectile-find-file-hook))
|
||||||
|
|
||||||
(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))))
|
||||||
|
|
@ -922,6 +940,18 @@ Relies on `ivy--switch-buffer-matcher' and
|
||||||
(switch-to-buffer-other-window name)
|
(switch-to-buffer-other-window name)
|
||||||
(counsel-projectile-find-file-action-other-window name)))
|
(counsel-projectile-find-file-action-other-window name)))
|
||||||
|
|
||||||
|
(defun counsel-projectile-action-file-extern (name)
|
||||||
|
"Find file named NAME externally."
|
||||||
|
(if (member name counsel-projectile--buffers)
|
||||||
|
(message "This action does not apply to buffers.")
|
||||||
|
(counsel-projectile-find-file-action-extern name)))
|
||||||
|
|
||||||
|
(defun counsel-projectile-action-file-root (name)
|
||||||
|
"Find file named NAME as root."
|
||||||
|
(if (member name counsel-projectile--buffers)
|
||||||
|
(message "This action does not apply to buffers.")
|
||||||
|
(counsel-projectile-find-file-action-root name)))
|
||||||
|
|
||||||
(defun counsel-projectile-transformer (name)
|
(defun counsel-projectile-transformer (name)
|
||||||
"Fontifies modified, file-visiting buffers as well as non-visited files."
|
"Fontifies modified, file-visiting buffers as well as non-visited files."
|
||||||
(if (member name counsel-projectile--buffers)
|
(if (member name counsel-projectile--buffers)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue