]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix reading and writing cpp-config-file under home directory (Bug#28685)
authorMasatake YAMATO <yamato@redhat.com>
Sun, 22 Oct 2017 09:22:40 +0000 (18:22 +0900)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 22 Oct 2017 15:33:40 +0000 (11:33 -0400)
* 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

index 8aaebdde5bcc75615404a190342f04352fd532a8..186312f333bc9fb44a073044a887a5938c9f4778 100644 (file)
@@ -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,10 @@ 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 +604,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."