unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs Improvement
@ 2004-01-08 15:36 Adam Morton
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Morton @ 2004-01-08 15:36 UTC (permalink / raw)



Hello I'm a PHP programmer and an avid emacs user.  This is an issue that
comes up every day with me and is just generally annoying.

If you initially open a file in emacs (say test.php), C-x C-f to select
another file (say test2.php), then when you've opened test2.php, you C-x
C-f again and hit the up arrow to get the last file, emacs says "No
preceding file found" or something similar, when it should allow you to
hit the up arrow and get the original test.php file that was being edited
first.

Please take a look at addressing this issue as I have spoken to other
emacs users that believe this would be a good change to the current
behavior.  If there is some flag I need to set that allows the first file
opened to be placed in the history list, then please educate me as to what
it is because I cannot find any information on this issue anywhere.

Thank you for your time,
Adam

-- 
Adam Morton
Developer - Appalachian Technologies
http://www.apptechnc.net
Founder - Appalachian Linux Users Group
http://alug.appstate.edu

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

* Re: Emacs Improvement
       [not found] <mailman.229.1073581027.928.bug-gnu-emacs@gnu.org>
@ 2004-01-08 16:45 ` Klaus Uhl
  2004-01-09 13:04   ` era
  0 siblings, 1 reply; 8+ messages in thread
From: Klaus Uhl @ 2004-01-08 16:45 UTC (permalink / raw)


Hello Adam,

"Adam Morton" <adam@tux.appstate.edu> writes:

> Hello I'm a PHP programmer and an avid emacs user.  This is an issue that
> comes up every day with me and is just generally annoying.
> 
> If you initially open a file in emacs (say test.php), C-x C-f to select
> another file (say test2.php), then when you've opened test2.php, you C-x
> C-f again and hit the up arrow to get the last file, emacs says "No
> preceding file found" or something similar, when it should allow you to
> hit the up arrow and get the original test.php file that was being edited
> first.

I hope I correctly understood what you did. You just opened two files
in emacs without closing the first of them explicitly.

Emacs does not automatically close buffers (i.e. files in your case)
when you open a different buffer (or file) but keeps those buffers
open but invisible. So you do not need to reopen the first file. You
simply can switch to this file by either using the "Buffers" menu or
by typing C-x b and supplying the name of the buffer you want to
switch to. If you type the TAB key instead you get a buffer which
shows all currently open buffers. 

Read the chapter "Using Multiple Buffers" in the emacs manual for more
information.

BTW. The C-x b command supporst a history of the last visited buffers
which seems to be what you want.

--

                 God is real ...
\|/ ____ \|/     ... unless declared integer.
"@'/ ,. \`@"     
\_| \__/ |_/     Mail me : news@u-h-l.de
   \__U_/        WWW     : www.u-h-l.de
                 PGP     : Look at your favourite PGP-keyserver

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

* Re: Emacs Improvement
  2004-01-08 16:45 ` Klaus Uhl
@ 2004-01-09 13:04   ` era
  2004-01-10  0:43     ` Arturo García Ares
  0 siblings, 1 reply; 8+ messages in thread
From: era @ 2004-01-09 13:04 UTC (permalink / raw)


On 08 Jan 2004 17:45:57 +0100, Klaus Uhl <news@u-h-l.de> posted to
bug-gnu-emacs:
 > "Adam Morton" <adam@tux.appstate.edu> writes:
 >> Hello I'm a PHP programmer and an avid emacs user.  This is an issue that
 >> comes up every day with me and is just generally annoying.
 >> If you initially open a file in emacs (say test.php), C-x C-f to select
 >> another file (say test2.php), then when you've opened test2.php, you C-x
 >> C-f again and hit the up arrow to get the last file, emacs says "No
 >> preceding file found" or something similar, when it should allow you to
 >> hit the up arrow and get the original test.php file that was being edited
 >> first.
 > I hope I correctly understood what you did. You just opened two files
 > in emacs without closing the first of them explicitly.
 > Emacs does not automatically close buffers (i.e. files in your case)
 > when you open a different buffer (or file) but keeps those buffers
 > open but invisible. So you do not need to reopen the first file. You
 > simply can switch to this file by either using the "Buffers" menu or
 > by typing C-x b and supplying the name of the buffer you want to
 > switch to. If you type the TAB key instead you get a buffer which
 > shows all currently open buffers. 

Or maybe he just wants whatever file(s) he specified on the command
line to also be added to the minibuffer history. I don't see a good
reason for that, but it shouldn't be hard to do. (It's not a very
intuitive thing to do so it should probably not be made the default,
and probably not even a feature shipped with Emacs, but somebody could
easily hook up a snippet to put in your .emacs.)

/* era */

-- 
The email address era     the contact information   Just for kicks, imagine
at iki dot fi is heavily  link on my home page at   what it's like to get
spam filtered.  If you    <http://www.iki.fi/era/>  500 pieces of spam for
want to reach me, see     instead.                  each wanted message.

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

* Re: Emacs Improvement
  2004-01-09 13:04   ` era
@ 2004-01-10  0:43     ` Arturo García Ares
  2004-01-12 11:44       ` era
  0 siblings, 1 reply; 8+ messages in thread
From: Arturo García Ares @ 2004-01-10  0:43 UTC (permalink / raw)


On Fri, Jan 09, 2004 at 03:04:17PM +0200, era@iki.fi wrote:

> Or maybe he just wants whatever file(s) he specified on the command
> line to also be added to the minibuffer history. I don't see a good
> reason for that, but it shouldn't be hard to do. (It's not a very
> intuitive thing to do so it should probably not be made the default,
> and probably not even a feature shipped with Emacs, but somebody could
> easily hook up a snippet to put in your .emacs.)

This is such a snippet:

(add-hook 'find-file-hooks
          (lambda ()
            (add-to-list 'file-name-history
                         (abbreviate-file-name (buffer-file-name)))))
					       

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

* Re: Emacs Improvement
  2004-01-10  0:43     ` Arturo García Ares
@ 2004-01-12 11:44       ` era
  2004-01-12 17:27         ` Arturo García Ares
  0 siblings, 1 reply; 8+ messages in thread
From: era @ 2004-01-12 11:44 UTC (permalink / raw)


On Sat, 10 Jan 2004 01:43:09 +0100, Arturo García Ares
<arturo@pikatoste.homeip.net> posted to bug-gnu-emacs:
 > On Fri, Jan 09, 2004 at 03:04:17PM +0200, era@iki.fi wrote:
 >> Or maybe he just wants whatever file(s) he specified on the command
 >> line to also be added to the minibuffer history. I don't see a good
 >> reason for that, but it shouldn't be hard to do. (It's not a very
 >> intuitive thing to do so it should probably not be made the default,
 >> and probably not even a feature shipped with Emacs, but somebody could
 >> easily hook up a snippet to put in your .emacs.)
 > This is such a snippet:
 > (add-hook 'find-file-hooks
 >           (lambda ()
 >             (add-to-list 'file-name-history
 >                          (abbreviate-file-name (buffer-file-name)))))

This modifies what happens when you M-x find-file within Emacs, not
what happens with file name arguments passed in on the command line.
Also it duplicates what Emacs already does by itself (you don't get
duplicates on file-name-history because add-to-list won't add a file
name which is there already).

I'd imagine something like emacs-startup-hook could be used to add the
contents of command-line-args-left or some such to file-name-history.
(Correction: I couldn't quickly figure out how to get a list of the
files which were passed in as command-line arguments.)

Oh heck, here:

  (require 'cl)
  (add-hook 'emacs-startup-hook
            (lambda ()
              (mapc (lambda (buf)
                      (let ((file (buffer-file-name buf)))
                        (when file
                          (add-to-list 'file-name-history file)) ))
                    (buffer-list) ) ))

It's probably not sufficiently tested.

Oh, and feel free to add abbreviate-file-name back on.

/* era */

-- 
The email address era     the contact information   Just for kicks, imagine
at iki dot fi is heavily  link on my home page at   what it's like to get
spam filtered.  If you    <http://www.iki.fi/era/>  500 pieces of spam for
want to reach me, see     instead.                  each wanted message.

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

* Re: Emacs Improvement
  2004-01-12 11:44       ` era
@ 2004-01-12 17:27         ` Arturo García Ares
  2004-01-13  7:33           ` era
  0 siblings, 1 reply; 8+ messages in thread
From: Arturo García Ares @ 2004-01-12 17:27 UTC (permalink / raw)
  Cc: bug-gnu-emacs

On Mon, Jan 12, 2004 at 01:44:14PM +0200, era@iki.fi wrote:
>  > This is such a snippet:
>  > (add-hook 'find-file-hooks
>  >           (lambda ()
>  >             (add-to-list 'file-name-history
>  >                          (abbreviate-file-name (buffer-file-name)))))
> 
> This modifies what happens when you M-x find-file within Emacs, not
> what happens with file name arguments passed in on the command line.
> Also it duplicates what Emacs already does by itself (you don't get
> duplicates on file-name-history because add-to-list won't add a file
> name which is there already).

File names passed as arguments to emacs are opened via find-file, so in
effect the above code adds those files to file-name-history.
Yes: duplicates are (intentionally) avoided by add-to-list, and it's
not optimal to let the hook execute for every visited file when it's
only required for non-interactive (by interactive I mean those opened
via C-x C-f) file opens. Nevertheless, it's harmless, except for the
extra cpu cycles. It's just a quick hack tu put in your .emacs, but it
does the job (have you tried it?)

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

* Re: Emacs Improvement
  2004-01-12 17:27         ` Arturo García Ares
@ 2004-01-13  7:33           ` era
  2004-01-13 21:21             ` Arturo García Ares
  0 siblings, 1 reply; 8+ messages in thread
From: era @ 2004-01-13  7:33 UTC (permalink / raw)


On Mon, 12 Jan 2004 18:27:51 +0100, Arturo García Ares
<arturo@pikatoste.homeip.net> posted to bug-gnu-emacs:
 > On Mon, Jan 12, 2004 at 01:44:14PM +0200, era@iki.fi wrote:
 >> > This is such a snippet:
 >> > (add-hook 'find-file-hooks
 >> >           (lambda ()
 >> >             (add-to-list 'file-name-history
 >> >                          (abbreviate-file-name (buffer-file-name)))))
 >> This modifies what happens when you M-x find-file within Emacs, not
 >> what happens with file name arguments passed in on the command line.
 >> Also it duplicates what Emacs already does by itself (you don't get
 >> duplicates on file-name-history because add-to-list won't add a file
 >> name which is there already).
 > File names passed as arguments to emacs are opened via find-file, so in
 > effect the above code adds those files to file-name-history.
 > Yes: duplicates are (intentionally) avoided by add-to-list, and it's
 > not optimal to let the hook execute for every visited file when it's
 > only required for non-interactive (by interactive I mean those opened
 > via C-x C-f) file opens. Nevertheless, it's harmless, except for the
 > extra cpu cycles. It's just a quick hack tu put in your .emacs, but it
 > does the job (have you tried it?)

Yes, I tried it, and it didn't work for me. But maybe my Emacs is too
old (or too new? :-)

/* era */

-- 
The email address era     the contact information   Just for kicks, imagine
at iki dot fi is heavily  link on my home page at   what it's like to get
spam filtered.  If you    <http://www.iki.fi/era/>  500 pieces of spam for
want to reach me, see     instead.                  each wanted message.

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

* Re: Emacs Improvement
  2004-01-13  7:33           ` era
@ 2004-01-13 21:21             ` Arturo García Ares
  0 siblings, 0 replies; 8+ messages in thread
From: Arturo García Ares @ 2004-01-13 21:21 UTC (permalink / raw)


On Tue, Jan 13, 2004 at 09:33:37AM +0200, era@iki.fi wrote:
>  > does the job (have you tried it?)
> 
> Yes, I tried it, and it didn't work for me. But maybe my Emacs is too
> old (or too new? :-)

strange ... it works on mine:

$ emacs -version
GNU Emacs 21.3.1
[...]

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

end of thread, other threads:[~2004-01-13 21:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-08 15:36 Emacs Improvement Adam Morton
     [not found] <mailman.229.1073581027.928.bug-gnu-emacs@gnu.org>
2004-01-08 16:45 ` Klaus Uhl
2004-01-09 13:04   ` era
2004-01-10  0:43     ` Arturo García Ares
2004-01-12 11:44       ` era
2004-01-12 17:27         ` Arturo García Ares
2004-01-13  7:33           ` era
2004-01-13 21:21             ` Arturo García Ares

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).