2011-03-11 15:04:22 -05:00
|
|
|
|
;;; abbrev.el --- abbrev mode commands for Emacs -*- lexical-binding: t -*-
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
|
;; Copyright (C) 1985-1987, 1992, 2001-2022 Free Software Foundation,
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Inc.
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2019-05-25 13:43:06 -07:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1998-05-26 09:23:23 +00:00
|
|
|
|
;; Keywords: abbrev convenience
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
1993-03-18 21:29:42 +00:00
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1991-08-27 03:29:52 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
1993-03-22 03:27:18 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This facility is documented in the Emacs Manual.
|
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; Todo:
|
|
|
|
|
|
|
|
|
|
;; - Cleanup name space.
|
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 07:51:54 -04:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(require 'obarray)
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defgroup abbrev-mode nil
|
|
|
|
|
"Word abbreviations mode."
|
|
|
|
|
:link '(custom-manual "(emacs)Abbrevs")
|
|
|
|
|
:group 'abbrev)
|
|
|
|
|
|
2009-08-29 19:22:38 +00:00
|
|
|
|
(defcustom abbrev-file-name
|
|
|
|
|
(locate-user-emacs-file "abbrev_defs" ".abbrev_defs")
|
2009-09-11 21:25:44 +00:00
|
|
|
|
"Default name of file from which to read abbrevs."
|
|
|
|
|
:initialize 'custom-initialize-delay
|
2009-08-29 19:22:38 +00:00
|
|
|
|
:type 'file)
|
|
|
|
|
|
2002-01-05 19:02:27 +00:00
|
|
|
|
(defcustom only-global-abbrevs nil
|
2004-08-01 03:56:05 +00:00
|
|
|
|
"Non-nil means user plans to use global abbrevs only.
|
1997-08-11 23:54:58 +00:00
|
|
|
|
This makes the commands that normally define mode-specific abbrevs
|
|
|
|
|
define global abbrevs instead."
|
|
|
|
|
:type 'boolean
|
1998-05-26 09:23:23 +00:00
|
|
|
|
:group 'abbrev-mode
|
|
|
|
|
:group 'convenience)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2008-04-01 08:36:57 +00:00
|
|
|
|
(define-minor-mode abbrev-mode
|
2004-06-13 21:55:49 +00:00
|
|
|
|
"Toggle Abbrev mode in the current buffer.
|
Fix minor mode docstrings for the new meaning of a nil ARG.
* abbrev.el (abbrev-mode):
* allout.el (allout-mode):
* autoinsert.el (auto-insert-mode):
* autoarg.el (autoarg-mode, autoarg-kp-mode):
* autorevert.el (auto-revert-mode, auto-revert-tail-mode)
(global-auto-revert-mode):
* battery.el (display-battery-mode):
* composite.el (global-auto-composition-mode)
(auto-composition-mode):
* delsel.el (delete-selection-mode):
* desktop.el (desktop-save-mode):
* dired-x.el (dired-omit-mode):
* dirtrack.el (dirtrack-mode):
* doc-view.el (doc-view-minor-mode):
* double.el (double-mode):
* electric.el (electric-indent-mode, electric-pair-mode):
* emacs-lock.el (emacs-lock-mode):
* epa-hook.el (auto-encryption-mode):
* follow.el (follow-mode):
* font-core.el (font-lock-mode):
* frame.el (auto-raise-mode, auto-lower-mode, blink-cursor-mode):
* help.el (temp-buffer-resize-mode):
* hilit-chg.el (highlight-changes-mode)
(highlight-changes-visible-mode):
* hi-lock.el (hi-lock-mode):
* hl-line.el (hl-line-mode, global-hl-line-mode):
* icomplete.el (icomplete-mode):
* ido.el (ido-everywhere):
* image-file.el (auto-image-file-mode):
* image-mode.el (image-minor-mode):
* iswitchb.el (iswitchb-mode):
* jka-cmpr-hook.el (auto-compression-mode):
* linum.el (linum-mode):
* longlines.el (longlines-mode):
* master.el (master-mode):
* mb-depth.el (minibuffer-depth-indicate-mode):
* menu-bar.el (menu-bar-mode):
* minibuf-eldef.el (minibuffer-electric-default-mode):
* mouse-sel.el (mouse-sel-mode):
* msb.el (msb-mode):
* mwheel.el (mouse-wheel-mode):
* outline.el (outline-minor-mode):
* paren.el (show-paren-mode):
* recentf.el (recentf-mode):
* reveal.el (reveal-mode, global-reveal-mode):
* rfn-eshadow.el (file-name-shadow-mode):
* ruler-mode.el (ruler-mode):
* savehist.el (savehist-mode):
* scroll-all.el (scroll-all-mode):
* scroll-bar.el (scroll-bar-mode):
* server.el (server-mode):
* shell.el (shell-dirtrack-mode):
* simple.el (auto-fill-mode, transient-mark-mode)
(visual-line-mode, overwrite-mode, binary-overwrite-mode)
(line-number-mode, column-number-mode, size-indication-mode)
(auto-save-mode, normal-erase-is-backspace-mode, visible-mode):
* strokes.el (strokes-mode):
* time.el (display-time-mode):
* t-mouse.el (gpm-mouse-mode):
* tool-bar.el (tool-bar-mode):
* tooltip.el (tooltip-mode):
* type-break.el (type-break-mode-line-message-mode)
(type-break-query-mode):
* view.el (view-mode):
* whitespace.el (whitespace-mode, whitespace-newline-mode)
(global-whitespace-mode, global-whitespace-newline-mode):
* xt-mouse.el (xterm-mouse-mode): Doc fix.
* emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Fix
autogenerated docstring.
2011-10-19 08:54:24 -04:00
|
|
|
|
|
|
|
|
|
In Abbrev mode, inserting an abbreviation causes it to expand and
|
|
|
|
|
be replaced by its expansion."
|
2010-10-28 20:29:29 -07:00
|
|
|
|
;; It's defined in C, this stops the d-m-m macro defining it again.
|
|
|
|
|
:variable abbrev-mode)
|
1997-08-11 23:54:58 +00:00
|
|
|
|
|
2008-03-14 17:42:18 +00:00
|
|
|
|
(put 'abbrev-mode 'safe-local-variable 'booleanp)
|
1997-08-11 23:54:58 +00:00
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2018-04-20 18:34:39 -04:00
|
|
|
|
(define-obsolete-variable-alias 'edit-abbrevs-map
|
|
|
|
|
'edit-abbrevs-mode-map "24.4")
|
2022-01-10 01:03:22 +01:00
|
|
|
|
(defvar-keymap edit-abbrevs-mode-map
|
|
|
|
|
:doc "Keymap used in `edit-abbrevs'."
|
|
|
|
|
"C-x C-s" #'abbrev-edit-save-buffer
|
|
|
|
|
"C-x C-w" #'abbrev-edit-save-to-file
|
|
|
|
|
"C-c C-c" #'edit-abbrevs-redefine)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun kill-all-abbrevs ()
|
|
|
|
|
"Undefine all defined abbrevs."
|
|
|
|
|
(interactive)
|
2007-11-18 19:32:53 +00:00
|
|
|
|
(dolist (tablesym abbrev-table-name-list)
|
|
|
|
|
(clear-abbrev-table (symbol-value tablesym))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2002-09-12 03:19:25 +00:00
|
|
|
|
(defun copy-abbrev-table (table)
|
2012-03-03 18:45:04 -08:00
|
|
|
|
"Make a new abbrev-table with the same abbrevs as TABLE.
|
|
|
|
|
Does not copy property lists."
|
2002-09-12 03:19:25 +00:00
|
|
|
|
(let ((new-table (make-abbrev-table)))
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(obarray-map
|
2002-09-12 03:19:25 +00:00
|
|
|
|
(lambda (symbol)
|
|
|
|
|
(define-abbrev new-table
|
|
|
|
|
(symbol-name symbol)
|
|
|
|
|
(symbol-value symbol)
|
|
|
|
|
(symbol-function symbol)))
|
|
|
|
|
table)
|
|
|
|
|
new-table))
|
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(defun insert-abbrevs ()
|
|
|
|
|
"Insert after point a description of all defined abbrevs.
|
|
|
|
|
Mark is set after the inserted text."
|
|
|
|
|
(interactive)
|
|
|
|
|
(push-mark
|
|
|
|
|
(save-excursion
|
2007-11-18 19:32:53 +00:00
|
|
|
|
(dolist (tablesym abbrev-table-name-list)
|
|
|
|
|
(insert-abbrev-table-description tablesym t))
|
2005-04-23 12:34:05 +00:00
|
|
|
|
(point))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2000-08-28 16:07:10 +00:00
|
|
|
|
(defun list-abbrevs (&optional local)
|
|
|
|
|
"Display a list of defined abbrevs.
|
|
|
|
|
If LOCAL is non-nil, interactively when invoked with a
|
|
|
|
|
prefix arg, display only local, i.e. mode-specific, abbrevs.
|
|
|
|
|
Otherwise display all abbrevs."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(display-buffer (prepare-abbrev-list-buffer local)))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-table-name (table)
|
|
|
|
|
"Value is the name of abbrev table TABLE."
|
|
|
|
|
(let ((tables abbrev-table-name-list)
|
|
|
|
|
found)
|
|
|
|
|
(while (and (not found) tables)
|
|
|
|
|
(when (eq (symbol-value (car tables)) table)
|
|
|
|
|
(setq found (car tables)))
|
|
|
|
|
(setq tables (cdr tables)))
|
|
|
|
|
found))
|
2002-01-05 19:02:27 +00:00
|
|
|
|
|
2000-08-28 16:07:10 +00:00
|
|
|
|
(defun prepare-abbrev-list-buffer (&optional local)
|
2011-01-02 22:13:35 -08:00
|
|
|
|
(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)
|
2011-03-28 22:34:32 +08:00
|
|
|
|
(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))
|
2012-04-19 00:43:23 +08:00
|
|
|
|
(insert-abbrev-table-description table t)))
|
2012-04-22 22:44:49 -07:00
|
|
|
|
;; Note: `list-abbrevs' can display only local abbrevs, in
|
2012-04-19 00:43:23 +08:00
|
|
|
|
;; which case editing could lose abbrevs of other tables. Thus
|
|
|
|
|
;; enter `edit-abbrevs-mode' only if LOCAL is nil.
|
|
|
|
|
(edit-abbrevs-mode))
|
2011-01-02 22:13:35 -08:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(current-buffer))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun edit-abbrevs ()
|
|
|
|
|
"Alter abbrev definitions by editing a list of them.
|
2012-04-19 00:43:23 +08:00
|
|
|
|
Selects a buffer containing a list of abbrev definitions with
|
2018-11-23 12:16:48 +02:00
|
|
|
|
point located in the abbrev table for the current buffer, and
|
|
|
|
|
turns on `edit-abbrevs-mode' in that buffer.
|
2022-01-10 00:59:59 +01:00
|
|
|
|
|
|
|
|
|
You can edit them and type \\<edit-abbrevs-mode-map>\\[edit-abbrevs-redefine] \
|
|
|
|
|
to redefine abbrevs
|
1991-08-27 03:29:52 +00:00
|
|
|
|
according to your editing.
|
2022-01-10 00:59:59 +01:00
|
|
|
|
|
2018-11-23 12:16:48 +02:00
|
|
|
|
The abbrevs editing buffer contains a header line for each
|
|
|
|
|
abbrev table, which is the abbrev table name in parentheses.
|
2022-01-10 00:59:59 +01:00
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
This is followed by one line per abbrev in that table:
|
2022-01-10 00:59:59 +01:00
|
|
|
|
|
|
|
|
|
NAME USECOUNT EXPANSION HOOK
|
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
where NAME and EXPANSION are strings with quotes,
|
|
|
|
|
USECOUNT is an integer, and HOOK is any valid function
|
|
|
|
|
or may be omitted (it is usually omitted)."
|
|
|
|
|
(interactive)
|
2012-04-19 00:43:23 +08:00
|
|
|
|
(let ((table-name (abbrev-table-name local-abbrev-table)))
|
|
|
|
|
(switch-to-buffer (prepare-abbrev-list-buffer))
|
|
|
|
|
(when (and table-name
|
|
|
|
|
(search-forward
|
|
|
|
|
(concat "(" (symbol-name table-name) ")\n\n") nil t))
|
|
|
|
|
(goto-char (match-end 0)))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun edit-abbrevs-redefine ()
|
|
|
|
|
"Redefine abbrevs according to current buffer contents."
|
2022-01-10 00:55:16 +01:00
|
|
|
|
(interactive nil edit-abbrevs-mode)
|
2006-04-18 21:16:13 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(define-abbrevs t)
|
|
|
|
|
(set-buffer-modified-p nil)))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun define-abbrevs (&optional arg)
|
|
|
|
|
"Define abbrevs according to current visible buffer contents.
|
|
|
|
|
See documentation of `edit-abbrevs' for info on the format of the
|
|
|
|
|
text you must have in the buffer.
|
|
|
|
|
With argument, eliminate all abbrev definitions except
|
|
|
|
|
the ones defined from the buffer now."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg (kill-all-abbrevs))
|
|
|
|
|
(save-excursion
|
2005-04-23 12:34:05 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (and (not (eobp)) (re-search-forward "^(" nil t))
|
|
|
|
|
(let* ((buf (current-buffer))
|
|
|
|
|
(table (read buf))
|
|
|
|
|
abbrevs name hook exp count sys)
|
|
|
|
|
(forward-line 1)
|
2020-10-27 12:18:27 +01:00
|
|
|
|
(while (and (not (eobp))
|
|
|
|
|
;; Advance as long as we're looking at blank lines
|
|
|
|
|
;; or we have an abbrev.
|
|
|
|
|
(looking-at "[ \t\n]\\|\\(\"\\)"))
|
|
|
|
|
(when (match-string 1)
|
|
|
|
|
(setq name (read buf) count (read buf))
|
|
|
|
|
(if (equal count '(sys))
|
|
|
|
|
(setq sys t count (read buf))
|
|
|
|
|
(setq sys nil))
|
|
|
|
|
(setq exp (read buf))
|
|
|
|
|
(skip-chars-backward " \t\n\f")
|
|
|
|
|
(setq hook (if (not (eolp)) (read buf)))
|
|
|
|
|
(skip-chars-backward " \t\n\f")
|
|
|
|
|
(setq abbrevs (cons (list name exp hook count sys) abbrevs)))
|
|
|
|
|
(forward-line 1))
|
2005-04-23 12:34:05 +00:00
|
|
|
|
(define-abbrev-table table abbrevs)))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun read-abbrev-file (&optional file quietly)
|
|
|
|
|
"Read abbrev definitions from file written with `write-abbrev-file'.
|
|
|
|
|
Optional argument FILE is the name of the file to read;
|
|
|
|
|
it defaults to the value of `abbrev-file-name'.
|
2001-11-11 01:49:05 +00:00
|
|
|
|
Optional second argument QUIETLY non-nil means don't display a message."
|
2006-04-18 21:16:13 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 16:56:44 +02:00
|
|
|
|
(read-file-name (format-prompt "Read abbrev file" abbrev-file-name)
|
2006-04-18 21:16:13 +00:00
|
|
|
|
nil abbrev-file-name t)))
|
2006-04-18 22:04:27 +00:00
|
|
|
|
(load (or file abbrev-file-name) nil quietly)
|
2001-11-11 01:49:05 +00:00
|
|
|
|
(setq abbrevs-changed nil))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun quietly-read-abbrev-file (&optional file)
|
2004-08-01 03:56:05 +00:00
|
|
|
|
"Read abbrev definitions from file written with `write-abbrev-file'.
|
1991-08-27 03:29:52 +00:00
|
|
|
|
Optional argument FILE is the name of the file to read;
|
|
|
|
|
it defaults to the value of `abbrev-file-name'.
|
2001-11-11 01:49:05 +00:00
|
|
|
|
Does not display any message."
|
2005-04-23 12:34:05 +00:00
|
|
|
|
;(interactive "fRead abbrev file: ")
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(read-abbrev-file file t))
|
|
|
|
|
|
2011-03-30 09:06:00 +08:00
|
|
|
|
(defun write-abbrev-file (&optional file verbose)
|
2004-02-24 03:25:33 +00:00
|
|
|
|
"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'.
|
1991-08-27 03:29:52 +00:00
|
|
|
|
The file written can be loaded in another session to define the same abbrevs.
|
2004-02-24 03:25:33 +00:00
|
|
|
|
The argument FILE is the file name to write. If omitted or nil, the file
|
2011-03-30 09:06:00 +08:00
|
|
|
|
specified in `abbrev-file-name' is used.
|
|
|
|
|
If VERBOSE is non-nil, display a message indicating where abbrevs
|
|
|
|
|
have been saved."
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
2020-09-13 14:58:24 +02:00
|
|
|
|
(read-file-name "Write abbrev file: "
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(file-name-directory (expand-file-name abbrev-file-name))
|
|
|
|
|
abbrev-file-name)))
|
|
|
|
|
(or (and file (> (length file) 0))
|
|
|
|
|
(setq file abbrev-file-name))
|
2011-03-22 23:38:40 +08:00
|
|
|
|
(let ((coding-system-for-write 'utf-8))
|
|
|
|
|
(with-temp-buffer
|
2005-04-23 12:34:05 +00:00
|
|
|
|
(dolist (table
|
2011-03-22 23:38:40 +08:00
|
|
|
|
;; We sort the table in order to ease the automatic
|
|
|
|
|
;; merging of different versions of the user's abbrevs
|
|
|
|
|
;; file. This is useful, for example, for when the
|
|
|
|
|
;; user keeps their home directory in a revision
|
|
|
|
|
;; control system, and is therefore keeping multiple
|
|
|
|
|
;; slightly-differing copies loosely synchronized.
|
|
|
|
|
(sort (copy-sequence abbrev-table-name-list)
|
|
|
|
|
(lambda (s1 s2)
|
|
|
|
|
(string< (symbol-name s1)
|
|
|
|
|
(symbol-name s2)))))
|
2018-09-29 15:19:04 -07:00
|
|
|
|
(if (abbrev--table-symbols table)
|
|
|
|
|
(insert-abbrev-table-description table nil)))
|
2011-03-22 23:38:40 +08:00
|
|
|
|
(when (unencodable-char-position (point-min) (point-max) 'utf-8)
|
2020-05-16 17:02:18 +02:00
|
|
|
|
(setq coding-system-for-write 'utf-8-emacs))
|
2011-03-22 23:38:40 +08:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write))
|
2011-03-30 09:06:00 +08:00
|
|
|
|
(write-region nil nil file nil (and (not verbose) 0)))))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-edit-save-to-file (file)
|
|
|
|
|
"Save all user-level abbrev definitions in current buffer to FILE."
|
|
|
|
|
(interactive
|
2020-09-13 14:58:24 +02:00
|
|
|
|
(list (read-file-name "Save abbrevs to file: "
|
2011-03-30 09:06:00 +08:00
|
|
|
|
(file-name-directory
|
|
|
|
|
(expand-file-name abbrev-file-name))
|
2022-01-10 00:55:16 +01:00
|
|
|
|
abbrev-file-name))
|
|
|
|
|
edit-abbrevs-mode)
|
2011-03-30 09:06:00 +08:00
|
|
|
|
(edit-abbrevs-redefine)
|
|
|
|
|
(write-abbrev-file file t))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-edit-save-buffer ()
|
|
|
|
|
"Save all user-level abbrev definitions in current buffer.
|
|
|
|
|
The saved abbrevs are written to the file specified by
|
|
|
|
|
`abbrev-file-name'."
|
2022-01-10 00:55:16 +01:00
|
|
|
|
(interactive nil edit-abbrevs-mode)
|
2011-03-30 09:06:00 +08:00
|
|
|
|
(abbrev-edit-save-to-file abbrev-file-name))
|
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun add-mode-abbrev (arg)
|
|
|
|
|
"Define mode-specific abbrev for last word(s) before point.
|
|
|
|
|
Argument is how many words before point form the expansion;
|
|
|
|
|
or zero means the region is the expansion.
|
|
|
|
|
A negative argument means to undefine the specified abbrev.
|
|
|
|
|
Reads the abbreviation in the minibuffer.
|
|
|
|
|
|
2021-09-02 20:34:28 +03:00
|
|
|
|
See also `inverse-add-mode-abbrev', which performs the opposite task:
|
|
|
|
|
if the abbrev text is already in the buffer, use this command to
|
|
|
|
|
define an abbrev by specifying the expansion in the minibuffer.
|
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
Don't use this function in a Lisp program; use `define-abbrev' instead."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(add-abbrev
|
|
|
|
|
(if only-global-abbrevs
|
2003-02-04 11:26:42 +00:00
|
|
|
|
global-abbrev-table
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(or local-abbrev-table
|
|
|
|
|
(error "No per-mode abbrev table")))
|
|
|
|
|
"Mode" arg))
|
|
|
|
|
|
|
|
|
|
(defun add-global-abbrev (arg)
|
|
|
|
|
"Define global (all modes) abbrev for last word(s) before point.
|
|
|
|
|
The prefix argument specifies the number of words before point that form the
|
|
|
|
|
expansion; or zero means the region is the expansion.
|
|
|
|
|
A negative argument means to undefine the specified abbrev.
|
|
|
|
|
This command uses the minibuffer to read the abbreviation.
|
|
|
|
|
|
2021-09-02 20:34:28 +03:00
|
|
|
|
See also `inverse-add-global-abbrev', which performs the opposite task:
|
|
|
|
|
if the abbrev text is already in the buffer, use this command to
|
|
|
|
|
define an abbrev by specifying the expansion in the minibuffer.
|
|
|
|
|
|
1991-08-27 03:29:52 +00:00
|
|
|
|
Don't use this function in a Lisp program; use `define-abbrev' instead."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(add-abbrev global-abbrev-table "Global" arg))
|
|
|
|
|
|
|
|
|
|
(defun add-abbrev (table type arg)
|
|
|
|
|
(let ((exp (and (>= arg 0)
|
1999-10-18 21:28:04 +00:00
|
|
|
|
(buffer-substring-no-properties
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(point)
|
|
|
|
|
(if (= arg 0) (mark)
|
|
|
|
|
(save-excursion (forward-word (- arg)) (point))))))
|
|
|
|
|
name)
|
|
|
|
|
(setq name
|
|
|
|
|
(read-string (format (if exp "%s abbrev for \"%s\": "
|
|
|
|
|
"Undefine %s abbrev: ")
|
|
|
|
|
type exp)))
|
1994-09-29 19:07:45 +00:00
|
|
|
|
(set-text-properties 0 (length name) nil name)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(if (or (null exp)
|
|
|
|
|
(not (abbrev-expansion name table))
|
|
|
|
|
(y-or-n-p (format "%s expands to \"%s\"; redefine? "
|
|
|
|
|
name (abbrev-expansion name table))))
|
|
|
|
|
(define-abbrev table (downcase name) exp))))
|
2002-01-05 19:02:27 +00:00
|
|
|
|
|
2005-07-20 10:59:36 +00:00
|
|
|
|
(defun inverse-add-mode-abbrev (n)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
"Define last word before point as a mode-specific abbrev.
|
|
|
|
|
With prefix argument N, defines the Nth word before point.
|
|
|
|
|
This command uses the minibuffer to read the expansion.
|
2021-09-02 20:34:28 +03:00
|
|
|
|
Expands the abbreviation after defining it.
|
|
|
|
|
|
|
|
|
|
See also `add-mode-abbrev', which performs the opposite task:
|
|
|
|
|
if the expansion is already in the buffer, use this command
|
|
|
|
|
to define an abbrev by specifying the abbrev in the minibuffer."
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(inverse-add-abbrev
|
|
|
|
|
(if only-global-abbrevs
|
2002-01-05 19:02:27 +00:00
|
|
|
|
global-abbrev-table
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(or local-abbrev-table
|
|
|
|
|
(error "No per-mode abbrev table")))
|
2005-07-20 10:59:36 +00:00
|
|
|
|
"Mode" n))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
2005-07-20 10:59:36 +00:00
|
|
|
|
(defun inverse-add-global-abbrev (n)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
"Define last word before point as a global (mode-independent) abbrev.
|
|
|
|
|
With prefix argument N, defines the Nth word before point.
|
|
|
|
|
This command uses the minibuffer to read the expansion.
|
2021-09-02 20:34:28 +03:00
|
|
|
|
Expands the abbreviation after defining it.
|
|
|
|
|
|
|
|
|
|
See also `add-global-abbrev', which performs the opposite task:
|
|
|
|
|
if the expansion is already in the buffer, use this command
|
|
|
|
|
to define an abbrev by specifying the abbrev in the minibuffer."
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(interactive "p")
|
2005-07-20 10:59:36 +00:00
|
|
|
|
(inverse-add-abbrev global-abbrev-table "Global" n))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun inverse-add-abbrev (table type arg)
|
2000-03-17 22:32:39 +00:00
|
|
|
|
(let (name exp start end)
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(save-excursion
|
2000-03-17 22:32:39 +00:00
|
|
|
|
(forward-word (1+ (- arg)))
|
2019-06-16 03:32:02 -07:00
|
|
|
|
(skip-syntax-backward "^w")
|
2000-03-17 22:32:39 +00:00
|
|
|
|
(setq end (point))
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(setq start (point)
|
|
|
|
|
name (buffer-substring-no-properties start end)))
|
|
|
|
|
|
|
|
|
|
(setq exp (read-string (format "%s expansion for \"%s\": " type name)
|
|
|
|
|
nil nil nil t))
|
|
|
|
|
(when (or (not (abbrev-expansion name table))
|
|
|
|
|
(y-or-n-p (format "%s expands to \"%s\"; redefine? "
|
|
|
|
|
name (abbrev-expansion name table))))
|
|
|
|
|
(define-abbrev table (downcase name) exp)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(expand-abbrev)))))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
|
|
|
|
|
(defun abbrev-prefix-mark (&optional arg)
|
|
|
|
|
"Mark current point as the beginning of an abbrev.
|
2019-07-10 14:46:05 +02:00
|
|
|
|
The abbrev to be expanded starts here rather than at beginning of
|
|
|
|
|
word. This way, you can expand an abbrev with a prefix: insert
|
|
|
|
|
the prefix, use this command, then insert the abbrev.
|
|
|
|
|
|
2019-07-18 15:44:51 +03:00
|
|
|
|
This command inserts a hyphen after the prefix, and if the abbrev
|
|
|
|
|
is subsequently expanded, this hyphen will be removed.
|
2019-07-10 14:46:05 +02:00
|
|
|
|
|
|
|
|
|
If the prefix is itself an abbrev, this command expands it,
|
|
|
|
|
unless ARG is non-nil. Interactively, ARG is the prefix
|
|
|
|
|
argument."
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(or arg (expand-abbrev))
|
|
|
|
|
(setq abbrev-start-location (point-marker)
|
|
|
|
|
abbrev-start-location-buffer (current-buffer))
|
|
|
|
|
(insert "-"))
|
|
|
|
|
|
|
|
|
|
(defun expand-region-abbrevs (start end &optional noquery)
|
|
|
|
|
"For abbrev occurrence in the region, offer to expand it.
|
2021-11-22 11:45:44 +01:00
|
|
|
|
The user is asked to type \\`y' or \\`n' for each occurrence.
|
2005-07-20 10:59:36 +00:00
|
|
|
|
A prefix argument means don't query; expand all abbrevs."
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(interactive "r\nP")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(let ((lim (- (point-max) end))
|
|
|
|
|
pnt string)
|
|
|
|
|
(while (and (not (eobp))
|
|
|
|
|
(progn (forward-word 1)
|
|
|
|
|
(<= (setq pnt (point)) (- (point-max) lim))))
|
|
|
|
|
(if (abbrev-expansion
|
|
|
|
|
(setq string
|
1999-10-18 21:28:04 +00:00
|
|
|
|
(buffer-substring-no-properties
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(save-excursion (forward-word -1) (point))
|
|
|
|
|
pnt)))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 08:41:44 -07:00
|
|
|
|
(if (or noquery (y-or-n-p (format-message "Expand `%s'? " string)))
|
1991-08-27 03:29:52 +00:00
|
|
|
|
(expand-abbrev)))))))
|
1992-05-30 23:54:21 +00:00
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;;; Abbrev properties.
|
|
|
|
|
|
|
|
|
|
(defun abbrev-table-get (table prop)
|
|
|
|
|
"Get the PROP property of abbrev table TABLE."
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let ((sym (obarray-get table "")))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(if sym (get sym prop))))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-table-put (table prop val)
|
|
|
|
|
"Set the PROP property of abbrev table TABLE to VAL."
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let ((sym (obarray-put table "")))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(set sym nil) ; Make sure it won't be confused for an abbrev.
|
|
|
|
|
(put sym prop val)))
|
|
|
|
|
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(defalias 'abbrev-get 'get
|
|
|
|
|
"Get the property PROP of abbrev ABBREV
|
|
|
|
|
|
|
|
|
|
\(fn ABBREV PROP)")
|
|
|
|
|
|
|
|
|
|
(defalias 'abbrev-put 'put
|
2013-12-27 22:37:35 -08:00
|
|
|
|
"Set the property PROP of abbrev ABBREV to value VAL.
|
2007-10-30 01:39:19 +00:00
|
|
|
|
See `define-abbrev' for the effect of some special properties.
|
|
|
|
|
|
|
|
|
|
\(fn ABBREV PROP VAL)")
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
;;; Code that used to be implemented in src/abbrev.c
|
|
|
|
|
|
|
|
|
|
(defvar abbrev-table-name-list '(fundamental-mode-abbrev-table
|
|
|
|
|
global-abbrev-table)
|
|
|
|
|
"List of symbols whose values are abbrev tables.")
|
|
|
|
|
|
|
|
|
|
(defun make-abbrev-table (&optional props)
|
|
|
|
|
"Create a new, empty abbrev table object.
|
2008-04-17 17:40:52 +00:00
|
|
|
|
PROPS is a list of properties."
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let ((table (obarray-make)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; Each abbrev-table has a `modiff' counter which can be used to detect
|
|
|
|
|
;; when an abbreviation was added. An example of use would be to
|
|
|
|
|
;; construct :regexp dynamically as the union of all abbrev names, so
|
|
|
|
|
;; `modiff' can let us detect that an abbrev was added and hence :regexp
|
|
|
|
|
;; needs to be refreshed.
|
|
|
|
|
;; The presence of `modiff' entry is also used as a tag indicating this
|
|
|
|
|
;; vector is really an abbrev-table.
|
|
|
|
|
(abbrev-table-put table :abbrev-table-modiff 0)
|
|
|
|
|
(while (consp props)
|
|
|
|
|
(abbrev-table-put table (pop props) (pop props)))
|
|
|
|
|
table))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-table-p (object)
|
2012-03-03 18:45:04 -08:00
|
|
|
|
"Return non-nil if OBJECT is an abbrev table."
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(and (obarrayp object)
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(numberp (abbrev-table-get object :abbrev-table-modiff))))
|
|
|
|
|
|
2011-03-28 22:34:32 +08:00
|
|
|
|
(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
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(obarray-map (lambda (abbrev)
|
|
|
|
|
(unless (or (zerop (length (symbol-name abbrev)))
|
|
|
|
|
(and ignore-system
|
|
|
|
|
(abbrev-get abbrev :system)))
|
|
|
|
|
(throw 'some t)))
|
|
|
|
|
object))))
|
2011-03-28 22:34:32 +08:00
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(defvar global-abbrev-table (make-abbrev-table)
|
|
|
|
|
"The abbrev table whose abbrevs affect all buffers.
|
|
|
|
|
Each buffer may also have a local abbrev table.
|
|
|
|
|
If it does, the local table overrides the global one
|
|
|
|
|
for any particular abbrev defined in both.")
|
|
|
|
|
|
|
|
|
|
(defvar abbrev-minor-mode-table-alist nil
|
|
|
|
|
"Alist of abbrev tables to use for minor modes.
|
|
|
|
|
Each element looks like (VARIABLE . ABBREV-TABLE);
|
2012-03-03 18:45:04 -08:00
|
|
|
|
ABBREV-TABLE is active whenever VARIABLE's value is non-nil.
|
|
|
|
|
ABBREV-TABLE can also be a list of abbrev tables.")
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defvar fundamental-mode-abbrev-table
|
|
|
|
|
(let ((table (make-abbrev-table)))
|
|
|
|
|
;; Set local-abbrev-table's default to be fundamental-mode-abbrev-table.
|
|
|
|
|
(setq-default local-abbrev-table table)
|
|
|
|
|
table)
|
|
|
|
|
"The abbrev table of mode-specific abbrevs for Fundamental Mode.")
|
|
|
|
|
|
|
|
|
|
(defvar abbrevs-changed nil
|
|
|
|
|
"Set non-nil by defining or altering any word abbrevs.
|
|
|
|
|
This causes `save-some-buffers' to offer to save the abbrevs.")
|
|
|
|
|
|
|
|
|
|
(defcustom abbrev-all-caps nil
|
|
|
|
|
"Non-nil means expand multi-word abbrevs all caps if abbrev was so."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'abbrev-mode)
|
|
|
|
|
|
|
|
|
|
(defvar abbrev-start-location nil
|
|
|
|
|
"Buffer position for `expand-abbrev' to use as the start of the abbrev.
|
|
|
|
|
When nil, use the word before point as the abbrev.
|
|
|
|
|
Calling `expand-abbrev' sets this to nil.")
|
|
|
|
|
|
|
|
|
|
(defvar abbrev-start-location-buffer nil
|
|
|
|
|
"Buffer that `abbrev-start-location' has been set for.
|
|
|
|
|
Trying to expand an abbrev in any other buffer clears `abbrev-start-location'.")
|
|
|
|
|
|
|
|
|
|
(defvar last-abbrev nil
|
|
|
|
|
"The abbrev-symbol of the last abbrev expanded. See `abbrev-symbol'.")
|
|
|
|
|
|
|
|
|
|
(defvar last-abbrev-text nil
|
|
|
|
|
"The exact text of the last abbrev expanded.
|
2010-04-26 11:55:29 +02:00
|
|
|
|
It is nil if the abbrev has already been unexpanded.")
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defvar last-abbrev-location 0
|
|
|
|
|
"The location of the start of the last abbrev expanded.")
|
|
|
|
|
|
Prefer defvar-local in preloaded files
* lisp/abbrev.el:
* lisp/bindings.el (mode-line-mule-info, mode-line-modified)
(mode-line-remote, mode-line-process)
(mode-line-buffer-identification):
* lisp/buff-menu.el (Buffer-menu-files-only):
* lisp/files.el (buffer-file-number, buffer-file-read-only)
(local-write-file-hooks, write-contents-functions)
(file-local-variables-alist, dir-local-variables-alist)
(save-buffer-coding-system, buffer-save-without-query):
* lisp/font-core.el (font-lock-defaults):
* lisp/font-lock.el (font-lock-keywords-case-fold-search)
(font-lock-syntactically-fontified)
(font-lock-extend-after-change-region-function)
(font-lock-extend-region-functions, font-lock-major-mode):
* lisp/menu-bar.el (list-buffers-directory):
* lisp/simple.el (next-error--message-highlight-overlay)
(next-error-buffer, next-error-function)
(next-error-move-function, goto-line-history)
(minibuffer-default-add-done, undo-extra-outer-limit):
* lisp/tab-bar.el (tab-switcher-column):
* lisp/term/ns-win.el (ns-select-overlay):
* lisp/window.el (window-size-fixed, window-area-factor)
(window-group-start-function, window-group-end-function)
(set-window-group-start-function)
(recenter-window-group-function)
(pos-visible-in-window-group-p-function)
(selected-window-group-function)
(move-to-window-group-line-function): Prefer defvar-local.
2021-01-31 19:46:20 +01:00
|
|
|
|
;; (defvar-local local-abbrev-table fundamental-mode-abbrev-table
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; "Local (mode-specific) abbrev table of current buffer.")
|
|
|
|
|
|
|
|
|
|
(defun clear-abbrev-table (table)
|
|
|
|
|
"Undefine all abbrevs in abbrev table TABLE, leaving it empty."
|
|
|
|
|
(setq abbrevs-changed t)
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let* ((sym (obarray-get table "")))
|
2007-11-18 19:32:53 +00:00
|
|
|
|
(dotimes (i (length table))
|
|
|
|
|
(aset table i 0))
|
|
|
|
|
;; Preserve the table's properties.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 07:51:54 -04:00
|
|
|
|
(cl-assert sym)
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let ((newsym (obarray-put table "")))
|
2008-01-14 20:17:52 +00:00
|
|
|
|
(set newsym nil) ; Make sure it won't be confused for an abbrev.
|
|
|
|
|
(setplist newsym (symbol-plist sym)))
|
2007-11-18 19:32:53 +00:00
|
|
|
|
(abbrev-table-put table :abbrev-table-modiff
|
2009-03-01 19:22:22 +00:00
|
|
|
|
(1+ (abbrev-table-get table :abbrev-table-modiff))))
|
2009-03-01 19:24:15 +00:00
|
|
|
|
;; For backward compatibility, always return nil.
|
2009-03-01 19:22:22 +00:00
|
|
|
|
nil)
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defun define-abbrev (table name expansion &optional hook &rest props)
|
|
|
|
|
"Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK.
|
|
|
|
|
NAME must be a string, and should be lower-case.
|
|
|
|
|
EXPANSION should usually be a string.
|
|
|
|
|
To undefine an abbrev, define it with EXPANSION = nil.
|
|
|
|
|
If HOOK is non-nil, it should be a function of no arguments;
|
|
|
|
|
it is called after EXPANSION is inserted.
|
2008-10-17 21:25:58 +00:00
|
|
|
|
If EXPANSION is not a string (and not nil), the abbrev is a
|
|
|
|
|
special one, which does not expand in the usual way but only
|
|
|
|
|
runs HOOK.
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
2012-03-03 18:45:04 -08:00
|
|
|
|
If HOOK is a non-nil symbol with a non-nil `no-self-insert' property,
|
|
|
|
|
it can control whether the character that triggered abbrev expansion
|
|
|
|
|
is inserted. If such a HOOK returns non-nil, the character is not
|
|
|
|
|
inserted. If such a HOOK returns nil, then so does `abbrev-insert'
|
|
|
|
|
\(and `expand-abbrev'), as if no abbrev expansion had taken place.
|
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
PROPS is a property list. The following properties are special:
|
2008-04-17 17:40:52 +00:00
|
|
|
|
- `:count': the value for the abbrev's usage-count, which is incremented each
|
|
|
|
|
time the abbrev is used (the default is zero).
|
2007-10-30 01:39:19 +00:00
|
|
|
|
- `:system': if non-nil, says that this is a \"system\" abbreviation
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
which should not be saved in the user's abbreviation file.
|
2007-10-30 01:39:19 +00:00
|
|
|
|
Unless `:system' is `force', a system abbreviation will not
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
overwrite a non-system abbreviation of the same name.
|
|
|
|
|
- `:case-fixed': non-nil means that abbreviations are looked up without
|
|
|
|
|
case-folding, and the expansion is not capitalized/upcased.
|
2008-04-26 02:33:08 +00:00
|
|
|
|
- `:enable-function': a function of no argument which returns non-nil if the
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
abbrev should be used for a particular call of `expand-abbrev'.
|
|
|
|
|
|
|
|
|
|
An obsolete but still supported calling form is:
|
|
|
|
|
|
2007-10-30 01:39:19 +00:00
|
|
|
|
\(define-abbrev TABLE NAME EXPANSION &optional HOOK COUNT SYSTEM)."
|
2021-10-13 21:21:23 +02:00
|
|
|
|
(declare (indent defun))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(when (and (consp props) (or (null (car props)) (numberp (car props))))
|
|
|
|
|
;; Old-style calling convention.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 07:51:54 -04:00
|
|
|
|
(setq props `(:count ,(car props)
|
|
|
|
|
,@(if (cadr props) (list :system (cadr props))))))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(unless (plist-get props :count)
|
|
|
|
|
(setq props (plist-put props :count 0)))
|
2015-11-07 13:32:33 +02:00
|
|
|
|
(setq props (plist-put props :abbrev-table-modiff
|
|
|
|
|
(abbrev-table-get table :abbrev-table-modiff)))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(let ((system-flag (plist-get props :system))
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(sym (obarray-put table name)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; Don't override a prior user-defined abbrev with a system abbrev,
|
|
|
|
|
;; unless system-flag is `force'.
|
|
|
|
|
(unless (and (not (memq system-flag '(nil force)))
|
|
|
|
|
(boundp sym) (symbol-value sym)
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(not (abbrev-get sym :system)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(unless (or system-flag
|
2014-01-06 18:34:05 -05:00
|
|
|
|
(and (boundp sym)
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; load-file-name
|
|
|
|
|
(equal (symbol-value sym) expansion)
|
|
|
|
|
(equal (symbol-function sym) hook)))
|
|
|
|
|
(setq abbrevs-changed t))
|
|
|
|
|
(set sym expansion)
|
|
|
|
|
(fset sym hook)
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(setplist sym
|
|
|
|
|
;; Don't store the `force' value of `system-flag' into
|
|
|
|
|
;; the :system property.
|
|
|
|
|
(if (eq 'force system-flag) (plist-put props :system t) props))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(abbrev-table-put table :abbrev-table-modiff
|
|
|
|
|
(1+ (abbrev-table-get table :abbrev-table-modiff))))
|
|
|
|
|
name))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--check-chars (abbrev global)
|
|
|
|
|
"Check if the characters in ABBREV have word syntax in either the
|
|
|
|
|
current (if global is nil) or standard syntax table."
|
|
|
|
|
(with-syntax-table
|
2013-09-12 15:36:23 -04:00
|
|
|
|
(cond ((null global) (syntax-table))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; ((syntax-table-p global) global)
|
2013-09-12 15:36:23 -04:00
|
|
|
|
(t (standard-syntax-table)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(when (string-match "\\W" abbrev)
|
|
|
|
|
(let ((badchars ())
|
|
|
|
|
(pos 0))
|
|
|
|
|
(while (string-match "\\W" abbrev pos)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 07:51:54 -04:00
|
|
|
|
(cl-pushnew (aref abbrev (match-beginning 0)) badchars)
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(setq pos (1+ pos)))
|
|
|
|
|
(error "Some abbrev characters (%s) are not word constituents %s"
|
|
|
|
|
(apply 'string (nreverse badchars))
|
|
|
|
|
(if global "in the standard syntax" "in this mode"))))))
|
|
|
|
|
|
|
|
|
|
(defun define-global-abbrev (abbrev expansion)
|
|
|
|
|
"Define ABBREV as a global abbreviation for EXPANSION.
|
|
|
|
|
The characters in ABBREV must all be word constituents in the standard
|
|
|
|
|
syntax table."
|
|
|
|
|
(interactive "sDefine global abbrev: \nsExpansion for %s: ")
|
|
|
|
|
(abbrev--check-chars abbrev 'global)
|
|
|
|
|
(define-abbrev global-abbrev-table (downcase abbrev) expansion))
|
|
|
|
|
|
|
|
|
|
(defun define-mode-abbrev (abbrev expansion)
|
|
|
|
|
"Define ABBREV as a mode-specific abbreviation for EXPANSION.
|
|
|
|
|
The characters in ABBREV must all be word-constituents in the current mode."
|
|
|
|
|
(interactive "sDefine mode abbrev: \nsExpansion for %s: ")
|
|
|
|
|
(unless local-abbrev-table
|
|
|
|
|
(error "Major mode has no abbrev table"))
|
|
|
|
|
(abbrev--check-chars abbrev nil)
|
|
|
|
|
(define-abbrev local-abbrev-table (downcase abbrev) expansion))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--active-tables (&optional tables)
|
|
|
|
|
"Return the list of abbrev tables currently active.
|
|
|
|
|
TABLES if non-nil overrides the usual rules. It can hold
|
|
|
|
|
either a single abbrev table or a list of abbrev tables."
|
|
|
|
|
;; We could just remove the `tables' arg and let callers use
|
|
|
|
|
;; (or table (abbrev--active-tables)) but then they'd have to be careful
|
|
|
|
|
;; to treat the distinction between a single table and a list of tables.
|
|
|
|
|
(cond
|
|
|
|
|
((consp tables) tables)
|
2019-06-26 10:24:59 -04:00
|
|
|
|
((vectorp tables) (list tables))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(t
|
|
|
|
|
(let ((tables (if (listp local-abbrev-table)
|
|
|
|
|
(append local-abbrev-table
|
|
|
|
|
(list global-abbrev-table))
|
|
|
|
|
(list local-abbrev-table global-abbrev-table))))
|
|
|
|
|
;; Add the minor-mode abbrev tables.
|
|
|
|
|
(dolist (x abbrev-minor-mode-table-alist)
|
|
|
|
|
(when (and (symbolp (car x)) (boundp (car x)) (symbol-value (car x)))
|
|
|
|
|
(setq tables
|
|
|
|
|
(if (listp (cdr x))
|
|
|
|
|
(append (cdr x) tables) (cons (cdr x) tables)))))
|
|
|
|
|
tables))))
|
2007-11-04 23:01:15 +00:00
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
2013-04-16 13:28:11 -04:00
|
|
|
|
(defun abbrev--symbol (abbrev table)
|
|
|
|
|
"Return the symbol representing abbrev named ABBREV in TABLE.
|
|
|
|
|
This symbol's name is ABBREV, but it is not the canonical symbol of that name;
|
|
|
|
|
it is interned in the abbrev-table TABLE rather than the normal obarray.
|
|
|
|
|
The value is nil if that abbrev is not defined."
|
|
|
|
|
(let* ((case-fold (not (abbrev-table-get table :case-fixed)))
|
|
|
|
|
;; In case the table doesn't set :case-fixed but some of the
|
|
|
|
|
;; abbrevs do, we have to be careful.
|
|
|
|
|
(sym
|
|
|
|
|
;; First try without case-folding.
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(or (obarray-get table abbrev)
|
2013-04-16 13:28:11 -04:00
|
|
|
|
(when case-fold
|
|
|
|
|
;; We didn't find any abbrev, try case-folding.
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(let ((sym (obarray-get table (downcase abbrev))))
|
2013-04-16 13:28:11 -04:00
|
|
|
|
;; Only use it if it doesn't require :case-fixed.
|
|
|
|
|
(and sym (not (abbrev-get sym :case-fixed))
|
|
|
|
|
sym))))))
|
|
|
|
|
(if (symbol-value sym)
|
|
|
|
|
sym)))
|
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(defun abbrev-symbol (abbrev &optional table)
|
|
|
|
|
"Return the symbol representing abbrev named ABBREV.
|
|
|
|
|
This symbol's name is ABBREV, but it is not the canonical symbol of that name;
|
|
|
|
|
it is interned in an abbrev-table rather than the normal obarray.
|
|
|
|
|
The value is nil if that abbrev is not defined.
|
|
|
|
|
Optional second arg TABLE is abbrev table to look it up in.
|
|
|
|
|
The default is to try buffer's mode-specific abbrev table, then global table."
|
|
|
|
|
(let ((tables (abbrev--active-tables table))
|
|
|
|
|
sym)
|
2013-04-16 13:28:11 -04:00
|
|
|
|
(while (and tables (not sym))
|
|
|
|
|
(let* ((table (pop tables)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(setq tables (append (abbrev-table-get table :parents) tables))
|
2013-04-16 13:28:11 -04:00
|
|
|
|
(setq sym (abbrev--symbol abbrev table))))
|
|
|
|
|
sym))
|
2007-11-04 23:01:15 +00:00
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defun abbrev-expansion (abbrev &optional table)
|
|
|
|
|
"Return the string that ABBREV expands into in the current buffer.
|
|
|
|
|
Optionally specify an abbrev table as second arg;
|
|
|
|
|
then ABBREV is looked up in that table only."
|
|
|
|
|
(symbol-value (abbrev-symbol abbrev table)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun abbrev--before-point ()
|
|
|
|
|
"Try and find an abbrev before point. Return it if found, nil otherwise."
|
|
|
|
|
(unless (eq abbrev-start-location-buffer (current-buffer))
|
|
|
|
|
(setq abbrev-start-location nil))
|
|
|
|
|
|
|
|
|
|
(let ((tables (abbrev--active-tables))
|
|
|
|
|
(pos (point))
|
|
|
|
|
start end name res)
|
|
|
|
|
|
|
|
|
|
(if abbrev-start-location
|
|
|
|
|
(progn
|
|
|
|
|
(setq start abbrev-start-location)
|
|
|
|
|
(setq abbrev-start-location nil)
|
|
|
|
|
;; Remove the hyphen inserted by `abbrev-prefix-mark'.
|
2017-03-02 07:56:53 -05:00
|
|
|
|
(when (and (< start (point-max))
|
|
|
|
|
(eq (char-after start) ?-))
|
|
|
|
|
(delete-region start (1+ start))
|
|
|
|
|
(setq pos (1- pos)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(skip-syntax-backward " ")
|
|
|
|
|
(setq end (point))
|
2007-10-31 15:47:02 +00:00
|
|
|
|
(when (> end start)
|
|
|
|
|
(setq name (buffer-substring start end))
|
|
|
|
|
(goto-char pos) ; Restore point.
|
|
|
|
|
(list (abbrev-symbol name tables) name start end)))
|
2007-11-04 23:01:15 +00:00
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(while (and tables (not (car res)))
|
|
|
|
|
(let* ((table (pop tables))
|
|
|
|
|
(enable-fun (abbrev-table-get table :enable-function)))
|
|
|
|
|
(setq tables (append (abbrev-table-get table :parents) tables))
|
|
|
|
|
(setq res
|
|
|
|
|
(and (or (not enable-fun) (funcall enable-fun))
|
2009-11-25 04:59:02 +00:00
|
|
|
|
(let ((re (abbrev-table-get table :regexp)))
|
|
|
|
|
(if (null re)
|
|
|
|
|
;; We used to default `re' to "\\<\\(\\w+\\)\\W*"
|
|
|
|
|
;; but when words-include-escapes is set, that
|
|
|
|
|
;; is not right and fixing it is boring.
|
|
|
|
|
(let ((lim (point)))
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(setq start (point))
|
|
|
|
|
(forward-word 1)
|
|
|
|
|
(setq end (min (point) lim)))
|
|
|
|
|
(when (looking-back re (line-beginning-position))
|
|
|
|
|
(setq start (match-beginning 1))
|
|
|
|
|
(setq end (match-end 1)))))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(setq name (buffer-substring start end))
|
2013-04-16 13:28:11 -04:00
|
|
|
|
(let ((abbrev (abbrev--symbol name table)))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(when abbrev
|
|
|
|
|
(setq enable-fun (abbrev-get abbrev :enable-function))
|
|
|
|
|
(and (or (not enable-fun) (funcall enable-fun))
|
|
|
|
|
;; This will also look it up in parent tables.
|
|
|
|
|
;; This is not on purpose, but it seems harmless.
|
|
|
|
|
(list abbrev name start end))))))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; Restore point.
|
|
|
|
|
(goto-char pos)))
|
|
|
|
|
res)))
|
|
|
|
|
|
2008-04-17 19:54:00 +00:00
|
|
|
|
(defun abbrev-insert (abbrev &optional name wordstart wordend)
|
|
|
|
|
"Insert abbrev ABBREV at point.
|
|
|
|
|
If non-nil, NAME is the name by which this abbrev was found.
|
|
|
|
|
If non-nil, WORDSTART is the place where to insert the abbrev.
|
2009-05-13 01:13:51 +00:00
|
|
|
|
If WORDEND is non-nil, the abbrev replaces the previous text between
|
2008-04-17 19:54:00 +00:00
|
|
|
|
WORDSTART and WORDEND.
|
2012-03-03 18:45:04 -08:00
|
|
|
|
Return ABBREV if the expansion should be considered as having taken place.
|
|
|
|
|
The return value can be influenced by a `no-self-insert' property;
|
|
|
|
|
see `define-abbrev' for details."
|
2008-04-17 19:54:00 +00:00
|
|
|
|
(unless name (setq name (symbol-name abbrev)))
|
|
|
|
|
(unless wordstart (setq wordstart (point)))
|
|
|
|
|
(unless wordend (setq wordend wordstart))
|
|
|
|
|
;; Increment use count.
|
|
|
|
|
(abbrev-put abbrev :count (1+ (abbrev-get abbrev :count)))
|
|
|
|
|
(let ((value abbrev))
|
|
|
|
|
;; If this abbrev has an expansion, delete the abbrev
|
|
|
|
|
;; and insert the expansion.
|
|
|
|
|
(when (stringp (symbol-value abbrev))
|
|
|
|
|
(goto-char wordstart)
|
|
|
|
|
;; Insert at beginning so that markers at the end (e.g. point)
|
|
|
|
|
;; are preserved.
|
|
|
|
|
(insert (symbol-value abbrev))
|
|
|
|
|
(delete-char (- wordend wordstart))
|
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
;; If the abbrev's name is different from the buffer text (the
|
|
|
|
|
;; only difference should be capitalization), then we may want
|
|
|
|
|
;; to adjust the capitalization of the expansion.
|
|
|
|
|
(when (and (not (equal name (symbol-name abbrev)))
|
|
|
|
|
(string-match "[[:upper:]]" name))
|
|
|
|
|
(if (not (string-match "[[:lower:]]" name))
|
|
|
|
|
;; Abbrev was all caps. If expansion is multiple words,
|
|
|
|
|
;; normally capitalize each word.
|
|
|
|
|
(if (and (not abbrev-all-caps)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(> (progn (backward-word 1) (point))
|
|
|
|
|
(progn (goto-char wordstart)
|
|
|
|
|
(forward-word 1) (point)))))
|
|
|
|
|
(upcase-initials-region wordstart (point))
|
|
|
|
|
(upcase-region wordstart (point)))
|
|
|
|
|
;; Abbrev included some caps. Cap first initial of expansion.
|
|
|
|
|
(let ((end (point)))
|
|
|
|
|
;; Find the initial.
|
|
|
|
|
(goto-char wordstart)
|
|
|
|
|
(skip-syntax-forward "^w" (1- end))
|
|
|
|
|
;; Change just that.
|
|
|
|
|
(upcase-initials-region (point) (1+ (point)))
|
|
|
|
|
(goto-char end))))))
|
|
|
|
|
;; Now point is at the end of the expansion and the beginning is
|
|
|
|
|
;; in last-abbrev-location.
|
|
|
|
|
(when (symbol-function abbrev)
|
|
|
|
|
(let* ((hook (symbol-function abbrev))
|
|
|
|
|
(expanded
|
|
|
|
|
;; If the abbrev has a hook function, run it.
|
|
|
|
|
(funcall hook)))
|
|
|
|
|
;; In addition, if the hook function is a symbol with
|
|
|
|
|
;; a non-nil `no-self-insert' property, let the value it
|
|
|
|
|
;; returned specify whether we consider that an expansion took
|
|
|
|
|
;; place. If it returns nil, no expansion has been done.
|
|
|
|
|
(if (and (symbolp hook)
|
|
|
|
|
(null expanded)
|
|
|
|
|
(get hook 'no-self-insert))
|
|
|
|
|
(setq value nil))))
|
|
|
|
|
value))
|
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(defvar abbrev-expand-functions nil
|
2014-05-26 18:09:45 -07:00
|
|
|
|
"Wrapper hook around `abbrev--default-expand'.")
|
2013-04-17 20:12:33 -04:00
|
|
|
|
(make-obsolete-variable 'abbrev-expand-functions 'abbrev-expand-function "24.4")
|
|
|
|
|
|
|
|
|
|
(defvar abbrev-expand-function #'abbrev--default-expand
|
2014-05-26 18:09:45 -07:00
|
|
|
|
"Function that `expand-abbrev' uses to perform abbrev expansion.
|
2013-04-17 20:12:33 -04:00
|
|
|
|
Takes no argument and should return the abbrev symbol if expansion took place.")
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
2020-09-26 15:03:58 -04:00
|
|
|
|
(defcustom abbrev-suggest nil
|
2020-09-27 08:57:17 +03:00
|
|
|
|
"Non-nil means suggest using abbrevs to save typing.
|
|
|
|
|
When abbrev mode is active and this option is non-nil, Emacs will
|
|
|
|
|
suggest in the echo area to use an existing abbrev if doing so
|
|
|
|
|
will save enough typing. See `abbrev-suggest-hint-threshold' for
|
|
|
|
|
the definition of \"enough typing\"."
|
2020-09-26 15:03:58 -04:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defcustom abbrev-suggest-hint-threshold 3
|
2020-09-27 08:57:17 +03:00
|
|
|
|
"Threshold for when to suggest to use an abbrev to save typing.
|
|
|
|
|
The threshold is the amount of typing, in terms of the number of
|
|
|
|
|
characters, that would be saved by using the abbrev. The
|
|
|
|
|
thinking is that if the expansion is only a few characters
|
2020-09-26 15:03:58 -04:00
|
|
|
|
longer than the abbrev, the benefit of informing the user is not
|
2020-09-27 08:57:17 +03:00
|
|
|
|
significant. If you always want to be informed about existing
|
|
|
|
|
abbrevs for the text you type, set this value to zero or less.
|
|
|
|
|
This setting only applies if `abbrev-suggest' is non-nil."
|
2020-09-26 15:03:58 -04:00
|
|
|
|
:type 'number
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-get-active-tables-including-parents ()
|
|
|
|
|
"Return a list of all active abbrev tables, including parent tables."
|
|
|
|
|
(let* ((tables (abbrev--active-tables))
|
|
|
|
|
(all tables))
|
|
|
|
|
(dolist (table tables)
|
|
|
|
|
(setq all (append (abbrev-table-get table :parents) all)))
|
|
|
|
|
all))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-get-active-abbrev-expansions ()
|
|
|
|
|
"Return a list of all the active abbrev expansions.
|
|
|
|
|
Includes expansions from parent abbrev tables."
|
|
|
|
|
(let (expansions)
|
|
|
|
|
(dolist (table (abbrev--suggest-get-active-tables-including-parents))
|
|
|
|
|
(mapatoms (lambda (e)
|
|
|
|
|
(let ((value (symbol-value (abbrev--symbol e table))))
|
|
|
|
|
(when value
|
|
|
|
|
(push (cons value (symbol-name e)) expansions))))
|
|
|
|
|
table))
|
|
|
|
|
expansions))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-count-words (expansion)
|
|
|
|
|
"Return the number of words in EXPANSION.
|
|
|
|
|
Expansion is a string of one or more words."
|
|
|
|
|
(length (split-string expansion " " t)))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-get-previous-words (n)
|
|
|
|
|
"Return the N words before point, spaces included."
|
|
|
|
|
(let ((end (point)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-word n)
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"\\s " " "
|
|
|
|
|
(buffer-substring-no-properties (point) end)))))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-above-threshold (expansion)
|
|
|
|
|
"Return non-nil if the abbrev in EXPANSION provides significant savings.
|
|
|
|
|
A significant saving, here, is the difference in length between
|
|
|
|
|
the abbrev and the abbrev expansion. EXPANSION is a cons cell
|
|
|
|
|
where the car is the expansion and the cdr is the abbrev."
|
|
|
|
|
(>= (- (length (car expansion))
|
|
|
|
|
(length (cdr expansion)))
|
|
|
|
|
abbrev-suggest-hint-threshold))
|
|
|
|
|
|
|
|
|
|
(defvar abbrev--suggest-saved-recommendations nil
|
|
|
|
|
"Keeps a list of expansions that have abbrevs defined.
|
|
|
|
|
The user can show this list by calling
|
|
|
|
|
`abbrev-suggest-show-report'.")
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-inform-user (expansion)
|
|
|
|
|
"Display a message to the user about the existing abbrev.
|
|
|
|
|
EXPANSION is a cons cell where the `car' is the expansion and the
|
|
|
|
|
`cdr' is the abbrev."
|
|
|
|
|
(run-with-idle-timer
|
|
|
|
|
1 nil
|
|
|
|
|
(lambda ()
|
|
|
|
|
(message "You can write `%s' using the abbrev `%s'."
|
|
|
|
|
(car expansion) (cdr expansion))))
|
|
|
|
|
(push expansion abbrev--suggest-saved-recommendations))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-shortest-abbrev (new current)
|
|
|
|
|
"Return the shortest abbrev of NEW and CURRENT.
|
|
|
|
|
NEW and CURRENT are cons cells where the `car' is the expansion
|
|
|
|
|
and the `cdr' is the abbrev."
|
|
|
|
|
(if (not current)
|
|
|
|
|
new
|
|
|
|
|
(if (< (length (cdr new))
|
|
|
|
|
(length (cdr current)))
|
|
|
|
|
new
|
|
|
|
|
current)))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-maybe-suggest ()
|
|
|
|
|
"Suggest an abbrev to the user based on the word(s) before point.
|
|
|
|
|
Uses `abbrev-suggest-hint-threshold' to find out if the user should be
|
|
|
|
|
informed about the existing abbrev."
|
|
|
|
|
(let (words abbrev-found word-count)
|
|
|
|
|
(dolist (expansion (abbrev--suggest-get-active-abbrev-expansions))
|
|
|
|
|
(setq word-count (abbrev--suggest-count-words (car expansion))
|
|
|
|
|
words (abbrev--suggest-get-previous-words word-count))
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(when (and (> word-count 0)
|
|
|
|
|
(string-match (car expansion) words)
|
|
|
|
|
(abbrev--suggest-above-threshold expansion))
|
|
|
|
|
(setq abbrev-found (abbrev--suggest-shortest-abbrev
|
|
|
|
|
expansion abbrev-found)))))
|
|
|
|
|
(when abbrev-found
|
|
|
|
|
(abbrev--suggest-inform-user abbrev-found))))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--suggest-get-totals ()
|
|
|
|
|
"Return a list of all expansions and how many times they were used.
|
|
|
|
|
Each expansion is a cons cell where the `car' is the expansion
|
|
|
|
|
and the `cdr' is the number of times the expansion has been
|
|
|
|
|
typed."
|
|
|
|
|
(let (total cell)
|
|
|
|
|
(dolist (expansion abbrev--suggest-saved-recommendations)
|
|
|
|
|
(if (not (assoc (car expansion) total))
|
|
|
|
|
(push (cons (car expansion) 1) total)
|
|
|
|
|
(setq cell (assoc (car expansion) total))
|
|
|
|
|
(setcdr cell (1+ (cdr cell)))))
|
|
|
|
|
total))
|
|
|
|
|
|
|
|
|
|
(defun abbrev-suggest-show-report ()
|
2020-09-27 08:57:17 +03:00
|
|
|
|
"Show a buffer with the list of abbrevs you could have used.
|
|
|
|
|
This shows the abbrevs you've \"missed\" because you typed the
|
|
|
|
|
full text instead of the abbrevs that expand into that text."
|
2020-09-26 15:03:58 -04:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((totals (abbrev--suggest-get-totals))
|
|
|
|
|
(buf (get-buffer-create "*abbrev-suggest*")))
|
|
|
|
|
(set-buffer buf)
|
|
|
|
|
(erase-buffer)
|
2021-09-24 20:59:32 +02:00
|
|
|
|
(insert (substitute-command-keys "** Abbrev expansion usage **
|
2020-09-26 15:03:58 -04:00
|
|
|
|
|
|
|
|
|
Below is a list of expansions for which abbrevs are defined, and
|
|
|
|
|
the number of times the expansion was typed manually. To display
|
2021-09-24 20:59:32 +02:00
|
|
|
|
and edit all abbrevs, type \\[edit-abbrevs].\n\n"))
|
2020-09-26 15:03:58 -04:00
|
|
|
|
(dolist (expansion totals)
|
|
|
|
|
(insert (format " %s: %d\n" (car expansion) (cdr expansion))))
|
|
|
|
|
(display-buffer buf)))
|
|
|
|
|
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(defun expand-abbrev ()
|
|
|
|
|
"Expand the abbrev before point, if there is an abbrev there.
|
|
|
|
|
Effective when explicitly called even when `abbrev-mode' is nil.
|
2016-09-26 19:02:01 +03:00
|
|
|
|
Calls the value of `abbrev-expand-function' with no argument to do
|
|
|
|
|
the work, and returns whatever it does. (That return value should
|
|
|
|
|
be the abbrev symbol if expansion occurred, else nil.)"
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(interactive)
|
2020-09-26 15:03:58 -04:00
|
|
|
|
(or (funcall abbrev-expand-function)
|
|
|
|
|
(if abbrev-suggest
|
|
|
|
|
(abbrev--suggest-maybe-suggest))))
|
2013-04-17 20:12:33 -04:00
|
|
|
|
|
|
|
|
|
(defun abbrev--default-expand ()
|
2014-05-26 18:09:45 -07:00
|
|
|
|
"Default function to use for `abbrev-expand-function'.
|
2016-09-26 19:02:01 +03:00
|
|
|
|
This also respects the obsolete wrapper hook `abbrev-expand-functions'.
|
|
|
|
|
\(See `with-wrapper-hook' for details about wrapper hooks.)
|
2014-05-26 18:09:45 -07:00
|
|
|
|
Calls `abbrev-insert' to insert any expansion, and returns what it does."
|
2016-05-18 00:12:01 -07:00
|
|
|
|
(subr--with-wrapper-hook-no-warnings abbrev-expand-functions ()
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 07:51:54 -04:00
|
|
|
|
(pcase-let ((`(,sym ,name ,wordstart ,wordend) (abbrev--before-point)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(when sym
|
2011-07-08 10:42:36 -04:00
|
|
|
|
(let ((startpos (copy-marker (point) t))
|
|
|
|
|
(endmark (copy-marker wordend t)))
|
|
|
|
|
(unless (or ;; executing-kbd-macro
|
|
|
|
|
noninteractive
|
Do not call to `selected-window' where it is assumed by default.
Affected functions are `window-minibuffer-p', `window-dedicated-p',
`window-hscroll', `window-width', `window-height', `window-buffer',
`window-frame', `window-start', `window-point', `next-window'
and `window-display-table'.
* abbrev.el (abbrev--default-expand):
* bs.el (bs--show-with-configuration):
* buff-menu.el (Buffer-menu-mouse-select):
* calc/calc.el (calc):
* calendar/calendar.el (calendar-generate-window):
* calendar/diary-lib.el (diary-simple-display, diary-show-all-entries)
(diary-make-entry):
* comint.el (send-invisible, comint-dynamic-complete-filename)
(comint-dynamic-simple-complete, comint-dynamic-list-completions):
* completion.el (complete):
* dabbrev.el (dabbrev-expand, dabbrev--make-friend-buffer-list):
* disp-table.el (describe-current-display-table):
* doc-view.el (doc-view-insert-image):
* ebuff-menu.el (Electric-buffer-menu-mouse-select):
* ehelp.el (with-electric-help):
* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* emacs-lisp/edebug.el (edebug-two-window-p, edebug-pop-to-buffer):
* emacs-lisp/helper.el (Helper-help-scroller):
* emulation/cua-base.el (cua--post-command-handler-1):
* eshell/esh-mode.el (eshell-output-filter):
* ffap.el (ffap-gnus-wrapper):
* help-macro.el (make-help-screen):
* hilit-chg.el (highlight-compare-buffers):
* hippie-exp.el (hippie-expand, try-expand-dabbrev-visible):
* hl-line.el (global-hl-line-highlight):
* icomplete.el (icomplete-simple-completing-p):
* isearch.el (isearch-done):
* jit-lock.el (jit-lock-stealth-fontify):
* mail/rmailsum.el (rmail-summary-scroll-msg-up):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* mpc.el (mpc-tagbrowser, mpc):
* net/rcirc.el (rcirc-any-buffer):
* play/gomoku.el (gomoku-max-width, gomoku-max-height):
* play/landmark.el (landmark-max-width, landmark-max-height):
* play/zone.el (zone):
* progmodes/compile.el (compilation-goto-locus):
* progmodes/ebrowse.el (ebrowse-view/find-file-and-search-pattern):
* progmodes/etags.el (find-tag-other-window):
* progmodes/fortran.el (fortran-column-ruler):
* progmodes/gdb-mi.el (gdb-mouse-toggle-breakpoint-fringe):
* progmodes/verilog-mode.el (verilog-point-text):
* reposition.el (reposition-window):
* rot13.el (toggle-rot13-mode):
* server.el (server-switch-buffer):
* shell.el (shell-dynamic-complete-command)
(shell-dynamic-complete-environment-variable):
* simple.el (insert-buffer, set-selective-display)
(delete-completion-window):
* speedbar.el (speedbar-timer-fn, speedbar-center-buffer-smartly)
(speedbar-recenter):
* startup.el (fancy-splash-head):
* textmodes/ispell.el (ispell-command-loop):
* textmodes/makeinfo.el (makeinfo-compilation-sentinel-region):
* tutorial.el (help-with-tutorial):
* vc/add-log.el (add-change-log-entry):
* vc/compare-w.el (compare-windows):
* vc/ediff-help.el (ediff-indent-help-message):
* vc/ediff-util.el (ediff-setup-control-buffer, ediff-position-region):
* vc/ediff-wind.el (ediff-skip-unsuitable-frames)
(ediff-setup-control-frame):
* vc/emerge.el (emerge-position-region):
* vc/pcvs-util.el (cvs-bury-buffer):
* window.el (walk-windows, mouse-autoselect-window-select):
* winner.el (winner-set-conf, winner-undo): Related users changed.
2013-08-05 18:26:57 +04:00
|
|
|
|
(window-minibuffer-p))
|
2011-07-08 10:42:36 -04:00
|
|
|
|
;; Add an undo boundary, in case we are doing this for
|
|
|
|
|
;; a self-inserting command which has avoided making one so far.
|
|
|
|
|
(undo-boundary))
|
|
|
|
|
;; Now sym is the abbrev symbol.
|
|
|
|
|
(setq last-abbrev-text name)
|
|
|
|
|
(setq last-abbrev sym)
|
|
|
|
|
(setq last-abbrev-location wordstart)
|
|
|
|
|
;; If this abbrev has an expansion, delete the abbrev
|
|
|
|
|
;; and insert the expansion.
|
|
|
|
|
(prog1
|
|
|
|
|
(abbrev-insert sym name wordstart wordend)
|
|
|
|
|
;; Yuck!! If expand-abbrev is called with point slightly
|
|
|
|
|
;; further than the end of the abbrev, move point back to
|
|
|
|
|
;; where it started.
|
|
|
|
|
(if (and (> startpos endmark)
|
|
|
|
|
(= (point) endmark)) ;Obey skeletons that move point.
|
|
|
|
|
(goto-char startpos))))))))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defun unexpand-abbrev ()
|
|
|
|
|
"Undo the expansion of the last abbrev that expanded.
|
|
|
|
|
This differs from ordinary undo in that other editing done since then
|
|
|
|
|
is not undone."
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (or (< last-abbrev-location (point-min))
|
|
|
|
|
(> last-abbrev-location (point-max)))
|
|
|
|
|
(goto-char last-abbrev-location)
|
|
|
|
|
(when (stringp last-abbrev-text)
|
|
|
|
|
;; This isn't correct if last-abbrev's hook was used
|
|
|
|
|
;; to do the expansion.
|
|
|
|
|
(let ((val (symbol-value last-abbrev)))
|
|
|
|
|
(unless (stringp val)
|
2008-06-05 05:06:58 +00:00
|
|
|
|
(error "Value of abbrev-symbol must be a string"))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
;; Don't inherit properties here; just copy from old contents.
|
|
|
|
|
(insert last-abbrev-text)
|
2008-06-05 05:06:58 +00:00
|
|
|
|
;; Delete after inserting, to better preserve markers.
|
|
|
|
|
(delete-region (point) (+ (point) (length val)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(setq last-abbrev-text nil))))))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--write (sym)
|
|
|
|
|
"Write the abbrev in a `read'able form.
|
|
|
|
|
Presumes that `standard-output' points to `current-buffer'."
|
2017-12-31 20:33:21 -08:00
|
|
|
|
(insert " (")
|
|
|
|
|
(prin1 (symbol-name sym))
|
|
|
|
|
(insert " ")
|
|
|
|
|
(prin1 (symbol-value sym))
|
|
|
|
|
(insert " ")
|
|
|
|
|
(prin1 (symbol-function sym))
|
|
|
|
|
(insert " :count ")
|
|
|
|
|
(prin1 (abbrev-get sym :count))
|
|
|
|
|
(when (abbrev-get sym :case-fixed)
|
|
|
|
|
(insert " :case-fixed ")
|
|
|
|
|
(prin1 (abbrev-get sym :case-fixed)))
|
|
|
|
|
(when (abbrev-get sym :enable-function)
|
|
|
|
|
(insert " :enable-function ")
|
|
|
|
|
(prin1 (abbrev-get sym :enable-function)))
|
|
|
|
|
(insert ")\n"))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defun abbrev--describe (sym)
|
|
|
|
|
(when (symbol-value sym)
|
|
|
|
|
(prin1 (symbol-name sym))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(if (null (abbrev-get sym :system))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(indent-to 15 1)
|
|
|
|
|
(insert " (sys)")
|
|
|
|
|
(indent-to 20 1))
|
2007-10-30 01:39:19 +00:00
|
|
|
|
(prin1 (abbrev-get sym :count))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(indent-to 20 1)
|
|
|
|
|
(prin1 (symbol-value sym))
|
|
|
|
|
(when (symbol-function sym)
|
|
|
|
|
(indent-to 45 1)
|
|
|
|
|
(prin1 (symbol-function sym)))
|
|
|
|
|
(terpri)))
|
|
|
|
|
|
|
|
|
|
(defun insert-abbrev-table-description (name &optional readable)
|
|
|
|
|
"Insert before point a full description of abbrev table named NAME.
|
|
|
|
|
NAME is a symbol whose value is an abbrev table.
|
|
|
|
|
If optional 2nd arg READABLE is non-nil, a human-readable description
|
2017-12-31 20:33:21 -08:00
|
|
|
|
is inserted.
|
|
|
|
|
|
|
|
|
|
If READABLE is nil, an expression is inserted. The expression is
|
|
|
|
|
a call to `define-abbrev-table' that when evaluated will define
|
|
|
|
|
the abbrev table NAME exactly as it is currently defined.
|
2018-09-29 15:19:04 -07:00
|
|
|
|
Abbrevs marked as \"system abbrevs\" are ignored."
|
2019-04-01 12:35:10 -04:00
|
|
|
|
(let ((symbols (abbrev--table-symbols name readable)))
|
2018-09-29 15:19:04 -07:00
|
|
|
|
(setq symbols (sort symbols 'string-lessp))
|
|
|
|
|
(let ((standard-output (current-buffer)))
|
|
|
|
|
(if readable
|
|
|
|
|
(progn
|
|
|
|
|
(insert "(")
|
|
|
|
|
(prin1 name)
|
|
|
|
|
(insert ")\n\n")
|
|
|
|
|
(mapc 'abbrev--describe symbols)
|
|
|
|
|
(insert "\n\n"))
|
|
|
|
|
(insert "(define-abbrev-table '")
|
|
|
|
|
(prin1 name)
|
|
|
|
|
(if (null symbols)
|
|
|
|
|
(insert " '())\n\n")
|
|
|
|
|
(insert "\n '(\n")
|
|
|
|
|
(mapc 'abbrev--write symbols)
|
|
|
|
|
(insert " ))\n\n")))
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
(defun abbrev--table-symbols (name &optional system)
|
|
|
|
|
"Return the user abbrev symbols in the abbrev table named NAME.
|
|
|
|
|
NAME is a symbol whose value is an abbrev table. System abbrevs
|
|
|
|
|
are omitted unless SYSTEM is non-nil."
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(let ((table (symbol-value name))
|
|
|
|
|
(symbols ()))
|
2017-12-31 20:33:21 -08:00
|
|
|
|
(mapatoms (lambda (sym)
|
2018-09-29 15:19:04 -07:00
|
|
|
|
(if (and (symbol-value sym) (or system (not (abbrev-get sym :system))))
|
2017-12-31 20:33:21 -08:00
|
|
|
|
(push sym symbols)))
|
|
|
|
|
table)
|
2018-09-29 15:19:04 -07:00
|
|
|
|
symbols))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
|
|
|
|
|
(defun define-abbrev-table (tablename definitions
|
|
|
|
|
&optional docstring &rest props)
|
|
|
|
|
"Define TABLENAME (a symbol) as an abbrev table name.
|
|
|
|
|
Define abbrevs in it according to DEFINITIONS, which is a list of elements
|
2008-04-17 17:40:52 +00:00
|
|
|
|
of the form (ABBREVNAME EXPANSION ...) that are passed to `define-abbrev'.
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
PROPS is a property list to apply to the table.
|
|
|
|
|
Properties with special meaning:
|
|
|
|
|
- `:parents' contains a list of abbrev tables from which this table inherits
|
|
|
|
|
abbreviations.
|
|
|
|
|
- `:case-fixed' non-nil means that abbreviations are looked up without
|
|
|
|
|
case-folding, and the expansion is not capitalized/upcased.
|
2012-03-03 18:45:04 -08:00
|
|
|
|
- `:regexp' is a regular expression that specifies how to extract the
|
|
|
|
|
name of the abbrev before point. The submatch 1 is treated
|
|
|
|
|
as the potential name of an abbrev. If :regexp is nil, the default
|
|
|
|
|
behavior uses `backward-word' and `forward-word' to extract the name
|
|
|
|
|
of the abbrev, which can therefore only be a single word.
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
- `:enable-function' can be set to a function of no argument which returns
|
2008-05-08 03:35:38 +00:00
|
|
|
|
non-nil if and only if the abbrevs in this table should be used for this
|
|
|
|
|
instance of `expand-abbrev'."
|
2021-10-13 21:21:23 +02:00
|
|
|
|
(declare (doc-string 3) (indent defun))
|
2007-11-09 16:07:18 +00:00
|
|
|
|
;; We used to manually add the docstring, but we also want to record this
|
|
|
|
|
;; location as the definition of the variable (in load-history), so we may
|
|
|
|
|
;; as well just use `defvar'.
|
2016-12-10 19:44:14 -08:00
|
|
|
|
(when (and docstring props (symbolp docstring))
|
|
|
|
|
;; There is really no docstring, instead the docstring arg
|
|
|
|
|
;; is a property name.
|
|
|
|
|
(push docstring props) (setq docstring nil))
|
2015-04-10 02:47:44 -04:00
|
|
|
|
(eval `(defvar ,tablename nil ,@(if docstring (list docstring))))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(let ((table (if (boundp tablename) (symbol-value tablename))))
|
|
|
|
|
(unless table
|
2008-04-26 01:59:04 +00:00
|
|
|
|
(setq table (make-abbrev-table))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(set tablename table)
|
2011-06-15 14:33:33 -04:00
|
|
|
|
(unless (memq tablename abbrev-table-name-list)
|
|
|
|
|
(push tablename abbrev-table-name-list)))
|
2008-04-26 01:59:04 +00:00
|
|
|
|
;; We used to just pass them to `make-abbrev-table', but that fails
|
|
|
|
|
;; if the table was pre-existing as is the case if it was created by
|
|
|
|
|
;; loading the user's abbrev file.
|
|
|
|
|
(while (consp props)
|
2015-04-02 10:00:48 -04:00
|
|
|
|
(unless (cdr props) (error "Missing value for property %S" (car props)))
|
2008-04-26 01:59:04 +00:00
|
|
|
|
(abbrev-table-put table (pop props) (pop props)))
|
Rewrite abbrev.c in Elisp.
* image.c (Qcount): Don't declare as extern.
(syms_of_image): Initialize and staticpro `Qcount'.
* puresize.h (BASE_PURESIZE): Increase for the new abbrev.el functions.
* emacs.c (main): Don't call syms_of_abbrev.
* Makefile.in (obj): Remove abbrev.o.
(abbrev.o): Remove.
* abbrev.c: Remove.
Rewrite abbrev.c in Elisp.
* abbrev.el (abbrev-mode): Move custom group from cus-edit.el.
(abbrev-table-get, abbrev-table-put, abbrev-get)
(abbrev-put, make-abbrev-table, abbrev-table-p, clear-abbrev-table)
(define-abbrev, abbrev--check-chars, define-global-abbrev)
(define-mode-abbrev, abbrev--active-tables, abbrev-symbol)
(abbrev-expansion, abbrev--before-point, expand-abbrev)
(unexpand-abbrev, abbrev--write, abbrev--describe)
(insert-abbrev-table-description, define-abbrev-table):
New funs, largely transcribed from abbrev.c.
(abbrev-with-wrapper-hook): New macro.
(abbrev-table-name-list, global-abbrev-table)
(abbrev-minor-mode-table-alist, fundamental-mode-abbrev-table)
(abbrevs-changed, abbrev-all-caps, abbrev-start-location)
(abbrev-start-location-buffer, last-abbrev, last-abbrev-text)
(last-abbrev-location, pre-abbrev-expand-hook, abbrev-expand-function):
New vars, largely transcribed from abbrev.c.
* cus-edit.el (abbrev-mode): Remove. Move to abbrev.el.
* cus-start.el: Remove abbrev-all-caps and pre-abbrev-expand-hook.
* loadup.el: Load "abbrev.el" before "lisp-mode.el".
2007-10-28 02:41:00 +00:00
|
|
|
|
(dolist (elt definitions)
|
|
|
|
|
(apply 'define-abbrev table elt))))
|
|
|
|
|
|
2008-04-17 19:54:00 +00:00
|
|
|
|
(defun abbrev-table-menu (table &optional prompt sortfun)
|
|
|
|
|
"Return a menu that shows all abbrevs in TABLE.
|
|
|
|
|
Selecting an entry runs `abbrev-insert'.
|
|
|
|
|
PROMPT is the prompt to use for the keymap.
|
|
|
|
|
SORTFUN is passed to `sort' to change the default ordering."
|
|
|
|
|
(unless sortfun (setq sortfun 'string-lessp))
|
|
|
|
|
(let ((entries ()))
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(obarray-map (lambda (abbrev)
|
|
|
|
|
(when (symbol-value abbrev)
|
|
|
|
|
(let ((name (symbol-name abbrev)))
|
|
|
|
|
(push `(,(intern name) menu-item ,name
|
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(abbrev-insert ',abbrev)))
|
|
|
|
|
entries))))
|
|
|
|
|
table)
|
2008-04-17 19:54:00 +00:00
|
|
|
|
(nconc (make-sparse-keymap prompt)
|
|
|
|
|
(sort entries (lambda (x y)
|
2015-11-08 19:19:15 +01:00
|
|
|
|
(funcall sortfun (nth 2 x) (nth 2 y)))))))
|
2008-04-17 19:54:00 +00:00
|
|
|
|
|
2013-09-06 11:37:01 -04:00
|
|
|
|
;; Keep it after define-abbrev-table, since define-derived-mode uses
|
|
|
|
|
;; define-abbrev-table.
|
2014-02-07 20:26:13 -05:00
|
|
|
|
(define-derived-mode edit-abbrevs-mode fundamental-mode "Edit-Abbrevs"
|
2018-11-23 12:16:48 +02:00
|
|
|
|
"Major mode for editing the list of abbrev definitions.
|
|
|
|
|
This mode is for editing abbrevs in a buffer prepared by `edit-abbrevs',
|
2022-01-10 00:55:16 +01:00
|
|
|
|
which see."
|
|
|
|
|
:interactive nil)
|
2013-09-06 11:37:01 -04:00
|
|
|
|
|
2007-03-09 22:02:50 +00:00
|
|
|
|
(provide 'abbrev)
|
|
|
|
|
|
1992-05-30 23:54:21 +00:00
|
|
|
|
;;; abbrev.el ends here
|