unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Use .emacs.d in savehist.el
@ 2005-10-24 15:58 Stefan Monnier
  2005-10-24 21:22 ` Kim F. Storm
                   ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Stefan Monnier @ 2005-10-24 15:58 UTC (permalink / raw)
  Cc: Hrvoje Niksic

Any objection to the patch below?


        Stefan


Index: lisp/savehist.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/savehist.el,v
retrieving revision 1.7
diff -u -r1.7 savehist.el
--- lisp/savehist.el	22 Oct 2005 17:45:50 -0000	1.7
+++ lisp/savehist.el	24 Oct 2005 15:55:38 -0000
@@ -110,7 +73,13 @@
   :type '(repeat (symbol :tag "Variable"))
   :group 'savehist)
 
-(defcustom savehist-file "~/.emacs-history"
+(defcustom savehist-file
+  (cond
+   ;; Backward compatibility with previous versions of savehist.
+   ((file-exists-p "~/.emacs-history") "~/.emacs-history")
+   ((and (not (featurep 'xemacs)) (file-directory-p "~/.emacs.d/"))
+    "~/.emacs.d/history")
+   (t "~/.emacs-history"))
-  "*File name to save minibuffer history to.
+  "File name to save minibuffer history to.
 The minibuffer history is a series of Lisp expressions, which should be
 loaded using `savehist-load' from your .emacs.  See `savehist-load' for

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

* Re: Use .emacs.d in savehist.el
  2005-10-24 15:58 Use .emacs.d in savehist.el Stefan Monnier
@ 2005-10-24 21:22 ` Kim F. Storm
  2005-10-25 20:27   ` Richard M. Stallman
  2005-10-25  9:30 ` Hrvoje Niksic
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Kim F. Storm @ 2005-10-24 21:22 UTC (permalink / raw)
  Cc: Hrvoje Niksic, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Any objection to the patch below?

I like it.

But shouldn't it create .emacs.d if it doesn't already exist?

I can think of several other packages which can benefit from 
this functionality (e.g. ido), so what about writing a function
which can make the decision on the fly --

and preferably move old files to .emacs.d.


Something like this [not tested]

(defcustom savehist-file 
           (expand-saved-state-file "history" "~/.emacs-history")
  "...")

(defun expand-saved-state-file (name &optional oldname)
  "Return expanded file-name NAME in directory ~/.emacs.d.
If OLDNAME exists, move that file into NAME, or delete OLDNAME if NAME
already exists."
  (let ((file (expand-file-name name "~/.emacs.d"))
	(oldfile (and oldname (expand-file-name oldname))))
    (if (and oldfile (file-exists-p oldfile))
	(if (file-exists-p file)
	    (delete-file oldfile)
	  (rename oldfile file)))
    file))

>
>
>         Stefan
>
>
> Index: lisp/savehist.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/savehist.el,v
> retrieving revision 1.7
> diff -u -r1.7 savehist.el
> --- lisp/savehist.el	22 Oct 2005 17:45:50 -0000	1.7
> +++ lisp/savehist.el	24 Oct 2005 15:55:38 -0000
> @@ -110,7 +73,13 @@
>    :type '(repeat (symbol :tag "Variable"))
>    :group 'savehist)
>  
> -(defcustom savehist-file "~/.emacs-history"
> +(defcustom savehist-file
> +  (cond
> +   ;; Backward compatibility with previous versions of savehist.
> +   ((file-exists-p "~/.emacs-history") "~/.emacs-history")
> +   ((and (not (featurep 'xemacs)) (file-directory-p "~/.emacs.d/"))
> +    "~/.emacs.d/history")
> +   (t "~/.emacs-history"))
> -  "*File name to save minibuffer history to.
> +  "File name to save minibuffer history to.
>  The minibuffer history is a series of Lisp expressions, which should be
>  loaded using `savehist-load' from your .emacs.  See `savehist-load' for
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
>

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

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

* Re: Use .emacs.d in savehist.el
  2005-10-24 15:58 Use .emacs.d in savehist.el Stefan Monnier
  2005-10-24 21:22 ` Kim F. Storm
@ 2005-10-25  9:30 ` Hrvoje Niksic
  2005-10-25 14:30   ` David Kastrup
  2005-10-25 14:51   ` Stefan Monnier
       [not found] ` <87oe5e977f.fsf@mahaena.lrde>
  2005-10-25 15:58 ` Richard M. Stallman
  3 siblings, 2 replies; 36+ messages in thread
From: Hrvoje Niksic @ 2005-10-25  9:30 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Any objection to the patch below?

Ideally I was aiming to have both emacsen share their minibuffer
histories, but I'm not sure if that's realistic.  I suppose the patch
is OK, except you might want to use ~/.xemacs under XEmacs.  Something
like:

(defcustom savehist-file
  (cond
   ;; Backward compatibility with previous versions of savehist.
   ((file-exists-p "~/.emacs-history") "~/.emacs-history")
   ((and (not (featurep 'xemacs)) (file-directory-p "~/.emacs.d/"))
    "~/.emacs.d/history")
   ((and (featurep 'xemacs) (file-directory-p "~/.xemacs/"))
    "~/.xemacs/history")
   ;; For users without .emacs.d.
   (t "~/.emacs-history"))
  "File name to save minibuffer history to.
The minibuffer history is a series of Lisp expressions, which should be
loaded using `savehist-load' from your .emacs.  See `savehist-load' for
more details."
  :type 'file
  :group 'savehist)

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

* Re: Use .emacs.d in savehist.el
       [not found] ` <87oe5e977f.fsf@mahaena.lrde>
@ 2005-10-25  9:59   ` Michael Cadilhac
  2005-10-25 14:54     ` Stefan Monnier
  0 siblings, 1 reply; 36+ messages in thread
From: Michael Cadilhac @ 2005-10-25  9:59 UTC (permalink / raw)



       (Sorry if this message appears twice)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Any objection to the patch below?
>
> +    "~/.emacs.d/history")

   Just for consistency sake, shouldn't it be `~/.emacs.d/.history', as
   we have ~/.emacs.d/.emacs ?

   I think `.emacs' is more likely to be most read by the user than the
   `history' file, so make this file hidden seems better, nop ?

-- 
    Michael Cadilhac, a.k.a. Micha [mika] |
                    Epita/LRDE promo 2007 |   )\._.,--....,'``.
  2 rue de la Convention | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'

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

* Re: Use .emacs.d in savehist.el
  2005-10-25  9:30 ` Hrvoje Niksic
@ 2005-10-25 14:30   ` David Kastrup
  2005-10-25 14:51   ` Stefan Monnier
  1 sibling, 0 replies; 36+ messages in thread
From: David Kastrup @ 2005-10-25 14:30 UTC (permalink / raw)
  Cc: Stefan Monnier, emacs-devel

Hrvoje Niksic <hniksic@xemacs.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> Any objection to the patch below?
>
> Ideally I was aiming to have both emacsen share their minibuffer
> histories, but I'm not sure if that's realistic.

I think it is in particular not desirable.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Use .emacs.d in savehist.el
  2005-10-25  9:30 ` Hrvoje Niksic
  2005-10-25 14:30   ` David Kastrup
@ 2005-10-25 14:51   ` Stefan Monnier
  2005-10-25 19:13     ` Hrvoje Niksic
  1 sibling, 1 reply; 36+ messages in thread
From: Stefan Monnier @ 2005-10-25 14:51 UTC (permalink / raw)
  Cc: emacs-devel

>> Any objection to the patch below?

> Ideally I was aiming to have both emacsen share their minibuffer
> histories, but I'm not sure if that's realistic.

Yes, that's the only objection I could imagine myself.  I'm not sure what to
think of it.  OT1H it makes sense to try and share the history, but OTOH
there's a pretty clear risk that it won't work right.
To be on the safe side, I think it's best to keep them separate (and
I think the fact that XEmacs now uses ~/.emacs/init.el in preference to
~/.emacs indicates that the XEmacs maintainers have followed a similar
reasoning).  For the few users who actively use both Emacs and XEmacs and
who care about sharing their histories, I'd say: customize the savehist-file
variable.

> I suppose the patch is OK, except you might want to use ~/.xemacs under
> XEmacs.

Thanks, I wasn't quite sure which dir to use for XEmacs and I figured you'd
know better ;-)


        Stefan

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

* Re: Use .emacs.d in savehist.el
  2005-10-25  9:59   ` Michael Cadilhac
@ 2005-10-25 14:54     ` Stefan Monnier
  2005-10-26 16:46       ` Richard M. Stallman
  2005-10-30  4:07       ` Chong Yidong
  0 siblings, 2 replies; 36+ messages in thread
From: Stefan Monnier @ 2005-10-25 14:54 UTC (permalink / raw)
  Cc: emacs-devel

>    Just for consistency sake, shouldn't it be `~/.emacs.d/.history', as
>    we have ~/.emacs.d/.emacs ?

I don't care about this kind of consistency.  The "." prefix doesn't make
much sense here: it's only useful to hide "administrative" files among other
non-adminitrative files.  E.g. in config files in ~ or for ~/.cvsignore.
If the user looks inside ~/.emacs.d he probably doesn't want to ignore the
emacs config file and the history file.  Otherwise, there won't be
anything left.  So if anything needs fixing it's the ~/.emacs.d/.emacs.


        Stefan

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

* Re: Use .emacs.d in savehist.el
  2005-10-24 15:58 Use .emacs.d in savehist.el Stefan Monnier
                   ` (2 preceding siblings ...)
       [not found] ` <87oe5e977f.fsf@mahaena.lrde>
@ 2005-10-25 15:58 ` Richard M. Stallman
  3 siblings, 0 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-25 15:58 UTC (permalink / raw)
  Cc: hniksic, emacs-devel

I think it is a good change.  It increases consistency.

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

* Re: Use .emacs.d in savehist.el
  2005-10-25 14:51   ` Stefan Monnier
@ 2005-10-25 19:13     ` Hrvoje Niksic
  0 siblings, 0 replies; 36+ messages in thread
From: Hrvoje Niksic @ 2005-10-25 19:13 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> Any objection to the patch below?
>
>> Ideally I was aiming to have both emacsen share their minibuffer
>> histories, but I'm not sure if that's realistic.
>
> Yes, that's the only objection I could imagine myself.  I'm not sure
> what to think of it.  OT1H it makes sense to try and share the
> history, but OTOH there's a pretty clear risk that it won't work
> right.

It should work correctly -- the only thing that could not work are the
differences in coding systems.

> For the few users who actively use both Emacs and XEmacs and who
> care about sharing their histories, I'd say: customize the
> savehist-file variable.

Agreed.  That's exactly what the code I proposed does.

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

* Re: Use .emacs.d in savehist.el
  2005-10-24 21:22 ` Kim F. Storm
@ 2005-10-25 20:27   ` Richard M. Stallman
  0 siblings, 0 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-25 20:27 UTC (permalink / raw)
  Cc: hniksic, monnier, emacs-devel

    But shouldn't it create .emacs.d if it doesn't already exist?

That would be a big general change in how Emacs stores its init files.
I don't want to go that far.

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

* Re: Use .emacs.d in savehist.el
  2005-10-25 14:54     ` Stefan Monnier
@ 2005-10-26 16:46       ` Richard M. Stallman
  2005-10-26 23:28         ` Miles Bader
  2005-10-27  9:16         ` Kim F. Storm
  2005-10-30  4:07       ` Chong Yidong
  1 sibling, 2 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-26 16:46 UTC (permalink / raw)
  Cc: michael.cadilhac, emacs-devel

    If the user looks inside ~/.emacs.d he probably doesn't want to ignore the
    emacs config file and the history file.  Otherwise, there won't be
    anything left.  So if anything needs fixing it's the ~/.emacs.d/.emacs.

I agree with that reasoning.  It looks like the file name
~/.emacs.d/.emacs is a feature added since the last release.  So there
is no problem removing the dot, and it would be better to do it now,
so that we avoid an incompatible change between releases.

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

* Re: Use .emacs.d in savehist.el
  2005-10-26 16:46       ` Richard M. Stallman
@ 2005-10-26 23:28         ` Miles Bader
  2005-10-27  3:58           ` Richard M. Stallman
  2005-10-27  9:16         ` Kim F. Storm
  1 sibling, 1 reply; 36+ messages in thread
From: Miles Bader @ 2005-10-26 23:28 UTC (permalink / raw)
  Cc: michael.cadilhac, Stefan Monnier, emacs-devel

2005/10/27, Richard M. Stallman <rms@gnu.org>:
>     If the user looks inside ~/.emacs.d he probably doesn't want to ignore the
>     emacs config file and the history file.  Otherwise, there won't be
>     anything left.  So if anything needs fixing it's the ~/.emacs.d/.emacs.
>
> I agree with that reasoning.  It looks like the file name
> ~/.emacs.d/.emacs is a feature added since the last release.  So there
> is no problem removing the dot, and it would be better to do it now,
> so that we avoid an incompatible change between releases.

BTW, the name "~/.emacs.d/emacs" (with or without a dot) seems rather
weird, and gives me little clue what the file actualy is for.  Is it
an init file, like ~/.emacs?  If so, something like
"~/.emacs.d/init.el" would be a great deal more clear...

[and as you say, this is the one chance to rename it without headaches, so...]

-Miles
--
Do not taunt Happy Fun Ball.

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

* Re: Use .emacs.d in savehist.el
  2005-10-26 23:28         ` Miles Bader
@ 2005-10-27  3:58           ` Richard M. Stallman
  2005-10-27 16:53             ` Kevin Rodgers
  2005-10-29  3:51             ` Chong Yidong
  0 siblings, 2 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-27  3:58 UTC (permalink / raw)
  Cc: michael.cadilhac, monnier, emacs-devel

    BTW, the name "~/.emacs.d/emacs" (with or without a dot) seems rather
    weird, and gives me little clue what the file actualy is for.  Is it
    an init file, like ~/.emacs?  If so, something like
    "~/.emacs.d/init.el" would be a great deal more clear...

That is a good point.

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

* Re: Use .emacs.d in savehist.el
  2005-10-26 16:46       ` Richard M. Stallman
  2005-10-26 23:28         ` Miles Bader
@ 2005-10-27  9:16         ` Kim F. Storm
  1 sibling, 0 replies; 36+ messages in thread
From: Kim F. Storm @ 2005-10-27  9:16 UTC (permalink / raw)
  Cc: emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:

>     If the user looks inside ~/.emacs.d he probably doesn't want to ignore the
>     emacs config file and the history file.  Otherwise, there won't be
>     anything left.  So if anything needs fixing it's the ~/.emacs.d/.emacs.
>
> I agree with that reasoning.  It looks like the file name
> ~/.emacs.d/.emacs is a feature added since the last release.  So there
> is no problem removing the dot, and it would be better to do it now,
> so that we avoid an incompatible change between releases.

Hear hear!

So why not call it with a proper name like

   ~/.emacs.d/emacs.el or (IMO better) ~/.emacs.d/init.el

?

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

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

* Re: Use .emacs.d in savehist.el
  2005-10-27  3:58           ` Richard M. Stallman
@ 2005-10-27 16:53             ` Kevin Rodgers
  2005-10-28 16:19               ` Richard M. Stallman
  2005-10-29  3:51             ` Chong Yidong
  1 sibling, 1 reply; 36+ messages in thread
From: Kevin Rodgers @ 2005-10-27 16:53 UTC (permalink / raw)


Richard M. Stallman wrote:
>     BTW, the name "~/.emacs.d/emacs" (with or without a dot) seems rather
>     weird, and gives me little clue what the file actualy is for.  Is it
>     an init file, like ~/.emacs?  If so, something like
>     "~/.emacs.d/init.el" would be a great deal more clear...
> 
> That is a good point.

I've always wondered where the "~/.emacs.d" directory name comes from.

Wouldn't (convert-standard-filename "~/.emacs_savehist") be more
obvious?

-- 
Kevin Rodgers

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

* Re: Use .emacs.d in savehist.el
  2005-10-27 16:53             ` Kevin Rodgers
@ 2005-10-28 16:19               ` Richard M. Stallman
  2005-10-28 20:16                 ` Miles Bader
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-28 16:19 UTC (permalink / raw)
  Cc: emacs-devel

    I've always wondered where the "~/.emacs.d" directory name comes from.

I think I chose that name.  It doesn't "come from" anywhere.

    Wouldn't (convert-standard-filename "~/.emacs_savehist") be more
    obvious?

convert-standard-filename does not do anything like this.

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

* Re: Use .emacs.d in savehist.el
  2005-10-28 16:19               ` Richard M. Stallman
@ 2005-10-28 20:16                 ` Miles Bader
  2005-10-29  5:12                   ` Richard M. Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Miles Bader @ 2005-10-28 20:16 UTC (permalink / raw)
  Cc: Kevin Rodgers, emacs-devel

2005/10/29, Richard M. Stallman <rms@gnu.org>:
>     Wouldn't (convert-standard-filename "~/.emacs_savehist") be more
>     obvious?
>
> convert-standard-filename does not do anything like this.

Though perhaps a standard function to do such name munging would be a
nice idea, e.g.:

  (user-customization-file-name BASE &optional DOTFILE)

if .emacs.d doesn't exist  =>  (concat "~/" (or DOTFILE (concat "." BASE)))
if .emacs.d does eixst     =>  (concat "~/.emacs.d/" BASE)

Then the savehist example would be (user-customization-file-name "savehist"),
and .emacs would be (user-customization-file-name "init.el" ".emacs")

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: Use .emacs.d in savehist.el
  2005-10-27  3:58           ` Richard M. Stallman
  2005-10-27 16:53             ` Kevin Rodgers
@ 2005-10-29  3:51             ` Chong Yidong
  2005-10-29 20:33               ` Richard M. Stallman
  1 sibling, 1 reply; 36+ messages in thread
From: Chong Yidong @ 2005-10-29  3:51 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

>     BTW, the name "~/.emacs.d/emacs" (with or without a dot) seems rather
>     weird, and gives me little clue what the file actualy is for.  Is it
>     an init file, like ~/.emacs?  If so, something like
>     "~/.emacs.d/init.el" would be a great deal more clear...
>
> That is a good point.

Shall I implement the ~/.emacs.d/init.el change?  I know where the
necessary documentation changes need to be made, so I can do that at
the same time.

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

* Re: Use .emacs.d in savehist.el
  2005-10-28 20:16                 ` Miles Bader
@ 2005-10-29  5:12                   ` Richard M. Stallman
  2005-10-29 17:31                     ` Kim F. Storm
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-29  5:12 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

    Though perhaps a standard function to do such name munging would be a
    nice idea, e.g.:

      (user-customization-file-name BASE &optional DOTFILE)

    if .emacs.d doesn't exist  =>  (concat "~/" (or DOTFILE (concat "." BASE)))
    if .emacs.d does eixst     =>  (concat "~/.emacs.d/" BASE)

    Then the savehist example would be (user-customization-file-name "savehist"),
    and .emacs would be (user-customization-file-name "init.el" ".emacs")

That does sound convenient.  Would you like to do it?

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

* Re: Use .emacs.d in savehist.el
  2005-10-29  5:12                   ` Richard M. Stallman
@ 2005-10-29 17:31                     ` Kim F. Storm
  2005-10-30  0:03                       ` Miles Bader
  0 siblings, 1 reply; 36+ messages in thread
From: Kim F. Storm @ 2005-10-29 17:31 UTC (permalink / raw)
  Cc: ihs_4664, snogglethorpe, emacs-devel, miles

"Richard M. Stallman" <rms@gnu.org> writes:

>     Though perhaps a standard function to do such name munging would be a
>     nice idea, e.g.:
>
>       (user-customization-file-name BASE &optional DOTFILE)
>
>     if .emacs.d doesn't exist  =>  (concat "~/" (or DOTFILE (concat "." BASE)))
>     if .emacs.d does eixst     =>  (concat "~/.emacs.d/" BASE)
>
>     Then the savehist example would be (user-customization-file-name "savehist"),
>     and .emacs would be (user-customization-file-name "init.el" ".emacs")
>
> That does sound convenient.  Would you like to do it?

I like this too, but functionality should be:

If DOTFILE non-nil and ~/DOTFILE exists, use ~/DOTFILE, else [as above].

Otherwise, some old DOTFILE will suddenly "disappear" if the user later creates .emacs.d



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

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

* Re: Use .emacs.d in savehist.el
  2005-10-29  3:51             ` Chong Yidong
@ 2005-10-29 20:33               ` Richard M. Stallman
  2005-10-30  4:00                 ` Chong Yidong
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-29 20:33 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

    Shall I implement the ~/.emacs.d/init.el change?  I know where the
    necessary documentation changes need to be made, so I can do that at
    the same time.

Please do.  And if you want to implement Miles' suggestion of a
subroutine to check the various file names, please do that too.

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

* Re: Use .emacs.d in savehist.el
  2005-10-29 17:31                     ` Kim F. Storm
@ 2005-10-30  0:03                       ` Miles Bader
  0 siblings, 0 replies; 36+ messages in thread
From: Miles Bader @ 2005-10-30  0:03 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel, rms, miles

2005/10/30, Kim F. Storm <storm@cua.dk>:
> I like this too, but functionality should be:
> If DOTFILE non-nil and ~/DOTFILE exists, use ~/DOTFILE, else [as above].
> Otherwise, some old DOTFILE will suddenly "disappear" if the user later creates .emacs.d

Good point; this rule should apply to implicitly specified dotfile
name too of course.

Here's an implementation that seems to get the details right (it
probably ought to check that "~/.emacs.d" is actually a directory,
rather than seeing if merely exists or not):

(defvar user-customization-file-dir "~/.emacs.d")

(defun user-customization-file-name (base &optional dotfile)
  (unless dotfile
    (setq dotfile (concat "." base)))
  (setq dotfile (expand-file-name dotfile "~"))
  (if (or (file-exists-p dotfile)
	  (not (file-exists-p user-customization-file-dir)))
      dotfile
    (expand-file-name base user-customization-file-dir)))

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: Use .emacs.d in savehist.el
  2005-10-29 20:33               ` Richard M. Stallman
@ 2005-10-30  4:00                 ` Chong Yidong
  2005-10-30  4:30                   ` Miles Bader
  0 siblings, 1 reply; 36+ messages in thread
From: Chong Yidong @ 2005-10-30  4:00 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

"Richard M. Stallman" <rms@gnu.org> writes:

>     Shall I implement the ~/.emacs.d/init.el change?  I know where the
>     necessary documentation changes need to be made, so I can do that at
>     the same time.
>
> Please do.  And if you want to implement Miles' suggestion of a
> subroutine to check the various file names, please do that too.

Done.

I didn't implement Miles' suggestion; it just doesn't seem necessary
(unless I'm missing something.)

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

* Re: Use .emacs.d in savehist.el
  2005-10-25 14:54     ` Stefan Monnier
  2005-10-26 16:46       ` Richard M. Stallman
@ 2005-10-30  4:07       ` Chong Yidong
  1 sibling, 0 replies; 36+ messages in thread
From: Chong Yidong @ 2005-10-30  4:07 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>    Just for consistency sake, shouldn't it be `~/.emacs.d/.history', as
>>    we have ~/.emacs.d/.emacs ?
>
> I don't care about this kind of consistency.  The "." prefix doesn't make
> much sense here: it's only useful to hide "administrative" files among other
> non-adminitrative files.  E.g. in config files in ~ or for ~/.cvsignore.
> If the user looks inside ~/.emacs.d he probably doesn't want to ignore the
> emacs config file and the history file.  Otherwise, there won't be
> anything left.  So if anything needs fixing it's the ~/.emacs.d/.emacs.

On a similar note, how about the shell init files .emacs_SHELLNAME?
Currently, they can go into ~/.emacs.d/ too.

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

* Re: Use .emacs.d in savehist.el
  2005-10-30  4:00                 ` Chong Yidong
@ 2005-10-30  4:30                   ` Miles Bader
  2005-10-30 13:59                     ` Chong Yidong
  0 siblings, 1 reply; 36+ messages in thread
From: Miles Bader @ 2005-10-30  4:30 UTC (permalink / raw)
  Cc: emacs-devel, michael.cadilhac, rms, monnier, miles

2005/10/30, Chong Yidong <cyd@stupidchicken.com>:
> I didn't implement Miles' suggestion; it just doesn't seem necessary
> (unless I'm missing something.)

The point is that are various simple rules and guidelines that apply
to _every_ customization file, if we allow them to go in either ~ or
in ~/.emacs.d, and it's silly to duplicate the code for each
customization file.

Centralizing the policy with a function also allows later changes or
enhancement to be done more easily and cleanly.

If you don't want to add it though, I will do it.

-Miles
--
Do not taunt Happy Fun Ball.

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

* Re: Use .emacs.d in savehist.el
  2005-10-30  4:30                   ` Miles Bader
@ 2005-10-30 13:59                     ` Chong Yidong
  2005-10-31  1:14                       ` Richard M. Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Chong Yidong @ 2005-10-30 13:59 UTC (permalink / raw)
  Cc: emacs-devel, michael.cadilhac, rms, monnier, miles

Miles Bader <snogglethorpe@gmail.com> writes:

>> I didn't implement Miles' suggestion; it just doesn't seem necessary
>> (unless I'm missing something.)
>
> The point is that are various simple rules and guidelines that apply
> to _every_ customization file, if we allow them to go in either ~ or
> in ~/.emacs.d, and it's silly to duplicate the code for each
> customization file.
>
> Centralizing the policy with a function also allows later changes or
> enhancement to be done more easily and cleanly.

OK, now I see.

It may or may not make sense to use such a function for the init file
(though I agree that it's useful for elsewhere in Emacs.)  The
`command-line' has some strange magic going on in it: instead of
checking whether the file exists and is readable, it sets
`user-init-file' to t, and tries to load the filename
(`user-init-file-1'):

      ;; This tells `load' to store the file name found
      ;; into user-init-file.
      (setq user-init-file t)
      (load user-init-file-1 t t)

If the `load' function succeeds, it automagically binds
`user-init-file' to the loaded filename.  I don't know why this was
written this way, but maybe there is a reason?

Also, if you want to use this function for the init file, you would
have to account for the "_emacs" dotfile name used on MS-DOS and
MS-Windows.  In particular, MS-Windows uses "~/.emacs" by default, but
if that is not available it accepts "~/_emacs" as the dotfile.


Another note: it seems to me that most libraries that use ".emacs.d"
look for it in "~".  Would it make sense to extend the
`init-file-user' variable so that the directory goes into

      (concat "~" init-file-user "/.emacs.d")

instead?  Or should `init-file-user' continue to apply to init files
only?

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

* Re: Use .emacs.d in savehist.el
  2005-10-30 13:59                     ` Chong Yidong
@ 2005-10-31  1:14                       ` Richard M. Stallman
  2005-10-31  2:29                         ` Chong Yidong
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-10-31  1:14 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

	  ;; This tells `load' to store the file name found
	  ;; into user-init-file.
	  (setq user-init-file t)
	  (load user-init-file-1 t t)

    If the `load' function succeeds, it automagically binds
    `user-init-file' to the loaded filename.  I don't know why this was
    written this way, but maybe there is a reason?

The reason is to record the actual name found, whether it be .emacs or
.emacs.el, or whatever.

We need the actual file name, not just something that we could
pass to `load' and load the same file.

    Also, if you want to use this function for the init file, you would
    have to account for the "_emacs" dotfile name used on MS-DOS and
    MS-Windows.  In particular, MS-Windows uses "~/.emacs" by default, but
    if that is not available it accepts "~/_emacs" as the dotfile.

That particular case does seem to needs special code.
It is no big deal if the one case of .emacs can't use the
general function (but it would be nice if it could).

    Another note: it seems to me that most libraries that use ".emacs.d"
    look for it in "~".  Would it make sense to extend the
    `init-file-user' variable so that the directory goes into

	  (concat "~" init-file-user "/.emacs.d")

Yes!

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

* Re: Use .emacs.d in savehist.el
  2005-10-31  1:14                       ` Richard M. Stallman
@ 2005-10-31  2:29                         ` Chong Yidong
  2005-11-01  2:14                           ` Richard M. Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Chong Yidong @ 2005-10-31  2:29 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

>     Another note: it seems to me that most libraries that use ".emacs.d"
>     look for it in "~".  Would it make sense to extend the
>     `init-file-user' variable so that the directory goes into
>
> 	  (concat "~" init-file-user "/.emacs.d")
>
> Yes!

You sure?  What is the intended usage of init-file-user anyway?

If normal libraries follow init-file-user, you could have a situation
where a user tries to write customization files into the home
directory of another user.  This doesn't make much sense, but I don't
understand when it makes sense to set init-file-user in the first
place.

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

* Re: Use .emacs.d in savehist.el
  2005-10-31  2:29                         ` Chong Yidong
@ 2005-11-01  2:14                           ` Richard M. Stallman
  2005-11-01  3:43                             ` Chong Yidong
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-11-01  2:14 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

    If normal libraries follow init-file-user, you could have a situation
    where a user tries to write customization files into the home
    directory of another user.  This doesn't make much sense, but I don't
    understand when it makes sense to set init-file-user in the first
    place.

If the customized values that Emacs read _came from_ another user's
init file, the only place to store them back is into that user's init
file.

Ordinarily you won't be able to write that file.  Instead you will get
a clear error message saying so.  That seems correct to me.

Meanwhile, in at least one case you WILL be able to write that file.
Namely, when you are root and you told Emacs to use your own personal
init file.  (In particular, this is what happens when you run emacs
under su.)

So we ought to make this work.

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

* Re: Use .emacs.d in savehist.el
  2005-11-01  2:14                           ` Richard M. Stallman
@ 2005-11-01  3:43                             ` Chong Yidong
  2005-11-01  5:12                               ` Stefan Monnier
  2005-11-02 10:26                               ` Richard M. Stallman
  0 siblings, 2 replies; 36+ messages in thread
From: Chong Yidong @ 2005-11-01  3:43 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

>     If normal libraries follow init-file-user, you could have a situation
>     where a user tries to write customization files into the home
>     directory of another user.  This doesn't make much sense, but I don't
>     understand when it makes sense to set init-file-user in the first
>     place.
>
> If the customized values that Emacs read _came from_ another user's
> init file, the only place to store them back is into that user's init
> file.
>
> Ordinarily you won't be able to write that file.  Instead you will get
> a clear error message saying so.  That seems correct to me.
>
> Meanwhile, in at least one case you WILL be able to write that file.
> Namely, when you are root and you told Emacs to use your own personal
> init file.  (In particular, this is what happens when you run emacs
> under su.)

When you are root, creating a file or directory in another user's home
directory is problematic.  The file will be owned by root, and the
user won't be able to write to it.

I looked into the possibility of making Miles' "find customization
file" function do a chown and chgrp on the customization file, so that
this problem won't arise.  But Emacs doesn't have any built-in chown
or chgrp.  Dired can do it, but it's by calling an external program.

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

* Re: Use .emacs.d in savehist.el
  2005-11-01  3:43                             ` Chong Yidong
@ 2005-11-01  5:12                               ` Stefan Monnier
  2005-11-01 12:54                                 ` Chong Yidong
  2005-11-02 10:26                                 ` Richard M. Stallman
  2005-11-02 10:26                               ` Richard M. Stallman
  1 sibling, 2 replies; 36+ messages in thread
From: Stefan Monnier @ 2005-11-01  5:12 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, rms, miles

> When you are root, creating a file or directory in another user's home
> directory is problematic.  The file will be owned by root, and the
> user won't be able to write to it.

He can copy it, remove it, and then replace it, tho, so it's not nearly as
serious as it sounds.  Directories are more problematic.

> I looked into the possibility of making Miles' "find customization
> file" function do a chown and chgrp on the customization file, so that
> this problem won't arise.  But Emacs doesn't have any built-in chown
> or chgrp.  Dired can do it, but it's by calling an external program.

I tend to think that people who use "emacs -u foo" as root just get what
they deserve.


        Stefan

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

* Re: Use .emacs.d in savehist.el
  2005-11-01  5:12                               ` Stefan Monnier
@ 2005-11-01 12:54                                 ` Chong Yidong
  2005-11-02 10:27                                   ` Richard M. Stallman
  2005-11-02 10:26                                 ` Richard M. Stallman
  1 sibling, 1 reply; 36+ messages in thread
From: Chong Yidong @ 2005-11-01 12:54 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, rms, miles

>> I looked into the possibility of making Miles' "find customization
>> file" function do a chown and chgrp on the customization file, so that
>> this problem won't arise.  But Emacs doesn't have any built-in chown
>> or chgrp.  Dired can do it, but it's by calling an external program.
>
> I tend to think that people who use "emacs -u foo" as root just get what
> they deserve.

In that case, maybe using root's own .emacs.d is actually the safer
thing to do, even if it is inconsistent with the meaning of "-u foo".

Here are two possibilities I can think of:

1. Let `init-file-user' apply to the init file only.  The init file
   has enough complications anyway that Miles' proposed function won't
   do the trick (apart from `init-file-user', there is the MS-DOS
   "_emacs" issue).  That function can be implemented so other
   libraries can use it, but it ignores init-file-user.

2. Go through the code in such a way that when init-file-user is
   non-nil, files are *read* from ~INIT_FILE_USER/.emacs.d, but
   *written* to the user's own home directory.  This can be made
   simpler by implementing Miles' function with an optional
   `read-only' argument, but we will still have to go through all the
   places that currently use .emacs.d to make sure they DTRT.

Personally, I like the first possibility because it's much
simpler... no one has actually complained about the interaction
between .emacs.d and init-file-user (at least until I brought it up
:-P), so I think it's not a big enough problem to justify a
far-reaching fix, especially close to release.

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

* Re: Use .emacs.d in savehist.el
  2005-11-01  3:43                             ` Chong Yidong
  2005-11-01  5:12                               ` Stefan Monnier
@ 2005-11-02 10:26                               ` Richard M. Stallman
  1 sibling, 0 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-11-02 10:26 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

    When you are root, creating a file or directory in another user's home
    directory is problematic.  The file will be owned by root, and the
    user won't be able to write to it.

It sounds easy to fix.

      But Emacs doesn't have any built-in chown
    or chgrp.  Dired can do it, but it's by calling an external program.

I see no disgrace in using an external program.  Why worry about it?
(We could add a function to do it, if we want to.)

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

* Re: Use .emacs.d in savehist.el
  2005-11-01  5:12                               ` Stefan Monnier
  2005-11-01 12:54                                 ` Chong Yidong
@ 2005-11-02 10:26                                 ` Richard M. Stallman
  1 sibling, 0 replies; 36+ messages in thread
From: Richard M. Stallman @ 2005-11-02 10:26 UTC (permalink / raw)
  Cc: miles, cyd, snogglethorpe, michael.cadilhac, emacs-devel

    I tend to think that people who use "emacs -u foo" as root just get what
    they deserve.

If you su to root, Emacs automatically uses your own init file.

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

* Re: Use .emacs.d in savehist.el
  2005-11-01 12:54                                 ` Chong Yidong
@ 2005-11-02 10:27                                   ` Richard M. Stallman
  2005-11-02 15:54                                     ` Stefan Monnier
  0 siblings, 1 reply; 36+ messages in thread
From: Richard M. Stallman @ 2005-11-02 10:27 UTC (permalink / raw)
  Cc: emacs-devel, snogglethorpe, michael.cadilhac, monnier, miles

    In that case, maybe using root's own .emacs.d is actually the safer
    thing to do, even if it is inconsistent with the meaning of "-u foo".

I don't agree with Stefan.  I want this to work right,
which means, to edit the init file of the specified user,
or get an error if it can't write that file.

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

* Re: Use .emacs.d in savehist.el
  2005-11-02 10:27                                   ` Richard M. Stallman
@ 2005-11-02 15:54                                     ` Stefan Monnier
  0 siblings, 0 replies; 36+ messages in thread
From: Stefan Monnier @ 2005-11-02 15:54 UTC (permalink / raw)
  Cc: Chong Yidong, snogglethorpe, michael.cadilhac, emacs-devel, miles

>     In that case, maybe using root's own .emacs.d is actually the safer
>     thing to do, even if it is inconsistent with the meaning of "-u foo".

> I don't agree with Stefan.  I want this to work right,
> which means, to edit the init file of the specified user,
> or get an error if it can't write that file.

For what it's worth I agree with that, at least if it means not doing
anything special for root.  That towhich I'm opposed is code that
special-cases the situation where the user is root.

People who run Emas as root should get what they ask for (aka what they
deserve).  If they don't like it because it's "dangerous" they should simply
not do it.


        Stefan

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

end of thread, other threads:[~2005-11-02 15:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-24 15:58 Use .emacs.d in savehist.el Stefan Monnier
2005-10-24 21:22 ` Kim F. Storm
2005-10-25 20:27   ` Richard M. Stallman
2005-10-25  9:30 ` Hrvoje Niksic
2005-10-25 14:30   ` David Kastrup
2005-10-25 14:51   ` Stefan Monnier
2005-10-25 19:13     ` Hrvoje Niksic
     [not found] ` <87oe5e977f.fsf@mahaena.lrde>
2005-10-25  9:59   ` Michael Cadilhac
2005-10-25 14:54     ` Stefan Monnier
2005-10-26 16:46       ` Richard M. Stallman
2005-10-26 23:28         ` Miles Bader
2005-10-27  3:58           ` Richard M. Stallman
2005-10-27 16:53             ` Kevin Rodgers
2005-10-28 16:19               ` Richard M. Stallman
2005-10-28 20:16                 ` Miles Bader
2005-10-29  5:12                   ` Richard M. Stallman
2005-10-29 17:31                     ` Kim F. Storm
2005-10-30  0:03                       ` Miles Bader
2005-10-29  3:51             ` Chong Yidong
2005-10-29 20:33               ` Richard M. Stallman
2005-10-30  4:00                 ` Chong Yidong
2005-10-30  4:30                   ` Miles Bader
2005-10-30 13:59                     ` Chong Yidong
2005-10-31  1:14                       ` Richard M. Stallman
2005-10-31  2:29                         ` Chong Yidong
2005-11-01  2:14                           ` Richard M. Stallman
2005-11-01  3:43                             ` Chong Yidong
2005-11-01  5:12                               ` Stefan Monnier
2005-11-01 12:54                                 ` Chong Yidong
2005-11-02 10:27                                   ` Richard M. Stallman
2005-11-02 15:54                                     ` Stefan Monnier
2005-11-02 10:26                                 ` Richard M. Stallman
2005-11-02 10:26                               ` Richard M. Stallman
2005-10-27  9:16         ` Kim F. Storm
2005-10-30  4:07       ` Chong Yidong
2005-10-25 15:58 ` Richard M. Stallman

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