bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28685: 25.3; wrong handling ~/.cpp.el


From: Masatake YAMATO
Subject: bug#28685: 25.3; wrong handling ~/.cpp.el
Date: Fri, 20 Oct 2017 04:12:01 +0900 (JST)

commit 784582fa24623a3658d25e211f98c28212ff628d (HEAD -> cpp-highlight-check)
Author: Masatake YAMATO <address@hidden>
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 <address@hidden>
    
    * 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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]