unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28685: 25.3; wrong handling ~/.cpp.el
@ 2017-10-03 11:19 Masatake YAMATO
  2017-10-14  5:38 ` Noam Postavsky
  0 siblings, 1 reply; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-03 11:19 UTC (permalink / raw)
  To: 28685

cpp.el tries to load ./.cpp.el even when it is not readable.  Though
it checks ~/.cpp.el can be readable, it still tries to load ./.cpp.el.

A patch is attached to the end of this mail.

In GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.19)
 of 2017-09-12 built on buildvm-08.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.11903000
System Description:	Fedora release 26 (Twenty Six)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg
 --with-png --with-rsvg --with-tiff --with-xft --with-xpm
 --with-x-toolkit=gtk3 --with-gpm=no --with-xwidgets --with-modules
 build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
 -m64 -mtune=generic' LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
  value of $LC_MONETARY: ja_JP.UTF-8
  value of $LC_NUMERIC: ja_JP.UTF-8
  value of $LC_TIME: ja_JP.UTF-8
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  which-function-mode: t
  show-paren-mode: t
  savehist-mode: t
  winner-mode: t
  iswitchb-mode: t
  editorconfig-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Undo! [2 times]
Mark set [5 times]
Saving file /home/yamato/var/emacs/MESSAGE...
Wrote /home/yamato/var/emacs/MESSAGE
line-move-visual: Beginning of buffer [13 times]
Mark set
Saving file /home/yamato/var/emacs/MESSAGE...
Wrote /home/yamato/var/emacs/MESSAGE
Saving file /home/yamato/var/emacs/MESSAGE...
Wrote /home/yamato/var/emacs/MESSAGE
line-move-visual: Beginning of buffer [7 times]

Load-path shadows:
/home/yamato/.emacs.d/ioccur hides /home/yamato/.emacs.d/elpa/ioccur-2.4/ioccur
/home/yamato/.emacs.d/markdown-mode hides /home/yamato/.emacs.d/elpa/markdown-mode-20160928.932/markdown-mode
/home/yamato/.emacs.d/bs hides /usr/share/emacs/25.3/lisp/bs

Features:
(shadow emacsbug message idna rfc822 mml mml-sec epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums bug-reference cpp whitespace
go-mode find-file ffap css-mode ruby-mode markdown-mode ewoc eww
mm-url gnus gnus-ems nnheader mail-utils url-queue url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse url-vars mailcap shr dom debug tramp-cache
cmake-mode rx nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt
rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util
nxml-glyph nxml-enc xmltok desktop-entry-mode conf-mode js sgml-mode
lookup-entry lookup-content lookup-vse ndtp lookup lookup-types
lookup-utils lookup-vars evi evi-mule smerge-mode novice log-view
pcvs-util vc-annotate tex-mode latexenc ediff-merg ediff-wind
ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff python
tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize
format-spec json map rst eieio-opt speedbar sb-image ezimage dframe
find-func bat-mode make-mode yaml-mode dabbrev ispell vc pcmpl-unix
autoconf autoconf-mode vc-git diff-mode sh-script smie executable rect
skk-isearch skk-comp skk-cdb cdb skk-num skk-tankan skk-cursor
skk-server skk-cus cus-edit skk skk-emacs skk-macs hl-line shell
pcomplete thingatpt tabify man parse-time cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs misearch
multi-isearch skk-vars dired-aux zoom-frm frame-cmds frame-fns pp qp
network-stream nsm auth-source gnus-util mm-util help-fns mail-prsvr
password-cache starttls tls gnutls mew-varsx mew-unix warnings ccc
spelunker etags xref project eieio eieio-core assoc ibuf-macs ibuf-ext
ibuffer grep srpmix-guess col-highlight vline dee-record scheme
edit-string tour stitch vc-dispatcher vc-svn editorconfig-core
editorconfig-core-handle editorconfig-fnmatch avoid add-log mew-w3m
w3m doc-view subr-x jka-compr image-mode timezone w3m-hist w3m-fb
bookmark-w3m w3m-ems wid-edit w3m-ccl w3m-favicon w3m-image w3m-proc
w3m-util mew-auth mew-config mew-imap2 mew-imap mew-nntp2 mew-nntp
mew-pop mew-smtp mew-ssl mew-ssh mew-net mew-highlight mew-sort
mew-fib mew-ext mew-refile mew-demo mew-attach mew-draft mew-message
mew-thread mew-virtual mew-summary4 mew-summary3 mew-summary2
mew-summary mew-search mew-pick mew-passwd mew-scan mew-syntax mew-bq
mew-smime mew-pgp mew-header mew-exec mew-mark mew-mime mew-edit
mew-decode mew-encode mew-cache mew-minibuf mew-complete mew-addrbook
mew-local mew-vars3 mew-vars2 mew-vars mew-env mew-mule3 mew-mule
mew-gemacs mew-key mew-func mew-blvs mew-const mew mew-ical cal-menu
calendar cal-loaddefs browse-url tango-dark-theme which-func imenu
paren savehist cus-start cus-load yamato izonmoji-mode ccl dired-tar
compile comint ansi-color server winner ring windmove gauche
scheme-complete graphviz-dot-mode ioccur cl-seq cl-macs edmacro kmacro
wdired noutline outline easy-mmode cl derived dired-x dired iswitchb
editorconfig finder-inf info go-mode-autoloads ioccur-autoloads
minimap-autoloads register-list-autoloads package epg-config seq
byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv
cl-loaddefs pcase cl-lib mozc skk-leim time-date mule-util advice
skk-setup skk-autoloads tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese charscript case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face
macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting
font-render-setting xwidget-internal move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 2902878 333248)
 (symbols 48 64343 1)
 (miscs 40 9256 11314)
 (strings 32 199064 26399)
 (string-bytes 1 6554129)
 (vectors 16 87195)
 (vector-slots 8 2451990 90410)
 (floats 8 1375 3690)
 (intervals 56 491991 4413)
 (buffers 976 519))

commit f8c0c6c11c9cce6429476070bcc550526d534651 (HEAD -> master)
Author: Masatake YAMATO <yamato@redhat.com>
Date:   Tue Oct 3 20:18:06 2017 +0900

    Fix reading and writing cpp-config-file under home directory
    
    * lisp/progmodes/cpp.el (cpp-edit-load): load ~/.cpp.el when
    it is readable.
    (cpp-edit-save): write to ~/.cpp.el when it is wriable.

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 8aaebdde5b..3a7dab72b4 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -577,7 +577,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
        ((file-readable-p cpp-config-file)
         (load-file cpp-config-file))
        ((file-readable-p (concat "~/" cpp-config-file))
-        (load-file cpp-config-file)))
+        (load-file (concat "~/" cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -586,7 +586,11 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
   (interactive)
   (require 'pp)
   (with-current-buffer cpp-edit-buffer
-    (let ((buffer (find-file-noselect cpp-config-file)))
+    (let* ((config-file (if (file-writable-p cpp-config-file)
+                            cpp-config-file
+                          (concat "~/" cpp-config-file)))
+           (buffer (find-file-noselect config-file))
+           )
       (set-buffer buffer)
       (erase-buffer)
       (pp (list 'setq 'cpp-known-face
@@ -601,7 +605,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
                (list 'quote cpp-unknown-writable)) buffer)
       (pp (list 'setq 'cpp-edit-list
                (list 'quote cpp-edit-list)) buffer)
-      (write-file cpp-config-file))))
+      (write-file config-file))))
 
 (defun cpp-edit-home ()
   "Switch back to original buffer."





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-03 11:19 bug#28685: 25.3; wrong handling ~/.cpp.el Masatake YAMATO
@ 2017-10-14  5:38 ` Noam Postavsky
  2017-10-14  7:21   ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2017-10-14  5:38 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: 28685

tags 28685 + patch
quit

Masatake YAMATO <yamato@redhat.com> writes:

> cpp.el tries to load ./.cpp.el even when it is not readable.  Though
> it checks ~/.cpp.el can be readable, it still tries to load ./.cpp.el.

Thanks, the patch looks good.  But since this bug has apparently been
present since the initial revision in 1994 and nobody ever noticed until
now, I wonder if we should instead just remove the ~/.cpp.el feature
altogether.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14  5:38 ` Noam Postavsky
@ 2017-10-14  7:21   ` Eli Zaretskii
  2017-10-14 14:14     ` Noam Postavsky
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2017-10-14  7:21 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yamato, 28685

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sat, 14 Oct 2017 01:38:47 -0400
> Cc: 28685@debbugs.gnu.org
> 
> Masatake YAMATO <yamato@redhat.com> writes:
> 
> > cpp.el tries to load ./.cpp.el even when it is not readable.  Though
> > it checks ~/.cpp.el can be readable, it still tries to load ./.cpp.el.
> 
> Thanks, the patch looks good.  But since this bug has apparently been
> present since the initial revision in 1994 and nobody ever noticed until
> now, I wonder if we should instead just remove the ~/.cpp.el feature
> altogether.

AFAIK, it's a standard feature of many packages (not only Emacs
packages) to try .FOO in the home directory if the one in the CWD is
not usable.  So I think we should fix this rather than remove the
feature.  (cpp.el is under-used in general, so it's small wonder no
one paid attention to this bug.)

Btw, I think we should use expand-file-name rather than concat, to
access ~/.cpp.el.

Thanks.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14  7:21   ` Eli Zaretskii
@ 2017-10-14 14:14     ` Noam Postavsky
  2017-10-14 15:01       ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2017-10-14 14:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: yamato, 28685

Eli Zaretskii <eliz@gnu.org> writes:

> AFAIK, it's a standard feature of many packages (not only Emacs
> packages) to try .FOO in the home directory if the one in the CWD is
> not usable.  So I think we should fix this rather than remove the
> feature.  (cpp.el is under-used in general, so it's small wonder no
> one paid attention to this bug.)
>
> Btw, I think we should use expand-file-name rather than concat, to
> access ~/.cpp.el.

Hmm, actually shouldn't it be ~/.emacs.d/cpp.el rather than ~/.cpp.el?

By ~/.emacs.d/cpp.el I really mean (expand-file-name "cpp.el"
user-emacs-directory).





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14 14:14     ` Noam Postavsky
@ 2017-10-14 15:01       ` Eli Zaretskii
  2017-10-14 15:17         ` Noam Postavsky
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2017-10-14 15:01 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yamato, 28685

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: yamato@redhat.com,  28685@debbugs.gnu.org
> Date: Sat, 14 Oct 2017 10:14:22 -0400
> 
> > Btw, I think we should use expand-file-name rather than concat, to
> > access ~/.cpp.el.
> 
> Hmm, actually shouldn't it be ~/.emacs.d/cpp.el rather than ~/.cpp.el?

That'd be a change in behavior, although I don't mind it.  But is it
really necessary, and if so, why?





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14 15:01       ` Eli Zaretskii
@ 2017-10-14 15:17         ` Noam Postavsky
  2017-10-14 15:32           ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2017-10-14 15:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: yamato, 28685

Eli Zaretskii <eliz@gnu.org> writes:

>> Hmm, actually shouldn't it be ~/.emacs.d/cpp.el rather than ~/.cpp.el?
>
> That'd be a change in behavior, although I don't mind it.

Sure, but fixing the bug to actually start using ~/.cpp.el would also
change behaviour.

> But is it really necessary, and if so, why?

My impression is that Emacs packages are generally moving dotfiles from
~/ into ~/.emacs.d/ instead.  So looking at ~/.cpp.el (which, due to the
bug, we never actually did) is by now a bit non-standard.

E.g. this entry from NEWS.24:

** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>.
Affected files:
~/.emacs.d/timelog	replaces  ~/.timelog
~/.emacs.d/vip		replaces  ~/.vip
~/.emacs.d/viper	replaces  ~/.viper
~/.emacs.d/ido.last	replaces  ~/.ido.last
~/.emacs.d/kkcrc	replaces  ~/.kkcrc
~/.emacs.d/quickurls	replaces  ~/.quickurls
~/.emacs.d/idlwave/	replaces  ~/.idlwave/
~/.emacs.d/bdfcache.el	replaces  ~/.bdfcache.el
~/.emacs.d/places	replaces  ~/.emacs-places
~/.emacs.d/shadows	replaces  ~/.shadows
~/.emacs.d/shadow_todo	replaces  ~/.shadow_todo
~/.emacs.d/strokes	replaces  ~/.strokes
~/.emacs.d/notes	replaces  ~/.notes
~/.emacs.d/type-break	replaces  ~/.type-break
Also the following files used by the now obsolete otodo-mode.el:
~/.emacs.d/todo-do	replaces  ~/.todo-do
~/.emacs.d/todo-done	replaces  ~/.todo-done
~/.emacs.d/todo-top	replaces  ~/.todo-top






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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14 15:17         ` Noam Postavsky
@ 2017-10-14 15:32           ` Eli Zaretskii
  2017-10-14 22:11             ` Glenn Morris
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2017-10-14 15:32 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yamato, 28685

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: yamato@redhat.com,  28685@debbugs.gnu.org
> Date: Sat, 14 Oct 2017 11:17:17 -0400
> 
> E.g. this entry from NEWS.24:
> 
> ** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>.

I'm okay with looking in both places.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14 15:32           ` Eli Zaretskii
@ 2017-10-14 22:11             ` Glenn Morris
  2017-10-17 10:23               ` Masatake YAMATO
  0 siblings, 1 reply; 20+ messages in thread
From: Glenn Morris @ 2017-10-14 22:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: yamato, 28685, Noam Postavsky

Eli Zaretskii wrote:

>> E.g. this entry from NEWS.24:
>> 
>> ** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>.
>
> I'm okay with looking in both places.

This is what locate-user-emacs-file is for.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-14 22:11             ` Glenn Morris
@ 2017-10-17 10:23               ` Masatake YAMATO
  2017-10-17 12:43                 ` Noam Postavsky
  0 siblings, 1 reply; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-17 10:23 UTC (permalink / raw)
  To: rgm; +Cc: 28685, npostavs

On Sat, 14 Oct 2017 18:11:06 -0400, Glenn Morris <rgm@gnu.org> wrote:
> Eli Zaretskii wrote:
> 
>>> E.g. this entry from NEWS.24:
>>> 
>>> ** More packages look for ~/.emacs.d/<foo> additionally to ~/.<foo>.
>>
>> I'm okay with looking in both places.
> 
> This is what locate-user-emacs-file is for.

How about following extra patch?
Ideally, ~/.emacs.d/.cpp.el should be ~/.emacs.d/cpp.el.
However, I cannot find good way to implement it.

commit 765dfed4bd1ea1a3b6d9b51383fa0ec745479cce (HEAD -> cpp-highlight-check)
Author: Masatake YAMATO <yamato@redhat.com>
Date:   Tue Oct 17 19:20:38 2017 +0900

    Put .cpp.el to ~/.emacs.d if possible
    
    *lisp/progmodes/cpp.el (cpp-edit-load): Use locate-user-emacs-file
    instead of specifying "~/"
    (cpp-edit-save): Ditto.

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 3a7dab72b4..0a68a0cf2c 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -576,8 +576,8 @@ cpp-edit-load
         nil)
        ((file-readable-p cpp-config-file)
         (load-file cpp-config-file))
-       ((file-readable-p (concat "~/" cpp-config-file))
-        (load-file (concat "~/" cpp-config-file))))
+       ((file-readable-p (locate-user-emacs-file cpp-config-file))
+        (load-file (locate-user-emacs-file cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -588,7 +588,7 @@ cpp-edit-save
   (with-current-buffer cpp-edit-buffer
     (let* ((config-file (if (file-writable-p cpp-config-file)
                             cpp-config-file
-                          (concat "~/" cpp-config-file)))
+                          (locate-user-emacs-file cpp-config-file)))
            (buffer (find-file-noselect config-file))
            )
       (set-buffer buffer)





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-17 10:23               ` Masatake YAMATO
@ 2017-10-17 12:43                 ` Noam Postavsky
  2017-10-17 14:53                   ` Eli Zaretskii
                                     ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Noam Postavsky @ 2017-10-17 12:43 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: 28685

Masatake YAMATO <yamato@redhat.com> writes:

> On Sat, 14 Oct 2017 18:11:06 -0400, Glenn Morris <rgm@gnu.org> wrote:

> +       ((file-readable-p (locate-user-emacs-file cpp-config-file))
> +        (load-file (locate-user-emacs-file cpp-config-file))))

This would find ~/.emacs.d/.cpp.el, but I believe we would rather get
~/.emacs.d/cpp.el.  Which is to say, we want

    (locate-user-emacs-file "cpp.el" ".cpp.el")






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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-17 12:43                 ` Noam Postavsky
@ 2017-10-17 14:53                   ` Eli Zaretskii
  2017-10-19 18:55                   ` Masatake YAMATO
  2017-10-19 19:12                   ` Masatake YAMATO
  2 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2017-10-17 14:53 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yamato, 28685

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: rgm@gnu.org,  eliz@gnu.org,  28685@debbugs.gnu.org
> Date: Tue, 17 Oct 2017 08:43:39 -0400
> 
> This would find ~/.emacs.d/.cpp.el, but I believe we would rather get
> ~/.emacs.d/cpp.el.  Which is to say, we want
> 
>     (locate-user-emacs-file "cpp.el" ".cpp.el")

Yes, please.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-17 12:43                 ` Noam Postavsky
  2017-10-17 14:53                   ` Eli Zaretskii
@ 2017-10-19 18:55                   ` Masatake YAMATO
  2017-10-19 19:12                   ` Masatake YAMATO
  2 siblings, 0 replies; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-19 18:55 UTC (permalink / raw)
  To: npostavs; +Cc: 28685

cpp-config-file is a customizable variable.
So a user can change its name.

Masatake YAMATO

On Tue, 17 Oct 2017 08:43:39 -0400, Noam Postavsky <npostavs@users.sourceforge.net> wrote:
> Masatake YAMATO <yamato@redhat.com> writes:
> 
>> On Sat, 14 Oct 2017 18:11:06 -0400, Glenn Morris <rgm@gnu.org> wrote:
> 
>> +       ((file-readable-p (locate-user-emacs-file cpp-config-file))
>> +        (load-file (locate-user-emacs-file cpp-config-file))))
> 
> This would find ~/.emacs.d/.cpp.el, but I believe we would rather get
> ~/.emacs.d/cpp.el.  Which is to say, we want
> 
>     (locate-user-emacs-file "cpp.el" ".cpp.el")
> 





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-17 12:43                 ` Noam Postavsky
  2017-10-17 14:53                   ` Eli Zaretskii
  2017-10-19 18:55                   ` Masatake YAMATO
@ 2017-10-19 19:12                   ` Masatake YAMATO
  2017-10-21  0:44                     ` Noam Postavsky
  2017-10-21 20:16                     ` Noam Postavsky
  2 siblings, 2 replies; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-19 19:12 UTC (permalink / raw)
  To: npostavs; +Cc: 28685

commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check)
Author: Masatake YAMATO <yamato@redhat.com>
Date:   Fri Oct 20 04:10:28 2017 +0900

    Put cpp config file to ~/.emacs.d/cpp.el if possible
    
    If `cpp-config-file` starts with '.', remove the '.'
    when putting the file to ~/.emacs.d.
    Suggested by Noam Postavsky <npostavs@users.sourceforge.net>
    
    * lisp/progmodes/cpp.el (cpp-locate-user-emacs-file): New
    function wrapping `locate-user-emacs-file`.
    (cpp-edit-load): Use `cpp-locate-user-emacs-file`.
    (cpp-edit-save): Ditto.

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 0a68a0cf2c..c1f7088895 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -568,6 +568,14 @@ cpp-edit-reset
     (set-window-start nil start)
     (goto-char pos)))
 
+(defun cpp-locate-user-emacs-file (file)
+  (locate-user-emacs-file
+   ;; Remove initial '.' from file.
+   (if (eq (aref file 0) ?.)
+       (substring file 1)
+     file)
+   file))
+
 (defun cpp-edit-load ()
   "Load cpp configuration."
   (interactive)
@@ -576,8 +584,8 @@ cpp-edit-load
         nil)
        ((file-readable-p cpp-config-file)
         (load-file cpp-config-file))
-       ((file-readable-p (locate-user-emacs-file cpp-config-file))
-        (load-file (locate-user-emacs-file cpp-config-file))))
+       ((file-readable-p (cpp-locate-user-emacs-file cpp-config-file))
+        (load-file (cpp-locate-user-emacs-file cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -588,7 +596,7 @@ cpp-edit-save
   (with-current-buffer cpp-edit-buffer
     (let* ((config-file (if (file-writable-p cpp-config-file)
                             cpp-config-file
-                          (locate-user-emacs-file cpp-config-file)))
+                          (cpp-locate-user-emacs-file cpp-config-file)))
            (buffer (find-file-noselect config-file))
            )
       (set-buffer buffer)





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-19 19:12                   ` Masatake YAMATO
@ 2017-10-21  0:44                     ` Noam Postavsky
  2017-10-21  7:14                       ` Eli Zaretskii
  2017-10-21 20:16                     ` Noam Postavsky
  1 sibling, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2017-10-21  0:44 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: 28685

Masatake YAMATO <yamato@redhat.com> writes:

> commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check)
> Author: Masatake YAMATO <yamato@redhat.com>
> Date:   Fri Oct 20 04:10:28 2017 +0900
>
>     Put cpp config file to ~/.emacs.d/cpp.el if possible
>     
>     If `cpp-config-file` starts with '.', remove the '.'
>     when putting the file to ~/.emacs.d.
>     Suggested by Noam Postavsky <npostavs@users.sourceforge.net>

Oh, I wasn't even thinking about the configurable part of it.  Anyway,
looks fine, I guess this should go to master?





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-21  0:44                     ` Noam Postavsky
@ 2017-10-21  7:14                       ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2017-10-21  7:14 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yamato, 28685

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: rgm@gnu.org,  eliz@gnu.org,  28685@debbugs.gnu.org
> Date: Fri, 20 Oct 2017 20:44:48 -0400
> 
> Masatake YAMATO <yamato@redhat.com> writes:
> 
> > commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check)
> > Author: Masatake YAMATO <yamato@redhat.com>
> > Date:   Fri Oct 20 04:10:28 2017 +0900
> >
> >     Put cpp config file to ~/.emacs.d/cpp.el if possible
> >     
> >     If `cpp-config-file` starts with '.', remove the '.'
> >     when putting the file to ~/.emacs.d.
> >     Suggested by Noam Postavsky <npostavs@users.sourceforge.net>
> 
> Oh, I wasn't even thinking about the configurable part of it.  Anyway,
> looks fine, I guess this should go to master?

Yes, please, and thanks.





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

* bug#28685: 25.3; wrong handling ~/.cpp.el
  2017-10-19 19:12                   ` Masatake YAMATO
  2017-10-21  0:44                     ` Noam Postavsky
@ 2017-10-21 20:16                     ` Noam Postavsky
  2017-10-22  9:22                       ` bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory Masatake YAMATO
  1 sibling, 1 reply; 20+ messages in thread
From: Noam Postavsky @ 2017-10-21 20:16 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: 28685

Masatake YAMATO <yamato@redhat.com> writes:

> commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check)
> Author: Masatake YAMATO <yamato@redhat.com>
> Date:   Fri Oct 20 04:10:28 2017 +0900
>
>     Put cpp config file to ~/.emacs.d/cpp.el if possible

Hmm, actually I'm having trouble applying this.  Could you resend all
changes formatted with 'git format-patch' please?





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

* bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory
  2017-10-21 20:16                     ` Noam Postavsky
@ 2017-10-22  9:22                       ` Masatake YAMATO
  2017-10-22  9:22                         ` bug#28685: [PATCH 2/3] Put .cpp.el to ~/.emacs.d if possible Masatake YAMATO
  2017-10-22  9:22                         ` bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el " Masatake YAMATO
  0 siblings, 2 replies; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-22  9:22 UTC (permalink / raw)
  To: npostavs; +Cc: yamato, 28685

* lisp/progmodes/cpp.el (cpp-edit-load): load ~/.cpp.el when
it is readable.
(cpp-edit-save): write to ~/.cpp.el when it is wriable.
---
 lisp/progmodes/cpp.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 8aaebdde5b..3a7dab72b4 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -577,7 +577,7 @@ cpp-edit-load
 	((file-readable-p cpp-config-file)
 	 (load-file cpp-config-file))
 	((file-readable-p (concat "~/" cpp-config-file))
-	 (load-file cpp-config-file)))
+	 (load-file (concat "~/" cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -586,7 +586,11 @@ cpp-edit-save
   (interactive)
   (require 'pp)
   (with-current-buffer cpp-edit-buffer
-    (let ((buffer (find-file-noselect cpp-config-file)))
+    (let* ((config-file (if (file-writable-p cpp-config-file)
+                            cpp-config-file
+                          (concat "~/" cpp-config-file)))
+           (buffer (find-file-noselect config-file))
+           )
       (set-buffer buffer)
       (erase-buffer)
       (pp (list 'setq 'cpp-known-face
@@ -601,7 +605,7 @@ cpp-edit-save
 		(list 'quote cpp-unknown-writable)) buffer)
       (pp (list 'setq 'cpp-edit-list
 		(list 'quote cpp-edit-list)) buffer)
-      (write-file cpp-config-file))))
+      (write-file config-file))))
 
 (defun cpp-edit-home ()
   "Switch back to original buffer."
-- 
2.13.6






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

* bug#28685: [PATCH 2/3] Put .cpp.el to ~/.emacs.d if possible
  2017-10-22  9:22                       ` bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory Masatake YAMATO
@ 2017-10-22  9:22                         ` Masatake YAMATO
  2017-10-22  9:22                         ` bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el " Masatake YAMATO
  1 sibling, 0 replies; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-22  9:22 UTC (permalink / raw)
  To: npostavs; +Cc: yamato, 28685

* lisp/progmodes/cpp.el (cpp-edit-load): Use locate-user-emacs-file
instead of specifying "~/"
(cpp-edit-save): Ditto.
---
 lisp/progmodes/cpp.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 3a7dab72b4..0a68a0cf2c 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -576,8 +576,8 @@ cpp-edit-load
 	 nil)
 	((file-readable-p cpp-config-file)
 	 (load-file cpp-config-file))
-	((file-readable-p (concat "~/" cpp-config-file))
-	 (load-file (concat "~/" cpp-config-file))))
+	((file-readable-p (locate-user-emacs-file cpp-config-file))
+	 (load-file (locate-user-emacs-file cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -588,7 +588,7 @@ cpp-edit-save
   (with-current-buffer cpp-edit-buffer
     (let* ((config-file (if (file-writable-p cpp-config-file)
                             cpp-config-file
-                          (concat "~/" cpp-config-file)))
+                          (locate-user-emacs-file cpp-config-file)))
            (buffer (find-file-noselect config-file))
            )
       (set-buffer buffer)
-- 
2.13.6






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

* bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el if possible
  2017-10-22  9:22                       ` bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory Masatake YAMATO
  2017-10-22  9:22                         ` bug#28685: [PATCH 2/3] Put .cpp.el to ~/.emacs.d if possible Masatake YAMATO
@ 2017-10-22  9:22                         ` Masatake YAMATO
  2017-10-22 16:41                           ` Noam Postavsky
  1 sibling, 1 reply; 20+ messages in thread
From: Masatake YAMATO @ 2017-10-22  9:22 UTC (permalink / raw)
  To: npostavs; +Cc: yamato, 28685

If `cpp-config-file` starts with '.', remove the '.'
when putting the file to ~/.emacs.d.
Suggested by Noam Postavsky <npostavs@users.sourceforge.net>

* lisp/progmodes/cpp.el (cpp-locate-user-emacs-file): New
function wrapping `locate-user-emacs-file`.
(cpp-edit-load): Use `cpp-locate-user-emacs-file`.
(cpp-edit-save): Ditto.
---
 lisp/progmodes/cpp.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 0a68a0cf2c..c1f7088895 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -568,6 +568,14 @@ cpp-edit-reset
     (set-window-start nil start)
     (goto-char pos)))
 
+(defun cpp-locate-user-emacs-file (file)
+  (locate-user-emacs-file
+   ;; Remove initial '.' from file.
+   (if (eq (aref file 0) ?.)
+       (substring file 1)
+     file)
+   file))
+
 (defun cpp-edit-load ()
   "Load cpp configuration."
   (interactive)
@@ -576,8 +584,8 @@ cpp-edit-load
 	 nil)
 	((file-readable-p cpp-config-file)
 	 (load-file cpp-config-file))
-	((file-readable-p (locate-user-emacs-file cpp-config-file))
-	 (load-file (locate-user-emacs-file cpp-config-file))))
+	((file-readable-p (cpp-locate-user-emacs-file cpp-config-file))
+	 (load-file (cpp-locate-user-emacs-file cpp-config-file))))
   (if (derived-mode-p 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -588,7 +596,7 @@ cpp-edit-save
   (with-current-buffer cpp-edit-buffer
     (let* ((config-file (if (file-writable-p cpp-config-file)
                             cpp-config-file
-                          (locate-user-emacs-file cpp-config-file)))
+                          (cpp-locate-user-emacs-file cpp-config-file)))
            (buffer (find-file-noselect config-file))
            )
       (set-buffer buffer)
-- 
2.13.6






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

* bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el if possible
  2017-10-22  9:22                         ` bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el " Masatake YAMATO
@ 2017-10-22 16:41                           ` Noam Postavsky
  0 siblings, 0 replies; 20+ messages in thread
From: Noam Postavsky @ 2017-10-22 16:41 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: 28685

tags 28685 fixed
close 28685 27.1
quit


Thanks, pushed to master (I tucked in a stray paren, and reformatted the
second commit message a bit).

: [1: aa44308429] [2: 9c8f8de0f3] 

[1: aa44308429]: 2017-10-22 11:33:40 -0400
  Fix reading and writing cpp-config-file under home directory (Bug#28685)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=aa44308429e952388a2403e8dda6c1cbf6c5d802

[2: 9c8f8de0f3]: 2017-10-22 11:33:40 -0400
  Put cpp config file to ~/.emacs.d/cpp.el if possible (Bug#28685)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=9c8f8de0f3e00d4f862fa5c17e3b46fcd23e5f7f





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

end of thread, other threads:[~2017-10-22 16:41 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 11:19 bug#28685: 25.3; wrong handling ~/.cpp.el Masatake YAMATO
2017-10-14  5:38 ` Noam Postavsky
2017-10-14  7:21   ` Eli Zaretskii
2017-10-14 14:14     ` Noam Postavsky
2017-10-14 15:01       ` Eli Zaretskii
2017-10-14 15:17         ` Noam Postavsky
2017-10-14 15:32           ` Eli Zaretskii
2017-10-14 22:11             ` Glenn Morris
2017-10-17 10:23               ` Masatake YAMATO
2017-10-17 12:43                 ` Noam Postavsky
2017-10-17 14:53                   ` Eli Zaretskii
2017-10-19 18:55                   ` Masatake YAMATO
2017-10-19 19:12                   ` Masatake YAMATO
2017-10-21  0:44                     ` Noam Postavsky
2017-10-21  7:14                       ` Eli Zaretskii
2017-10-21 20:16                     ` Noam Postavsky
2017-10-22  9:22                       ` bug#28685: [PATCH 1/3] Fix reading and writing cpp-config-file under home directory Masatake YAMATO
2017-10-22  9:22                         ` bug#28685: [PATCH 2/3] Put .cpp.el to ~/.emacs.d if possible Masatake YAMATO
2017-10-22  9:22                         ` bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el " Masatake YAMATO
2017-10-22 16:41                           ` Noam Postavsky

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