Put cpp config file to ~/.emacs.d/cpp.el if possible (Bug#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, cpp-edit-save): Use it.
This commit is contained in:
parent
aa44308429
commit
9c8f8de0f3
1 changed files with 11 additions and 3 deletions
|
@ -568,6 +568,14 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
|
|||
(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 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
|
|||
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 (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 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
|
|||
(with-current-buffer cpp-edit-buffer
|
||||
(let* ((config-file (if (file-writable-p cpp-config-file)
|
||||
cpp-config-file
|
||||
(concat "~/" cpp-config-file)))
|
||||
(cpp-locate-user-emacs-file cpp-config-file)))
|
||||
(buffer (find-file-noselect config-file)))
|
||||
(set-buffer buffer)
|
||||
(erase-buffer)
|
||||
|
|
Loading…
Add table
Reference in a new issue