From: Jorgen Grahn <grahn+nntp@snipabacken.se>
To: help-gnu-emacs@gnu.org
Subject: Re: C-x C-b (switch-to-buffer) smarter suggestions?
Date: 11 Feb 2010 22:45:30 GMT [thread overview]
Message-ID: <slrnhn924a.1qf.grahn+nntp@frailea.sa.invalid> (raw)
In-Reply-To: mailman.897.1265690809.14305.help-gnu-emacs@gnu.org
On Tue, 2010-02-09, Kevin Rodgers wrote:
> Jorgen Grahn wrote:
>> This is a minor annoyance for me daily, and I'm hoping someone has a
>> readymade elisp fix. I'm not much of an elisp hacker -- my ~/.emacs
>> has stayed basically the same since 1996.
>>
>> Let's say I have a dozen buffers, including foo.c and foo.h. I am in
>> foo.c but I want to jump to foo.h. So I do
>>
>> C-x C-b foo TAB
>>
>> But this doesn't complete to foo.h, because foo.c is also an
>> alternative -- even though that's the buffer I'm explicitly trying to
>> switch *from*.
>
> (defvar switch-from-buffer nil)
>
> (defadvice switch-to-buffer (before switch-from-buffer activate)
> "Temporarily bind `switch-from-buffer' to the current buffer
> while reading args interactively. See `internal-complete-buffer'."
> (interactive (let ((switch-from-buffer (current-buffer)))
> (read-buffer "Switch to buffer: " (other-buffer)))))
>
> (defun internal-complete-buffer (string predicate flag)
> "Just like Finternal_complete_buffer(), but exclude `switch-from-buffer'."
> ;; emulate buffer-alist:
> (let ((buffer-alist (mapcar (lambda (buffer)
> (cons (buffer-name buffer) buffer))
> (delq switch-from-buffer (buffer-list)))))
> (cond ((null flag)
> (try-completion string buffer-alist predicate))
> ((eq flag t)
> (all-completions string buffer-alist predicate t))
> (t ; assume `lambda'
> (test-completion string buffer-alist predicate)))))
Thanks! I can't get it to work though, when just pasted into ~/.emacs:
- C-x b
- prompt appears, I type 'foo' and press return
- error message: 'Wrong type argument: listp, "foo"'
/Jorgen
PS I'm slow to respond as you see -- so don't spend too much time
debugging it unless you get something out of it for yourself.
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
next prev parent reply other threads:[~2010-02-11 22:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-06 8:03 C-x C-b (switch-to-buffer) smarter suggestions? Jorgen Grahn
2010-02-07 8:47 ` Alberto Luaces
[not found] ` <mailman.826.1265532477.14305.help-gnu-emacs@gnu.org>
2010-02-07 22:54 ` Jorgen Grahn
2010-02-08 2:11 ` Stefan Monnier
2010-02-08 12:17 ` Jorgen Grahn
2010-02-08 17:38 ` Stefan Monnier
2010-02-08 18:23 ` Teemu Likonen
2010-02-11 10:35 ` Jorgen Grahn
2010-02-11 14:48 ` Richard Riley
2010-02-09 15:15 ` Richard Riley
[not found] ` <mailman.926.1265729432.14305.help-gnu-emacs@gnu.org>
2010-02-11 18:59 ` Jorgen Grahn
2010-02-08 5:55 ` Dmitri Minaev
[not found] ` <mailman.852.1265608552.14305.help-gnu-emacs@gnu.org>
2010-02-08 11:45 ` Jorgen Grahn
2010-02-10 6:16 ` Dmitri Minaev
2010-02-09 4:46 ` Kevin Rodgers
[not found] ` <mailman.897.1265690809.14305.help-gnu-emacs@gnu.org>
2010-02-11 22:45 ` Jorgen Grahn [this message]
2010-02-12 4:42 ` Kevin Rodgers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=slrnhn924a.1qf.grahn+nntp@frailea.sa.invalid \
--to=grahn+nntp@snipabacken.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.