* Re: C-x C-b (switch-to-buffer) smarter suggestions?
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>
` (5 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Alberto Luaces @ 2010-02-07 8:47 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
Jorgen Grahn writes:
[...]
> 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*.
Take a look at ff-find-other-file.
--
Alberto
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.826.1265532477.14305.help-gnu-emacs@gnu.org>]
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
[not found] ` <mailman.826.1265532477.14305.help-gnu-emacs@gnu.org>
@ 2010-02-07 22:54 ` Jorgen Grahn
0 siblings, 0 replies; 17+ messages in thread
From: Jorgen Grahn @ 2010-02-07 22:54 UTC (permalink / raw)
To: help-gnu-emacs
On Sun, 2010-02-07, Alberto Luaces wrote:
> Hi,
>
> Jorgen Grahn writes:
>
> [...]
>
>> 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*.
>
> Take a look at ff-find-other-file.
("Find the header or source file corresponding to this file")
Thanks. Yes, that solves the particular example above. Not the
general case though -- the buffers might equally well be foo.cc and
foo.1 (for the manual page) or Makefile and Makefile<2>. Come to
think of it, that last example is probably the one that annoys me the
most.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
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-08 2:11 ` Stefan Monnier
2010-02-08 12:17 ` Jorgen Grahn
2010-02-08 5:55 ` Dmitri Minaev
` (3 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2010-02-08 2:11 UTC (permalink / raw)
To: help-gnu-emacs
> 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*.
Apparently, you haven't yet upgraded to Emacs-23.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-08 2:11 ` Stefan Monnier
@ 2010-02-08 12:17 ` Jorgen Grahn
2010-02-08 17:38 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Jorgen Grahn @ 2010-02-08 12:17 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 2010-02-08, Stefan Monnier wrote:
>> 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*.
>
> Apparently, you haven't yet upgraded to Emacs-23.
So you're implying that Emacs 23 fixes exactly that, or that it
reworks the buffer selection interface completely?
Actually I still use Emacs 21. Emacs 22 is also available as part of
Debian Linux, but I gain more by sticking to 21, which is the one
available at work (semi-officially available -- officially we are
stuck with 20).
So, this annoyance of mine isn't so important that I'm willing to
upgrade to Emacs 23 everywhere just yet.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
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-09 15:15 ` Richard Riley
[not found] ` <mailman.926.1265729432.14305.help-gnu-emacs@gnu.org>
2 siblings, 2 replies; 17+ messages in thread
From: Stefan Monnier @ 2010-02-08 17:38 UTC (permalink / raw)
To: help-gnu-emacs
> So you're implying that Emacs 23 fixes exactly that, or that it
> reworks the buffer selection interface completely?
I revamped the minibuffer completion code in Emacs-23, and along the way
someone installed a patch that provides just the feature you're
asking for.
> Actually I still use Emacs 21. Emacs 22 is also available as part of
> Debian Linux, but I gain more by sticking to 21, which is the one
> available at work (semi-officially available -- officially we are
> stuck with 20).
Emacs-23 is also available in Debian (at least in Debian testing).
> So, this annoyance of mine isn't so important that I'm willing to
> upgrade to Emacs 23 everywhere just yet.
As long as you're a happy Emacs user,
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-08 17:38 ` Stefan Monnier
@ 2010-02-08 18:23 ` Teemu Likonen
2010-02-11 10:35 ` Jorgen Grahn
1 sibling, 0 replies; 17+ messages in thread
From: Teemu Likonen @ 2010-02-08 18:23 UTC (permalink / raw)
To: help-gnu-emacs
* 2010-02-08 12:38 (-0500), Stefan Monnier wrote:
> Emacs-23 is also available in Debian (at least in Debian testing).
It's also available for stable (Lenny) from www.backports.org .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
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
1 sibling, 1 reply; 17+ messages in thread
From: Jorgen Grahn @ 2010-02-11 10:35 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 2010-02-08, Stefan Monnier wrote:
>> So you're implying that Emacs 23 fixes exactly that, or that it
>> reworks the buffer selection interface completely?
>
> I revamped the minibuffer completion code in Emacs-23, and along the way
> someone installed a patch that provides just the feature you're
> asking for.
>
>> Actually I still use Emacs 21. Emacs 22 is also available as part of
>> Debian Linux, but I gain more by sticking to 21, which is the one
>> available at work (semi-officially available -- officially we are
>> stuck with 20).
>
> Emacs-23 is also available in Debian (at least in Debian testing).
I'm sure it is, but I'm a Debian "stable" kind of guy.
>> So, this annoyance of mine isn't so important that I'm willing to
>> upgrade to Emacs 23 everywhere just yet.
>
> As long as you're a happy Emacs user,
I indeed am. I don't see myself switching to anything else, ever.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-11 10:35 ` Jorgen Grahn
@ 2010-02-11 14:48 ` Richard Riley
0 siblings, 0 replies; 17+ messages in thread
From: Richard Riley @ 2010-02-11 14:48 UTC (permalink / raw)
To: help-gnu-emacs
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> On Mon, 2010-02-08, Stefan Monnier wrote:
>>> So you're implying that Emacs 23 fixes exactly that, or that it
>>> reworks the buffer selection interface completely?
>>
>> I revamped the minibuffer completion code in Emacs-23, and along the way
>> someone installed a patch that provides just the feature you're
>> asking for.
>>
>>> Actually I still use Emacs 21. Emacs 22 is also available as part of
>>> Debian Linux, but I gain more by sticking to 21, which is the one
>>> available at work (semi-officially available -- officially we are
>>> stuck with 20).
>>
>> Emacs-23 is also available in Debian (at least in Debian testing).
>
> I'm sure it is, but I'm a Debian "stable" kind of guy.
You probably know, but just in case ;), Emacs 23 is also available for
Debian Stable in the Lenny backports.
regards
r.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-08 12:17 ` Jorgen Grahn
2010-02-08 17:38 ` Stefan Monnier
@ 2010-02-09 15:15 ` Richard Riley
[not found] ` <mailman.926.1265729432.14305.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 17+ messages in thread
From: Richard Riley @ 2010-02-09 15:15 UTC (permalink / raw)
To: help-gnu-emacs
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> On Mon, 2010-02-08, Stefan Monnier wrote:
>>> 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*.
>>
>> Apparently, you haven't yet upgraded to Emacs-23.
>
> So you're implying that Emacs 23 fixes exactly that, or that it
> reworks the buffer selection interface completely?
>
> Actually I still use Emacs 21. Emacs 22 is also available as part of
> Debian Linux, but I gain more by sticking to 21, which is the one
> available at work (semi-officially available -- officially we are
> stuck with 20).
Interesting. I find it astonishing that anyone would insist on using
such an old version. Are your customisations so incompatible with newer
Emacs? The call of the daemon and anti aliased fonts would be enough to
move for most .. Or do you just have an intransigent BOFH?
>
> So, this annoyance of mine isn't so important that I'm willing to
> upgrade to Emacs 23 everywhere just yet.
>
> /Jorgen
The only issue I noticed moving from 22 to 23 was the line wrapping. The
rest just seemed minor trivialities totally offset by being on a modern
version.
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.926.1265729432.14305.help-gnu-emacs@gnu.org>]
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
[not found] ` <mailman.926.1265729432.14305.help-gnu-emacs@gnu.org>
@ 2010-02-11 18:59 ` Jorgen Grahn
0 siblings, 0 replies; 17+ messages in thread
From: Jorgen Grahn @ 2010-02-11 18:59 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 2010-02-09, Richard Riley wrote:
> Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
>
>> On Mon, 2010-02-08, Stefan Monnier wrote:
>>>> 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*.
>>>
>>> Apparently, you haven't yet upgraded to Emacs-23.
>>
>> So you're implying that Emacs 23 fixes exactly that, or that it
>> reworks the buffer selection interface completely?
>>
>> Actually I still use Emacs 21. Emacs 22 is also available as part of
>> Debian Linux, but I gain more by sticking to 21, which is the one
>> available at work (semi-officially available -- officially we are
>> stuck with 20).
>
> Interesting. I find it astonishing that anyone would insist on using
> such an old version. Are your customisations so incompatible with newer
> Emacs? The call of the daemon and anti aliased fonts would be enough to
> move for most .. Or do you just have an intransigent BOFH?
I don't know, but for the Emacs 20 part (20.7, installed on Solaris in
2000 according to time stamps) my guess is a combination of:
- lack of attention to the Solaris environment when more and more
work is done on Linux
- outsourcing of BOFH activities
- hard to know what problems an upgrade would cause for hundreds of
users; hard to know exactly *who* they are and what features they
have come to rely on
- maintaining an existing development environment = bad career move;
implementing new, complex, proprietary and expensive = good move
- the programmers who really care install their own newer Emacs and
tell noone about it
- Emacs 20 is still a very good text editor
I don't think it's uncommon for organizations to end up in that
situation, unfortunately. But I wouldn't want to live at the bleeding
edge either ...
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-06 8:03 C-x C-b (switch-to-buffer) smarter suggestions? Jorgen Grahn
` (2 preceding siblings ...)
2010-02-08 2:11 ` Stefan Monnier
@ 2010-02-08 5:55 ` Dmitri Minaev
[not found] ` <mailman.852.1265608552.14305.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Dmitri Minaev @ 2010-02-08 5:55 UTC (permalink / raw)
To: Jorgen Grahn; +Cc: help-gnu-emacs
On Sat, Feb 6, 2010 at 12:03 PM, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
>
> 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*.
iswitchb?
--
With best regards,
Dmitri Minaev
Russian history blog: http://minaev.blogspot.com
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.852.1265608552.14305.help-gnu-emacs@gnu.org>]
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-06 8:03 C-x C-b (switch-to-buffer) smarter suggestions? Jorgen Grahn
` (4 preceding siblings ...)
[not found] ` <mailman.852.1265608552.14305.help-gnu-emacs@gnu.org>
@ 2010-02-09 4:46 ` Kevin Rodgers
[not found] ` <mailman.897.1265690809.14305.help-gnu-emacs@gnu.org>
6 siblings, 0 replies; 17+ messages in thread
From: Kevin Rodgers @ 2010-02-09 4:46 UTC (permalink / raw)
To: help-gnu-emacs
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)))))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.897.1265690809.14305.help-gnu-emacs@gnu.org>]
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
[not found] ` <mailman.897.1265690809.14305.help-gnu-emacs@gnu.org>
@ 2010-02-11 22:45 ` Jorgen Grahn
2010-02-12 4:42 ` Kevin Rodgers
0 siblings, 1 reply; 17+ messages in thread
From: Jorgen Grahn @ 2010-02-11 22:45 UTC (permalink / raw)
To: help-gnu-emacs
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 .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: C-x C-b (switch-to-buffer) smarter suggestions?
2010-02-11 22:45 ` Jorgen Grahn
@ 2010-02-12 4:42 ` Kevin Rodgers
0 siblings, 0 replies; 17+ messages in thread
From: Kevin Rodgers @ 2010-02-12 4:42 UTC (permalink / raw)
To: help-gnu-emacs
Jorgen Grahn wrote:
> On Tue, 2010-02-09, Kevin Rodgers wrote:
...
> 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"'
Sorry, I pasted a test version. The only change is:
(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)))
(list (read-buffer "Switch to buffer: " (other-buffer))))))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 17+ messages in thread