Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extra functions for helm #160

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ script:

env:
matrix:
- EVM_EMACS=emacs-26.1-travis
- EVM_EMACS=emacs-26.1-travis-linux-xenial
- EVM_EMACS=emacs-25.3-travis
# don't need 25.2 because it's the same 25.3
- EVM_EMACS=emacs-25.1-travis
Expand Down
2 changes: 1 addition & 1 deletion window-purpose-switch.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ used. This is an internal variable, don't set it yourself.")
it yourself.")

(defvar purpose-action-sequences
'((switch-to-buffer . (purpose-display-reuse-window-buffer
'((switch-to-buffer . (;;purpose-display-reuse-window-buffer
purpose-display-reuse-window-purpose
purpose-display-maybe-same-window
purpose-display-maybe-other-window
Expand Down
43 changes: 27 additions & 16 deletions window-purpose.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,59 @@
;; commands that know when to use `ido-find-file' and when to use `find-file'.
;; the result: Purpose works well both with `ido' and `helm'!!!

(defmacro purpose-ido-caller (ido-fn other-fn)
"Create an interactive lambda to conditionally call an ido command.
The lambda calls IDO-FN interactively when `ido-mode' is on, otherwise
it calls OTHER-FN interactively.
(defmacro purpose-ido-caller (ido-fn helm-fn other-fn)
"Create an interactive lambda to conditionally call a command.
The lambda calls IDO-FN interactively when `ido-mode' is on, it calls
HELM-FN when `helm-mode' is on, and it calls OTHER-FN interactively.
Example:
(purpose-ido-caller #'ido-find-file #'find-file)"
(declare (indent nil) (debug (function-form function-form)))
`(lambda (&rest _args)
(interactive)
(call-interactively (if ido-mode ,ido-fn ,other-fn))))
(call-interactively (cond (ido-mode ,ido-fn)
(helm-mode ,helm-fn)
(t ,other-fn)))))

(defalias 'purpose-friendly-find-file
(purpose-ido-caller #'ido-find-file #'find-file)
"Call `find-file' or `ido-find-file' intelligently.
If `ido-mode' is on, call `ido-find-file'. Otherwise, call `find-file'.
(purpose-ido-caller #'ido-find-file #'helm-find-files #'find-file)
"Call `find-file', `helm-find-files' or `ido-find-file' intelligently.
If `ido-mode' is on, call `ido-find-file'. If `helm-mode' is on,
call `helm-find-files'. Otherwise, call `find-file'.
This allows Purpose to work well with both `ido' and `helm'.")

(defalias 'purpose-friendly-find-file-other-window
(purpose-ido-caller #'ido-find-file-other-window #'find-file-other-window)
(purpose-ido-caller #'ido-find-file-other-window
#'find-file-other-window
#'find-file-other-window)
"Call `find-file-other-window' or `ido-find-file-other-window'
intelligently.
If `ido-mode' is on, call `ido-find-file-other-window'. Otherwise, call
`find-file-other-window'.
This allows Purpose to work well with both `ido' and `helm'.")

(defalias 'purpose-friendly-find-file-other-frame
(purpose-ido-caller #'ido-find-file-other-frame #'find-file-other-frame)
(purpose-ido-caller #'ido-find-file-other-frame
#'find-file-other-frame
#'find-file-other-frame)
"Call `find-file-other-frame' or `ido-find-file-other-frame'
intelligently.
If `ido-mode' is on, call `ido-find-file-other-frame'. Otherwise, call
`find-file-other-frame'.
This allows Purpose to work well with both `ido' and `helm'.")

(defalias 'purpose-friendly-switch-buffer
(purpose-ido-caller #'ido-switch-buffer #'switch-to-buffer)
"Call `switch-to-buffer' or `ido-switch-buffer' intelligently.
If `ido-mode' is on, call `ido-switch-buffer'. Otherwise, call
`switch-to-buffer'.
(purpose-ido-caller #'ido-switch-buffer
#'helm-mini
#'switch-to-buffer)
"Call `switch-to-buffer', `helm-mini' or `ido-switch-buffer' intelligently.
If `ido-mode' is on, call `ido-switch-buffer'. If `helm-mode'
is on, call `helm-mini'. Otherwise, call `switch-to-buffer'.
This allows Purpose to work well with both `ido' and `helm'.")

(defalias 'purpose-friendly-switch-buffer-other-window
(purpose-ido-caller #'ido-switch-buffer-other-window
#'switch-to-buffer-other-window)
#'switch-to-buffer-other-window
#'switch-to-buffer-other-window)
"Call `switch-to-buffer-other-window' or
`ido-switch-buffer-other-window' intelligently.
If `ido-mode' is on, call `ido-switch-buffer-other-window'. Otherwise,
Expand All @@ -134,7 +144,8 @@ This allows Purpose to work well with both `ido' and `helm'.")

(defalias 'purpose-friendly-switch-buffer-other-frame
(purpose-ido-caller #'ido-switch-buffer-other-frame
#'switch-to-buffer-other-frame)
#'switch-to-buffer-other-frame
#'switch-to-buffer-other-frame)
"Call `switch-to-buffer-other-frame' or
`ido-switch-buffer-other-frame' intelligently.
If `ido-mode' is on, call `ido-switch-buffer-other-frame'. Otherwise,
Expand Down