emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master aa44308 1/2: Fix reading and writing cpp-config-fil


From: Noam Postavsky
Subject: [Emacs-diffs] master aa44308 1/2: Fix reading and writing cpp-config-file under home directory (Bug#28685)
Date: Sun, 22 Oct 2017 12:40:19 -0400 (EDT)

branch: master
commit aa44308429e952388a2403e8dda6c1cbf6c5d802
Author: Masatake YAMATO <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Fix reading and writing cpp-config-file under home directory (Bug#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 | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 8aaebdd..186312f 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,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."



reply via email to

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