From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#5937: 23.1.95; why saving empty abbrev tables Date: Tue, 29 Mar 2011 12:41:44 +0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1301375248 12466 80.91.229.12 (29 Mar 2011 05:07:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 29 Mar 2011 05:07:28 +0000 (UTC) Cc: 5937@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 29 07:07:24 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4R9H-0002Tg-BH for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Mar 2011 07:07:23 +0200 Original-Received: from localhost ([127.0.0.1]:33822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4R9G-0004EM-Hw for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Mar 2011 01:07:22 -0400 Original-Received: from [140.186.70.92] (port=36689 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4R95-0004DZ-7H for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:07:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4R93-0001RX-PT for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:07:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4R93-0001RT-Ls for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:07:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q4Qkl-0003Tw-BR; Tue, 29 Mar 2011 00:42:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Mar 2011 04:42:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5937 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5937-submit@debbugs.gnu.org id=B5937.130137372113374 (code B ref 5937); Tue, 29 Mar 2011 04:42:03 +0000 Original-Received: (at 5937) by debbugs.gnu.org; 29 Mar 2011 04:42:01 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Qki-0003Tf-Nt for submit@debbugs.gnu.org; Tue, 29 Mar 2011 00:42:01 -0400 Original-Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Qkf-0003TT-TA for 5937@debbugs.gnu.org; Tue, 29 Mar 2011 00:41:58 -0400 Original-Received: by iwn39 with SMTP id 39so3784678iwn.3 for <5937@debbugs.gnu.org>; Mon, 28 Mar 2011 21:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=+JLIx1g+5BJGsoBpMgXu3SQrW1KmppjEzehiIPBbh0E=; b=Taa8IQed3a1XiyMi/JNfycl4N/MYFpqOgQQY3xb5HxuV1NlZdHbTqtWwbrlYpjtW9h kG35a2SoD4w/VWM8vQsDpkgBfyXlnAchZY+ipm/WxHjQP+mOX9izuUbPNWJFZWP4nypr I90TXKP8lcPi3yzW9DCiLuwz1q7FFF5aGCl5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=ZpceyODVNvPuxSYbZFd/zJMZMWG92Z3TQmzoT/gEXjWd4YORGs75rEPmQ667sO/sDZ n0NYbEguGg7dCa/r7TsI/YufkeV571XTjLr7D7ZphuopfNJwwnLu3W50EIcfKhfdVgQ0 5YDyXd+kaFHgqmaMVMWRdNNflGzJIs/NdJJ5c= Original-Received: by 10.42.157.193 with SMTP id e1mr8180412icx.178.1301373712158; Mon, 28 Mar 2011 21:41:52 -0700 (PDT) Original-Received: from Victoria.local ([114.249.26.81]) by mx.google.com with ESMTPS id y10sm3382812iba.29.2011.03.28.21.41.48 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 21:41:51 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 28 Mar 2011 23:31:13 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 29 Mar 2011 00:42:03 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45460 Archived-At: On 2011-03-29 11:31 +0800, Stefan Monnier wrote: > Oh, I didn't notice this part of the patch. So I guess what I'm > suggesting is to create a new command for use in C-x C-w which calls > edit-abbrevs-redefine and then calls interactively write-abbrev-file. > The issue with write-abbrev-file is that it's called from > save-some-buffers so we can't/shouldn't bind it to edit-abbrevs. Thanks for that. I forgot write-abbrev-file is also called elsewhere. How about this patch? diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 0a3e1fd1..b1d9e024 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -73,7 +73,8 @@ (put 'abbrev-mode 'safe-local-variable 'booleanp) (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'abbrev-save-buffer) + (define-key map "\C-x\C-w" 'abbrev-save-to-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -224,13 +225,15 @@ (defun quietly-read-abbrev-file (&optional file) ;(interactive "fRead abbrev file: ") (read-abbrev-file file t)) -(defun write-abbrev-file (&optional file) +(defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. This does not include system abbrevs; it includes only the abbrev tables listed in listed in `abbrev-table-name-list'. The file written can be loaded in another session to define the same abbrevs. The argument FILE is the file name to write. If omitted or nil, the file -specified in `abbrev-file-name' is used." +specified in `abbrev-file-name' is used. +If VERBOSE is non-nil, display a message indicating where abbrevs +have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -260,7 +263,28 @@ (defun write-abbrev-file (&optional file) 'emacs-mule))) (goto-char (point-min)) (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) - (write-region nil nil file nil 0)))) + (write-region nil nil file nil (and (not verbose) 0))))) + +(defun abbrev-save-buffer () + "Save all user-level abbrev definitions in current buffer. +The saved abbrevs are written to the file specified by +`abbrev-file-name'." + (interactive) + (and (derived-mode-p 'edit-abbrevs-mode) + (edit-abbrevs-redefine)) + (write-abbrev-file abbrev-file-name t)) + +(defun abbrev-save-to-file (file) + "Save all user-level abbrev definitions in current buffer to FILE." + (interactive + (list (read-file-name "Save abbrevs to file: " + (file-name-directory + (expand-file-name abbrev-file-name)) + abbrev-file-name))) + (and (derived-mode-p 'edit-abbrevs-mode) + (edit-abbrevs-redefine)) + (write-abbrev-file file t)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. > Maybe another solution is to change edit-abbrevs-mode so that > save-buffer and write-file work in it by calling internally > write-abbrev-file. Note sure if that can be made to work without major > surgery, tho (write-region-annotate-functions could do some of it, but > I think the lack of buffer-file-name setting will get in the way, so > we'd have to change edit-abbrevs so that it sets buffer-file-name and > is really turned into a major mode to edit the .abbrev-defs file, which > seems like a fairly different beast). > > > Stefan This isn't cleaner at the moment. So probably leave it for future improvement. Leo