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: Mon, 28 Mar 2011 12:45:47 +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 1301288851 28083 80.91.229.12 (28 Mar 2011 05:07:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Mar 2011 05:07:31 +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 Mon Mar 28 07:07:27 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 1Q44fl-0003oD-Q8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Mar 2011 07:07:26 +0200 Original-Received: from localhost ([127.0.0.1]:42490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q44fk-0007a6-Nt for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Mar 2011 01:07:24 -0400 Original-Received: from [140.186.70.92] (port=36656 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q44fW-0007ZO-2w for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 01:07:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q44fV-0005o9-1O for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 01:07:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q44fU-0005o5-Uv for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 01:07:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q44M1-0000rj-Ur; Mon, 28 Mar 2011 00:47:01 -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: Mon, 28 Mar 2011 04:47:01 +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.13012875643254 (code B ref 5937); Mon, 28 Mar 2011 04:47:01 +0000 Original-Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 04:46:04 +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 1Q44L5-0000qR-0c for submit@debbugs.gnu.org; Mon, 28 Mar 2011 00:46:03 -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 1Q44L3-0000py-Sa for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 00:46:02 -0400 Original-Received: by iwn39 with SMTP id 39so2640647iwn.3 for <5937@debbugs.gnu.org>; Sun, 27 Mar 2011 21:45:56 -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=VcxFuFW10ejc/JL49WEIp5u62l+XKjsGmubH+XRPYNw=; b=QXuy8Zy8546IBM13EsMlfUftebsumPHGOe7b8h5WvutUtuNvgg+EWSUwt5s8DRiyF9 I0J2p33CCJPBz0JtUp5qHwXkN8iJpjAdgwwYPu6QhNpmmuztZr0d11+rAhklRFMFfKX5 0JLshAGvl2uGeZv9esvvNNRilFGT4MA+e9uMw= 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=SFfD4sNgvegl1Of44+ZFM13GTRCMPf7A9kDMvjwGFbMsYpUqpjplZjYb4McpxqOMcd mV7OqAifs1mpoY0xDb1EqQTColVHgCVThvjjBcTfxTqi8S7sla/Yr59gnRDg7TtOhDA9 do6D0HNoppPj3AZTi1QI9/a8+TjMmJEuQZu2A= Original-Received: by 10.42.138.4 with SMTP id a4mr6004157icu.258.1301287556230; Sun, 27 Mar 2011 21:45:56 -0700 (PDT) Original-Received: from Victoria.local (th041068.ip.tsinghua.edu.cn [59.66.41.68]) by mx.google.com with ESMTPS id gy41sm2676133ibb.56.2011.03.27.21.45.52 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 21:45:55 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 27 Mar 2011 16:40:10 -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: Mon, 28 Mar 2011 00:47:01 -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:45408 Archived-At: On 2011-03-28 04:40 +0800, Stefan Monnier wrote: > You mean keep C-c C-c bound to edit-abbrevs-redefine, but change C-x C-s > to call write-abbrev-file? Sounds good (tho it'll have to call > edit-abbrevs-redefine before write-abbrev-file beforehand, of course). > Oh and by the way: the abbrev.el file should be (slowly) fixed to use > the "abbrev-" prefix for all functions and commands, so whenever you > introduce a new function/command/variable please use this prefix rather > than the previous style of -abbrev-. How about this patch? === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 +++ lisp/abbrev.el 2011-03-28 04:42:26 +0000 @@ -65,7 +65,8 @@ (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" 'write-abbrev-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -211,13 +212,14 @@ ;(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 where abbrevs have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -225,6 +227,7 @@ abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) + (edit-abbrevs-redefine) (let ((coding-system-for-write 'utf-8)) (with-temp-buffer (dolist (table @@ -247,7 +250,14 @@ '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 file name to use is `abbrev-file-name'." + (interactive) + (write-abbrev-file abbrev-file-name t)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point.