unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* *Occur in buf*?
@ 2002-07-25 10:05 Marshall, Simon
  2002-07-25 13:42 ` Sam Steingold
  2002-07-26 15:36 ` Richard Stallman
  0 siblings, 2 replies; 21+ messages in thread
From: Marshall, Simon @ 2002-07-25 10:05 UTC (permalink / raw)


I frequently use M-x occur in several different buffers, in order to
compare the occur results from the different buffers.  Trouble is, M-x
occur always writes to *Occur*, so if I do several M-x occurs in
different buffers I have to rename each *Occur* buffer to make it
unique.  It's inconvenient, and if I do this frequently the number of
*Occur*<n> buffers gets out of hand.  Sure, I could M-x kill-buffer
before M-x occur M-x rename-uniquely.

IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
to do this, rather than *Occur*.

It doesn't seem an outrageous request, after all, the *Occur* buffer is
necessarily tied to a particular originating buffer.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 10:05 *Occur in buf*? Marshall, Simon
@ 2002-07-25 13:42 ` Sam Steingold
  2002-07-25 14:37   ` Miles Bader
  2002-07-26 15:36 ` Richard Stallman
  1 sibling, 1 reply; 21+ messages in thread
From: Sam Steingold @ 2002-07-25 13:42 UTC (permalink / raw)
  Cc: 'Emacs Developers'

> * In message <FC3DA3DC8D4AD311AB910020352A8FDC1075509A@eagle.midas-kapiti.com>
> * On the subject of "*Occur in buf*?"
> * Sent on Thu, 25 Jul 2002 11:05:41 +0100
> * Honorable "Marshall, Simon" <simon.marshall@misys.com> writes:
>
> IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
> to do this, rather than *Occur*.

I like your idea.
unless there are objections, I will install the appended patch.

(the key bindings are slightly changed too).

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
A poet who reads his verse in public may have other nasty habits.


--- replace.el.~1.152.~	Fri Jul 19 04:11:46 2002
+++ replace.el	Thu Jul 25 09:40:06 2002
@@ -453,7 +453,8 @@
     (define-key map "\M-n" 'occur-next)
     (define-key map "\M-p" 'occur-prev)
     (define-key map "g" 'revert-buffer)
-    (define-key map "q" 'delete-window)
+    (define-key map "q" 'quit-window)
+    (define-key map "z" 'kill-this-buffer)
     map)
   "Keymap for `occur-mode'.")
 
@@ -633,14 +634,15 @@
 NLINES defaults to `list-matching-lines-default-context-lines'.
 Interactively it is the prefix arg.
 
-The lines are shown in a buffer named `*Occur*'.
+The lines are shown in a buffer named `*Occur:buf-name*'.
 It serves as a menu to find any of the occurrences in this buffer.
 \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
 
 If REGEXP contains upper case characters (excluding those preceded by `\\'),
 the matching is case-sensitive."
   (interactive (occur-read-primary-args))
-  (occur-1 regexp nlines (list (current-buffer))))
+  (occur-1 regexp nlines (list (current-buffer))
+           (concat "*Occur:" (buffer-name) "*")))
 
 (defun multi-occur (bufs regexp &optional nlines)
   "Show all lines in buffers BUFS containing a match for REGEXP.
@@ -658,7 +660,8 @@
 	(push buf bufs))
       (nreverse (mapcar #'get-buffer bufs)))
     (occur-read-primary-args)))
-  (occur-1 regexp nlines bufs))
+  (occur-1 regexp nlines bufs
+           (concat "*Occur:" (mapconcat #'buffer-name bufs "/") "*")))
 
 (defun multi-occur-by-filename-regexp (bufregexp regexp &optional nlines)
   "Show all lines matching REGEXP in buffers named by BUFREGEXP.
@@ -685,7 +688,8 @@
 					(string-match bufregexp
 						      (buffer-file-name buf)))
 			       buf))
-			   (buffer-list))))))
+			   (buffer-list)))
+             (concat "*Occur:" regexp "*"))))
 
 (defun occur-1 (regexp nlines bufs &optional buf-name)
   (unless buf-name

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 13:42 ` Sam Steingold
@ 2002-07-25 14:37   ` Miles Bader
  2002-07-25 15:01     ` Sam Steingold
  0 siblings, 1 reply; 21+ messages in thread
From: Miles Bader @ 2002-07-25 14:37 UTC (permalink / raw)
  Cc: Marshall, Simon, 'Emacs Developers'

On Thu, Jul 25, 2002 at 09:42:16AM -0400, Sam Steingold wrote:
> > IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
> > to do this, rather than *Occur*.
> 
> I like your idea.
> unless there are objections, I will install the appended patch.

The reason why it's common for commands such as occur to use a global buffer
is that otherwise you end up with lots of random buffers cluttering up things.

I would suggest to instead make a C-u prefix to occur create a unique buffer,
and keep the default behavior as-is.

Also note that a more general solution is the `clone-buffer' command, which
duplicates the current buffer with a unique name; in some modes such as info
this is bound to M-n (in occur though, M-n is bound to `occur-next', though
that command actually doesn't seem to work).

-Miles
-- 
P.S.  All information contained in the above letter is false,
      for reasons of military security.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 14:37   ` Miles Bader
@ 2002-07-25 15:01     ` Sam Steingold
  2002-07-26 15:36       ` Richard Stallman
  0 siblings, 1 reply; 21+ messages in thread
From: Sam Steingold @ 2002-07-25 15:01 UTC (permalink / raw)
  Cc: Marshall, Simon, 'Emacs Developers'

> * In message <20020725143738.GA26891@gnu.org>
> * On the subject of "Re: *Occur in buf*?"
> * Sent on Thu, 25 Jul 2002 10:37:38 -0400
> * Honorable Miles Bader <miles@gnu.org> writes:
>
> On Thu, Jul 25, 2002 at 09:42:16AM -0400, Sam Steingold wrote:
> > > IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
> > > to do this, rather than *Occur*.
> > 
> > I like your idea.
> > unless there are objections, I will install the appended patch.
> 
> The reason why it's common for commands such as occur to use a global
> buffer is that otherwise you end up with lots of random buffers
> cluttering up things.

this is why I bound 'z' to kill-this-buffer.
as for random buffer clutter, there is midnight.el for that.

> I would suggest to instead make a C-u prefix to occur create a unique
> buffer, and keep the default behavior as-is.

I thought about it.  occur uses the prefix argument to indicate the
number of lines, so this is not quite feasible.

> Also note that a more general solution is the `clone-buffer' command,
> which duplicates the current buffer with a unique name; in some modes
> such as info this is bound to M-n (in occur though, M-n is bound to
> `occur-next', though that command actually doesn't seem to work).

I can add an `occur-rename' command (bound to `r') that would rename the
occur buffer as proposed and bind `clone-buffer' to 'c'.
do you like this better?
then the effect of my original patch can be accomplished by adding
`occur-rename' to `occur-mode-hook'.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Good judgment comes from experience and experience comes from bad judgment.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: *Occur in buf*?
@ 2002-07-25 16:07 Marshall, Simon
  2002-07-25 18:46 ` Robert J. Chassell
  0 siblings, 1 reply; 21+ messages in thread
From: Marshall, Simon @ 2002-07-25 16:07 UTC (permalink / raw)
  Cc: 'Emacs Developers'

> I can add an `occur-rename' command (bound to `r') that would 
> rename the
> occur buffer as proposed and bind `clone-buffer' to 'c'.
> do you like this better?
> then the effect of my original patch can be accomplished by adding
> `occur-rename' to `occur-mode-hook'.

Sam, thanks for the suggestions.

I thought that this renaming might be optional, i.e., current behaviour
by default.  I was thinking in terms of a user variable rather than
adding to a hook.

But, I'm not sure how clean the Occur buffer key (to rename the *Occur*
buffer to *Occur: buf*) would actually be.  Suppose M-x occur simply
created an *Occur* buffer.  Suppose I was to rename one to *Occur: buf*
by using the key.  Then, I did another M-x occur (maybe for a different
regexp).  Should M-x occur create another *Occur* buffer?  Or reuse the
*Occur: buf* buffer?  The answer, of course, depends on what I happen to
feel like at the time.  Whichever it chooses will annoy me some of the
time.  "Damn, it went and created yet another buffer!"  Or "damn, it
overwrote my previous M-x occur buffer!".  M-x occur cannot know if I
had renamed the original *Occur* buffer so that *Occur: buf* is the
buffer I want for future M-x occur output or so that I could keep/save
that particular *Occur* buffer only.

Perhaps, in this case, it should create another *Occur* buffer.  If the
user uses the key again to rename it to *Occur: buf*, should Emacs
silently remove the old *Occur: buf* buffer?

Maybe it needs some more thought.

BTW, I prefer *Occur: buf* to *Occur:buf* though YMMV.
I find it easier to spot the original buffer name.
It follows the convention of other buffer names I've seen.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 16:07 Marshall, Simon
@ 2002-07-25 18:46 ` Robert J. Chassell
  0 siblings, 0 replies; 21+ messages in thread
From: Robert J. Chassell @ 2002-07-25 18:46 UTC (permalink / raw)
  Cc: sds, emacs-devel

   But, I'm not sure how clean the Occur buffer key (to rename the *Occur*
   buffer to *Occur: buf*) would actually be.  

My preference would be to see the Occur command create a buffer named
*Occur: buf*

If I run the occur command again in the same buffer, then it should 
reuse the *Occur: buf* buffer.

However, if I run the occur command in a different buffer, then then
it should create a new and different *Occur: different_buf* buffer.

Also, this means that the buffer created by `multi-occur' can continue
to be named *Occur* without a name collision.

-- 
    Robert J. Chassell                  bob@rattlesnake.com
    Rattlesnake Enterprises             http://www.rattlesnake.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 10:05 *Occur in buf*? Marshall, Simon
  2002-07-25 13:42 ` Sam Steingold
@ 2002-07-26 15:36 ` Richard Stallman
  2002-07-26 17:53   ` Benjamin Rutt
  2002-07-28  0:15   ` Kim F. Storm
  1 sibling, 2 replies; 21+ messages in thread
From: Richard Stallman @ 2002-07-26 15:36 UTC (permalink / raw)
  Cc: emacs-devel

    IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
    to do this, rather than *Occur*.

I think that for most users this would create unnecessary clutter.
Perhaps it is best if you simply do this as a customization.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-25 15:01     ` Sam Steingold
@ 2002-07-26 15:36       ` Richard Stallman
  2002-07-26 19:53         ` Sam Steingold
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Stallman @ 2002-07-26 15:36 UTC (permalink / raw)
  Cc: miles, simon.marshall, emacs-devel

    this is why I bound 'z' to kill-this-buffer.
    as for random buffer clutter, there is midnight.el for that.

I don't think that an obscure package that most people don't enable
qualifies as a total solution to this problem of clutter.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-26 15:36 ` Richard Stallman
@ 2002-07-26 17:53   ` Benjamin Rutt
  2002-07-28  0:15   ` Kim F. Storm
  1 sibling, 0 replies; 21+ messages in thread
From: Benjamin Rutt @ 2002-07-26 17:53 UTC (permalink / raw)
  Cc: simon.marshall, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
>     to do this, rather than *Occur*.
>
> I think that for most users this would create unnecessary clutter.
> Perhaps it is best if you simply do this as a customization.

Here is one such easy customization:

;; occur - make it work on occur buffers
(defadvice occur (before occur-uniquify activate)
  "Make occur work in *Occur* buffers."
  (if (string-match "\*Occur\*" (buffer-name)) (rename-uniquely)))
-- 
Benjamin

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-26 15:36       ` Richard Stallman
@ 2002-07-26 19:53         ` Sam Steingold
  0 siblings, 0 replies; 21+ messages in thread
From: Sam Steingold @ 2002-07-26 19:53 UTC (permalink / raw)
  Cc: emacs-devel

> * In message <200207261536.g6QFaLI09001@aztec.santafe.edu>
> * On the subject of "Re: *Occur in buf*?"
> * Sent on Fri, 26 Jul 2002 09:36:21 -0600 (MDT)
> * Honorable Richard Stallman <rms@gnu.org> writes:
>
>     as for random buffer clutter, there is midnight.el for that.
> 
> I don't think that an obscure package that most people don't enable
> qualifies as a total solution to this problem of clutter.

I do not see how "obscurity" disqualifies it as _a_ solution.

The fact that a construction worker does not know the Pythagoras
theorem does not mean that it is not the right solution if he needs to
compute the length of the stairway.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Bus error -- please leave by the rear door.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-26 15:36 ` Richard Stallman
  2002-07-26 17:53   ` Benjamin Rutt
@ 2002-07-28  0:15   ` Kim F. Storm
  2002-07-28  1:10     ` Miles Bader
  2002-07-29  1:42     ` Miles Bader
  1 sibling, 2 replies; 21+ messages in thread
From: Kim F. Storm @ 2002-07-28  0:15 UTC (permalink / raw)
  Cc: simon.marshall, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     IWBNI M-x occur created an *Occur in buf* buffer so that I wouldn't have
>     to do this, rather than *Occur*.
> 
> I think that for most users this would create unnecessary clutter.
> Perhaps it is best if you simply do this as a customization.

Alternatively, always name the buffer *Occur*, but provide a occur-save-buffer
command (bound to `s') which renames the buffer to *Occur: buffer*; then the
user can easily save precious occur buffers on a needed basis.

The same could be done for *Help* buffers where it would sometimes be very
useful to keep multiple help buffer around, e.g. *Help: save-buffer* and
*Help: bury-buffer*.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-28  0:15   ` Kim F. Storm
@ 2002-07-28  1:10     ` Miles Bader
  2002-07-29  8:31       ` Kim F. Storm
  2002-08-09  7:34       ` Stefan Monnier
  2002-07-29  1:42     ` Miles Bader
  1 sibling, 2 replies; 21+ messages in thread
From: Miles Bader @ 2002-07-28  1:10 UTC (permalink / raw)
  Cc: rms, simon.marshall, emacs-devel

On Sun, Jul 28, 2002 at 02:15:01AM +0200, Kim F. Storm wrote:
> Alternatively, always name the buffer *Occur*, but provide a occur-save-buffer
> command (bound to `s') which renames the buffer to *Occur: buffer*; then the
> user can easily save precious occur buffers on a needed basis.

As I noted, there already is such a command -- it's called `clone-buffer'.

-Miles
-- 
P.S.  All information contained in the above letter is false,
      for reasons of military security.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-28  0:15   ` Kim F. Storm
  2002-07-28  1:10     ` Miles Bader
@ 2002-07-29  1:42     ` Miles Bader
  1 sibling, 0 replies; 21+ messages in thread
From: Miles Bader @ 2002-07-29  1:42 UTC (permalink / raw)
  Cc: rms, simon.marshall, emacs-devel

There already is such a command, it's called `clone-buffer'.

-Miles
-- 
Come now, if we were really planning to harm you, would we be waiting here, 
 beside the path, in the very darkest part of the forest?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-28  1:10     ` Miles Bader
@ 2002-07-29  8:31       ` Kim F. Storm
  2002-07-30 14:20         ` Sam Steingold
  2002-08-09  7:34       ` Stefan Monnier
  1 sibling, 1 reply; 21+ messages in thread
From: Kim F. Storm @ 2002-07-29  8:31 UTC (permalink / raw)
  Cc: rms, simon.marshall, emacs-devel

Miles Bader <miles@gnu.org> writes:

> On Sun, Jul 28, 2002 at 02:15:01AM +0200, Kim F. Storm wrote:
> > Alternatively, always name the buffer *Occur*, but provide a occur-save-buffer
> > command (bound to `s') which renames the buffer to *Occur: buffer*; then the
> > user can easily save precious occur buffers on a needed basis.
> 
> As I noted, there already is such a command -- it's called `clone-buffer'.

I know, but the idea was to rename the occur buffer automatically to include
the name of the original buffer.  E.g. *Occur: xdisp.c* .

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: *Occur in buf*?
@ 2002-07-29 13:52 Marshall, Simon
  0 siblings, 0 replies; 21+ messages in thread
From: Marshall, Simon @ 2002-07-29 13:52 UTC (permalink / raw)
  Cc: emacs-devel, 'Andre Spiegel'

> Alternatively, always name the buffer *Occur*, but provide a 
> occur-save-buffer
> command (bound to `s') which renames the buffer to *Occur: 
> buffer*; then the
> user can easily save precious occur buffers on a needed basis.
> 
> The same could be done for *Help* buffers where it would 
> sometimes be very
> useful to keep multiple help buffer around, e.g. *Help: 
> save-buffer* and
> *Help: bury-buffer*.

Perhaps that's the best solution, since as you point out we can use it
in other Emacs-generated buffers.  I would find it useful for *VC-log*
buffers when checking in different files at the same time.  Or maybe
vc.el should always use the file buffer name in the temporary log buffer
name.

Perhaps there should be a command similar to rename-uniquely that runs
some function to generate a new name.  Different major modes could set
this function to do the appropriate thing, e.g., M-x occur to use the
original buffer's name; M-x describe-variable to use the variable's
name; etc.

The other suggestions:
Using defadvice (on a function I have to find in replace.el) is not easy
or intuitive.  (Richard, was this what you meant by "customization"?)
Using clone-buffer or rename-uniquely is not what I want---it will
increase the amount of clutter and will not make it easy to find the
buffer in the buffer list.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-29  8:31       ` Kim F. Storm
@ 2002-07-30 14:20         ` Sam Steingold
  2002-07-31  1:36           ` Miles Bader
                             ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Sam Steingold @ 2002-07-30 14:20 UTC (permalink / raw)
  Cc: Miles Bader, rms, simon.marshall, emacs-devel

> * In message <5xeldn7x5s.fsf@kfs2.cua.dk>
> * On the subject of "Re: *Occur in buf*?"
> * Sent on 29 Jul 2002 10:31:27 +0200
> * Honorable storm@cua.dk (Kim F. Storm) writes:
>
> Miles Bader <miles@gnu.org> writes:
> 
> > On Sun, Jul 28, 2002 at 02:15:01AM +0200, Kim F. Storm wrote:
> > > Alternatively, always name the buffer *Occur*, but provide a
> > > occur-save-buffer command (bound to `s') which renames the buffer
> > > to *Occur: buffer*; then the user can easily save precious occur
> > > buffers on a needed basis.
> > 
> > As I noted, there already is such a command -- it's called `clone-buffer'.
> 
> I know, but the idea was to rename the occur buffer automatically to
> include the name of the original buffer.  E.g. *Occur: xdisp.c* .

TRT, IMO, is to make `generate-new-buffer-name' mode-specific.
E.g., have a buffer-local variable 'uniquify-buffer-name' or a similar
property of the major-mode name, which would hold a mode-specific
function which is to be run in the buffer being renamed.

E.g., for occur-mode:

(defun occur-mode-uniquify ()
  (concat "*Occur: " (mapconcat #'buffer-name
                                (car (cddr occur-revert-arguments)) "/")
          "*"))

for help-mode:

(defun help-mode-uniquify ()
  (concat "*Help: "
          (case (car help-xref-stack-item)
            ((describe-function describe-variable)
             (symbol-name (cadr help-xref-stack-item)))
            ((describe-bindings)
             (concat "keybindings in buffer "
                     (buffer-name (window-buffer
                                   (car help-return-method)))))
            (t "???"))
          "*"))

etc.

Then `rename-buffer', `clone-buffer' &c will DTRT automatically.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
When you are arguing with an idiot, your opponent is doing the same.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-30 14:20         ` Sam Steingold
@ 2002-07-31  1:36           ` Miles Bader
  2002-07-31  5:54           ` Richard Stallman
  2002-08-09  7:32           ` Stefan Monnier
  2 siblings, 0 replies; 21+ messages in thread
From: Miles Bader @ 2002-07-31  1:36 UTC (permalink / raw)
  Cc: rms, simon.marshall, emacs-devel

Sam Steingold <sds@gnu.org> writes:
> TRT, IMO, is to make `generate-new-buffer-name' mode-specific.
> E.g., have a buffer-local variable 'uniquify-buffer-name' or a similar
> property of the major-mode name, which would hold a mode-specific
> function which is to be run in the buffer being renamed.

That sounds like a great solution (the variable should end in
`-function', following emacs convention,
e.g. 'uniquify-buffer-name-function').

-Miles
-- 
Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-30 14:20         ` Sam Steingold
  2002-07-31  1:36           ` Miles Bader
@ 2002-07-31  5:54           ` Richard Stallman
  2002-07-31 15:33             ` Sam Steingold
  2002-08-09  7:32           ` Stefan Monnier
  2 siblings, 1 reply; 21+ messages in thread
From: Richard Stallman @ 2002-07-31  5:54 UTC (permalink / raw)
  Cc: storm, miles, simon.marshall, emacs-devel

    > I know, but the idea was to rename the occur buffer automatically to
    > include the name of the original buffer.  E.g. *Occur: xdisp.c* .

    TRT, IMO, is to make `generate-new-buffer-name' mode-specific.
    E.g., have a buffer-local variable 'uniquify-buffer-name' or a similar
    property of the major-mode name, which would hold a mode-specific
    function which is to be run in the buffer being renamed.

This could be a reasonable idea.  Do people agree that there
is a particular "right" behavior for any given mode?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-31  5:54           ` Richard Stallman
@ 2002-07-31 15:33             ` Sam Steingold
  0 siblings, 0 replies; 21+ messages in thread
From: Sam Steingold @ 2002-07-31 15:33 UTC (permalink / raw)
  Cc: storm, miles, simon.marshall, emacs-devel

> * In message <200207310554.g6V5swA16517@aztec.santafe.edu>
> * On the subject of "Re: *Occur in buf*?"
> * Sent on Tue, 30 Jul 2002 23:54:58 -0600 (MDT)
> * Honorable Richard Stallman <rms@gnu.org> writes:
>
>     > I know, but the idea was to rename the occur buffer automatically to
>     > include the name of the original buffer.  E.g. *Occur: xdisp.c* .
> 
>     TRT, IMO, is to make `generate-new-buffer-name' mode-specific.
>     E.g., have a buffer-local variable 'uniquify-buffer-name' or a similar
>     property of the major-mode name, which would hold a mode-specific
>     function which is to be run in the buffer being renamed.
> 
> This could be a reasonable idea.  Do people agree that there
> is a particular "right" behavior for any given mode?

there is probably "right" behavior for most "*foo*" modes.
for file-visiting buffers &c we can always resort to <n>.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Whether pronounced "leenooks" or "line-uks", it's better than Windows.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-30 14:20         ` Sam Steingold
  2002-07-31  1:36           ` Miles Bader
  2002-07-31  5:54           ` Richard Stallman
@ 2002-08-09  7:32           ` Stefan Monnier
  2 siblings, 0 replies; 21+ messages in thread
From: Stefan Monnier @ 2002-08-09  7:32 UTC (permalink / raw)
  Cc: Kim F. Storm, Miles Bader, rms, simon.marshall, emacs-devel

> > > > Alternatively, always name the buffer *Occur*, but provide a
> > > > occur-save-buffer command (bound to `s') which renames the buffer
> > > > to *Occur: buffer*; then the user can easily save precious occur
> > > > buffers on a needed basis.
> > > As I noted, there already is such a command -- it's called `clone-buffer'.
> > I know, but the idea was to rename the occur buffer automatically to
> > include the name of the original buffer.  E.g. *Occur: xdisp.c* .
> 
> TRT, IMO, is to make `generate-new-buffer-name' mode-specific.

I think this is a good idea.  I'm not sure if a generic function
is necessary or if we can get away with a standard `buffer-topic'
variable (would contain the source buffer name for *Occur* buffers,
or the command name for *Help* buffers, ...) which rename-uniquely
and friends would use to generate pretty names.
I like the idea of `buffer-topic' (better name welcome) since we could
display it in ibuffer as well.

This issue of "*Help*" vs "*Help fun*" and friends is old.  There are
two issues:
- how to generate pretty names when calling rename-uniquely
(or clone-buffer since Miles seems to shy away from r-u ;-) and I think
your proposal above is a good solution to this problem (although
not as easy as it seems because the current foo<N> stuff is hardcoded
at a few places).
- whether to use a single buffer or several.  This one is more difficult
and will probably require customization.  Ideally

    (add-hook 'occur-mode-hook 'give-unique-name)

is all that's needed, but `give-unique-name' is still to be written.
Also ideally, there should be some way to set this hook "globally".

Of course this is also related to `uniquify', of course.  E.g.
in PCL-CVS I use "several buffers" by default so you don't need
to M-x r-u but then you may need to kill old *cvs* buffers
after a while.  By default the first buffer is called *cvs* but
is renamed by uniquify (just like dired buffers) as soon as
a second *cvs* buffer is created.

Maybe `buffer-topic' could be somewhat merged with
list-buffers-directory (used by dired and PCL-CVS to tell ibuffer
and uniquify which directory this is related to).


	Stefan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: *Occur in buf*?
  2002-07-28  1:10     ` Miles Bader
  2002-07-29  8:31       ` Kim F. Storm
@ 2002-08-09  7:34       ` Stefan Monnier
  1 sibling, 0 replies; 21+ messages in thread
From: Stefan Monnier @ 2002-08-09  7:34 UTC (permalink / raw)
  Cc: Kim F. Storm, rms, simon.marshall, emacs-devel

> > Alternatively, always name the buffer *Occur*, but provide a occur-save-buffer
> > command (bound to `s') which renames the buffer to *Occur: buffer*; then the
> > user can easily save precious occur buffers on a needed basis.
> 
> As I noted, there already is such a command -- it's called `clone-buffer'.

The lighter-weight (and older) one is `rename-uniquely'.


	Stefan

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2002-08-09  7:34 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 10:05 *Occur in buf*? Marshall, Simon
2002-07-25 13:42 ` Sam Steingold
2002-07-25 14:37   ` Miles Bader
2002-07-25 15:01     ` Sam Steingold
2002-07-26 15:36       ` Richard Stallman
2002-07-26 19:53         ` Sam Steingold
2002-07-26 15:36 ` Richard Stallman
2002-07-26 17:53   ` Benjamin Rutt
2002-07-28  0:15   ` Kim F. Storm
2002-07-28  1:10     ` Miles Bader
2002-07-29  8:31       ` Kim F. Storm
2002-07-30 14:20         ` Sam Steingold
2002-07-31  1:36           ` Miles Bader
2002-07-31  5:54           ` Richard Stallman
2002-07-31 15:33             ` Sam Steingold
2002-08-09  7:32           ` Stefan Monnier
2002-08-09  7:34       ` Stefan Monnier
2002-07-29  1:42     ` Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2002-07-25 16:07 Marshall, Simon
2002-07-25 18:46 ` Robert J. Chassell
2002-07-29 13:52 Marshall, Simon

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).