2020-09-09 13:29:59 -04:00
|
|
|
|
;;; easy-mmode.el --- easy definition for major and minor modes -*- lexical-binding: t; -*-
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
|
;; Copyright (C) 1997, 2000-2022 Free Software Foundation, Inc.
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
2001-07-17 07:37:19 +00:00
|
|
|
|
;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
|
|
|
|
|
;; Maintainer: Stefan Monnier <monnier@gnu.org>
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
2001-07-17 07:37:19 +00:00
|
|
|
|
|
|
|
|
|
;; Keywords: extensions lisp
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-06-22 20:08:32 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-06-22 20:08:32 +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/>.
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Minor modes are useful and common. This package makes defining a
|
|
|
|
|
;; minor mode easy, by focusing on the writing of the minor mode
|
|
|
|
|
;; functionalities themselves. Moreover, this package enforces a
|
|
|
|
|
;; conventional naming of user interface primitives, making things
|
|
|
|
|
;; natural for the minor-mode end-users.
|
|
|
|
|
|
|
|
|
|
;; For each mode, easy-mmode defines the following:
|
2021-09-14 07:55:56 +02:00
|
|
|
|
;; <mode> : The minor mode predicate. A buffer-local variable.
|
1997-06-22 20:08:32 +00:00
|
|
|
|
;; <mode>-map : The keymap possibly associated to <mode>.
|
2000-05-21 01:44:08 +00:00
|
|
|
|
;; see `define-minor-mode' documentation
|
1997-06-22 20:08:32 +00:00
|
|
|
|
;;
|
|
|
|
|
;; eval
|
2000-05-21 01:44:08 +00:00
|
|
|
|
;; (pp (macroexpand '(define-minor-mode <your-mode> <doc>)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
;; to check the result before using it.
|
|
|
|
|
|
|
|
|
|
;; The order in which minor modes are installed is important. Keymap
|
|
|
|
|
;; lookup proceeds down minor-mode-map-alist, and the order there
|
|
|
|
|
;; tends to be the reverse of the order in which the modes were
|
|
|
|
|
;; installed. Perhaps there should be a feature to let you specify
|
|
|
|
|
;; orderings.
|
|
|
|
|
|
2000-03-10 01:17:04 +00:00
|
|
|
|
;; Additionally to `define-minor-mode', the package provides convenient
|
|
|
|
|
;; ways to define keymaps, and other helper functions for major and minor modes.
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
2000-03-10 01:17:04 +00:00
|
|
|
|
;;; Code:
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
2000-06-04 20:59:47 +00:00
|
|
|
|
(defun easy-mmode-pretty-mode-name (mode &optional lighter)
|
|
|
|
|
"Turn the symbol MODE into a string intended for the user.
|
2005-05-07 15:06:42 +00:00
|
|
|
|
If provided, LIGHTER will be used to help choose capitalization by,
|
|
|
|
|
replacing its case-insensitive matches with the literal string in LIGHTER."
|
2000-06-04 20:59:47 +00:00
|
|
|
|
(let* ((case-fold-search t)
|
2005-05-08 19:39:20 +00:00
|
|
|
|
;; Produce "Foo-Bar minor mode" from foo-bar-minor-mode.
|
2000-10-01 00:58:35 +00:00
|
|
|
|
(name (concat (replace-regexp-in-string
|
2005-05-08 19:39:20 +00:00
|
|
|
|
;; If the original mode name included "-minor" (some
|
|
|
|
|
;; of them don't, e.g. auto-revert-mode), then
|
|
|
|
|
;; replace it with " minor".
|
2000-10-01 00:58:35 +00:00
|
|
|
|
"-Minor" " minor"
|
2005-05-07 15:06:42 +00:00
|
|
|
|
;; "foo-bar-minor" -> "Foo-Bar-Minor"
|
2000-10-01 00:58:35 +00:00
|
|
|
|
(capitalize (replace-regexp-in-string
|
2005-05-07 15:06:42 +00:00
|
|
|
|
;; "foo-bar-minor-mode" -> "foo-bar-minor"
|
2012-06-27 10:05:24 -04:00
|
|
|
|
"toggle-\\|-mode\\'" ""
|
|
|
|
|
(symbol-name mode))))
|
2000-06-04 20:59:47 +00:00
|
|
|
|
" mode")))
|
2016-02-15 21:46:17 +02:00
|
|
|
|
(setq name (replace-regexp-in-string "\\`Global-" "Global " name))
|
2000-06-04 20:59:47 +00:00
|
|
|
|
(if (not (stringp lighter)) name
|
2005-05-07 15:06:42 +00:00
|
|
|
|
;; Strip leading and trailing whitespace from LIGHTER.
|
|
|
|
|
(setq lighter (replace-regexp-in-string "\\`\\s-+\\|\\s-+\\'" ""
|
|
|
|
|
lighter))
|
|
|
|
|
;; Replace any (case-insensitive) matches for LIGHTER in NAME
|
|
|
|
|
;; with a literal LIGHTER. E.g., if NAME is "Iimage mode" and
|
|
|
|
|
;; LIGHTER is " iImag", then this will produce "iImage mode".
|
|
|
|
|
;; (LIGHTER normally comes from the mode-line string passed to
|
|
|
|
|
;; define-minor-mode, and normally includes at least one leading
|
|
|
|
|
;; space.)
|
|
|
|
|
(replace-regexp-in-string (regexp-quote lighter) lighter name t t))))
|
2000-06-02 23:07:08 +00:00
|
|
|
|
|
2018-07-01 23:34:53 -04:00
|
|
|
|
(defconst easy-mmode--arg-docstring
|
2022-04-03 14:07:55 +02:00
|
|
|
|
"This is a %sminor mode. If called interactively, toggle the
|
|
|
|
|
`%s' mode. If the prefix argument is positive, enable the mode,
|
|
|
|
|
and if it is zero or negative, disable the mode.
|
2020-11-01 15:00:36 +01:00
|
|
|
|
|
2020-11-01 09:39:44 -08:00
|
|
|
|
If called from Lisp, toggle the mode if ARG is `toggle'.
|
2020-11-01 15:00:36 +01:00
|
|
|
|
Enable the mode if ARG is nil, omitted, or is a positive number.
|
2020-11-02 10:17:08 +01:00
|
|
|
|
Disable the mode if ARG is a negative number.
|
2020-08-21 17:15:22 +02:00
|
|
|
|
|
2021-06-22 16:03:37 +02:00
|
|
|
|
To check whether the minor mode is enabled in the current buffer,
|
2021-10-03 11:35:28 +02:00
|
|
|
|
evaluate `%s'.
|
2021-06-22 16:03:37 +02:00
|
|
|
|
|
2020-08-21 17:15:22 +02:00
|
|
|
|
The mode's hook is called both when the mode is enabled and when
|
|
|
|
|
it is disabled.")
|
2018-07-01 23:34:53 -04:00
|
|
|
|
|
2021-06-22 16:03:37 +02:00
|
|
|
|
(defun easy-mmode--mode-docstring (doc mode-pretty-name keymap-sym
|
2022-04-03 14:07:55 +02:00
|
|
|
|
getter global)
|
2022-04-02 15:55:29 +02:00
|
|
|
|
;; If we have a doc string, and it's already complete (which we
|
|
|
|
|
;; guess at with the simple heuristic below), then just return that
|
|
|
|
|
;; as is.
|
|
|
|
|
(if (and doc (string-match-p "\\bARG\\b" doc))
|
|
|
|
|
doc
|
|
|
|
|
;; Compose a new doc string.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(let ((lines (if doc
|
|
|
|
|
(string-lines doc)
|
|
|
|
|
(list (format "Toggle %s on or off." mode-pretty-name)))))
|
|
|
|
|
;; Insert the first line from the doc string.
|
|
|
|
|
(insert (pop lines))
|
|
|
|
|
;; Ensure that we have (only) one blank line after the first
|
|
|
|
|
;; line.
|
|
|
|
|
(ensure-empty-lines)
|
|
|
|
|
(while (and lines
|
2022-04-02 16:53:24 +02:00
|
|
|
|
(equal (car lines) ""))
|
2022-04-02 15:55:29 +02:00
|
|
|
|
(pop lines))
|
|
|
|
|
;; Insert the doc string.
|
|
|
|
|
(dolist (line lines)
|
|
|
|
|
(insert line "\n"))
|
|
|
|
|
(ensure-empty-lines)
|
|
|
|
|
;; Insert the boilerplate.
|
|
|
|
|
(let* ((fill-prefix nil)
|
|
|
|
|
(docs-fc (bound-and-true-p emacs-lisp-docstring-fill-column))
|
|
|
|
|
(fill-column (if (integerp docs-fc) docs-fc 65))
|
2022-04-03 14:07:55 +02:00
|
|
|
|
(argdoc (format
|
|
|
|
|
easy-mmode--arg-docstring
|
|
|
|
|
(if global "global " "")
|
|
|
|
|
mode-pretty-name
|
|
|
|
|
;; Avoid having quotes turn into pretty quotes.
|
2022-04-06 13:47:46 +02:00
|
|
|
|
(string-replace "'" "\\='" (format "%S" getter)))))
|
2022-04-02 15:55:29 +02:00
|
|
|
|
(let ((start (point)))
|
|
|
|
|
(insert argdoc)
|
|
|
|
|
(when (fboundp 'fill-region)
|
|
|
|
|
(fill-region start (point) 'left t))))
|
|
|
|
|
;; Finally, insert the keymap.
|
|
|
|
|
(when (and (boundp keymap-sym)
|
|
|
|
|
(or (not doc)
|
|
|
|
|
(not (string-search "\\{" doc))))
|
|
|
|
|
(ensure-empty-lines)
|
|
|
|
|
(insert (format "\\{%s}" keymap-sym)))
|
|
|
|
|
(buffer-string)))))
|
2018-07-01 23:34:53 -04:00
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
|
;;;###autoload
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(defalias 'easy-mmode-define-minor-mode #'define-minor-mode)
|
1999-11-23 09:08:38 +00:00
|
|
|
|
;;;###autoload
|
2021-04-20 19:40:09 -04:00
|
|
|
|
(defmacro define-minor-mode (mode doc &rest body)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
"Define a new minor mode MODE.
|
2012-01-30 20:52:29 -08:00
|
|
|
|
This defines the toggle command MODE and (by default) a control variable
|
|
|
|
|
MODE (you can override this with the :variable keyword, see below).
|
1997-06-22 20:08:32 +00:00
|
|
|
|
DOC is the documentation for the mode toggle command.
|
2010-08-22 15:30:26 -04:00
|
|
|
|
|
2012-02-07 00:26:54 -08:00
|
|
|
|
The defined mode command takes one optional (prefix) argument.
|
2012-09-22 23:24:26 +08:00
|
|
|
|
Interactively with no prefix argument, it toggles the mode.
|
|
|
|
|
A prefix argument enables the mode if the argument is positive,
|
|
|
|
|
and disables it otherwise.
|
|
|
|
|
|
|
|
|
|
When called from Lisp, the mode command toggles the mode if the
|
|
|
|
|
argument is `toggle', disables the mode if the argument is a
|
|
|
|
|
non-positive integer, and enables the mode otherwise (including
|
|
|
|
|
if the argument is omitted or nil or a positive integer).
|
|
|
|
|
|
|
|
|
|
If DOC is nil, give the mode command a basic doc-string
|
2018-07-01 23:34:53 -04:00
|
|
|
|
documenting what its argument does. If the word \"ARG\" does not
|
|
|
|
|
appear in DOC, a paragraph is added to DOC explaining
|
|
|
|
|
usage of the mode argument.
|
2012-02-07 00:26:54 -08:00
|
|
|
|
|
2010-08-22 15:30:26 -04:00
|
|
|
|
BODY contains code to execute each time the mode is enabled or disabled.
|
|
|
|
|
It is executed after toggling the mode, and before running MODE-hook.
|
|
|
|
|
Before the actual body code, you can write keyword arguments, i.e.
|
2015-02-16 04:22:16 +00:00
|
|
|
|
alternating keywords and values. If you provide BODY, then you must
|
2021-04-16 23:40:51 -04:00
|
|
|
|
provide at least one keyword argument (e.g. `:lighter nil`).
|
|
|
|
|
The following special keywords are supported (other keywords are passed
|
|
|
|
|
to `defcustom' if the minor mode is global):
|
2010-08-22 15:30:26 -04:00
|
|
|
|
|
2002-09-13 14:16:02 +00:00
|
|
|
|
:global GLOBAL If non-nil specifies that the minor mode is not meant to be
|
2005-04-05 14:46:29 +00:00
|
|
|
|
buffer-local, so don't make the variable MODE buffer-local.
|
2002-10-07 22:49:39 +00:00
|
|
|
|
By default, the mode is buffer-local.
|
2021-04-12 11:08:19 -04:00
|
|
|
|
:init-value VAL the initial value of the mode's variable.
|
|
|
|
|
Note that the minor mode function won't be called by setting
|
|
|
|
|
this option, so the value *reflects* the minor mode's natural
|
|
|
|
|
initial state, rather than *setting* it.
|
|
|
|
|
In the vast majority of cases it should be nil.
|
2012-01-30 20:52:29 -08:00
|
|
|
|
Not used if you also specify :variable.
|
2021-04-12 11:08:19 -04:00
|
|
|
|
:lighter SPEC Text displayed in the mode line when the mode is on.
|
|
|
|
|
:keymap MAP Keymap bound to the mode keymap. Defaults to `MODE-map'.
|
2021-09-25 17:54:49 +02:00
|
|
|
|
If non-nil, it should be an unquoted variable name (whose value
|
|
|
|
|
is a keymap), or an expression that returns either a keymap or
|
2021-04-12 11:08:19 -04:00
|
|
|
|
a list of (KEY . BINDING) pairs where KEY and BINDING are
|
|
|
|
|
suitable for `define-key'. If you supply a KEYMAP argument
|
|
|
|
|
that is not a symbol, this macro defines the variable MODE-map
|
|
|
|
|
and gives it the value that KEYMAP specifies.
|
2021-02-14 14:06:16 +01:00
|
|
|
|
:interactive VAL Whether this mode should be a command or not. The default
|
|
|
|
|
is to make it one; use nil to avoid that. If VAL is a list,
|
|
|
|
|
it's interpreted as a list of major modes this minor mode
|
|
|
|
|
is useful in.
|
2012-01-30 20:52:29 -08:00
|
|
|
|
:variable PLACE The location to use instead of the variable MODE to store
|
|
|
|
|
the state of the mode. This can be simply a different
|
2013-02-14 09:16:47 -08:00
|
|
|
|
named variable, or a generalized variable.
|
2015-09-17 16:08:20 -07:00
|
|
|
|
PLACE can also be of the form (GET . SET), where GET is
|
2013-02-14 09:16:47 -08:00
|
|
|
|
an expression that returns the current state, and SET is
|
2021-08-16 14:24:53 +02:00
|
|
|
|
a function that takes one argument, the new state, which should
|
|
|
|
|
be assigned to PLACE. If you specify a :variable, this function
|
|
|
|
|
does not define a MODE variable (nor any of the terms used
|
2013-02-14 09:16:47 -08:00
|
|
|
|
in :variable).
|
2021-09-14 07:55:56 +02:00
|
|
|
|
:after-hook A single Lisp form which is evaluated after the mode hooks
|
2012-02-23 18:51:22 +00:00
|
|
|
|
have been run. It should not be quoted.
|
2002-10-07 22:49:39 +00:00
|
|
|
|
|
|
|
|
|
For example, you could write
|
|
|
|
|
(define-minor-mode foo-mode \"If enabled, foo on you!\"
|
2015-11-17 15:28:50 -08:00
|
|
|
|
:lighter \" Foo\" :require \\='foo :global t :group \\='hassle :version \"27.5\"
|
2021-04-12 11:08:19 -04:00
|
|
|
|
...BODY CODE...)
|
|
|
|
|
|
|
|
|
|
For backward compatibility with the Emacs<21 calling convention,
|
2021-04-16 23:40:51 -04:00
|
|
|
|
the keywords can also be preceded by the obsolete triplet
|
|
|
|
|
INIT-VALUE LIGHTER KEYMAP.
|
|
|
|
|
|
2021-04-17 09:57:01 -04:00
|
|
|
|
\(fn MODE DOC [KEYWORD VAL ... &rest BODY])"
|
2012-05-17 21:46:20 -04:00
|
|
|
|
(declare (doc-string 2)
|
2021-10-13 21:52:50 +02:00
|
|
|
|
(indent defun)
|
2014-02-24 11:55:17 +08:00
|
|
|
|
(debug (&define name string-or-null-p
|
2016-01-07 09:48:00 +08:00
|
|
|
|
[&optional [¬ keywordp] sexp
|
|
|
|
|
&optional [¬ keywordp] sexp
|
|
|
|
|
&optional [¬ keywordp] sexp]
|
|
|
|
|
[&rest [keywordp sexp]]
|
|
|
|
|
def-body)))
|
2002-10-07 22:49:39 +00:00
|
|
|
|
|
2007-09-21 18:27:34 +00:00
|
|
|
|
(let* ((last-message (make-symbol "last-message"))
|
|
|
|
|
(mode-name (symbol-name mode))
|
2021-04-20 19:40:09 -04:00
|
|
|
|
(init-value nil)
|
|
|
|
|
(keymap nil)
|
|
|
|
|
(lighter nil)
|
2021-04-12 11:08:19 -04:00
|
|
|
|
(pretty-name nil)
|
2000-05-21 01:44:08 +00:00
|
|
|
|
(globalp nil)
|
2005-07-16 02:25:48 +00:00
|
|
|
|
(set nil)
|
2005-07-14 00:56:13 +00:00
|
|
|
|
(initialize nil)
|
2005-07-16 02:25:48 +00:00
|
|
|
|
(type nil)
|
2000-11-03 04:26:33 +00:00
|
|
|
|
(extra-args nil)
|
2003-03-24 17:41:43 +00:00
|
|
|
|
(extra-keywords nil)
|
2010-05-05 22:53:56 -04:00
|
|
|
|
(variable nil) ;The PLACE where the state is stored.
|
2015-06-17 14:52:54 -04:00
|
|
|
|
(setter `(setq ,mode)) ;The beginning of the exp to set the mode var.
|
|
|
|
|
(getter mode) ;The exp to get the mode value.
|
2010-05-05 22:53:56 -04:00
|
|
|
|
(modefun mode) ;The minor mode function name we're defining.
|
2012-02-23 18:51:22 +00:00
|
|
|
|
(after-hook nil)
|
2000-06-04 20:59:47 +00:00
|
|
|
|
(hook (intern (concat mode-name "-hook")))
|
|
|
|
|
(hook-on (intern (concat mode-name "-on-hook")))
|
2003-03-24 17:41:43 +00:00
|
|
|
|
(hook-off (intern (concat mode-name "-off-hook")))
|
2021-02-14 14:06:16 +01:00
|
|
|
|
(interactive t)
|
2021-04-20 19:40:09 -04:00
|
|
|
|
(warnwrap (if (or (null body) (keywordp (car body))) #'identity
|
2021-04-12 11:08:19 -04:00
|
|
|
|
(lambda (exp)
|
|
|
|
|
(macroexp-warn-and-return
|
|
|
|
|
"Use keywords rather than deprecated positional arguments to `define-minor-mode'"
|
|
|
|
|
exp))))
|
2012-01-30 20:35:57 -08:00
|
|
|
|
keyw keymap-sym tmp)
|
2000-06-04 20:59:47 +00:00
|
|
|
|
|
2021-04-20 19:40:09 -04:00
|
|
|
|
;; Allow BODY to start with the old INIT-VALUE LIGHTER KEYMAP triplet.
|
|
|
|
|
(unless (keywordp (car body))
|
|
|
|
|
(setq init-value (pop body))
|
|
|
|
|
(unless (keywordp (car body))
|
|
|
|
|
(setq lighter (pop body))
|
|
|
|
|
(unless (keywordp (car body))
|
|
|
|
|
(setq keymap (pop body)))))
|
2021-04-12 11:08:19 -04:00
|
|
|
|
|
2000-06-04 20:59:47 +00:00
|
|
|
|
;; Check keys.
|
2003-03-24 17:41:43 +00:00
|
|
|
|
(while (keywordp (setq keyw (car body)))
|
|
|
|
|
(setq body (cdr body))
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(pcase keyw
|
2018-10-27 01:48:35 +02:00
|
|
|
|
(:init-value (setq init-value (pop body)))
|
|
|
|
|
(:lighter (setq lighter (purecopy (pop body))))
|
|
|
|
|
(:global (setq globalp (pop body))
|
|
|
|
|
(when (and globalp (symbolp mode))
|
|
|
|
|
(setq setter `(setq-default ,mode))
|
|
|
|
|
(setq getter `(default-value ',mode))))
|
|
|
|
|
(:extra-args (setq extra-args (pop body)))
|
|
|
|
|
(:set (setq set (list :set (pop body))))
|
2021-07-31 13:37:42 +02:00
|
|
|
|
(:initialize (setq initialize (list :initialize (pop body))))
|
2018-10-27 01:48:35 +02:00
|
|
|
|
(:type (setq type (list :type (pop body))))
|
|
|
|
|
(:keymap (setq keymap (pop body)))
|
2021-02-14 14:06:16 +01:00
|
|
|
|
(:interactive (setq interactive (pop body)))
|
2018-10-27 01:48:35 +02:00
|
|
|
|
(:variable (setq variable (pop body))
|
|
|
|
|
(if (not (and (setq tmp (cdr-safe variable))
|
|
|
|
|
(or (symbolp tmp)
|
|
|
|
|
(functionp tmp))))
|
|
|
|
|
;; PLACE is not of the form (GET . SET).
|
|
|
|
|
(progn
|
|
|
|
|
(setq setter `(setf ,variable))
|
|
|
|
|
(setq getter variable))
|
|
|
|
|
(setq getter (car variable))
|
|
|
|
|
(setq setter `(funcall #',(cdr variable)))))
|
|
|
|
|
(:after-hook (setq after-hook (pop body)))
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(_ (push keyw extra-keywords) (push (pop body) extra-keywords))))
|
2000-10-28 06:07:30 +00:00
|
|
|
|
|
2021-04-12 11:08:19 -04:00
|
|
|
|
(setq pretty-name (easy-mmode-pretty-mode-name mode lighter))
|
2003-05-29 21:54:35 +00:00
|
|
|
|
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap
|
|
|
|
|
(intern (concat mode-name "-map"))))
|
|
|
|
|
|
2015-06-17 14:52:54 -04:00
|
|
|
|
(unless set (setq set '(:set #'custom-set-minor-mode)))
|
2005-07-16 02:25:48 +00:00
|
|
|
|
|
2005-07-14 00:56:13 +00:00
|
|
|
|
(unless initialize
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(setq initialize '(:initialize #'custom-initialize-default)))
|
2005-07-14 00:56:13 +00:00
|
|
|
|
|
2010-10-28 20:29:29 -07:00
|
|
|
|
;; TODO? Mark booleans as safe if booleanp? Eg abbrev-mode.
|
2005-07-16 02:25:48 +00:00
|
|
|
|
(unless type (setq type '(:type 'boolean)))
|
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
|
`(progn
|
1999-08-28 15:13:37 +00:00
|
|
|
|
;; Define the variable to enable or disable the mode.
|
2010-05-04 22:08:25 -04:00
|
|
|
|
,(cond
|
|
|
|
|
;; If :variable is specified, then the var will be
|
|
|
|
|
;; declared elsewhere.
|
|
|
|
|
(variable nil)
|
|
|
|
|
((not globalp)
|
|
|
|
|
`(progn
|
2012-05-30 21:41:17 -04:00
|
|
|
|
:autoload-end
|
2021-01-31 14:55:53 +01:00
|
|
|
|
(defvar-local ,mode ,init-value
|
2020-12-10 22:36:18 +01:00
|
|
|
|
,(concat (format "Non-nil if %s is enabled.\n" pretty-name)
|
|
|
|
|
(internal--format-docstring-line
|
2021-01-31 14:55:53 +01:00
|
|
|
|
"Use the command `%s' to change this variable." mode)))))
|
2010-05-04 22:08:25 -04:00
|
|
|
|
(t
|
2005-08-24 11:54:25 +00:00
|
|
|
|
(let ((base-doc-string
|
|
|
|
|
(concat "Non-nil if %s is enabled.
|
2016-04-29 23:25:07 +02:00
|
|
|
|
See the `%s' command
|
|
|
|
|
for a description of this minor mode."
|
2005-08-24 11:54:25 +00:00
|
|
|
|
(if body "
|
2000-06-05 06:06:30 +00:00
|
|
|
|
Setting this variable directly does not take effect;
|
2006-08-31 23:14:26 +00:00
|
|
|
|
either customize it (see the info node `Easy Customization')
|
|
|
|
|
or call the function `%s'."))))
|
2005-06-08 15:54:43 +00:00
|
|
|
|
`(defcustom ,mode ,init-value
|
|
|
|
|
,(format base-doc-string pretty-name mode mode)
|
2005-07-16 02:25:48 +00:00
|
|
|
|
,@set
|
2005-07-14 00:56:13 +00:00
|
|
|
|
,@initialize
|
2005-07-16 02:25:48 +00:00
|
|
|
|
,@type
|
2010-05-04 22:08:25 -04:00
|
|
|
|
,@(nreverse extra-keywords)))))
|
2000-06-11 04:55:57 +00:00
|
|
|
|
|
2000-06-04 20:59:47 +00:00
|
|
|
|
;; The actual function.
|
2021-04-12 11:08:19 -04:00
|
|
|
|
,(funcall
|
|
|
|
|
warnwrap
|
|
|
|
|
`(defun ,modefun (&optional arg ,@extra-args)
|
2021-06-22 16:03:37 +02:00
|
|
|
|
,(easy-mmode--mode-docstring doc pretty-name keymap-sym
|
2022-04-03 14:07:55 +02:00
|
|
|
|
getter globalp)
|
2021-04-12 11:08:19 -04:00
|
|
|
|
,(when interactive
|
|
|
|
|
;; Use `toggle' rather than (if ,mode 0 1) so that using
|
|
|
|
|
;; repeat-command still does the toggling correctly.
|
|
|
|
|
(if (consp interactive)
|
|
|
|
|
`(interactive
|
|
|
|
|
(list (if current-prefix-arg
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
|
|
|
|
'toggle))
|
|
|
|
|
,@interactive)
|
|
|
|
|
'(interactive
|
|
|
|
|
(list (if current-prefix-arg
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
|
|
|
|
'toggle)))))
|
|
|
|
|
(let ((,last-message (current-message)))
|
|
|
|
|
(,@setter
|
|
|
|
|
(cond ((eq arg 'toggle)
|
|
|
|
|
(not ,getter))
|
|
|
|
|
((and (numberp arg)
|
|
|
|
|
(< arg 1))
|
|
|
|
|
nil)
|
|
|
|
|
(t
|
|
|
|
|
t)))
|
|
|
|
|
;; Keep minor modes list up to date.
|
|
|
|
|
,@(if globalp
|
|
|
|
|
;; When running this byte-compiled code in earlier
|
|
|
|
|
;; Emacs versions, these variables may not be defined
|
|
|
|
|
;; there. So check defensively, even if they're
|
|
|
|
|
;; always defined in Emacs 28 and up.
|
|
|
|
|
`((when (boundp 'global-minor-modes)
|
|
|
|
|
(setq global-minor-modes
|
|
|
|
|
(delq ',modefun global-minor-modes))
|
|
|
|
|
(when ,getter
|
|
|
|
|
(push ',modefun global-minor-modes))))
|
|
|
|
|
;; Ditto check.
|
|
|
|
|
`((when (boundp 'local-minor-modes)
|
|
|
|
|
(setq local-minor-modes
|
|
|
|
|
(delq ',modefun local-minor-modes))
|
|
|
|
|
(when ,getter
|
|
|
|
|
(push ',modefun local-minor-modes)))))
|
|
|
|
|
,@body
|
|
|
|
|
;; The on/off hooks are here for backward compatibility only.
|
|
|
|
|
(run-hooks ',hook (if ,getter ',hook-on ',hook-off))
|
|
|
|
|
(if (called-interactively-p 'any)
|
|
|
|
|
(progn
|
|
|
|
|
,(if (and globalp (not variable))
|
|
|
|
|
`(customize-mark-as-set ',mode))
|
|
|
|
|
;; Avoid overwriting a message shown by the body,
|
|
|
|
|
;; but do overwrite previous messages.
|
|
|
|
|
(unless (and (current-message)
|
|
|
|
|
(not (equal ,last-message
|
|
|
|
|
(current-message))))
|
|
|
|
|
(let ((local ,(if globalp "" " in current buffer")))
|
|
|
|
|
(message ,(format "%s %%sabled%%s" pretty-name)
|
|
|
|
|
(if ,getter "en" "dis") local)))))
|
|
|
|
|
,@(when after-hook `(,after-hook)))
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
;; Return the new setting.
|
|
|
|
|
,getter))
|
2003-05-29 21:54:35 +00:00
|
|
|
|
|
2005-04-05 14:46:29 +00:00
|
|
|
|
;; Autoloading a define-minor-mode autoloads everything
|
|
|
|
|
;; up-to-here.
|
2000-06-11 04:55:57 +00:00
|
|
|
|
:autoload-end
|
|
|
|
|
|
2017-10-16 23:38:42 +13:00
|
|
|
|
(defvar ,hook nil)
|
|
|
|
|
(unless (get ',hook 'variable-documentation)
|
|
|
|
|
(put ',hook 'variable-documentation
|
|
|
|
|
,(format "Hook run after entering or leaving `%s'.
|
2013-05-27 12:12:52 -04:00
|
|
|
|
No problems result if this variable is not bound.
|
|
|
|
|
`add-hook' automatically binds it. (This is true for all hook variables.)"
|
2017-10-16 23:38:42 +13:00
|
|
|
|
modefun)))
|
2022-07-02 12:01:18 +02:00
|
|
|
|
;; Allow using `M-x customize-variable' on the hook.
|
2020-09-19 17:21:02 +02:00
|
|
|
|
(put ',hook 'custom-type 'hook)
|
|
|
|
|
(put ',hook 'standard-value (list nil))
|
2013-05-27 12:12:52 -04:00
|
|
|
|
|
2000-06-05 06:06:30 +00:00
|
|
|
|
;; Define the minor-mode keymap.
|
2000-06-11 04:55:57 +00:00
|
|
|
|
,(unless (symbolp keymap) ;nil is also a symbol.
|
2000-06-05 06:06:30 +00:00
|
|
|
|
`(defvar ,keymap-sym
|
2000-06-11 04:55:57 +00:00
|
|
|
|
(let ((m ,keymap))
|
|
|
|
|
(cond ((keymapp m) m)
|
2022-09-01 13:42:19 +02:00
|
|
|
|
;; FIXME: `easy-mmode-define-keymap' is obsolete,
|
|
|
|
|
;; so this form should also be obsolete somehow.
|
2022-09-02 14:58:30 +02:00
|
|
|
|
((listp m)
|
|
|
|
|
(with-suppressed-warnings ((obsolete
|
|
|
|
|
easy-mmode-define-keymap))
|
|
|
|
|
(easy-mmode-define-keymap m)))
|
2011-01-17 16:42:23 -05:00
|
|
|
|
(t (error "Invalid keymap %S" m))))
|
2000-06-05 06:06:30 +00:00
|
|
|
|
,(format "Keymap for `%s'." mode-name)))
|
|
|
|
|
|
2015-06-17 14:52:54 -04:00
|
|
|
|
,(let ((modevar (pcase getter (`(default-value ',v) v) (_ getter))))
|
|
|
|
|
(if (not (symbolp modevar))
|
|
|
|
|
(if (or lighter keymap)
|
|
|
|
|
(error ":lighter and :keymap unsupported with mode expression %S" getter))
|
|
|
|
|
`(with-no-warnings
|
|
|
|
|
(add-minor-mode ',modevar ',lighter
|
|
|
|
|
,(if keymap keymap-sym
|
|
|
|
|
`(if (boundp ',keymap-sym) ,keymap-sym))
|
|
|
|
|
nil
|
|
|
|
|
,(unless (eq mode modefun) `',modefun))))))))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
|
2000-06-04 23:40:58 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; make global minor mode
|
|
|
|
|
;;;
|
|
|
|
|
|
2000-06-05 06:06:30 +00:00
|
|
|
|
;;;###autoload
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(defalias 'easy-mmode-define-global-mode #'define-globalized-minor-mode)
|
2005-03-31 21:16:54 +00:00
|
|
|
|
;;;###autoload
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(defalias 'define-global-minor-mode #'define-globalized-minor-mode)
|
2007-02-03 17:26:28 +00:00
|
|
|
|
;;;###autoload
|
2019-08-03 20:19:31 -04:00
|
|
|
|
(defmacro define-globalized-minor-mode (global-mode mode turn-on &rest body)
|
2006-12-30 21:34:14 +00:00
|
|
|
|
"Make a global mode GLOBAL-MODE corresponding to buffer-local minor MODE.
|
2000-06-04 23:40:58 +00:00
|
|
|
|
TURN-ON is a function that will be called with no args in every buffer
|
2020-10-26 19:13:14 +01:00
|
|
|
|
and that should try to turn MODE on if applicable for that buffer.
|
|
|
|
|
|
|
|
|
|
Each of KEY VALUE is a pair of CL-style keyword arguments. :predicate
|
|
|
|
|
specifies which major modes the globalized minor mode should be switched on
|
|
|
|
|
in. As the minor mode defined by this function is always global, any
|
|
|
|
|
:global keyword is ignored. Other keywords have the same meaning as in
|
|
|
|
|
`define-minor-mode', which see. In particular, :group specifies the custom
|
|
|
|
|
group. The most useful keywords are those that are passed on to the
|
|
|
|
|
`defcustom'. It normally makes no sense to pass the :lighter or :keymap
|
|
|
|
|
keywords to `define-globalized-minor-mode', since these are usually passed
|
|
|
|
|
to the buffer-local version of the minor mode.
|
|
|
|
|
|
2019-08-03 20:19:31 -04:00
|
|
|
|
BODY contains code to execute each time the mode is enabled or disabled.
|
2020-10-26 19:13:14 +01:00
|
|
|
|
It is executed after toggling the mode, and before running
|
|
|
|
|
GLOBAL-MODE-hook.
|
2005-06-04 22:13:57 +00:00
|
|
|
|
|
|
|
|
|
If MODE's set-up depends on the major mode in effect when it was
|
|
|
|
|
enabled, then disabling and reenabling MODE should make MODE work
|
|
|
|
|
correctly with the current major mode. This is important to
|
|
|
|
|
prevent problems with derived modes, that is, major modes that
|
2013-02-15 20:01:51 +00:00
|
|
|
|
call another major mode in their body.
|
|
|
|
|
|
|
|
|
|
When a major mode is initialized, MODE is actually turned on just
|
|
|
|
|
after running the major mode's hook. However, MODE is not turned
|
2019-08-03 20:19:31 -04:00
|
|
|
|
on if the hook has explicitly disabled it.
|
|
|
|
|
|
|
|
|
|
\(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)"
|
2021-10-13 21:52:50 +02:00
|
|
|
|
(declare (doc-string 2) (indent defun))
|
2000-11-03 04:26:33 +00:00
|
|
|
|
(let* ((global-mode-name (symbol-name global-mode))
|
2013-02-15 20:01:51 +00:00
|
|
|
|
(mode-name (symbol-name mode))
|
2000-06-04 23:40:58 +00:00
|
|
|
|
(pretty-name (easy-mmode-pretty-mode-name mode))
|
|
|
|
|
(pretty-global-name (easy-mmode-pretty-mode-name global-mode))
|
2000-11-03 04:26:33 +00:00
|
|
|
|
(group nil)
|
2005-11-05 23:03:57 +00:00
|
|
|
|
(extra-keywords nil)
|
2021-02-04 15:22:40 +01:00
|
|
|
|
(MODE-variable mode)
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(MODE-buffers (intern (concat global-mode-name "-buffers")))
|
|
|
|
|
(MODE-enable-in-buffers
|
|
|
|
|
(intern (concat global-mode-name "-enable-in-buffers")))
|
|
|
|
|
(MODE-check-buffers
|
|
|
|
|
(intern (concat global-mode-name "-check-buffers")))
|
|
|
|
|
(MODE-cmhh (intern (concat global-mode-name "-cmhh")))
|
2013-02-15 20:01:51 +00:00
|
|
|
|
(minor-MODE-hook (intern (concat mode-name "-hook")))
|
2013-02-25 20:50:45 -05:00
|
|
|
|
(MODE-set-explicitly (intern (concat mode-name "-set-explicitly")))
|
2005-11-05 23:03:57 +00:00
|
|
|
|
(MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
|
2020-10-26 19:13:14 +01:00
|
|
|
|
(MODE-predicate (intern (concat (replace-regexp-in-string
|
|
|
|
|
"-mode\\'" "" global-mode-name)
|
|
|
|
|
"-modes")))
|
|
|
|
|
(turn-on-function `#',turn-on)
|
|
|
|
|
keyw predicate)
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
;; Check keys.
|
2019-08-03 20:19:31 -04:00
|
|
|
|
(while (keywordp (setq keyw (car body)))
|
|
|
|
|
(pop body)
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(pcase keyw
|
2019-08-03 20:19:31 -04:00
|
|
|
|
(:group (setq group (nconc group (list :group (pop body)))))
|
|
|
|
|
(:global (pop body))
|
2021-02-04 15:22:40 +01:00
|
|
|
|
(:variable (setq MODE-variable (pop body)))
|
2020-10-26 19:13:14 +01:00
|
|
|
|
(:predicate
|
|
|
|
|
(setq predicate (list (pop body)))
|
|
|
|
|
(setq turn-on-function
|
|
|
|
|
`(lambda ()
|
|
|
|
|
(require 'easy-mmode)
|
|
|
|
|
(when (easy-mmode--globalized-predicate-p ,(car predicate))
|
|
|
|
|
(funcall ,turn-on-function)))))
|
2019-08-03 20:19:31 -04:00
|
|
|
|
(_ (push keyw extra-keywords) (push (pop body) extra-keywords))))
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
`(progn
|
2012-05-30 21:41:17 -04:00
|
|
|
|
(progn
|
2019-10-01 16:45:24 +02:00
|
|
|
|
(put ',global-mode 'globalized-minor-mode t)
|
2012-05-30 21:41:17 -04:00
|
|
|
|
:autoload-end
|
2021-01-31 14:55:53 +01:00
|
|
|
|
(defvar-local ,MODE-major-mode nil))
|
2000-06-04 23:40:58 +00:00
|
|
|
|
;; The actual global minor-mode
|
|
|
|
|
(define-minor-mode ,global-mode
|
2020-12-10 22:36:18 +01:00
|
|
|
|
,(concat (format "Toggle %s in all buffers.\n" pretty-name)
|
|
|
|
|
(internal--format-docstring-line
|
2021-09-28 13:30:02 +02:00
|
|
|
|
(concat "With prefix ARG, enable %s if ARG is positive; "
|
|
|
|
|
"otherwise, disable it.")
|
2020-12-10 22:36:18 +01:00
|
|
|
|
pretty-global-name)
|
2021-09-28 13:30:02 +02:00
|
|
|
|
"\n\n"
|
2021-08-04 09:38:45 +02:00
|
|
|
|
"If called from Lisp, toggle the mode if ARG is `toggle'.
|
|
|
|
|
Enable the mode if ARG is nil, omitted, or is a positive number.
|
|
|
|
|
Disable the mode if ARG is a negative number.\n\n"
|
2020-12-10 22:36:18 +01:00
|
|
|
|
(internal--format-docstring-line
|
2021-09-28 13:30:02 +02:00
|
|
|
|
"%s is enabled in all buffers where `%s' would do it."
|
2020-12-10 22:36:18 +01:00
|
|
|
|
pretty-name turn-on)
|
2021-09-28 13:30:02 +02:00
|
|
|
|
"\n\n"
|
2020-12-10 22:36:18 +01:00
|
|
|
|
(internal--format-docstring-line
|
|
|
|
|
"See `%s' for more information on %s."
|
|
|
|
|
mode pretty-name)
|
2020-10-26 19:13:14 +01:00
|
|
|
|
(if predicate
|
2020-12-10 22:36:18 +01:00
|
|
|
|
(concat
|
|
|
|
|
"\n\n"
|
|
|
|
|
(internal--format-docstring-line
|
|
|
|
|
"`%s' is used to control which modes this minor mode is used in."
|
|
|
|
|
MODE-predicate))
|
2020-10-26 19:13:14 +01:00
|
|
|
|
""))
|
|
|
|
|
:global t ,@group ,@(nreverse extra-keywords)
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
;; Setup hook to handle future mode changes and new buffers.
|
|
|
|
|
(if ,global-mode
|
2000-06-05 06:06:30 +00:00
|
|
|
|
(progn
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(add-hook 'after-change-major-mode-hook
|
2021-04-16 23:40:51 -04:00
|
|
|
|
#',MODE-enable-in-buffers)
|
|
|
|
|
(add-hook 'find-file-hook #',MODE-check-buffers)
|
|
|
|
|
(add-hook 'change-major-mode-hook #',MODE-cmhh))
|
|
|
|
|
(remove-hook 'after-change-major-mode-hook #',MODE-enable-in-buffers)
|
|
|
|
|
(remove-hook 'find-file-hook #',MODE-check-buffers)
|
|
|
|
|
(remove-hook 'change-major-mode-hook #',MODE-cmhh))
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
;; Go through existing buffers.
|
|
|
|
|
(dolist (buf (buffer-list))
|
|
|
|
|
(with-current-buffer buf
|
2020-10-26 19:13:14 +01:00
|
|
|
|
(if ,global-mode (funcall ,turn-on-function)
|
|
|
|
|
(when ,mode (,mode -1)))))
|
2019-08-03 20:19:31 -04:00
|
|
|
|
,@body)
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
2020-10-26 20:44:15 +01:00
|
|
|
|
,(when predicate
|
|
|
|
|
`(defcustom ,MODE-predicate ,(car predicate)
|
|
|
|
|
,(format "Which major modes `%s' is switched on in.
|
|
|
|
|
This variable can be either t (all major modes), nil (no major modes),
|
|
|
|
|
or a list of modes and (not modes) to switch use this minor mode or
|
|
|
|
|
not. For instance
|
|
|
|
|
|
|
|
|
|
(c-mode (not message-mode mail-mode) text-mode)
|
|
|
|
|
|
|
|
|
|
means \"use this mode in all modes derived from `c-mode', don't use in
|
|
|
|
|
modes derived from `message-mode' or `mail-mode', but do use in other
|
|
|
|
|
modes derived from `text-mode'\". An element with value t means \"use\"
|
|
|
|
|
and nil means \"don't use\". There's an implicit nil at the end of the
|
|
|
|
|
list."
|
|
|
|
|
mode)
|
|
|
|
|
:type '(repeat sexp)
|
2022-06-18 14:11:01 +02:00
|
|
|
|
,@group))
|
2020-10-26 20:44:15 +01:00
|
|
|
|
|
2007-02-03 17:26:28 +00:00
|
|
|
|
;; Autoloading define-globalized-minor-mode autoloads everything
|
2005-05-17 15:17:18 +00:00
|
|
|
|
;; up-to-here.
|
2000-06-11 04:55:57 +00:00
|
|
|
|
:autoload-end
|
|
|
|
|
|
2013-05-21 00:25:14 -07:00
|
|
|
|
;; MODE-set-explicitly is set in MODE-set-explicitly and cleared by
|
|
|
|
|
;; kill-all-local-variables.
|
|
|
|
|
(defvar-local ,MODE-set-explicitly nil)
|
|
|
|
|
(defun ,MODE-set-explicitly ()
|
|
|
|
|
(setq ,MODE-set-explicitly t))
|
|
|
|
|
(put ',MODE-set-explicitly 'definition-name ',global-mode)
|
|
|
|
|
|
2013-02-15 20:01:51 +00:00
|
|
|
|
;; A function which checks whether MODE has been disabled in the major
|
|
|
|
|
;; mode hook which has just been run.
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(add-hook ',minor-MODE-hook #',MODE-set-explicitly)
|
2013-02-15 20:01:51 +00:00
|
|
|
|
|
2000-06-04 23:40:58 +00:00
|
|
|
|
;; List of buffers left to process.
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(defvar ,MODE-buffers nil)
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
;; The function that calls TURN-ON in each buffer.
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(defun ,MODE-enable-in-buffers ()
|
2018-06-23 11:12:44 -04:00
|
|
|
|
(let ((buffers ,MODE-buffers))
|
|
|
|
|
;; Clear MODE-buffers to avoid scanning the same list of
|
|
|
|
|
;; buffers in recursive calls to MODE-enable-in-buffers.
|
|
|
|
|
;; Otherwise it could lead to infinite recursion.
|
|
|
|
|
(setq ,MODE-buffers nil)
|
|
|
|
|
(dolist (buf buffers)
|
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(unless ,MODE-set-explicitly
|
|
|
|
|
(unless (eq ,MODE-major-mode major-mode)
|
2021-02-04 15:22:40 +01:00
|
|
|
|
(if ,MODE-variable
|
2018-06-23 11:12:44 -04:00
|
|
|
|
(progn
|
|
|
|
|
(,mode -1)
|
2020-10-26 19:13:14 +01:00
|
|
|
|
(funcall ,turn-on-function))
|
|
|
|
|
(funcall ,turn-on-function))))
|
2018-06-23 11:12:44 -04:00
|
|
|
|
(setq ,MODE-major-mode major-mode))))))
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(put ',MODE-enable-in-buffers 'definition-name ',global-mode)
|
|
|
|
|
|
|
|
|
|
(defun ,MODE-check-buffers ()
|
|
|
|
|
(,MODE-enable-in-buffers)
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(remove-hook 'post-command-hook #',MODE-check-buffers))
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(put ',MODE-check-buffers 'definition-name ',global-mode)
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
|
|
|
|
;; The function that catches kill-all-local-variables.
|
2005-06-04 22:13:57 +00:00
|
|
|
|
(defun ,MODE-cmhh ()
|
|
|
|
|
(add-to-list ',MODE-buffers (current-buffer))
|
2021-04-16 23:40:51 -04:00
|
|
|
|
(add-hook 'post-command-hook #',MODE-check-buffers))
|
2020-10-26 20:44:15 +01:00
|
|
|
|
(put ',MODE-cmhh 'definition-name ',global-mode))))
|
2020-10-26 19:13:14 +01:00
|
|
|
|
|
|
|
|
|
(defun easy-mmode--globalized-predicate-p (predicate)
|
|
|
|
|
(cond
|
|
|
|
|
((eq predicate t)
|
|
|
|
|
t)
|
|
|
|
|
((eq predicate nil)
|
|
|
|
|
nil)
|
|
|
|
|
((listp predicate)
|
|
|
|
|
;; Legacy support for (not a b c).
|
|
|
|
|
(when (eq (car predicate) 'not)
|
|
|
|
|
(setq predicate (nconc (mapcar (lambda (e) (list 'not e))
|
|
|
|
|
(cdr predicate))
|
|
|
|
|
(list t))))
|
|
|
|
|
(catch 'found
|
|
|
|
|
(dolist (elem predicate)
|
|
|
|
|
(cond
|
|
|
|
|
((eq elem t)
|
|
|
|
|
(throw 'found t))
|
|
|
|
|
((eq elem nil)
|
|
|
|
|
(throw 'found nil))
|
|
|
|
|
((and (consp elem)
|
|
|
|
|
(eq (car elem) 'not))
|
|
|
|
|
(when (apply #'derived-mode-p (cdr elem))
|
|
|
|
|
(throw 'found nil)))
|
|
|
|
|
((symbolp elem)
|
|
|
|
|
(when (derived-mode-p elem)
|
|
|
|
|
(throw 'found t)))))))))
|
2000-06-04 23:40:58 +00:00
|
|
|
|
|
2000-03-10 01:17:04 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; easy-mmode-defmap
|
|
|
|
|
;;;
|
|
|
|
|
|
2013-02-25 20:50:45 -05:00
|
|
|
|
(defun easy-mmode-set-keymap-parents (m parents)
|
|
|
|
|
(set-keymap-parent
|
|
|
|
|
m (if (cdr parents) (make-composed-keymap parents) (car parents))))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
|
2000-09-29 03:27:28 +00:00
|
|
|
|
;;;###autoload
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(defun easy-mmode-define-keymap (bs &optional name m args)
|
|
|
|
|
"Return a keymap built from bindings BS.
|
|
|
|
|
BS must be a list of (KEY . BINDING) where
|
2000-06-02 23:07:08 +00:00
|
|
|
|
KEY and BINDINGS are suitable for `define-key'.
|
|
|
|
|
Optional NAME is passed to `make-sparse-keymap'.
|
|
|
|
|
Optional map M can be used to modify an existing map.
|
2008-04-24 05:47:18 +00:00
|
|
|
|
ARGS is a list of additional keyword arguments.
|
|
|
|
|
|
|
|
|
|
Valid keywords and arguments are:
|
|
|
|
|
|
|
|
|
|
:name Name of the keymap; overrides NAME argument.
|
|
|
|
|
:dense Non-nil for a dense keymap.
|
|
|
|
|
:inherit Parent keymap.
|
|
|
|
|
:group Ignored.
|
|
|
|
|
:suppress Non-nil to call `suppress-keymap' on keymap,
|
2015-11-17 15:28:50 -08:00
|
|
|
|
`nodigits' to suppress digits as prefix arguments."
|
2022-09-01 13:42:19 +02:00
|
|
|
|
(declare (obsolete define-keymap "29.1"))
|
2008-04-24 05:47:18 +00:00
|
|
|
|
(let (inherit dense suppress)
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(while args
|
|
|
|
|
(let ((key (pop args))
|
|
|
|
|
(val (pop args)))
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(pcase key
|
2018-10-27 01:48:35 +02:00
|
|
|
|
(:name (setq name val))
|
|
|
|
|
(:dense (setq dense val))
|
|
|
|
|
(:inherit (setq inherit val))
|
|
|
|
|
(:suppress (setq suppress val))
|
|
|
|
|
(:group)
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(_ (message "Unknown argument %s in defmap" key)))))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(unless (keymapp m)
|
|
|
|
|
(setq bs (append m bs))
|
|
|
|
|
(setq m (if dense (make-keymap name) (make-sparse-keymap name))))
|
2008-04-24 05:47:18 +00:00
|
|
|
|
(when suppress
|
|
|
|
|
(suppress-keymap m (eq suppress 'nodigits)))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(dolist (b bs)
|
|
|
|
|
(let ((keys (car b))
|
|
|
|
|
(binding (cdr b)))
|
|
|
|
|
(dolist (key (if (consp keys) keys (list keys)))
|
|
|
|
|
(cond
|
|
|
|
|
((symbolp key)
|
|
|
|
|
(substitute-key-definition key binding m global-map))
|
|
|
|
|
((null binding)
|
|
|
|
|
(unless (keymapp (lookup-key m key)) (define-key m key binding)))
|
|
|
|
|
((let ((o (lookup-key m key)))
|
|
|
|
|
(or (null o) (numberp o) (eq o 'undefined)))
|
|
|
|
|
(define-key m key binding))))))
|
|
|
|
|
(cond
|
|
|
|
|
((keymapp inherit) (set-keymap-parent m inherit))
|
|
|
|
|
((consp inherit) (easy-mmode-set-keymap-parents m inherit)))
|
|
|
|
|
m))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defmacro easy-mmode-defmap (m bs doc &rest args)
|
2009-09-10 06:20:51 +00:00
|
|
|
|
"Define a constant M whose value is the result of `easy-mmode-define-keymap'.
|
|
|
|
|
The M, BS, and ARGS arguments are as per that function. DOC is
|
2022-01-13 23:16:16 +01:00
|
|
|
|
the constant's documentation.
|
|
|
|
|
|
|
|
|
|
This macro is deprecated; use `defvar-keymap' instead."
|
2022-09-01 13:39:14 +02:00
|
|
|
|
(declare (doc-string 3) (indent 1) (obsolete defvar-keymap "29.1"))
|
2000-09-29 03:27:28 +00:00
|
|
|
|
`(defconst ,m
|
|
|
|
|
(easy-mmode-define-keymap ,bs nil (if (boundp ',m) ,m) ,(cons 'list args))
|
|
|
|
|
,doc))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; easy-mmode-defsyntax
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defun easy-mmode-define-syntax (css args)
|
2000-10-15 05:25:57 +00:00
|
|
|
|
(let ((st (make-syntax-table (plist-get args :copy)))
|
|
|
|
|
(parent (plist-get args :inherit)))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(dolist (cs css)
|
|
|
|
|
(let ((char (car cs))
|
|
|
|
|
(syntax (cdr cs)))
|
|
|
|
|
(if (sequencep char)
|
2007-09-26 00:12:23 +00:00
|
|
|
|
(mapc (lambda (c) (modify-syntax-entry c syntax st)) char)
|
2000-03-10 01:17:04 +00:00
|
|
|
|
(modify-syntax-entry char syntax st))))
|
2000-10-15 05:25:57 +00:00
|
|
|
|
(if parent (set-char-table-parent
|
|
|
|
|
st (if (symbolp parent) (symbol-value parent) parent)))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
st))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defmacro easy-mmode-defsyntax (st css doc &rest args)
|
2000-10-15 05:25:57 +00:00
|
|
|
|
"Define variable ST as a syntax-table.
|
2001-04-19 22:45:04 +00:00
|
|
|
|
CSS contains a list of syntax specifications of the form (CHAR . SYNTAX)."
|
2022-01-03 17:21:55 +03:00
|
|
|
|
(declare (doc-string 3) (indent 1))
|
2000-03-11 03:37:37 +00:00
|
|
|
|
`(progn
|
|
|
|
|
(autoload 'easy-mmode-define-syntax "easy-mmode")
|
2001-04-19 22:45:04 +00:00
|
|
|
|
(defconst ,st (easy-mmode-define-syntax ,css ,(cons 'list args)) ,doc)))
|
2000-03-10 01:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
2000-03-21 15:35:06 +00:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; easy-mmode-define-navigation
|
|
|
|
|
;;;
|
|
|
|
|
|
2007-10-20 01:46:38 +00:00
|
|
|
|
(defmacro easy-mmode-define-navigation (base re &optional name endfun narrowfun
|
|
|
|
|
&rest body)
|
2000-03-21 15:35:06 +00:00
|
|
|
|
"Define BASE-next and BASE-prev to navigate in the buffer.
|
|
|
|
|
RE determines the places the commands should move point to.
|
2000-11-09 23:51:59 +00:00
|
|
|
|
NAME should describe the entities matched by RE. It is used to build
|
2000-03-21 15:35:06 +00:00
|
|
|
|
the docstrings of the two functions.
|
|
|
|
|
BASE-next also tries to make sure that the whole entry is visible by
|
|
|
|
|
searching for its end (by calling ENDFUN if provided or by looking for
|
|
|
|
|
the next entry) and recentering if necessary.
|
2003-11-14 16:18:01 +00:00
|
|
|
|
ENDFUN should return the end position (with or without moving point).
|
|
|
|
|
NARROWFUN non-nil means to check for narrowing before moving, and if
|
2007-10-20 01:46:38 +00:00
|
|
|
|
found, do `widen' first and then call NARROWFUN with no args after moving.
|
|
|
|
|
BODY is executed after moving to the destination location."
|
2019-10-16 04:44:22 +02:00
|
|
|
|
(declare (indent 5) (debug (exp exp exp def-form def-form def-body)))
|
2000-03-21 15:35:06 +00:00
|
|
|
|
(let* ((base-name (symbol-name base))
|
|
|
|
|
(prev-sym (intern (concat base-name "-prev")))
|
2003-11-14 16:18:01 +00:00
|
|
|
|
(next-sym (intern (concat base-name "-next")))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
(when-narrowed
|
|
|
|
|
(lambda (body)
|
|
|
|
|
(if (null narrowfun) body
|
2019-02-19 19:54:44 +01:00
|
|
|
|
`(let ((was-narrowed (prog1 (buffer-narrowed-p) (widen))))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
,body
|
2013-08-02 17:23:07 -04:00
|
|
|
|
(when was-narrowed (funcall #',narrowfun)))))))
|
2003-06-22 16:55:47 +00:00
|
|
|
|
(unless name (setq name base-name))
|
2019-03-13 15:55:39 -04:00
|
|
|
|
;; FIXME: Move most of those functions's bodies to helper functions!
|
2000-03-21 15:35:06 +00:00
|
|
|
|
`(progn
|
|
|
|
|
(defun ,next-sym (&optional count)
|
2018-11-09 11:22:46 +02:00
|
|
|
|
,(format "Go to the next COUNT'th %s.
|
|
|
|
|
Interactively, COUNT is the prefix numeric argument, and defaults to 1." name)
|
2006-11-28 19:22:31 +00:00
|
|
|
|
(interactive "p")
|
2000-03-21 15:35:06 +00:00
|
|
|
|
(unless count (setq count 1))
|
|
|
|
|
(if (< count 0) (,prev-sym (- count))
|
2003-10-20 19:07:02 +00:00
|
|
|
|
(if (looking-at ,re) (setq count (1+ count)))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
,(funcall when-narrowed
|
|
|
|
|
`(if (not (re-search-forward ,re nil t count))
|
|
|
|
|
(if (looking-at ,re)
|
2013-08-02 17:23:07 -04:00
|
|
|
|
(goto-char (or ,(if endfun `(funcall #',endfun)) (point-max)))
|
Add new error and function `user-error'.
* lisp/subr.el (user-error): New function.
* lisp/window.el (switch-to-buffer):
* lisp/vc/smerge-mode.el (smerge-resolve-function, smerge-resolve)
(smerge-match-conflict):
* lisp/simple.el (previous-matching-history-element)
(next-matching-history-element, goto-history-element, undo-more)
(undo-start):
* lisp/progmodes/etags.el (visit-tags-table-buffer, find-tag-tag)
(find-tag-noselect, find-tag-in-order, etags-goto-tag-location)
(next-file, tags-loop-scan, list-tags, complete-tag):
* lisp/progmodes/compile.el (compilation-loop):
* lisp/mouse.el (mouse-minibuffer-check):
* lisp/man.el (Man-bgproc-sentinel, Man-goto-page):
* lisp/info.el (Info-find-node-2, Info-extract-pointer, Info-history-back)
(Info-history-forward, Info-follow-reference, Info-menu)
(Info-extract-menu-item, Info-extract-menu-counting)
(Info-forward-node, Info-backward-node, Info-next-menu-item)
(Info-last-menu-item, Info-next-preorder, Info-last-preorder)
(Info-next-reference, Info-prev-reference, Info-index)
(Info-index-next, Info-follow-nearest-node)
(Info-copy-current-node-name):
* lisp/imenu.el (imenu--make-index-alist)
(imenu-default-create-index-function, imenu-add-to-menubar):
* lisp/files.el (basic-save-buffer, recover-file):
* lisp/emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* lisp/emacs-lisp/checkdoc.el (checkdoc-continue, checkdoc-comments)
(checkdoc-message-text, checkdoc-defun):
* lisp/dabbrev.el (dabbrev-completion, dabbrev--abbrev-at-point):
* lisp/cus-edit.el (customize-changed-options, customize-rogue)
(customize-saved, custom-variable-set, custom-variable-mark-to-save)
(custom-variable-mark-to-reset-standard)
(custom-variable-reset-backup, custom-face-mark-to-reset-standard)
(custom-file):
* lisp/completion.el (check-completion-length):
* lisp/comint.el (comint-search-arg)
(comint-previous-matching-input-string-position)
(comint-previous-matching-input)
(comint-replace-by-expanded-history-before-point, comint-send-input)
(comint-copy-old-input, comint-backward-matching-input)
(comint-goto-process-mark, comint-set-process-mark):
* lisp/calendar/calendar.el (calendar-cursor-to-date): Use it.
* lisp/bindings.el (debug-ignored-errors): Remove regexps, add `user-error'.
* src/data.c (PUT_ERROR): New macro.
(syms_of_data): Use it. Add new error type `user-error'.
* src/undo.c (user_error): New function.
(Fprimitive_undo): Use it.
* src/print.c (print_error_message): Adjust print style for `user-error'.
* src/keyboard.c (user_error): New function.
(Fexit_recursive_edit, Fabort_recursive_edit): Use it.
2012-05-04 19:16:47 -04:00
|
|
|
|
(user-error "No next %s" ,name))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
(goto-char (match-beginning 0))
|
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
|
|
|
|
(when (and (eq (current-buffer) (window-buffer))
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(called-interactively-p 'interactive))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
(let ((endpt (or (save-excursion
|
2013-08-02 17:23:07 -04:00
|
|
|
|
,(if endfun `(funcall #',endfun)
|
2007-10-20 01:46:38 +00:00
|
|
|
|
`(re-search-forward ,re nil t 2)))
|
|
|
|
|
(point-max))))
|
|
|
|
|
(unless (pos-visible-in-window-p endpt nil t)
|
2019-03-13 15:55:39 -04:00
|
|
|
|
(let ((ws (window-start)))
|
|
|
|
|
(recenter '(0))
|
|
|
|
|
(if (< (window-start) ws)
|
|
|
|
|
;; recenter scrolled in the wrong direction!
|
|
|
|
|
(set-window-start nil ws))))))))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
,@body))
|
2005-12-04 02:34:33 +00:00
|
|
|
|
(put ',next-sym 'definition-name ',base)
|
2000-03-21 15:35:06 +00:00
|
|
|
|
(defun ,prev-sym (&optional count)
|
2018-11-09 11:22:46 +02:00
|
|
|
|
,(format "Go to the previous COUNT'th %s.
|
|
|
|
|
Interactively, COUNT is the prefix numeric argument, and defaults to 1."
|
|
|
|
|
(or name base-name))
|
2006-11-28 19:22:31 +00:00
|
|
|
|
(interactive "p")
|
2000-03-21 15:35:06 +00:00
|
|
|
|
(unless count (setq count 1))
|
|
|
|
|
(if (< count 0) (,next-sym (- count))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
,(funcall when-narrowed
|
|
|
|
|
`(unless (re-search-backward ,re nil t count)
|
Add new error and function `user-error'.
* lisp/subr.el (user-error): New function.
* lisp/window.el (switch-to-buffer):
* lisp/vc/smerge-mode.el (smerge-resolve-function, smerge-resolve)
(smerge-match-conflict):
* lisp/simple.el (previous-matching-history-element)
(next-matching-history-element, goto-history-element, undo-more)
(undo-start):
* lisp/progmodes/etags.el (visit-tags-table-buffer, find-tag-tag)
(find-tag-noselect, find-tag-in-order, etags-goto-tag-location)
(next-file, tags-loop-scan, list-tags, complete-tag):
* lisp/progmodes/compile.el (compilation-loop):
* lisp/mouse.el (mouse-minibuffer-check):
* lisp/man.el (Man-bgproc-sentinel, Man-goto-page):
* lisp/info.el (Info-find-node-2, Info-extract-pointer, Info-history-back)
(Info-history-forward, Info-follow-reference, Info-menu)
(Info-extract-menu-item, Info-extract-menu-counting)
(Info-forward-node, Info-backward-node, Info-next-menu-item)
(Info-last-menu-item, Info-next-preorder, Info-last-preorder)
(Info-next-reference, Info-prev-reference, Info-index)
(Info-index-next, Info-follow-nearest-node)
(Info-copy-current-node-name):
* lisp/imenu.el (imenu--make-index-alist)
(imenu-default-create-index-function, imenu-add-to-menubar):
* lisp/files.el (basic-save-buffer, recover-file):
* lisp/emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* lisp/emacs-lisp/checkdoc.el (checkdoc-continue, checkdoc-comments)
(checkdoc-message-text, checkdoc-defun):
* lisp/dabbrev.el (dabbrev-completion, dabbrev--abbrev-at-point):
* lisp/cus-edit.el (customize-changed-options, customize-rogue)
(customize-saved, custom-variable-set, custom-variable-mark-to-save)
(custom-variable-mark-to-reset-standard)
(custom-variable-reset-backup, custom-face-mark-to-reset-standard)
(custom-file):
* lisp/completion.el (check-completion-length):
* lisp/comint.el (comint-search-arg)
(comint-previous-matching-input-string-position)
(comint-previous-matching-input)
(comint-replace-by-expanded-history-before-point, comint-send-input)
(comint-copy-old-input, comint-backward-matching-input)
(comint-goto-process-mark, comint-set-process-mark):
* lisp/calendar/calendar.el (calendar-cursor-to-date): Use it.
* lisp/bindings.el (debug-ignored-errors): Remove regexps, add `user-error'.
* src/data.c (PUT_ERROR): New macro.
(syms_of_data): Use it. Add new error type `user-error'.
* src/undo.c (user_error): New function.
(Fprimitive_undo): Use it.
* src/print.c (print_error_message): Adjust print style for `user-error'.
* src/keyboard.c (user_error): New function.
(Fexit_recursive_edit, Fabort_recursive_edit): Use it.
2012-05-04 19:16:47 -04:00
|
|
|
|
(user-error "No previous %s" ,name)))
|
2007-10-20 01:46:38 +00:00
|
|
|
|
,@body))
|
2005-12-04 02:34:33 +00:00
|
|
|
|
(put ',prev-sym 'definition-name ',base))))
|
2003-11-14 16:18:01 +00:00
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
|
(provide 'easy-mmode)
|
|
|
|
|
|
|
|
|
|
;;; easy-mmode.el ends here
|