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:03:22 +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 1301285257 14406 80.91.229.12 (28 Mar 2011 04:07:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Mar 2011 04:07:37 +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 06:07:32 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 1Q43jm-0005uA-Ep for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Mar 2011 06:07:30 +0200 Original-Received: from localhost ([127.0.0.1]:39623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q43jl-0008CX-Th for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Mar 2011 00:07:29 -0400 Original-Received: from [140.186.70.92] (port=56923 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q43jT-00086A-1g for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 00:07:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q43jR-0005Wi-6k for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 00:07:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q43jR-0005WN-4V for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2011 00:07:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q43gQ-0008MX-Ci; Mon, 28 Mar 2011 00:04:02 -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:04:02 +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.130128502032115 (code B ref 5937); Mon, 28 Mar 2011 04:04:02 +0000 Original-Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 04:03:40 +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 1Q43g3-0008Lw-1j for submit@debbugs.gnu.org; Mon, 28 Mar 2011 00:03:39 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q43g1-0008Lh-Ec for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 00:03:38 -0400 Original-Received: by pzk30 with SMTP id 30so457187pzk.3 for <5937@debbugs.gnu.org>; Sun, 27 Mar 2011 21:03:31 -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=5imKLcrYT1CiWo8hiZnJs5hsehOb5LJ0oVQKvMHZPzA=; b=UYKFMBXf9YBC8q2LMz8U+UsAK3h8A7efNvhPDKJxJ58AaPBWYU9vdDZ8Ei/8W29FSe vk3gVoPyseac0PXbAcd/ly7/TjeJRn8UThUoHJu8qtWyiDEyJ/5NFHXpbEumdIZ7WVzH 7lNkGHBpuGDhV6aoyk791G89uZ6k+pW71Cj7c= 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=ATdxXqntzuAONATQW4KU9FNG/e+YzZnPO8Sob+WSq+KiQSGVOs/mg/btDMI6dSpYcO r4fFB4vMwtgdgAn0XTpx3EcAXVJfvs6juAoNVWy482YYI8YMJPLQro/eztnGBQqOT++R YD52yHYaWVGkxQ4bSSC1UJ2DHGs0NEqU3Md/U= Original-Received: by 10.143.35.10 with SMTP id n10mr3398515wfj.429.1301285011461; Sun, 27 Mar 2011 21:03:31 -0700 (PDT) Original-Received: from Victoria.local (th041068.ip.tsinghua.edu.cn [59.66.41.68]) by mx.google.com with ESMTPS id o11sm5328971wfa.0.2011.03.27.21.03.27 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 21:03:30 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 27 Mar 2011 16:35:38 -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:04:02 -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:45407 Archived-At: On 2011-03-28 04:35 +0800, Stefan Monnier wrote: > I don't think we need such a thing. We just need to make it clear what > those empty tables mean and keep them out of the way. I.e. move them to > the end of the buffer and add a comment before them explaining that > these are currently empty. OK let's do this. I didn't insert a line explaining empty tables because they are obvious (See this screenshot: http://imgur.com/zCegB.png). (BTW, after looking at that screenshot I realised Makefile mode introduces 6 abbrev tables; amazing.) Let me know if you are OK with this patch. Thanks, Leo === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 +++ lisp/abbrev.el 2011-03-28 03:52:49 +0000 @@ -123,8 +123,13 @@ (if local (insert-abbrev-table-description (abbrev-table-name local-table) t) - (dolist (table abbrev-table-name-list) - (insert-abbrev-table-description table t))) + (let (empty-tables) + (dolist (table abbrev-table-name-list) + (if (abbrev-table-empty-p (symbol-value table)) + (push table empty-tables) + (insert-abbrev-table-description table t))) + (dolist (table (nreverse empty-tables)) + (insert-abbrev-table-description table t)))) (goto-char (point-min)) (set-buffer-modified-p nil) (edit-abbrevs-mode) @@ -420,6 +425,18 @@ (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object &optional ignore-system) + "Return nil if there are no abbrev symbols in OBJECT. +If IGNORE-SYSTEM is non-nil, system definitions are ignored." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (abbrev) + (unless (or (zerop (length (symbol-name abbrev))) + (and ignore-system (abbrev-get abbrev :system))) + (throw 'some t))) + object)))) + (defvar global-abbrev-table (make-abbrev-table) "The abbrev table whose abbrevs affect all buffers. Each buffer may also have a local abbrev table.