gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ;;; anything.el --- open anything


From: Mark Plaksin
Subject: Re: ;;; anything.el --- open anything
Date: Fri, 24 Aug 2007 07:57:54 -0400
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux)

Bill Clementson <address@hidden> writes:

> Hi Tamas/Tassilo,

Yes, Hi :)  anything and anything-config are awesome!  Thanks!

> "address@hidden" <address@hidden> writes:
>
>> Hi,,
>>
>> On Aug 23, 9:58 pm, Tassilo Horn <address@hidden> wrote:
>>>
>>> Oh, while I was typing those lines I realized that it's possible right
>>> now!  Add every and each source to anything-sources and fire up anything
>>> with
>>>
>>> (defun th-anything ()
>>>   (interactive)
>>>   (anything-set-source-filter '(anything-c-source-foo
>>>                                 anything-c-source-bar
>>>                                 anything-c-source-baz))
>>>   (anything))
>>>
>>> Oh, doesn't work!  It errors!
>
> Interestingly, I tried the same thing a few days ago (for much the
> same reason - I wanted to have a "trimmed-down" anything configuration
> for "normal" use and a "heavy-weight" anything configuration for
> "special" searches).

...

>> You can try setting anything-source-filter manually and start Anything
>> after that.
>
> It doesn't work if an anything buffer doesn't exist.

Hmm.  Maybe this is the same reason I couldn't create a key on
anything-map that switches to a specific buffer.  I figured I just
didn't understand anything.el well enough yet.  Is it me or anything.el
that's lacking? :)

A friend of mine wants to be able to press the "anything key" twice in a
row to swap between the two most recent buffers.  This should be easy
but my solution is convoluted.

I have anything bound to C-^ so the goal is to make C-^ C-^ swap between
the last two buffers that anything has visited.  I started out just
worrying about buffers that were chosen via the 'buffer' source.  My
solution is below but it's so clunky!  It involves faking a user press
of TAB (via self-insert-command).

(defvar anything-previous-buffer nil
  "Second to last buffer anything visted.")
(defvar anything-current-buffer nil
  "Last buffer anything visted.")

(defvar anything-source-buffers-plus-last
  (buffer . (("Switch to Buffer"
              . (lambda (buffer)
                  (if anything-current-buffer
                      (setq anything-previous-buffer anything-current-buffer))
                  (setq anything-current-buffer buffer)
                  (switch-to-buffer buffer)))
             ("Switch to Last Buffer" . anything-switch-to-last-buffer)
             ("Pop to Buffer"    . pop-to-buffer)
             ("Display Buffer"   . display-buffer)
             ("Kill Buffer"      . kill-buffer)))))

(defun anything-switch-to-last-buffer (&optional junk)
  (interactive)
  (if anything-previous-buffer
      (let ((switch-to anything-previous-buffer))
        (setq anything-current-buffer anything-previous-buffer)
        (setq anything-previous-buffer (buffer-name (current-buffer)))
        (switch-to-buffer switch-to))
    (message "Anything has not visited enough buffers yet.")))

(defun anything-fake-switch-to-last-buffer ()
  (interactive)
  ;; 9 = TAB on a terminal anyhow
  (self-insert-command 9)
  (anything-next-line)
  (anything-exit-minibuffer))

(define-key anything-map "\C-^" 'anything-fake-switch-to-last-buffer)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]