[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ;;; anything.el --- open anything
From: |
rubikitch |
Subject: |
Re: ;;; anything.el --- open anything |
Date: |
Thu, 26 Jul 2007 02:19:13 +0900 (JST) |
From: "address@hidden" <address@hidden>
Subject: ;;; anything.el --- open anything
Date: Fri, 22 Jun 2007 04:38:35 -0700
> This package provides a single command (M-x anything) and as I type
> the results are shown in a structured format. No need to tell emacs
> first I want to switch to a buffer, open a file or a manual page. See
> the commentary in the header.
Cool! I love it!!
I like menu using `read-char' rather than TAB and digit shortcut.
So I hacked up it.
(defvar anything-select-in-minibuffer-keys "asdfjkl;")
;; It is based on anything-select-action, so it needs refactoring.
(defun anything-select-action-in-minibuffer ()
"Select an action for the currently selected candidate in minibuffer."
(interactive)
(if anything-saved-sources
(error "Already showing the action list"))
(setq anything-saved-selection (anything-get-selection))
(unless anything-saved-selection
(error "Nothing is selected."))
(let ((actions (anything-get-action)))
(message "%s" (apply #'concat
(loop for action in actions
for i from 0 collecting
(format "[%c]%s\n"
(elt anything-select-in-minibuffer-keys
i)
(car action)))))
(let* ((key (read-char))
(idx (rindex anything-select-in-minibuffer-keys key)))
(or idx (error "bad selection"))
(setq anything-saved-action (cdr (elt actions idx)))
(anything-exit-minibuffer))))
(defvar anything-saved-action nil
"Saved value of the currently selected action by key.")
;; Redefined
(defun anything-execute-selection-action ()
"If a candidate was selected then perform the associated
action."
(let* ((selection (if anything-saved-selection
;; the action list is shown
anything-saved-selection
(anything-get-selection)))
(action (or anything-saved-action
(if anything-saved-sources
;; the action list is shown
(anything-get-selection)
(anything-get-action)))))
(if (anything-list-but-not-lambda-p action)
;; select the default action
(setq action (cdar action)))
(if (and selection action)
(funcall action selection))))
(define-key anything-map "\C-k" 'anything-select-action-in-minibuffer)
--
rubikitch
http://www.rubyist.net/~rubikitch/
Re: ;;; anything.el --- open anything, Tassilo Horn, 2007/07/24
Re: ;;; anything.el --- open anything, address@hidden, 2007/07/24
Re: ;;; anything.el --- open anything,
rubikitch <=