all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: npostavs@users.sourceforge.net
Cc: yamato@redhat.com, 28685@debbugs.gnu.org
Subject: bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el if possible
Date: Sun, 22 Oct 2017 18:22:42 +0900	[thread overview]
Message-ID: <20171022092242.7014-3-yamato@redhat.com> (raw)
In-Reply-To: <20171022092242.7014-1-yamato@redhat.com>

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






  parent reply	other threads:[~2017-10-22  9:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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                         ` Masatake YAMATO [this message]
2017-10-22 16:41                           ` bug#28685: [PATCH 3/3] Put cpp config file to ~/.emacs.d/cpp.el " Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171022092242.7014-3-yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=28685@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.