Subject: bug#7733: 23.1.90; C-u M-x list-abbrevs is not showing local abbrevs table

From: Brent Goodrick <[email-masked]>
Date: Fri, 24 Dec 2010 22:02:14 -0800

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the [email-masked] mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

Reproduce with:

1. Run emacs -Q.

2. From within the *scratch* buffer, type C-u M-x list-abbrevs RET.

3. See the *Abbrevs* buffer showing
   "(fundamental-mode-abbrev-table)". The bug is that the current mode
   at the time C-u M-x lisp-abbrevs RET is executed is in Lisp
   Interaction mode, not Fundamental mode. Therefore, the C-u M-x
   list-abbrevs RET operation should show lisp-mode-abbrev-table,
   but should not show fundamental-mode-abbrev-table.

I believe I have found the bug in prepare-abbrev-list-buffer. The
current definition of prepare-abbrev-list-buffer is:

(defun prepare-abbrev-list-buffer (&optional local)
  (with-current-buffer (get-buffer-create "*Abbrevs*")
    (erase-buffer)
    (if local
	(insert-abbrev-table-description
	 (abbrev-table-name local-abbrev-table) t)
      (dolist (table abbrev-table-name-list)
	(insert-abbrev-table-description table t)))
    (goto-char (point-min))
    (set-buffer-modified-p nil)
    (edit-abbrevs-mode)
    (current-buffer)))

My patched version that fixes the problem is as follows:

(defun prepare-abbrev-list-buffer (&optional local)
  (let ((local-table local-abbrev-table))
    (with-current-buffer (get-buffer-create "*Abbrevs*")
      (erase-buffer)
      (if local
	  (insert-abbrev-table-description
	   (abbrev-table-name local-table) t)
	(dolist (table abbrev-table-name-list)
	  (insert-abbrev-table-description table t)))
      (goto-char (point-min))
      (set-buffer-modified-p nil)
      (edit-abbrevs-mode)
      (current-buffer))))

The `with-current-buffer' call changes to the *Abbrevs* buffer which
is in fundamental mode, and then the local-abbrev-table (which is a
buffer-local value) is taken from fundamental mode, not from the mode
of the original buffer where the point was before the execution C-u
M-x list-abbrevs.

Thanks,
Brent

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/home/brentg/install/Linux.x86_64/share/emacs/23.1.90/etc/DEBUG.

In GNU Emacs 23.1.90.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.6)
 of 2010-07-04 on hungover
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--with-x-toolkit' '--with-xft' '--prefix=/home/brentg/install/Linux.x86_64''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  desktop-save-mode: t
  erc-ring-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  iswitchb-mode: t
  delete-selection-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: 1
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
C-v <return> C-p C-p C-p C-p C-p C-M-SPC M-( C-f l 
e t SPC M-( M-( t a b l e C-f C-f C-f C-f C-f C-f C-f 
C-b C-M-SPC C-w C-p C-n C-b C-b C-b C-b C-b C-b <return> 
C-v C-y <tab> C-p C-p C-a M-f M-f M-f M-b M-b C-M-SPC 
C-w C-M-u C-M-u C-M-SPC C-v C-p M-b M-b C-M-SPC a n 
d C-e M-SPC C-e C-y K C-M-u M-SPC C-n C-a C-M-SPC C-w 
M-b M-b M-b C-M-u C-M-u C-M-u C-M-n <return> C-v C-y 
<tab> C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-a 
M-f M-f M-b C-M-SPC C-z C-n C-n C-n C-n C-n M-f M-f 
M-b C-M-SPC C-v C-a C-M-x M-x M-P M-P <return> C-x 
o C-u M-x M-P M-P <return> C-x o C-1 C-p C-p C-p C-p 
C-p C-p C-M-SPC <backspace> C-k C-p C-M-SPC C-z C-x 
o C-x C-f ~ / t m p / p a t c h . t o . p r e p a r 
i - a b b r e v - l i s t . b u f f e r . C-x o M-f 
M-f M-b C-M-SPC C-z C-x o C-SPC C-x o C-SPC M-b C-f 
C-f C-f C-f C-f C-f C-f C-f C-f C-v . e l <return> 
C-v M-y <return> C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-x o C-x o C-p C-p C-p M-f M-f M-f M-f M-f M-b C-M-SPC 
C-w C-M-u C-M-u M-f M-f M-b C-M-SPC C-M-u C-g C-M-SPC 
C-v C-a C-x C-s C-4 e m a c s x f t SPC - Q <return> 
y y y M-x r e b p o r <backspace> <backspace> <backspace> 
<backspace> p o r t - b u <tab> <tab> <tab> e <tab> 
<tab> C-e <tab> <tab> <tab> <return>

Recent messages:
Pushed a window configuration.
Saving file /home/brentg/install/Linux.x86_64/share/emacs/23.1.90/lisp/abbrev.el.gz...
compressing abbrev.el.gz...done
Wrote /home/brentg/install/Linux.x86_64/share/emacs/23.1.90/lisp/abbrev.el.gz
Saving file /tmp/foo.cmake...
Wrote /tmp/foo.cmake
Saving file /tmp/o1.cpp...
Wrote /tmp/o1.cpp
Compilation finished
Making completion list... [2 times]

Load-path shadows:
/home/brentg/emacs_lisp_imported/slime/tree-widget hides /home/brentg/install/Linux.x86_64/share/emacs/23.1.90/lisp/tree-widget
/home/brentg/emacs_lisp_imported/remember/remember hides /home/brentg/install/Linux.x86_64/share/emacs/23.1.90/lisp/textmodes/remember
/home/brentg/emacs_lisp_imported/css-mode/css-mode hides /home/brentg/install/Linux.x86_64/share/emacs/23.1.90/lisp/textmodes/css-mode

Features:
(shadow mailalias vm-pgg vm-reply pgg pgg-parse pgg-def vm-rfaddons
gnus-group gnus-undo nnmail mail-source gnus-start gnus-spec gnus-int
gnus-range message ecomplete mml mml-sec password-cache mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums
gmm-utils mailheader canlock sha1 hex-util hashcash gnus-win bbdb-vm
vm-autoload bbdb-snarf mail-extr rfc822 bbdb-com vm-menu vm-window
vm-toolbar vm-folder vm-undo vm-summary vm-mouse vm-page vm-motion
vm-minibuf vm-misc emacsbug parse-time vc-cvs debug ansi-color
multi-isearch cl-specs bg-emacs bg-desktop-setup vc-git desktop
bg-customizations bg-x-setup bg-init-program-setup bg-dos-batch-mode
bg-cmake-setup cmake-mode bg-quack-setup quack bg-qmake-setup
bg-allout-setup bg-gimp-mode-setup eldoc cmuscheme scheme gimp-mode
scheme-complete snippet autoinsert bg-edebug-setup edebug
bg-lisppaste-setup bg-instrument-util bg-calc-setup calc-ext calc
calc-loaddefs calc-macs bg-sudo-setup sudo bg-crontab-util bg-reminder
bg-wikipedia-mode-setup wikipedia-mode bg-outline-magic-mode-setup
outline-magic noutline outline bg-emacs-lisp-mode-setup find-func
bg-lisp-setup bg-stumpwm-setup stumpwm-mode slime tree-widget
hyperspec hideshow bg-css-mode-setup bg-gnuserv-setup gnuserv
bg-compressed-files-setup bg-search-replace-util bg-apropos-mode-setup
apropos bg-search-tcl bg-man-setup bg-env-setup man assoc
bg-visual-basic-mode-setup bg-regr-util bg-help-mode-setup help-mode
bg-diag bg-password-hiding-setup bg-browser-setup bg-x-windows-util
bg-perl-setup gud bg-perl-util bg-rectangle-setup
bg-picture-mode-setup bg-xml-setup nxml-mode nxml-outln nxml-rap
nxml-util nxml-glyph nxml-enc xmltok boxquote bg-iswitchb-setup
bg-outline-setup allout bg-autosave-setup bg-planner-setup
bg-planner-indexing bg-planner-yank-link bg-planner-yank-link-man
bg-planner-yank-link-file bg-planner-yank-link-info bg-web-util mm-url
url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-util url-parse url-vars mailcap
bg-planner-yank-link-w3m bg-planner-yank-link-base bg-planner-elisp
bg-remember-mode-setup remember-planner remember bg-bbdb-setup
bbdb-autoloads bbdb bg-planner-note-util bg-elisp-unit-test-util
bg-planner-util bg-muse-hacks image-file planner-lisp planner-publish
muse-xml planner cal-menu calendar cal-loaddefs sort muse-colors
bg-muse-setup bg-planner-abbrevs-setup muse-html muse-xml-common
cus-edit cus-start cus-load muse-publish muse-project muse-protocols
muse-regexps muse muse-nested-tags muse-mode bg-planner-vars timeclock
bg-scrolling-setup bg-irc-setup erc-ring erc-join erc-services
erc-networks erc-dcc erc-fill erc-stamp erc-goodies erc erc-backend
erc-compat format-spec bg-ediff-setup bg-info-setup
bg-local-key-mappings bg-global-key-mappings bg-wrap-variable-util
bg-rx-interactive bg-grep-setup bg-grep-group grep-group grep
bg-color-moccur-setup color-moccur bg-occur-mode-setup
bg-find-file-setup bg-bookmark-definitions bookmark pp
bg-tabstop-definitions bg-mail-setup vm-w3m vm-mime vm-pine vm-macro
vm-message vm vm-autoloads vm-vars vm-version bg-encryption-setup dgpg
generic epa-file epa derived epg epg-config bg-w3m-setup edmacro
kmacro bg-w3m-hacks w3m browse-url doc-view jka-compr image-mode
timezone w3m-hist w3m-fb w3m-ems w3m-ccl ccl w3m-favicon w3m-image
w3m-proc w3m-util supercite regi smtpmail sendmail bg-gnus-definitions
imap gnus gnus-ems nnheader gnus-util netrc mail-utils mm-util
mail-prsvr wid-edit bg-octave-setup bg-scm-setup bg-vc-util vc
vc-dispatcher pcvs pcvs-parse pcvs-info pcvs-defs bg-git-setup git
log-edit easy-mmode pcvs-util add-log ewoc bg-tcl-mode-setup
bg-compile-setup bg-grep-compilation-util bg-python-mode-setup
python-21 python bg-buffer-menu-setup bg-makefile-mode-setup
bg-shell-script-mode-setup sh-script executable bg-sticky-windows
bg-dbx bg-gdb-mode-setup bg-gdb bg-gdb-util bg-javascript-setup js
byte-opt bytecomp byte-compile json etags imenu newcomment
bg-java-setup bg-calendar-setup bg-minibuffer-setup bg-abbrev-setup
bg-precision-util mailabbrev uniquify ibuffer bg-frame-definitions
bg-vc-mode-setup bg-dired-extensions bg-pdf-setup dired-aux dired
bg-forms-mode-setup forms-mode forms bg-defaults-definitions time
bg-isearch-setup bg-display-setup bg-cc-mode-setup bg-debug-util
bg-narrowing-setup advice advice-preload bg-cxx-nav bg-run-immediate
bg-window-config-helper bg-id-utils-setup idutils compile info
bg-info-util bg-symbol-stack bg-cxx-util bg-cxx-scan-debug-mode-base
bg-basic-regexps-and-chars bg-p4-setup bg-p4-completion bg-p4-resolve
bg-set-util bg-ediff-sparse-mode bg-ediff-sparse-mode-base
bg-p4-manual-apply-mode bg-p4-manual-apply-mode-base bg-p4-base
bg-det-setup bg-rx-extra bg-shell-mode-setup bg-rlogin-setup rlogin
shell comint ring bg-open-file-at-point bg-boilers bg-boiler-commands
help-fns bg-win32-utility bg-shell-util bg-win32-paths bg-background
time-date bg-p4-scan-mode bg-p4-scan-mode-base view
bg-button-mode-util bg-p4-basic-button bg-p4-util cc-mode cc-fonts
easymenu cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt bg-elisp-debug-util elp bg-utility rx iswitchb
bg-file-cleanup bg-os-util bg-linux-utility help-macro cl cl-19
ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult
ediff-init ediff perl-mode mouse-sel thingatpt rect
bg-delete-selection-mode-setup delsel bg-coding-system-setup
lisppaste-autoloads xml-rpc-autoloads package reporter tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)