* recentf: custom-file
@ 2005-07-31 21:12 David Reitter
2005-08-02 18:05 ` Kevin Rodgers
0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2005-07-31 21:12 UTC (permalink / raw)
custom-file pops up in the recentf menu. The fix below addresses the
issue. Alternatives would be adding a check for custom-file to
recentf-keep, but that would prevent .emacs (or whatever custom-file
is) from turning up there even if the user loads it. There could be
better (more elaborate) solutions that preserve the effect of file-
precious-flag, of course.
diff -c -r1.228 cus-edit.el
*** cus-edit.el 19 Jul 2005 11:21:30 -0000 1.228
--- cus-edit.el 31 Jul 2005 20:55:48 -0000
***************
*** 4132,4139 ****
(save-excursion
(let ((default-major-mode nil))
(set-buffer (find-file-noselect (custom-file))))
! (let ((file-precious-flag t))
! (save-buffer)))))
;;; The Customize Menu.
--- 4132,4138 ----
(save-excursion
(let ((default-major-mode nil))
(set-buffer (find-file-noselect (custom-file))))
! (write-region nil nil custom-file))))
;;; The Customize Menu.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: recentf: custom-file
2005-07-31 21:12 recentf: custom-file David Reitter
@ 2005-08-02 18:05 ` Kevin Rodgers
2005-08-02 18:58 ` David Reitter
2005-08-05 11:59 ` Richard M. Stallman
0 siblings, 2 replies; 4+ messages in thread
From: Kevin Rodgers @ 2005-08-02 18:05 UTC (permalink / raw)
David Reitter wrote:
> custom-file pops up in the recentf menu. The fix below addresses the
> issue. Alternatives would be adding a check for custom-file to
> recentf-keep, but that would prevent .emacs (or whatever custom-file
> is) from turning up there even if the user loads it. There could be
> better (more elaborate) solutions that preserve the effect of file-
> precious-flag, of course.
Using write-region also makes it susceptible to losing data (if
custom-file is already being visited, in a narrowed buffer).
I think a better solution would be to prevent custom-file from being
added to recentf-list by the 2 functions in cus-edit.el that visit it,
custom-save-delete and custom-save-all:
*** emacs-21.3/lisp/cus-edit.el~ Tue Oct 15 08:21:42 2002
--- emacs-21.3/lisp/cus-edit.el Tue Aug 2 12:02:32 2005
***************
*** 3465,3471 ****
"Visit `custom-file' and delete all calls to SYMBOL from it.
Leave point at the old location of the first such call,
or (if there were none) at the end of the buffer."
! (let ((default-major-mode))
(set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
;; Skip all whitespace and comments.
--- 3465,3476 ----
"Visit `custom-file' and delete all calls to SYMBOL from it.
Leave point at the old location of the first such call,
or (if there were none) at the end of the buffer."
! (let ((default-major-mode nil)
! (recentf-exclude (if recentf-mode
! (cons (concat "\\`"
! (regexp-quote (custom-file))
! "\\'")
! recentf-exclude))))
(set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
;; Skip all whitespace and comments.
***************
*** 3649,3655 ****
(custom-save-variables)
(custom-save-faces)
(save-excursion
! (let ((default-major-mode nil))
(set-buffer (find-file-noselect (custom-file))))
(let ((file-precious-flag t))
(save-buffer)))))
--- 3654,3665 ----
(custom-save-variables)
(custom-save-faces)
(save-excursion
! (let ((default-major-mode nil)
! (recentf-exclude (if recentf-mode
! (cons (concat "\\`"
! (regexp-quote
(custom-file))
! "\\'")
! recentf-exclude))))
(set-buffer (find-file-noselect (custom-file))))
(let ((file-precious-flag t))
(save-buffer)))))
--
Kevin Rodgers
David Reitter wrote:
> custom-file pops up in the recentf menu. The fix below addresses the
> issue. Alternatives would be adding a check for custom-file to
> recentf-keep, but that would prevent .emacs (or whatever custom-file
> is) from turning up there even if the user loads it. There could be
> better (more elaborate) solutions that preserve the effect of file-
> precious-flag, of course.
Using write-region also makes it susceptible to losing data (if
custom-file is already being visited, in a narrowed buffer).
I think a better solution would be to prevent custom-file from being
added to recentf-list by the 2 functions in cus-edit.el that visit it,
custom-save-delete and custom-save-all:
*** emacs-21.3/lisp/cus-edit.el~ Tue Oct 15 08:21:42 2002
--- emacs-21.3/lisp/cus-edit.el Tue Aug 2 12:02:32 2005
***************
*** 3465,3471 ****
"Visit `custom-file' and delete all calls to SYMBOL from it.
Leave point at the old location of the first such call,
or (if there were none) at the end of the buffer."
! (let ((default-major-mode))
(set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
;; Skip all whitespace and comments.
--- 3465,3476 ----
"Visit `custom-file' and delete all calls to SYMBOL from it.
Leave point at the old location of the first such call,
or (if there were none) at the end of the buffer."
! (let ((default-major-mode nil)
! (recentf-exclude (if recentf-mode
! (cons (concat "\\`"
! (regexp-quote (custom-file))
! "\\'")
! recentf-exclude))))
(set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
;; Skip all whitespace and comments.
***************
*** 3649,3655 ****
(custom-save-variables)
(custom-save-faces)
(save-excursion
! (let ((default-major-mode nil))
(set-buffer (find-file-noselect (custom-file))))
(let ((file-precious-flag t))
(save-buffer)))))
--- 3654,3665 ----
(custom-save-variables)
(custom-save-faces)
(save-excursion
! (let ((default-major-mode nil)
! (recentf-exclude (if recentf-mode
! (cons (concat "\\`"
! (regexp-quote
(custom-file))
! "\\'")
! recentf-exclude))))
(set-buffer (find-file-noselect (custom-file))))
(let ((file-precious-flag t))
(save-buffer)))))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: recentf: custom-file
2005-08-02 18:05 ` Kevin Rodgers
@ 2005-08-02 18:58 ` David Reitter
2005-08-05 11:59 ` Richard M. Stallman
1 sibling, 0 replies; 4+ messages in thread
From: David Reitter @ 2005-08-02 18:58 UTC (permalink / raw)
Cc: emacs-devel
On 2 Aug 2005, at 19:05, Kevin Rodgers wrote:
>
> I think a better solution would be to prevent custom-file from being
> added to recentf-list by the 2 functions in cus-edit.el that visit it,
> custom-save-delete and custom-save-all:
I agree, that'd be a better solution.
- D
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: recentf: custom-file
2005-08-02 18:05 ` Kevin Rodgers
2005-08-02 18:58 ` David Reitter
@ 2005-08-05 11:59 ` Richard M. Stallman
1 sibling, 0 replies; 4+ messages in thread
From: Richard M. Stallman @ 2005-08-05 11:59 UTC (permalink / raw)
Cc: emacs-devel
Your patch would work.
Here's another patch that I wrote in the same area,
but I have not had a chance to test it, so I have not installed it.
Could you test it for me?
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v
retrieving revision 1.228
diff -c -c -r1.228 cus-edit.el
*** cus-edit.el 19 Jul 2005 11:21:30 -0000 1.228
--- cus-edit.el 4 Aug 2005 20:47:16 -0000
***************
*** 3835,3842 ****
(setq magics (cdr magics)))))
(widget-put widget :custom-state found)))
(custom-magic-reset widget))
- ;;; The `custom-save-all' Function.
;;;###autoload
(defcustom custom-file nil
"File used for storing customization information.
--- 3835,3843 ----
(setq magics (cdr magics)))))
(widget-put widget :custom-state found)))
(custom-magic-reset widget))
+ \f
+ ;;; Reading and writing the custom file.
;;;###autoload
(defcustom custom-file nil
"File used for storing customization information.
***************
*** 3897,3908 ****
(setq user-init-file default-init-file))
user-init-file))))
(defun custom-save-delete (symbol)
! "Visit `custom-file' and delete all calls to SYMBOL from it.
Leave point at the old location of the first such call,
! or (if there were none) at the end of the buffer."
! (let ((default-major-mode 'emacs-lisp-mode))
! (set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
;; Skip all whitespace and comments.
(while (forward-comment 1))
--- 3898,3925 ----
(setq user-init-file default-init-file))
user-init-file))))
+ ;;;###autoload
+ (defun custom-save-all ()
+ "Save all customizations in `custom-file'."
+ (let* ((filename (custom-file))
+ (old-buffer (find-buffer-visiting filename)))
+ (with-current-buffer (or old-buffer (find-file-noselect filename))
+ (let ((inhibit-read-only t))
+ (custom-save-variables)
+ (custom-save-faces))
+ (let ((file-precious-flag t))
+ (save-buffer))
+ (unless old-buffer
+ (kill-buffer (current-buffer))))))
+ \f
+ ;; Editing the custom file contents in a buffer.
+
(defun custom-save-delete (symbol)
! "Delete all calls to SYMBOL from the contents of the custom file.
Leave point at the old location of the first such call,
! or (if there were none) at the end of the buffer.
!
! This function does not save the buffer back in the custom file."
(goto-char (point-min))
;; Skip all whitespace and comments.
(while (forward-comment 1))
***************
*** 4122,4140 ****
(put symbol 'customized-face-comment nil)))))
;; We really should update all custom buffers here.
(custom-save-all))
!
! ;;;###autoload
! (defun custom-save-all ()
! "Save all customizations in `custom-file'."
! (let ((inhibit-read-only t))
! (custom-save-variables)
! (custom-save-faces)
! (save-excursion
! (let ((default-major-mode nil))
! (set-buffer (find-file-noselect (custom-file))))
! (let ((file-precious-flag t))
! (save-buffer)))))
!
;;; The Customize Menu.
;;; Menu support
--- 4139,4145 ----
(put symbol 'customized-face-comment nil)))))
;; We really should update all custom buffers here.
(custom-save-all))
! \f
;;; The Customize Menu.
;;; Menu support
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-08-05 11:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-31 21:12 recentf: custom-file David Reitter
2005-08-02 18:05 ` Kevin Rodgers
2005-08-02 18:58 ` David Reitter
2005-08-05 11:59 ` Richard M. Stallman
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.