all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* custom-save-all leaves custom-file buffer
@ 2005-08-25 20:28 David Reitter
  2005-08-27  3:41 ` Richard M. Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2005-08-25 20:28 UTC (permalink / raw)


Is there a special reason why custom-save-all leaves the buffer with  
custom-file?
I don't think the file should appear in the buffers lists - it's  
loaded temporarily and should be discarded.

The problem with below patch is that if custom-file is already loaded  
as ordinary buffer, it will kill it as find-file-noselect doesn't  
load the file a second time.

*** cus-edit.el 12 Aug 2005 11:17:57 -0000      1.230
--- cus-edit.el 25 Aug 2005 20:25:23 -0000
***************
*** 4144,4150 ****
                                        recentf-exclude))))
         (set-buffer (find-file-noselect (custom-file))))
         (let ((file-precious-flag t))
!       (save-buffer)))))

   ;;; The Customize Menu.

--- 4144,4151 ----
                                        recentf-exclude))))
         (set-buffer (find-file-noselect (custom-file))))
         (let ((file-precious-flag t))
!       (save-buffer))
!       (kill-buffer nil))))

   ;;; The Customize Menu.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: custom-save-all leaves custom-file buffer
  2005-08-25 20:28 custom-save-all leaves custom-file buffer David Reitter
@ 2005-08-27  3:41 ` Richard M. Stallman
  2005-08-27 10:25   ` David Reitter
  0 siblings, 1 reply; 4+ messages in thread
From: Richard M. Stallman @ 2005-08-27  3:41 UTC (permalink / raw)
  Cc: emacs-devel

I wrote a cleaner patch to do a job like this, but I have not had time
to test it, so I have not installed it.  Can you test it?

Index: cus-edit.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v
retrieving revision 1.230
diff -c -c -r1.230 cus-edit.el
*** cus-edit.el	12 Aug 2005 11:17:57 -0000	1.230
--- cus-edit.el	27 Aug 2005 03:38:39 -0000
***************
*** 3836,3843 ****
  	    (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.
--- 3836,3844 ----
  	    (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.
***************
*** 3898,3914 ****
  	   (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)
! 	(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.
    (while (forward-comment 1))
--- 3899,3926 ----
  	   (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 current buffer.
  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."
    (goto-char (point-min))
    ;; Skip all whitespace and comments.
    (while (forward-comment 1))
***************
*** 4128,4151 ****
  		  (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)
! 	    (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)))))
! 
  ;;; The Customize Menu.
  
  ;;; Menu support
--- 4140,4146 ----
  		  (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

* Re: custom-save-all leaves custom-file buffer
  2005-08-27  3:41 ` Richard M. Stallman
@ 2005-08-27 10:25   ` David Reitter
  2005-08-27 12:56     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2005-08-27 10:25 UTC (permalink / raw)


On 27 Aug 2005, at 04:41, Richard M. Stallman wrote:

> I wrote a cleaner patch to do a job like this, but I have not had time
> to test it, so I have not installed it.  Can you test it?

OK, it works so far, but now custom-file turns up in the recentf list.
That was Eli's 05/08/12 patch was about:

Log message:
         (custom-save-all, custom-save-delete): Bind recentf-exclude  
to exclude
         custom-file.

> !       (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))))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: custom-save-all leaves custom-file buffer
  2005-08-27 10:25   ` David Reitter
@ 2005-08-27 12:56     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2005-08-27 12:56 UTC (permalink / raw)
  Cc: emacs-devel

> From: David Reitter <david.reitter@gmail.com>
> Date: Sat, 27 Aug 2005 11:25:47 +0100
> 
> On 27 Aug 2005, at 04:41, Richard M. Stallman wrote:
> 
> > I wrote a cleaner patch to do a job like this, but I have not had time
> > to test it, so I have not installed it.  Can you test it?
> 
> OK, it works so far, but now custom-file turns up in the recentf list.
> That was Eli's 05/08/12 patch was about:
> 
> Log message:
>          (custom-save-all, custom-save-delete): Bind recentf-exclude to exclude
>          custom-file.

That change wasn't mine; Richard asked me to install that.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-27 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-25 20:28 custom-save-all leaves custom-file buffer David Reitter
2005-08-27  3:41 ` Richard M. Stallman
2005-08-27 10:25   ` David Reitter
2005-08-27 12:56     ` Eli Zaretskii

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.