2013-01-08 15:15:15 -05:00
|
|
|
|
;;; simple.el --- basic editing commands for Emacs -*- lexical-binding: t -*-
|
1992-05-30 21:11:25 +00:00
|
|
|
|
|
2014-01-01 07:43:34 +00:00
|
|
|
|
;; Copyright (C) 1985-1987, 1993-2014 Free Software Foundation, Inc.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2014-02-09 17:34:22 -08:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2002-05-02 05:41:46 +00:00
|
|
|
|
;; Keywords: internal
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
2002-05-02 05:41:46 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +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-12-21 09:29:41 +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-12-21 09:29:41 +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
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1993-03-22 16:53:22 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; A grab-bag of basic Emacs commands not specifically related to some
|
|
|
|
|
;; major mode or to file-handling.
|
|
|
|
|
|
1992-07-22 04:22:42 +00:00
|
|
|
|
;;; Code:
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2008-03-14 17:42:18 +00:00
|
|
|
|
(declare-function widget-convert "wid-edit" (type &rest args))
|
|
|
|
|
(declare-function shell-mode "shell" ())
|
1999-11-16 13:29:51 +00:00
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
;;; From compile.el
|
2005-08-31 13:51:34 +00:00
|
|
|
|
(defvar compilation-current-error)
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defvar compilation-context-lines)
|
2005-08-31 13:51:34 +00:00
|
|
|
|
|
2005-03-29 20:53:19 +00:00
|
|
|
|
(defcustom idle-update-delay 0.5
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Idle time delay before updating various things on the screen.
|
2005-03-29 20:53:19 +00:00
|
|
|
|
Various Emacs features that update auxiliary information when point moves
|
|
|
|
|
wait this many seconds after Emacs becomes idle before doing an update."
|
|
|
|
|
:type 'number
|
|
|
|
|
:group 'display
|
|
|
|
|
:version "22.1")
|
1999-11-16 13:29:51 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defgroup killing nil
|
2004-06-10 04:20:02 +00:00
|
|
|
|
"Killing and yanking commands."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:group 'editing)
|
|
|
|
|
|
|
|
|
|
(defgroup paren-matching nil
|
|
|
|
|
"Highlight (un)matching of parens and expressions."
|
|
|
|
|
:group 'matching)
|
2004-09-01 18:41:06 +00:00
|
|
|
|
|
2004-04-21 21:36:15 +00:00
|
|
|
|
;;; next-error support framework
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
|
|
|
|
(defgroup next-error nil
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"`next-error' support framework."
|
2004-11-08 16:59:43 +00:00
|
|
|
|
:group 'compilation
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
|
|
|
|
(defface next-error
|
|
|
|
|
'((t (:inherit region)))
|
|
|
|
|
"Face used to highlight next error locus."
|
|
|
|
|
:group 'next-error
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
2006-09-24 20:38:47 +00:00
|
|
|
|
(defcustom next-error-highlight 0.5
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Highlighting of locations in selected source buffers.
|
2007-03-28 18:36:01 +00:00
|
|
|
|
If a number, highlight the locus in `next-error' face for the given time
|
|
|
|
|
in seconds, or until the next command is executed.
|
|
|
|
|
If t, highlight the locus until the next command is executed, or until
|
|
|
|
|
some other locus replaces it.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
If nil, don't highlight the locus in the source buffer.
|
2011-09-07 14:46:56 +03:00
|
|
|
|
If `fringe-arrow', indicate the locus by the fringe arrow
|
|
|
|
|
indefinitely until some other locus replaces it."
|
2006-09-11 19:05:46 +00:00
|
|
|
|
:type '(choice (number :tag "Highlight for specified time")
|
2006-09-11 22:33:46 +00:00
|
|
|
|
(const :tag "Semipermanent highlighting" t)
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(const :tag "No highlighting" nil)
|
2006-09-11 19:05:46 +00:00
|
|
|
|
(const :tag "Fringe arrow" fringe-arrow))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
:group 'next-error
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
2006-09-24 20:38:47 +00:00
|
|
|
|
(defcustom next-error-highlight-no-select 0.5
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Highlighting of locations in `next-error-no-select'.
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
If number, highlight the locus in `next-error' face for given time in seconds.
|
2006-09-11 19:05:46 +00:00
|
|
|
|
If t, highlight the locus indefinitely until some other locus replaces it.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
If nil, don't highlight the locus in the source buffer.
|
2011-09-07 14:46:56 +03:00
|
|
|
|
If `fringe-arrow', indicate the locus by the fringe arrow
|
|
|
|
|
indefinitely until some other locus replaces it."
|
2006-09-11 19:05:46 +00:00
|
|
|
|
:type '(choice (number :tag "Highlight for specified time")
|
2006-09-11 22:33:46 +00:00
|
|
|
|
(const :tag "Semipermanent highlighting" t)
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(const :tag "No highlighting" nil)
|
2006-09-11 19:05:46 +00:00
|
|
|
|
(const :tag "Fringe arrow" fringe-arrow))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
:group 'next-error
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
2007-06-22 07:56:01 +00:00
|
|
|
|
(defcustom next-error-recenter nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Display the line in the visited source file recentered as specified.
|
2007-06-23 12:19:38 +00:00
|
|
|
|
If non-nil, the value is passed directly to `recenter'."
|
|
|
|
|
:type '(choice (integer :tag "Line to recenter to")
|
|
|
|
|
(const :tag "Center of window" (4))
|
2007-06-22 07:56:01 +00:00
|
|
|
|
(const :tag "No recentering" nil))
|
|
|
|
|
:group 'next-error
|
|
|
|
|
:version "23.1")
|
|
|
|
|
|
2005-07-09 20:46:26 +00:00
|
|
|
|
(defcustom next-error-hook nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"List of hook functions run by `next-error' after visiting source file."
|
2005-07-09 20:46:26 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'next-error)
|
|
|
|
|
|
2005-03-29 04:55:43 +00:00
|
|
|
|
(defvar next-error-highlight-timer nil)
|
|
|
|
|
|
2005-04-07 15:15:15 +00:00
|
|
|
|
(defvar next-error-overlay-arrow-position nil)
|
2009-11-11 05:49:09 +00:00
|
|
|
|
(put 'next-error-overlay-arrow-position 'overlay-arrow-string (purecopy "=>"))
|
2005-04-07 15:15:15 +00:00
|
|
|
|
(add-to-list 'overlay-arrow-variable-list 'next-error-overlay-arrow-position)
|
|
|
|
|
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(defvar next-error-last-buffer nil
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"The most recent `next-error' buffer.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
A buffer becomes most recent when its compilation, grep, or
|
|
|
|
|
similar mode is started, or when it is used with \\[next-error]
|
|
|
|
|
or \\[compile-goto-error].")
|
|
|
|
|
|
|
|
|
|
(defvar next-error-function nil
|
2004-04-22 22:56:08 +00:00
|
|
|
|
"Function to use to find the next error in the current buffer.
|
|
|
|
|
The function is called with 2 parameters:
|
|
|
|
|
ARG is an integer specifying by how many errors to move.
|
|
|
|
|
RESET is a boolean which, if non-nil, says to go back to the beginning
|
|
|
|
|
of the errors before moving.
|
|
|
|
|
Major modes providing compile-like functionality should set this variable
|
|
|
|
|
to indicate to `next-error' that this is a candidate buffer and how
|
|
|
|
|
to navigate in it.")
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(make-variable-buffer-local 'next-error-function)
|
|
|
|
|
|
2009-08-13 00:57:17 +00:00
|
|
|
|
(defvar next-error-move-function nil
|
|
|
|
|
"Function to use to move to an error locus.
|
|
|
|
|
It takes two arguments, a buffer position in the error buffer
|
|
|
|
|
and a buffer position in the error locus buffer.
|
|
|
|
|
The buffer for the error locus should already be current.
|
|
|
|
|
nil means use goto-char using the second argument position.")
|
|
|
|
|
(make-variable-buffer-local 'next-error-move-function)
|
|
|
|
|
|
2004-12-14 00:51:02 +00:00
|
|
|
|
(defsubst next-error-buffer-p (buffer
|
2004-12-27 16:34:43 +00:00
|
|
|
|
&optional avoid-current
|
2004-12-14 00:51:02 +00:00
|
|
|
|
extra-test-inclusive
|
2004-11-29 18:44:29 +00:00
|
|
|
|
extra-test-exclusive)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Test if BUFFER is a `next-error' capable buffer.
|
2004-12-27 16:34:43 +00:00
|
|
|
|
|
|
|
|
|
If AVOID-CURRENT is non-nil, treat the current buffer
|
|
|
|
|
as an absolute last resort only.
|
|
|
|
|
|
|
|
|
|
The function EXTRA-TEST-INCLUSIVE, if non-nil, is called in each buffer
|
|
|
|
|
that normally would not qualify. If it returns t, the buffer
|
|
|
|
|
in question is treated as usable.
|
|
|
|
|
|
2005-12-23 21:50:38 +00:00
|
|
|
|
The function EXTRA-TEST-EXCLUSIVE, if non-nil, is called in each buffer
|
2005-06-20 10:29:02 +00:00
|
|
|
|
that would normally be considered usable. If it returns nil,
|
2004-12-27 16:34:43 +00:00
|
|
|
|
that buffer is rejected."
|
|
|
|
|
(and (buffer-name buffer) ;First make sure it's live.
|
|
|
|
|
(not (and avoid-current (eq buffer (current-buffer))))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(if next-error-function ; This is the normal test.
|
|
|
|
|
;; Optionally reject some buffers.
|
|
|
|
|
(if extra-test-exclusive
|
|
|
|
|
(funcall extra-test-exclusive)
|
|
|
|
|
t)
|
|
|
|
|
;; Optionally accept some other buffers.
|
|
|
|
|
(and extra-test-inclusive
|
|
|
|
|
(funcall extra-test-inclusive))))))
|
|
|
|
|
|
|
|
|
|
(defun next-error-find-buffer (&optional avoid-current
|
2004-12-14 00:51:02 +00:00
|
|
|
|
extra-test-inclusive
|
2004-11-29 18:44:29 +00:00
|
|
|
|
extra-test-exclusive)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Return a `next-error' capable buffer.
|
2005-12-23 21:50:38 +00:00
|
|
|
|
|
2004-12-27 16:34:43 +00:00
|
|
|
|
If AVOID-CURRENT is non-nil, treat the current buffer
|
|
|
|
|
as an absolute last resort only.
|
|
|
|
|
|
2005-06-20 10:29:02 +00:00
|
|
|
|
The function EXTRA-TEST-INCLUSIVE, if non-nil, is called in each buffer
|
2004-12-27 16:34:43 +00:00
|
|
|
|
that normally would not qualify. If it returns t, the buffer
|
|
|
|
|
in question is treated as usable.
|
|
|
|
|
|
2005-12-23 21:50:38 +00:00
|
|
|
|
The function EXTRA-TEST-EXCLUSIVE, if non-nil, is called in each buffer
|
2004-12-27 16:34:43 +00:00
|
|
|
|
that would normally be considered usable. If it returns nil,
|
|
|
|
|
that buffer is rejected."
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(or
|
|
|
|
|
;; 1. If one window on the selected frame displays such buffer, return it.
|
|
|
|
|
(let ((window-buffers
|
|
|
|
|
(delete-dups
|
|
|
|
|
(delq nil (mapcar (lambda (w)
|
|
|
|
|
(if (next-error-buffer-p
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(window-buffer w)
|
|
|
|
|
avoid-current
|
2004-12-14 00:51:02 +00:00
|
|
|
|
extra-test-inclusive extra-test-exclusive)
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(window-buffer w)))
|
|
|
|
|
(window-list))))))
|
|
|
|
|
(if (eq (length window-buffers) 1)
|
|
|
|
|
(car window-buffers)))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
;; 2. If next-error-last-buffer is an acceptable buffer, use that.
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(if (and next-error-last-buffer
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(next-error-buffer-p next-error-last-buffer avoid-current
|
2004-12-14 00:51:02 +00:00
|
|
|
|
extra-test-inclusive extra-test-exclusive))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
next-error-last-buffer)
|
|
|
|
|
;; 3. If the current buffer is acceptable, choose it.
|
|
|
|
|
(if (next-error-buffer-p (current-buffer) avoid-current
|
|
|
|
|
extra-test-inclusive extra-test-exclusive)
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(current-buffer))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
;; 4. Look for any acceptable buffer.
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(let ((buffers (buffer-list)))
|
|
|
|
|
(while (and buffers
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(not (next-error-buffer-p
|
|
|
|
|
(car buffers) avoid-current
|
|
|
|
|
extra-test-inclusive extra-test-exclusive)))
|
2004-09-01 17:05:59 +00:00
|
|
|
|
(setq buffers (cdr buffers)))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(car buffers))
|
|
|
|
|
;; 5. Use the current buffer as a last resort if it qualifies,
|
|
|
|
|
;; even despite AVOID-CURRENT.
|
|
|
|
|
(and avoid-current
|
|
|
|
|
(next-error-buffer-p (current-buffer) nil
|
|
|
|
|
extra-test-inclusive extra-test-exclusive)
|
|
|
|
|
(progn
|
2006-11-28 02:21:03 +00:00
|
|
|
|
(message "This is the only buffer with error message locations")
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(current-buffer)))
|
|
|
|
|
;; 6. Give up.
|
2006-11-28 02:21:03 +00:00
|
|
|
|
(error "No buffers contain error message locations")))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(defun next-error (&optional arg reset)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Visit next `next-error' message and corresponding source code.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
|
|
|
|
If all the error messages parsed so far have been processed already,
|
|
|
|
|
the message buffer is checked for new ones.
|
|
|
|
|
|
2004-04-22 22:56:08 +00:00
|
|
|
|
A prefix ARG specifies how many error messages to move;
|
2004-04-21 21:36:15 +00:00
|
|
|
|
negative means move back to previous error messages.
|
|
|
|
|
Just \\[universal-argument] as a prefix means reparse the error message buffer
|
|
|
|
|
and start at the first error.
|
|
|
|
|
|
2004-05-07 22:31:54 +00:00
|
|
|
|
The RESET argument specifies that we should restart from the beginning.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
|
|
|
|
\\[next-error] normally uses the most recently started
|
|
|
|
|
compilation, grep, or occur buffer. It can also operate on any
|
|
|
|
|
buffer with output from the \\[compile], \\[grep] commands, or,
|
|
|
|
|
more generally, on any buffer in Compilation mode or with
|
|
|
|
|
Compilation Minor mode enabled, or any buffer in which
|
2004-09-01 17:05:59 +00:00
|
|
|
|
`next-error-function' is bound to an appropriate function.
|
|
|
|
|
To specify use of a particular buffer for error messages, type
|
|
|
|
|
\\[next-error] in that buffer when it is the only one displayed
|
|
|
|
|
in the current frame.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2005-07-09 20:46:26 +00:00
|
|
|
|
Once \\[next-error] has chosen the buffer for error messages, it
|
|
|
|
|
runs `next-error-hook' with `run-hooks', and stays with that buffer
|
|
|
|
|
until you use it in some other buffer which uses Compilation mode
|
|
|
|
|
or Compilation Minor mode.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2011-02-07 09:41:11 -08:00
|
|
|
|
To control which errors are matched, customize the variable
|
|
|
|
|
`compilation-error-regexp-alist'."
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(interactive "P")
|
2004-04-22 22:56:08 +00:00
|
|
|
|
(if (consp arg) (setq reset t arg nil))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(when (setq next-error-last-buffer (next-error-find-buffer))
|
|
|
|
|
;; we know here that next-error-function is a valid symbol we can funcall
|
|
|
|
|
(with-current-buffer next-error-last-buffer
|
2005-07-09 20:46:26 +00:00
|
|
|
|
(funcall next-error-function (prefix-numeric-value arg) reset)
|
2007-06-22 07:56:01 +00:00
|
|
|
|
(when next-error-recenter
|
|
|
|
|
(recenter next-error-recenter))
|
2005-07-09 20:46:26 +00:00
|
|
|
|
(run-hooks 'next-error-hook))))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2005-10-02 03:33:02 +00:00
|
|
|
|
(defun next-error-internal ()
|
|
|
|
|
"Visit the source code corresponding to the `next-error' message at point."
|
|
|
|
|
(setq next-error-last-buffer (current-buffer))
|
|
|
|
|
;; we know here that next-error-function is a valid symbol we can funcall
|
|
|
|
|
(with-current-buffer next-error-last-buffer
|
|
|
|
|
(funcall next-error-function 0 nil)
|
2007-06-22 07:56:01 +00:00
|
|
|
|
(when next-error-recenter
|
|
|
|
|
(recenter next-error-recenter))
|
2005-10-02 03:33:02 +00:00
|
|
|
|
(run-hooks 'next-error-hook)))
|
|
|
|
|
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(defalias 'goto-next-locus 'next-error)
|
|
|
|
|
(defalias 'next-match 'next-error)
|
|
|
|
|
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(defun previous-error (&optional n)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Visit previous `next-error' message and corresponding source code.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
|
|
|
|
Prefix arg N says how many error messages to move backwards (or
|
|
|
|
|
forwards, if negative).
|
|
|
|
|
|
|
|
|
|
This operates on the output from the \\[compile] and \\[grep] commands."
|
|
|
|
|
(interactive "p")
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(next-error (- (or n 1))))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(defun first-error (&optional n)
|
2004-04-21 21:36:15 +00:00
|
|
|
|
"Restart at the first error.
|
|
|
|
|
Visit corresponding source code.
|
|
|
|
|
With prefix arg N, visit the source code of the Nth error.
|
|
|
|
|
This operates on the output from the \\[compile] command, for instance."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(next-error n t))
|
|
|
|
|
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(defun next-error-no-select (&optional n)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Move point to the next error in the `next-error' buffer and highlight match.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
Prefix arg N says how many error messages to move forwards (or
|
|
|
|
|
backwards, if negative).
|
|
|
|
|
Finds and highlights the source line like \\[next-error], but does not
|
|
|
|
|
select the source buffer."
|
|
|
|
|
(interactive "p")
|
2004-09-01 18:41:06 +00:00
|
|
|
|
(let ((next-error-highlight next-error-highlight-no-select))
|
|
|
|
|
(next-error n))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
(pop-to-buffer next-error-last-buffer))
|
|
|
|
|
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(defun previous-error-no-select (&optional n)
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
"Move point to the previous error in the `next-error' buffer and highlight match.
|
2004-04-21 21:36:15 +00:00
|
|
|
|
Prefix arg N says how many error messages to move backwards (or
|
|
|
|
|
forwards, if negative).
|
|
|
|
|
Finds and highlights the source line like \\[previous-error], but does not
|
|
|
|
|
select the source buffer."
|
|
|
|
|
(interactive "p")
|
2004-09-01 16:19:04 +00:00
|
|
|
|
(next-error-no-select (- (or n 1))))
|
2004-04-21 21:36:15 +00:00
|
|
|
|
|
2009-08-19 02:31:59 +00:00
|
|
|
|
;; Internal variable for `next-error-follow-mode-post-command-hook'.
|
2004-09-04 12:45:26 +00:00
|
|
|
|
(defvar next-error-follow-last-line nil)
|
|
|
|
|
|
2004-09-04 13:06:38 +00:00
|
|
|
|
(define-minor-mode next-error-follow-minor-mode
|
2004-09-04 12:45:26 +00:00
|
|
|
|
"Minor mode for compilation, occur and diff modes.
|
2012-02-07 21:12:24 -05:00
|
|
|
|
With a prefix argument ARG, enable mode if ARG is positive, and
|
|
|
|
|
disable it otherwise. If called from Lisp, enable mode if ARG is
|
|
|
|
|
omitted or nil.
|
2004-09-04 13:06:38 +00:00
|
|
|
|
When turned on, cursor motion in the compilation, grep, occur or diff
|
2012-02-07 21:12:24 -05:00
|
|
|
|
buffer causes automatic display of the corresponding source code location."
|
2005-08-15 17:23:50 +00:00
|
|
|
|
:group 'next-error :init-value nil :lighter " Fol"
|
2004-09-06 18:51:57 +00:00
|
|
|
|
(if (not next-error-follow-minor-mode)
|
2004-09-04 12:45:26 +00:00
|
|
|
|
(remove-hook 'post-command-hook 'next-error-follow-mode-post-command-hook t)
|
|
|
|
|
(add-hook 'post-command-hook 'next-error-follow-mode-post-command-hook nil t)
|
2005-07-29 20:55:36 +00:00
|
|
|
|
(make-local-variable 'next-error-follow-last-line)))
|
2004-09-04 12:45:26 +00:00
|
|
|
|
|
2009-08-19 02:31:59 +00:00
|
|
|
|
;; Used as a `post-command-hook' by `next-error-follow-mode'
|
|
|
|
|
;; for the *Compilation* *grep* and *Occur* buffers.
|
2004-09-04 12:45:26 +00:00
|
|
|
|
(defun next-error-follow-mode-post-command-hook ()
|
|
|
|
|
(unless (equal next-error-follow-last-line (line-number-at-pos))
|
|
|
|
|
(setq next-error-follow-last-line (line-number-at-pos))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(let ((compilation-context-lines nil))
|
|
|
|
|
(setq compilation-current-error (point))
|
|
|
|
|
(next-error-no-select 0))
|
|
|
|
|
(error t))))
|
|
|
|
|
|
2004-09-01 18:41:06 +00:00
|
|
|
|
|
2004-04-21 21:36:15 +00:00
|
|
|
|
;;;
|
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(defun fundamental-mode ()
|
|
|
|
|
"Major mode not specialized for anything in particular.
|
|
|
|
|
Other major modes are defined by comparison with this one."
|
|
|
|
|
(interactive)
|
2004-09-19 00:02:44 +00:00
|
|
|
|
(kill-all-local-variables)
|
2013-02-08 10:53:49 -05:00
|
|
|
|
(run-mode-hooks))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2008-06-20 17:10:33 +00:00
|
|
|
|
;; Special major modes to view specially formatted data rather than files.
|
|
|
|
|
|
|
|
|
|
(defvar special-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(suppress-keymap map)
|
|
|
|
|
(define-key map "q" 'quit-window)
|
2011-10-01 16:32:01 -04:00
|
|
|
|
(define-key map " " 'scroll-up-command)
|
2013-02-11 20:46:18 -08:00
|
|
|
|
(define-key map [?\S-\ ] 'scroll-down-command)
|
2011-10-01 16:32:01 -04:00
|
|
|
|
(define-key map "\C-?" 'scroll-down-command)
|
2008-06-20 17:10:33 +00:00
|
|
|
|
(define-key map "?" 'describe-mode)
|
2011-02-01 16:22:21 -05:00
|
|
|
|
(define-key map "h" 'describe-mode)
|
2008-06-20 17:10:33 +00:00
|
|
|
|
(define-key map ">" 'end-of-buffer)
|
|
|
|
|
(define-key map "<" 'beginning-of-buffer)
|
|
|
|
|
(define-key map "g" 'revert-buffer)
|
|
|
|
|
map))
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
|
2008-06-20 17:10:33 +00:00
|
|
|
|
(put 'special-mode 'mode-class 'special)
|
|
|
|
|
(define-derived-mode special-mode nil "Special"
|
|
|
|
|
"Parent major mode from which special major modes should inherit."
|
|
|
|
|
(setq buffer-read-only t))
|
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;; Making and deleting lines.
|
|
|
|
|
|
2014-08-18 11:20:27 -04:00
|
|
|
|
(defvar self-insert-uses-region-functions nil
|
|
|
|
|
"Special hook to tell if `self-insert-command' will use the region.
|
|
|
|
|
It must be called via `run-hook-with-args-until-success' with no arguments.
|
|
|
|
|
Any `post-self-insert-command' which consumes the region should
|
|
|
|
|
register a function on this hook so that things like `delete-selection-mode'
|
|
|
|
|
can refrain from consuming the region.")
|
|
|
|
|
|
2009-09-17 06:02:20 +00:00
|
|
|
|
(defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard))
|
|
|
|
|
"Propertized string representing a hard newline character.")
|
* simple.el (hard-newline): New variable.
* mail/sendmail.el (mail-setup, mail-send, mail-insert-from-field)
(sendmail-send-it, mail-do-fcc, mail-cc, mail-bcc, mail-fcc)
(mail-mail-reply-to, mail-mail-followup-to)
(mail-position-on-field, mail-signature, mail-yank-original)
(mail-attach-file): Use it.
* mail/mailheader.el (mail-header-format)
(mail-header-format-function): Likewise.
* add-log.el (add-change-log-entry, change-log-merge): Likewise.
2005-11-17 16:30:52 +00:00
|
|
|
|
|
2013-10-19 18:17:56 -04:00
|
|
|
|
(defun newline (&optional arg interactive)
|
1995-04-09 06:47:22 +00:00
|
|
|
|
"Insert a newline, and move to left margin of the new line if it's blank.
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
If option `use-hard-newlines' is non-nil, the newline is marked with the
|
2001-12-18 15:53:57 +00:00
|
|
|
|
text-property `hard'.
|
2000-09-29 03:18:24 +00:00
|
|
|
|
With ARG, insert that many newlines.
|
2013-12-21 17:55:59 -05:00
|
|
|
|
|
2014-03-05 20:11:08 -08:00
|
|
|
|
If `electric-indent-mode' is enabled, this indents the final new line
|
|
|
|
|
that it adds, and reindents the preceding line. To just insert
|
|
|
|
|
a newline, use \\[electric-indent-just-newline].
|
2013-12-21 17:55:59 -05:00
|
|
|
|
|
|
|
|
|
Calls `auto-fill-function' if the current column number is greater
|
2013-10-19 18:17:56 -04:00
|
|
|
|
than the value of `fill-column' and ARG is nil.
|
2013-12-21 17:55:59 -05:00
|
|
|
|
A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
|
2013-10-19 18:17:56 -04:00
|
|
|
|
(interactive "*P\np")
|
1995-10-06 22:40:25 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
2010-09-03 13:12:46 +02:00
|
|
|
|
;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
|
|
|
|
|
;; Set last-command-event to tell self-insert what to insert.
|
|
|
|
|
(let* ((was-page-start (and (bolp) (looking-at page-delimiter)))
|
|
|
|
|
(beforepos (point))
|
|
|
|
|
(last-command-event ?\n)
|
|
|
|
|
;; Don't auto-fill if we have a numeric argument.
|
|
|
|
|
(auto-fill-function (if arg nil auto-fill-function))
|
|
|
|
|
(postproc
|
|
|
|
|
;; Do the rest in post-self-insert-hook, because we want to do it
|
|
|
|
|
;; *before* other functions on that hook.
|
|
|
|
|
(lambda ()
|
|
|
|
|
;; Mark the newline(s) `hard'.
|
|
|
|
|
(if use-hard-newlines
|
|
|
|
|
(set-hard-newline-properties
|
|
|
|
|
(- (point) (prefix-numeric-value arg)) (point)))
|
|
|
|
|
;; If the newline leaves the previous line blank, and we
|
|
|
|
|
;; have a left margin, delete that from the blank line.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beforepos)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(and (looking-at "[ \t]$")
|
|
|
|
|
(> (current-left-margin) 0)
|
|
|
|
|
(delete-region (point)
|
|
|
|
|
(line-end-position))))
|
|
|
|
|
;; Indent the line after the newline, except in one case:
|
|
|
|
|
;; when we added the newline at the beginning of a line which
|
|
|
|
|
;; starts a page.
|
|
|
|
|
(or was-page-start
|
|
|
|
|
(move-to-left-margin nil t)))))
|
2013-10-19 18:17:56 -04:00
|
|
|
|
(if (not interactive)
|
|
|
|
|
;; FIXME: For non-interactive uses, many calls actually just want
|
|
|
|
|
;; (insert "\n"), so maybe we should do just that, so as to avoid
|
|
|
|
|
;; the risk of filling or running abbrevs unexpectedly.
|
|
|
|
|
(let ((post-self-insert-hook (list postproc)))
|
2010-09-03 13:12:46 +02:00
|
|
|
|
(self-insert-command (prefix-numeric-value arg)))
|
2013-10-19 18:17:56 -04:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(add-hook 'post-self-insert-hook postproc)
|
|
|
|
|
(self-insert-command (prefix-numeric-value arg)))
|
|
|
|
|
;; We first used let-binding to protect the hook, but that was naive
|
|
|
|
|
;; since add-hook affects the symbol-default value of the variable,
|
|
|
|
|
;; whereas the let-binding might only protect the buffer-local value.
|
|
|
|
|
(remove-hook 'post-self-insert-hook postproc))))
|
1995-03-01 15:09:58 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
1996-09-01 03:24:22 +00:00
|
|
|
|
(defun set-hard-newline-properties (from to)
|
|
|
|
|
(let ((sticky (get-text-property from 'rear-nonsticky)))
|
|
|
|
|
(put-text-property from to 'hard 't)
|
|
|
|
|
;; If rear-nonsticky is not "t", add 'hard to rear-nonsticky list
|
|
|
|
|
(if (and (listp sticky) (not (memq 'hard sticky)))
|
|
|
|
|
(put-text-property from (point) 'rear-nonsticky
|
|
|
|
|
(cons 'hard sticky)))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2004-05-07 22:31:54 +00:00
|
|
|
|
(defun open-line (n)
|
1992-08-21 07:18:16 +00:00
|
|
|
|
"Insert a newline and leave point before it.
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
If there is a fill prefix and/or a `left-margin', insert them
|
|
|
|
|
on the new line if the line would have been blank.
|
1992-08-31 20:22:03 +00:00
|
|
|
|
With arg N, insert N newlines."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*p")
|
1992-08-31 20:22:03 +00:00
|
|
|
|
(let* ((do-fill-prefix (and fill-prefix (bolp)))
|
1995-02-23 18:38:42 +00:00
|
|
|
|
(do-left-margin (and (bolp) (> (current-left-margin) 0)))
|
2010-11-12 08:32:02 -05:00
|
|
|
|
(loc (point-marker))
|
2001-01-26 09:23:17 +00:00
|
|
|
|
;; Don't expand an abbrev before point.
|
|
|
|
|
(abbrev-mode nil))
|
2004-05-07 22:31:54 +00:00
|
|
|
|
(newline n)
|
1995-04-09 06:47:22 +00:00
|
|
|
|
(goto-char loc)
|
2004-05-07 22:31:54 +00:00
|
|
|
|
(while (> n 0)
|
1995-04-09 06:47:22 +00:00
|
|
|
|
(cond ((bolp)
|
|
|
|
|
(if do-left-margin (indent-to (current-left-margin)))
|
|
|
|
|
(if do-fill-prefix (insert-and-inherit fill-prefix))))
|
|
|
|
|
(forward-line 1)
|
2004-05-07 22:31:54 +00:00
|
|
|
|
(setq n (1- n)))
|
1995-04-09 06:47:22 +00:00
|
|
|
|
(goto-char loc)
|
|
|
|
|
(end-of-line)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2003-01-03 22:46:06 +00:00
|
|
|
|
(defun split-line (&optional arg)
|
|
|
|
|
"Split current line, moving portion beyond point vertically down.
|
|
|
|
|
If the current line starts with `fill-prefix', insert it on the new
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
line as well. With prefix ARG, don't insert `fill-prefix' on new line.
|
2003-01-03 22:46:06 +00:00
|
|
|
|
|
2004-05-07 22:31:54 +00:00
|
|
|
|
When called from Lisp code, ARG may be a prefix string to copy."
|
2003-01-03 22:46:06 +00:00
|
|
|
|
(interactive "*P")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(skip-chars-forward " \t")
|
2003-01-06 01:17:19 +00:00
|
|
|
|
(let* ((col (current-column))
|
|
|
|
|
(pos (point))
|
|
|
|
|
;; What prefix should we check for (nil means don't).
|
|
|
|
|
(prefix (cond ((stringp arg) arg)
|
|
|
|
|
(arg nil)
|
|
|
|
|
(t fill-prefix)))
|
|
|
|
|
;; Does this line start with it?
|
|
|
|
|
(have-prfx (and prefix
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(looking-at (regexp-quote prefix))))))
|
1995-01-13 08:43:40 +00:00
|
|
|
|
(newline 1)
|
2003-01-06 01:17:19 +00:00
|
|
|
|
(if have-prfx (insert-and-inherit prefix))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(indent-to col 0)
|
|
|
|
|
(goto-char pos)))
|
|
|
|
|
|
|
|
|
|
(defun delete-indentation (&optional arg)
|
|
|
|
|
"Join this line to previous and fix up whitespace at join.
|
1992-07-29 02:15:26 +00:00
|
|
|
|
If there is a fill prefix, delete it from the beginning of this line.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
With argument, join this line to following line."
|
|
|
|
|
(interactive "*P")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if arg (forward-line 1))
|
|
|
|
|
(if (eq (preceding-char) ?\n)
|
|
|
|
|
(progn
|
|
|
|
|
(delete-region (point) (1- (point)))
|
1992-07-29 02:15:26 +00:00
|
|
|
|
;; If the second line started with the fill prefix,
|
|
|
|
|
;; delete the prefix.
|
|
|
|
|
(if (and fill-prefix
|
1992-09-30 10:31:31 +00:00
|
|
|
|
(<= (+ (point) (length fill-prefix)) (point-max))
|
1992-07-29 02:15:26 +00:00
|
|
|
|
(string= fill-prefix
|
|
|
|
|
(buffer-substring (point)
|
|
|
|
|
(+ (point) (length fill-prefix)))))
|
|
|
|
|
(delete-region (point) (+ (point) (length fill-prefix))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(fixup-whitespace))))
|
|
|
|
|
|
1999-01-15 16:57:27 +00:00
|
|
|
|
(defalias 'join-line #'delete-indentation) ; easier to find
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun delete-blank-lines ()
|
|
|
|
|
"On blank line, delete all surrounding blank lines, leaving just one.
|
|
|
|
|
On isolated blank line, delete that one.
|
1994-06-07 07:47:24 +00:00
|
|
|
|
On nonblank line, delete any immediately following blank lines."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*")
|
|
|
|
|
(let (thisblank singleblank)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq thisblank (looking-at "[ \t]*$"))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
;; Set singleblank if there is just one blank line here.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(setq singleblank
|
|
|
|
|
(and thisblank
|
|
|
|
|
(not (looking-at "[ \t]*\n[ \t]*$"))
|
|
|
|
|
(or (bobp)
|
|
|
|
|
(progn (forward-line -1)
|
|
|
|
|
(not (looking-at "[ \t]*$")))))))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
;; Delete preceding blank lines, and this one too if it's the only one.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(if thisblank
|
|
|
|
|
(progn
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if singleblank (forward-line 1))
|
|
|
|
|
(delete-region (point)
|
|
|
|
|
(if (re-search-backward "[^ \t\n]" nil t)
|
|
|
|
|
(progn (forward-line 1) (point))
|
|
|
|
|
(point-min)))))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
;; Delete following blank lines, unless the current line is blank
|
|
|
|
|
;; and there are no following blank lines.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(if (not (and thisblank singleblank))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(delete-region (point)
|
|
|
|
|
(if (re-search-forward "[^ \t\n]" nil t)
|
|
|
|
|
(progn (beginning-of-line) (point))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(point-max)))))
|
|
|
|
|
;; Handle the special case where point is followed by newline and eob.
|
|
|
|
|
;; Delete the line, leaving point at eob.
|
|
|
|
|
(if (looking-at "^[ \t]*\n\\'")
|
|
|
|
|
(delete-region (point) (point-max)))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2012-07-28 18:38:55 +08:00
|
|
|
|
(defcustom delete-trailing-lines t
|
|
|
|
|
"If non-nil, \\[delete-trailing-whitespace] deletes trailing lines.
|
|
|
|
|
Trailing lines are deleted only if `delete-trailing-whitespace'
|
|
|
|
|
is called on the entire buffer (rather than an active region)."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'editing
|
2012-08-15 09:29:11 -07:00
|
|
|
|
:version "24.3")
|
2012-07-28 18:38:55 +08:00
|
|
|
|
|
2011-02-11 19:25:06 +01:00
|
|
|
|
(defun delete-trailing-whitespace (&optional start end)
|
2012-07-28 18:38:55 +08:00
|
|
|
|
"Delete trailing whitespace between START and END.
|
|
|
|
|
If called interactively, START and END are the start/end of the
|
|
|
|
|
region if the mark is active, or of the buffer's accessible
|
|
|
|
|
portion if the mark is inactive.
|
|
|
|
|
|
|
|
|
|
This command deletes whitespace characters after the last
|
|
|
|
|
non-whitespace character in each line between START and END. It
|
|
|
|
|
does not consider formfeed characters to be whitespace.
|
|
|
|
|
|
|
|
|
|
If this command acts on the entire buffer (i.e. if called
|
|
|
|
|
interactively with the mark inactive, or called from Lisp with
|
|
|
|
|
END nil), it also deletes all trailing lines at the end of the
|
|
|
|
|
buffer if the variable `delete-trailing-lines' is non-nil."
|
2011-02-11 19:25:06 +01:00
|
|
|
|
(interactive (progn
|
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(if (use-region-p)
|
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
|
(list nil nil))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
(save-match-data
|
|
|
|
|
(save-excursion
|
2011-02-11 19:25:06 +01:00
|
|
|
|
(let ((end-marker (copy-marker (or end (point-max))))
|
|
|
|
|
(start (or start (point-min))))
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(while (re-search-forward "\\s-$" end-marker t)
|
2011-09-23 11:06:14 -04:00
|
|
|
|
(skip-syntax-backward "-" (line-beginning-position))
|
2011-02-11 19:25:06 +01:00
|
|
|
|
;; Don't delete formfeeds, even if they are considered whitespace.
|
2011-09-23 11:06:14 -04:00
|
|
|
|
(if (looking-at-p ".*\f")
|
|
|
|
|
(goto-char (match-end 0)))
|
2011-02-11 19:25:06 +01:00
|
|
|
|
(delete-region (point) (match-end 0)))
|
2011-09-23 11:06:14 -04:00
|
|
|
|
;; Delete trailing empty lines.
|
|
|
|
|
(goto-char end-marker)
|
|
|
|
|
(when (and (not end)
|
2012-07-28 18:38:55 +08:00
|
|
|
|
delete-trailing-lines
|
2011-09-23 11:06:14 -04:00
|
|
|
|
;; Really the end of buffer.
|
2012-09-30 16:41:37 +08:00
|
|
|
|
(= (point-max) (1+ (buffer-size)))
|
2011-09-28 16:50:16 -04:00
|
|
|
|
(<= (skip-chars-backward "\n") -2))
|
2011-09-23 11:06:14 -04:00
|
|
|
|
(delete-region (1+ (point)) end-marker))
|
2011-03-10 12:28:33 +01:00
|
|
|
|
(set-marker end-marker nil))))
|
|
|
|
|
;; Return nil for the benefit of `write-file-functions'.
|
|
|
|
|
nil)
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun newline-and-indent ()
|
|
|
|
|
"Insert a newline, then indent according to major mode.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
Indentation is done using the value of `indent-line-function'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
In programming language modes, this is the same as TAB.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
In some text modes, where TAB inserts a tab, this command indents to the
|
1995-01-19 04:21:56 +00:00
|
|
|
|
column specified by the function `current-left-margin'."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*")
|
2000-12-12 01:20:55 +00:00
|
|
|
|
(delete-horizontal-space t)
|
2014-03-18 16:49:24 -04:00
|
|
|
|
(newline nil t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(indent-according-to-mode))
|
|
|
|
|
|
|
|
|
|
(defun reindent-then-newline-and-indent ()
|
|
|
|
|
"Reindent current line, insert newline, then indent the new line.
|
|
|
|
|
Indentation of both lines is done according to the current major mode,
|
1992-08-21 07:18:16 +00:00
|
|
|
|
which means calling the current value of `indent-line-function'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
In programming language modes, this is the same as TAB.
|
|
|
|
|
In some text modes, where TAB inserts a tab, this indents to the
|
1995-01-19 04:21:56 +00:00
|
|
|
|
column specified by the function `current-left-margin'."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*")
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
;; Be careful to insert the newline before indenting the line.
|
|
|
|
|
;; Otherwise, the indentation might be wrong.
|
|
|
|
|
(newline)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char pos)
|
2007-10-24 01:51:03 +00:00
|
|
|
|
;; We are at EOL before the call to indent-according-to-mode, and
|
|
|
|
|
;; after it we usually are as well, but not always. We tried to
|
|
|
|
|
;; address it with `save-excursion' but that uses a normal marker
|
|
|
|
|
;; whereas we need `move after insertion', so we do the save/restore
|
|
|
|
|
;; by hand.
|
|
|
|
|
(setq pos (copy-marker pos t))
|
|
|
|
|
(indent-according-to-mode)
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
;; Remove the trailing white-space after indentation because
|
|
|
|
|
;; indentation may introduce the whitespace.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(delete-horizontal-space t))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(indent-according-to-mode)))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2013-10-29 22:14:16 -04:00
|
|
|
|
(defcustom read-quoted-char-radix 8
|
2014-02-21 14:22:14 +01:00
|
|
|
|
"Radix for \\[quoted-insert] and other uses of `read-quoted-char'.
|
2013-10-29 22:14:16 -04:00
|
|
|
|
Legitimate radix values are 8, 10 and 16."
|
|
|
|
|
:type '(choice (const 8) (const 10) (const 16))
|
|
|
|
|
:group 'editing-basics)
|
|
|
|
|
|
|
|
|
|
(defun read-quoted-char (&optional prompt)
|
|
|
|
|
"Like `read-char', but do not allow quitting.
|
|
|
|
|
Also, if the first character read is an octal digit,
|
|
|
|
|
we read any number of octal digits and return the
|
|
|
|
|
specified character code. Any nondigit terminates the sequence.
|
|
|
|
|
If the terminator is RET, it is discarded;
|
|
|
|
|
any other terminator is used itself as input.
|
|
|
|
|
|
|
|
|
|
The optional argument PROMPT specifies a string to use to prompt the user.
|
|
|
|
|
The variable `read-quoted-char-radix' controls which radix to use
|
|
|
|
|
for numeric input."
|
2014-06-20 08:14:43 +08:00
|
|
|
|
(let ((message-log-max nil)
|
|
|
|
|
(help-events (delq nil (mapcar (lambda (c) (unless (characterp c) c))
|
|
|
|
|
help-event-list)))
|
|
|
|
|
done (first t) (code 0) translated)
|
2013-10-29 22:14:16 -04:00
|
|
|
|
(while (not done)
|
|
|
|
|
(let ((inhibit-quit first)
|
2014-06-20 08:14:43 +08:00
|
|
|
|
;; Don't let C-h or other help chars get the help
|
|
|
|
|
;; message--only help function keys. See bug#16617.
|
2013-10-29 22:14:16 -04:00
|
|
|
|
(help-char nil)
|
2014-06-20 08:14:43 +08:00
|
|
|
|
(help-event-list help-events)
|
2013-10-29 22:14:16 -04:00
|
|
|
|
(help-form
|
|
|
|
|
"Type the special character you want to use,
|
|
|
|
|
or the octal character code.
|
|
|
|
|
RET terminates the character code and is discarded;
|
|
|
|
|
any other non-digit terminates the character code and is then used as input."))
|
|
|
|
|
(setq translated (read-key (and prompt (format "%s-" prompt))))
|
|
|
|
|
(if inhibit-quit (setq quit-flag nil)))
|
|
|
|
|
(if (integerp translated)
|
|
|
|
|
(setq translated (char-resolve-modifiers translated)))
|
|
|
|
|
(cond ((null translated))
|
|
|
|
|
((not (integerp translated))
|
|
|
|
|
(setq unread-command-events
|
|
|
|
|
(listify-key-sequence (this-single-command-raw-keys))
|
|
|
|
|
done t))
|
|
|
|
|
((/= (logand translated ?\M-\^@) 0)
|
|
|
|
|
;; Turn a meta-character into a character with the 0200 bit set.
|
|
|
|
|
(setq code (logior (logand translated (lognot ?\M-\^@)) 128)
|
|
|
|
|
done t))
|
|
|
|
|
((and (<= ?0 translated)
|
|
|
|
|
(< translated (+ ?0 (min 10 read-quoted-char-radix))))
|
|
|
|
|
(setq code (+ (* code read-quoted-char-radix) (- translated ?0)))
|
|
|
|
|
(and prompt (setq prompt (message "%s %c" prompt translated))))
|
|
|
|
|
((and (<= ?a (downcase translated))
|
|
|
|
|
(< (downcase translated)
|
|
|
|
|
(+ ?a -10 (min 36 read-quoted-char-radix))))
|
|
|
|
|
(setq code (+ (* code read-quoted-char-radix)
|
|
|
|
|
(+ 10 (- (downcase translated) ?a))))
|
|
|
|
|
(and prompt (setq prompt (message "%s %c" prompt translated))))
|
|
|
|
|
((and (not first) (eq translated ?\C-m))
|
|
|
|
|
(setq done t))
|
|
|
|
|
((not first)
|
|
|
|
|
(setq unread-command-events
|
|
|
|
|
(listify-key-sequence (this-single-command-raw-keys))
|
|
|
|
|
done t))
|
|
|
|
|
(t (setq code translated
|
|
|
|
|
done t)))
|
|
|
|
|
(setq first nil))
|
|
|
|
|
code))
|
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(defun quoted-insert (arg)
|
|
|
|
|
"Read next input character and insert it.
|
|
|
|
|
This is useful for inserting control characters.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With argument, insert ARG copies of the character.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
If the first character you type after this command is an octal digit,
|
|
|
|
|
you should type a sequence of octal digits which specify a character code.
|
|
|
|
|
Any nondigit terminates the sequence. If the terminator is a RET,
|
|
|
|
|
it is discarded; any other terminator is used itself as input.
|
|
|
|
|
The variable `read-quoted-char-radix' specifies the radix for this feature;
|
|
|
|
|
set it to 10 or 16 to use decimal or hex instead of octal.
|
1993-04-29 13:57:52 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
In overwrite mode, this function inserts the character anyway, and
|
|
|
|
|
does not handle octal digits specially. This means that if you use
|
|
|
|
|
overwrite as your normal editing mode, you can use this function to
|
|
|
|
|
insert characters when necessary.
|
1993-04-29 13:57:52 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
In binary overwrite mode, this function does overwrite, and octal
|
|
|
|
|
digits are interpreted as a character code. This is intended to be
|
|
|
|
|
useful for editing binary files."
|
|
|
|
|
(interactive "*p")
|
2009-02-14 09:06:30 +00:00
|
|
|
|
(let* ((char
|
|
|
|
|
;; Avoid "obsolete" warnings for translation-table-for-input.
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(let (translation-table-for-input input-method-function)
|
|
|
|
|
(if (or (not overwrite-mode)
|
|
|
|
|
(eq overwrite-mode 'overwrite-mode-binary))
|
|
|
|
|
(read-quoted-char)
|
|
|
|
|
(read-char))))))
|
2008-07-30 16:38:29 +00:00
|
|
|
|
;; This used to assume character codes 0240 - 0377 stand for
|
|
|
|
|
;; characters in some single-byte character set, and converted them
|
|
|
|
|
;; to Emacs characters. But in 23.1 this feature is deprecated
|
|
|
|
|
;; in favor of inserting the corresponding Unicode characters.
|
|
|
|
|
;; (if (and enable-multibyte-characters
|
|
|
|
|
;; (>= char ?\240)
|
|
|
|
|
;; (<= char ?\377))
|
|
|
|
|
;; (setq char (unibyte-char-to-multibyte char)))
|
2014-02-07 12:13:31 +01:00
|
|
|
|
(unless (characterp char)
|
|
|
|
|
(user-error "%s is not a valid character"
|
|
|
|
|
(key-description (vector char))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(if (> arg 0)
|
|
|
|
|
(if (eq overwrite-mode 'overwrite-mode-binary)
|
|
|
|
|
(delete-char arg)))
|
|
|
|
|
(while (> arg 0)
|
|
|
|
|
(insert-and-inherit char)
|
|
|
|
|
(setq arg (1- arg)))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun forward-to-indentation (&optional arg)
|
1999-08-16 20:42:38 +00:00
|
|
|
|
"Move forward ARG lines and position at first nonblank character."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(forward-line (or arg 1))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(skip-chars-forward " \t"))
|
1998-03-06 05:51:51 +00:00
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun backward-to-indentation (&optional arg)
|
1999-08-16 20:42:38 +00:00
|
|
|
|
"Move backward ARG lines and position at first nonblank character."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(forward-line (- (or arg 1)))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(skip-chars-forward " \t"))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(defun back-to-indentation ()
|
|
|
|
|
"Move point to the first non-whitespace character on this line."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^")
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(beginning-of-line 1)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(skip-syntax-forward " " (line-end-position))
|
2003-04-24 01:57:46 +00:00
|
|
|
|
;; Move back over chars that have whitespace syntax but have the p flag.
|
|
|
|
|
(backward-prefix-chars))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
|
|
|
|
(defun fixup-whitespace ()
|
|
|
|
|
"Fixup white space between objects around point.
|
|
|
|
|
Leave one space or none, according to the context."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(if (or (looking-at "^\\|\\s)")
|
|
|
|
|
(save-excursion (forward-char -1)
|
|
|
|
|
(looking-at "$\\|\\s(\\|\\s'")))
|
|
|
|
|
nil
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
(insert ?\s))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
2000-12-12 01:20:55 +00:00
|
|
|
|
(defun delete-horizontal-space (&optional backward-only)
|
|
|
|
|
"Delete all spaces and tabs around point.
|
2006-12-23 18:08:24 +00:00
|
|
|
|
If BACKWARD-ONLY is non-nil, only delete them before point."
|
2006-12-17 22:14:48 +00:00
|
|
|
|
(interactive "*P")
|
2001-05-18 07:13:47 +00:00
|
|
|
|
(let ((orig-pos (point)))
|
|
|
|
|
(delete-region
|
|
|
|
|
(if backward-only
|
|
|
|
|
orig-pos
|
|
|
|
|
(progn
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(constrain-to-field nil orig-pos t)))
|
2000-12-12 01:20:55 +00:00
|
|
|
|
(progn
|
2001-05-18 07:13:47 +00:00
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(constrain-to-field nil orig-pos)))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
2005-01-17 10:56:07 +00:00
|
|
|
|
(defun just-one-space (&optional n)
|
2010-12-06 13:21:42 -05:00
|
|
|
|
"Delete all spaces and tabs around point, leaving one space (or N spaces).
|
2014-01-29 00:27:55 -08:00
|
|
|
|
If N is negative, delete newlines as well, leaving -N spaces.
|
|
|
|
|
See also `cycle-spacing'."
|
2005-01-15 18:08:46 +00:00
|
|
|
|
(interactive "*p")
|
2013-01-30 21:57:35 -05:00
|
|
|
|
(cycle-spacing n nil t))
|
|
|
|
|
|
|
|
|
|
(defvar cycle-spacing--context nil
|
|
|
|
|
"Store context used in consecutive calls to `cycle-spacing' command.
|
|
|
|
|
The first time this function is run, it saves the original point
|
|
|
|
|
position and original spacing around the point in this
|
|
|
|
|
variable.")
|
|
|
|
|
|
|
|
|
|
(defun cycle-spacing (&optional n preserve-nl-back single-shot)
|
2014-01-29 00:27:55 -08:00
|
|
|
|
"Manipulate whitespace around point in a smart way.
|
|
|
|
|
In interactive use, this function behaves differently in successive
|
|
|
|
|
consecutive calls.
|
2013-01-30 21:57:35 -05:00
|
|
|
|
|
2014-01-29 00:27:55 -08:00
|
|
|
|
The first call in a sequence acts like `just-one-space'.
|
|
|
|
|
It deletes all spaces and tabs around point, leaving one space
|
|
|
|
|
\(or N spaces). N is the prefix argument. If N is negative,
|
|
|
|
|
it deletes newlines as well, leaving -N spaces.
|
|
|
|
|
\(If PRESERVE-NL-BACK is non-nil, it does not delete newlines before point.)
|
2013-01-30 21:57:35 -05:00
|
|
|
|
|
2014-01-29 00:27:55 -08:00
|
|
|
|
The second call in a sequence (or the first call if the above does
|
|
|
|
|
not result in any changes) deletes all spaces.
|
2013-01-30 21:57:35 -05:00
|
|
|
|
|
2014-01-29 00:27:55 -08:00
|
|
|
|
The third call in a sequence restores the original whitespace (and point).
|
2013-01-30 21:57:35 -05:00
|
|
|
|
|
2014-01-29 00:27:55 -08:00
|
|
|
|
If SINGLE-SHOT is non-nil, it only performs the first step in the sequence."
|
2013-01-30 21:57:35 -05:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(let ((orig-pos (point))
|
|
|
|
|
(skip-characters (if (and n (< n 0)) " \t\n\r" " \t"))
|
|
|
|
|
(n (abs (or n 1))))
|
|
|
|
|
(skip-chars-backward (if preserve-nl-back " \t" skip-characters))
|
2001-05-18 07:13:47 +00:00
|
|
|
|
(constrain-to-field nil orig-pos)
|
2013-01-30 21:57:35 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; Command run for the first time or single-shot is non-nil.
|
|
|
|
|
((or single-shot
|
|
|
|
|
(not (equal last-command this-command))
|
|
|
|
|
(not cycle-spacing--context))
|
|
|
|
|
(let* ((start (point))
|
|
|
|
|
(n (- n (skip-chars-forward " " (+ n (point)))))
|
|
|
|
|
(mid (point))
|
|
|
|
|
(end (progn
|
|
|
|
|
(skip-chars-forward skip-characters)
|
|
|
|
|
(constrain-to-field nil orig-pos t))))
|
|
|
|
|
(setq cycle-spacing--context ;; Save for later.
|
|
|
|
|
;; Special handling for case where there was no space at all.
|
|
|
|
|
(unless (= start end)
|
|
|
|
|
(cons orig-pos (buffer-substring start (point)))))
|
|
|
|
|
;; If this run causes no change in buffer content, delete all spaces,
|
2013-02-01 22:04:06 -08:00
|
|
|
|
;; otherwise delete all excess spaces.
|
2013-01-30 21:57:35 -05:00
|
|
|
|
(delete-region (if (and (not single-shot) (zerop n) (= mid end))
|
|
|
|
|
start mid) end)
|
2013-01-31 17:37:54 -05:00
|
|
|
|
(insert (make-string n ?\s))))
|
2013-01-30 21:57:35 -05:00
|
|
|
|
|
|
|
|
|
;; Command run for the second time.
|
|
|
|
|
((not (equal orig-pos (point)))
|
|
|
|
|
(delete-region (point) orig-pos))
|
|
|
|
|
|
|
|
|
|
;; Command run for the third time.
|
|
|
|
|
(t
|
|
|
|
|
(insert (cdr cycle-spacing--context))
|
|
|
|
|
(goto-char (car cycle-spacing--context))
|
|
|
|
|
(setq cycle-spacing--context nil)))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun beginning-of-buffer (&optional arg)
|
2010-08-26 11:09:45 -04:00
|
|
|
|
"Move point to the beginning of the buffer.
|
2004-07-16 10:42:00 +00:00
|
|
|
|
With numeric arg N, put point N/10 of the way from the beginning.
|
2010-08-26 11:09:45 -04:00
|
|
|
|
If the buffer is narrowed, this command uses the beginning of the
|
|
|
|
|
accessible part of the buffer.
|
1994-11-28 19:44:16 +00:00
|
|
|
|
|
2010-08-26 11:09:45 -04:00
|
|
|
|
If Transient Mark mode is disabled, leave mark at previous
|
|
|
|
|
position, unless a \\[universal-argument] prefix is supplied.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
|
|
|
|
|
Don't use this command in Lisp programs!
|
2010-08-26 11:09:45 -04:00
|
|
|
|
\(goto-char (point-min)) is faster."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^P")
|
2004-12-14 12:17:43 +00:00
|
|
|
|
(or (consp arg)
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(region-active-p)
|
2004-12-13 03:08:52 +00:00
|
|
|
|
(push-mark))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(let ((size (- (point-max) (point-min))))
|
2004-07-16 10:42:00 +00:00
|
|
|
|
(goto-char (if (and arg (not (consp arg)))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(+ (point-min)
|
|
|
|
|
(if (> size 10000)
|
|
|
|
|
;; Avoid overflow for large buffer sizes!
|
|
|
|
|
(* (prefix-numeric-value arg)
|
|
|
|
|
(/ size 10))
|
|
|
|
|
(/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
|
|
|
|
|
(point-min))))
|
2007-03-04 17:48:56 +00:00
|
|
|
|
(if (and arg (not (consp arg))) (forward-line 1)))
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'beginning-of-buffer 'interactive-only
|
|
|
|
|
"use `(goto-char (point-min))' instead.")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun end-of-buffer (&optional arg)
|
2010-08-26 11:09:45 -04:00
|
|
|
|
"Move point to the end of the buffer.
|
2004-07-16 10:42:00 +00:00
|
|
|
|
With numeric arg N, put point N/10 of the way from the end.
|
2010-08-26 11:09:45 -04:00
|
|
|
|
If the buffer is narrowed, this command uses the end of the
|
|
|
|
|
accessible part of the buffer.
|
1994-11-28 19:44:16 +00:00
|
|
|
|
|
2010-08-26 11:09:45 -04:00
|
|
|
|
If Transient Mark mode is disabled, leave mark at previous
|
|
|
|
|
position, unless a \\[universal-argument] prefix is supplied.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
|
|
|
|
|
Don't use this command in Lisp programs!
|
2010-08-26 11:09:45 -04:00
|
|
|
|
\(goto-char (point-max)) is faster."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^P")
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(or (consp arg) (region-active-p) (push-mark))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(let ((size (- (point-max) (point-min))))
|
2004-07-16 10:42:00 +00:00
|
|
|
|
(goto-char (if (and arg (not (consp arg)))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(- (point-max)
|
|
|
|
|
(if (> size 10000)
|
|
|
|
|
;; Avoid overflow for large buffer sizes!
|
|
|
|
|
(* (prefix-numeric-value arg)
|
|
|
|
|
(/ size 10))
|
|
|
|
|
(/ (* size (prefix-numeric-value arg)) 10)))
|
|
|
|
|
(point-max))))
|
1992-07-22 04:22:42 +00:00
|
|
|
|
;; If we went to a place in the middle of the buffer,
|
|
|
|
|
;; adjust it to the beginning of a line.
|
2007-03-04 17:48:56 +00:00
|
|
|
|
(cond ((and arg (not (consp arg))) (forward-line 1))
|
2013-02-08 10:53:49 -05:00
|
|
|
|
((and (eq (current-buffer) (window-buffer))
|
|
|
|
|
(> (point) (window-end nil t)))
|
1999-11-01 11:44:58 +00:00
|
|
|
|
;; If the end of the buffer is not already on the screen,
|
|
|
|
|
;; then scroll specially to put it near, but not at, the bottom.
|
|
|
|
|
(overlay-recenter (point))
|
|
|
|
|
(recenter -3))))
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'end-of-buffer 'interactive-only "use `(goto-char (point-max))' instead.")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2010-06-27 21:01:11 -04:00
|
|
|
|
(defcustom delete-active-region t
|
|
|
|
|
"Whether single-char deletion commands delete an active region.
|
|
|
|
|
This has an effect only if Transient Mark mode is enabled, and
|
|
|
|
|
affects `delete-forward-char' and `delete-backward-char', though
|
|
|
|
|
not `delete-char'.
|
|
|
|
|
|
|
|
|
|
If the value is the symbol `kill', the active region is killed
|
|
|
|
|
instead of deleted."
|
|
|
|
|
:type '(choice (const :tag "Delete active region" t)
|
|
|
|
|
(const :tag "Kill active region" kill)
|
|
|
|
|
(const :tag "Do ordinary deletion" nil))
|
2012-04-22 15:19:29 +08:00
|
|
|
|
:group 'killing
|
2010-06-27 21:01:11 -04:00
|
|
|
|
:version "24.1")
|
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defvar region-extract-function
|
|
|
|
|
(lambda (delete)
|
|
|
|
|
(when (region-beginning)
|
|
|
|
|
(if (eq delete 'delete-only)
|
|
|
|
|
(delete-region (region-beginning) (region-end))
|
|
|
|
|
(filter-buffer-substring (region-beginning) (region-end) delete))))
|
|
|
|
|
"Function to get the region's content.
|
|
|
|
|
Called with one argument DELETE.
|
|
|
|
|
If DELETE is `delete-only', then only delete the region and the return value
|
|
|
|
|
is undefined. If DELETE is nil, just return the content as a string.
|
|
|
|
|
If anything else, delete the region and return its content as a string.")
|
|
|
|
|
|
2010-06-27 21:01:11 -04:00
|
|
|
|
(defun delete-backward-char (n &optional killflag)
|
|
|
|
|
"Delete the previous N characters (following if N is negative).
|
|
|
|
|
If Transient Mark mode is enabled, the mark is active, and N is 1,
|
|
|
|
|
delete the text in the region and deactivate the mark instead.
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
To disable this, set option `delete-active-region' to nil.
|
2010-06-27 21:01:11 -04:00
|
|
|
|
|
|
|
|
|
Optional second arg KILLFLAG, if non-nil, means to kill (save in
|
|
|
|
|
kill ring) instead of delete. Interactively, N is the prefix
|
|
|
|
|
arg, and KILLFLAG is set if N is explicitly specified.
|
|
|
|
|
|
|
|
|
|
In Overwrite mode, single character backward deletion may replace
|
|
|
|
|
tabs with spaces so as to back over columns, unless point is at
|
|
|
|
|
the end of the line."
|
|
|
|
|
(interactive "p\nP")
|
|
|
|
|
(unless (integerp n)
|
|
|
|
|
(signal 'wrong-type-argument (list 'integerp n)))
|
|
|
|
|
(cond ((and (use-region-p)
|
|
|
|
|
delete-active-region
|
|
|
|
|
(= n 1))
|
|
|
|
|
;; If a region is active, kill or delete it.
|
|
|
|
|
(if (eq delete-active-region 'kill)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(kill-region (region-beginning) (region-end) 'region)
|
|
|
|
|
(funcall region-extract-function 'delete-only)))
|
2010-06-27 21:01:11 -04:00
|
|
|
|
;; In Overwrite mode, maybe untabify while deleting
|
|
|
|
|
((null (or (null overwrite-mode)
|
|
|
|
|
(<= n 0)
|
|
|
|
|
(memq (char-before) '(?\t ?\n))
|
|
|
|
|
(eobp)
|
|
|
|
|
(eq (char-after) ?\n)))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(let ((ocol (current-column)))
|
|
|
|
|
(delete-char (- n) killflag)
|
2010-06-27 21:01:11 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(insert-char ?\s (- ocol (current-column)) nil))))
|
|
|
|
|
;; Otherwise, do simple deletion.
|
|
|
|
|
(t (delete-char (- n) killflag))))
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'delete-backward-char 'interactive-only 'delete-char)
|
2010-06-27 21:01:11 -04:00
|
|
|
|
|
|
|
|
|
(defun delete-forward-char (n &optional killflag)
|
2010-08-07 13:11:07 +03:00
|
|
|
|
"Delete the following N characters (previous if N is negative).
|
2010-06-27 21:01:11 -04:00
|
|
|
|
If Transient Mark mode is enabled, the mark is active, and N is 1,
|
|
|
|
|
delete the text in the region and deactivate the mark instead.
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
To disable this, set variable `delete-active-region' to nil.
|
2010-06-27 21:01:11 -04:00
|
|
|
|
|
|
|
|
|
Optional second arg KILLFLAG non-nil means to kill (save in kill
|
|
|
|
|
ring) instead of delete. Interactively, N is the prefix arg, and
|
|
|
|
|
KILLFLAG is set if N was explicitly specified."
|
|
|
|
|
(interactive "p\nP")
|
|
|
|
|
(unless (integerp n)
|
|
|
|
|
(signal 'wrong-type-argument (list 'integerp n)))
|
|
|
|
|
(cond ((and (use-region-p)
|
|
|
|
|
delete-active-region
|
|
|
|
|
(= n 1))
|
|
|
|
|
;; If a region is active, kill or delete it.
|
|
|
|
|
(if (eq delete-active-region 'kill)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(kill-region (region-beginning) (region-end) 'region)
|
|
|
|
|
(funcall region-extract-function 'delete-only)))
|
|
|
|
|
|
2010-06-27 21:01:11 -04:00
|
|
|
|
;; Otherwise, do simple deletion.
|
|
|
|
|
(t (delete-char n killflag))))
|
2014-03-03 22:14:11 -05:00
|
|
|
|
(put 'delete-forward-char 'interactive-only 'delete-char)
|
2010-06-27 21:01:11 -04:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun mark-whole-buffer ()
|
1992-06-12 22:23:00 +00:00
|
|
|
|
"Put point at beginning and mark at end of buffer.
|
2011-11-14 19:38:10 -05:00
|
|
|
|
If narrowing is in effect, only uses the accessible part of the buffer.
|
1992-06-12 22:23:00 +00:00
|
|
|
|
You probably should not use this function in Lisp programs;
|
|
|
|
|
it is usually a mistake for a Lisp function to use any subroutine
|
|
|
|
|
that uses or sets the mark."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(push-mark (point))
|
1993-05-16 15:39:39 +00:00
|
|
|
|
(push-mark (point-max) nil t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(goto-char (point-min)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;; Counting lines, one way or another.
|
|
|
|
|
|
2008-11-22 17:33:06 +00:00
|
|
|
|
(defun goto-line (line &optional buffer)
|
2012-03-12 00:57:04 +08:00
|
|
|
|
"Go to LINE, counting from line 1 at beginning of buffer.
|
|
|
|
|
If called interactively, a numeric prefix argument specifies
|
|
|
|
|
LINE; without a numeric prefix argument, read LINE from the
|
|
|
|
|
minibuffer.
|
2008-11-22 17:33:06 +00:00
|
|
|
|
|
2012-03-12 00:57:04 +08:00
|
|
|
|
If optional argument BUFFER is non-nil, switch to that buffer and
|
|
|
|
|
move to line LINE there. If called interactively with \\[universal-argument]
|
|
|
|
|
as argument, BUFFER is the most recently selected other buffer.
|
|
|
|
|
|
|
|
|
|
Prior to moving point, this function sets the mark (without
|
|
|
|
|
activating it), unless Transient Mark mode is enabled and the
|
|
|
|
|
mark is already active.
|
2009-08-10 16:38:16 +00:00
|
|
|
|
|
|
|
|
|
This function is usually the wrong thing to use in a Lisp program.
|
|
|
|
|
What you probably want instead is something like:
|
2012-03-12 00:57:04 +08:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line (1- N))
|
2009-08-10 16:38:16 +00:00
|
|
|
|
If at all possible, an even better solution is to use char counts
|
|
|
|
|
rather than line counts."
|
2005-03-05 18:02:40 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(if (and current-prefix-arg (not (consp current-prefix-arg)))
|
|
|
|
|
(list (prefix-numeric-value current-prefix-arg))
|
|
|
|
|
;; Look for a default, a number in the buffer at point.
|
|
|
|
|
(let* ((default
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-backward "0-9")
|
|
|
|
|
(if (looking-at "[0-9]")
|
2011-07-28 16:05:07 +02:00
|
|
|
|
(string-to-number
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point)
|
|
|
|
|
(progn (skip-chars-forward "0-9")
|
|
|
|
|
(point)))))))
|
2005-03-05 18:02:40 +00:00
|
|
|
|
;; Decide if we're switching buffers.
|
|
|
|
|
(buffer
|
|
|
|
|
(if (consp current-prefix-arg)
|
|
|
|
|
(other-buffer (current-buffer) t)))
|
|
|
|
|
(buffer-prompt
|
|
|
|
|
(if buffer
|
|
|
|
|
(concat " in " (buffer-name buffer))
|
|
|
|
|
"")))
|
|
|
|
|
;; Read the argument, offering that number (if any) as default.
|
2012-07-29 21:11:42 +03:00
|
|
|
|
(list (read-number (format "Goto line%s: " buffer-prompt)
|
|
|
|
|
(list default (line-number-at-pos)))
|
2005-03-05 18:02:40 +00:00
|
|
|
|
buffer))))
|
|
|
|
|
;; Switch to the desired buffer, one way or another.
|
|
|
|
|
(if buffer
|
|
|
|
|
(let ((window (get-buffer-window buffer)))
|
|
|
|
|
(if window (select-window window)
|
|
|
|
|
(switch-to-buffer-other-window buffer))))
|
2008-03-16 17:45:11 +00:00
|
|
|
|
;; Leave mark at previous position
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(or (region-active-p) (push-mark))
|
2005-03-05 18:02:40 +00:00
|
|
|
|
;; Move to the specified line number in that buffer.
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
2009-08-10 16:38:16 +00:00
|
|
|
|
(goto-char (point-min))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(if (eq selective-display t)
|
2008-11-22 17:33:06 +00:00
|
|
|
|
(re-search-forward "[\n\C-m]" nil 'end (1- line))
|
|
|
|
|
(forward-line (1- line)))))
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'goto-line 'interactive-only 'forward-line)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2012-08-11 00:02:48 +08:00
|
|
|
|
(defun count-words-region (start end &optional arg)
|
2012-03-05 14:10:11 +08:00
|
|
|
|
"Count the number of words in the region.
|
2011-10-08 12:37:46 -04:00
|
|
|
|
If called interactively, print a message reporting the number of
|
2012-08-11 00:02:48 +08:00
|
|
|
|
lines, words, and characters in the region (whether or not the
|
|
|
|
|
region is active); with prefix ARG, report for the entire buffer
|
|
|
|
|
rather than the region.
|
|
|
|
|
|
2012-03-05 14:10:11 +08:00
|
|
|
|
If called from Lisp, return the number of words between positions
|
|
|
|
|
START and END."
|
2012-09-07 16:58:31 +08:00
|
|
|
|
(interactive (if current-prefix-arg
|
|
|
|
|
(list nil nil current-prefix-arg)
|
|
|
|
|
(list (region-beginning) (region-end) nil)))
|
2012-08-11 00:02:48 +08:00
|
|
|
|
(cond ((not (called-interactively-p 'any))
|
|
|
|
|
(count-words start end))
|
|
|
|
|
(arg
|
|
|
|
|
(count-words--buffer-message))
|
|
|
|
|
(t
|
|
|
|
|
(count-words--message "Region" start end))))
|
2012-03-05 14:10:11 +08:00
|
|
|
|
|
|
|
|
|
(defun count-words (start end)
|
|
|
|
|
"Count words between START and END.
|
|
|
|
|
If called interactively, START and END are normally the start and
|
|
|
|
|
end of the buffer; but if the region is active, START and END are
|
|
|
|
|
the start and end of the region. Print a message reporting the
|
|
|
|
|
number of lines, words, and chars.
|
|
|
|
|
|
|
|
|
|
If called from Lisp, return the number of words between START and
|
|
|
|
|
END, without printing any message."
|
|
|
|
|
(interactive (list nil nil))
|
|
|
|
|
(cond ((not (called-interactively-p 'any))
|
|
|
|
|
(let ((words 0))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region start end)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (forward-word 1)
|
|
|
|
|
(setq words (1+ words)))))
|
|
|
|
|
words))
|
|
|
|
|
((use-region-p)
|
|
|
|
|
(call-interactively 'count-words-region))
|
|
|
|
|
(t
|
2012-08-11 00:02:48 +08:00
|
|
|
|
(count-words--buffer-message))))
|
|
|
|
|
|
|
|
|
|
(defun count-words--buffer-message ()
|
|
|
|
|
(count-words--message
|
2012-09-07 16:58:31 +08:00
|
|
|
|
(if (buffer-narrowed-p) "Narrowed part of buffer" "Buffer")
|
2012-08-11 00:02:48 +08:00
|
|
|
|
(point-min) (point-max)))
|
2012-03-05 14:10:11 +08:00
|
|
|
|
|
|
|
|
|
(defun count-words--message (str start end)
|
|
|
|
|
(let ((lines (count-lines start end))
|
|
|
|
|
(words (count-words start end))
|
|
|
|
|
(chars (- end start)))
|
|
|
|
|
(message "%s has %d line%s, %d word%s, and %d character%s."
|
|
|
|
|
str
|
|
|
|
|
lines (if (= lines 1) "" "s")
|
|
|
|
|
words (if (= words 1) "" "s")
|
|
|
|
|
chars (if (= chars 1) "" "s"))))
|
|
|
|
|
|
|
|
|
|
(define-obsolete-function-alias 'count-lines-region 'count-words-region "24.1")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun what-line ()
|
1995-08-25 14:16:26 +00:00
|
|
|
|
"Print the current buffer line number and narrowed line number of point."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive)
|
2004-12-03 22:26:13 +00:00
|
|
|
|
(let ((start (point-min))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(n (line-number-at-pos)))
|
|
|
|
|
(if (= start 1)
|
|
|
|
|
(message "Line %d" n)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(message "line %d (narrowed line %d)"
|
|
|
|
|
(+ n (line-number-at-pos start) -1) n))))))
|
1995-08-25 14:16:26 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun count-lines (start end)
|
|
|
|
|
"Return number of lines between START and END.
|
|
|
|
|
This is usually the number of newlines between them,
|
1992-08-21 07:18:16 +00:00
|
|
|
|
but can be one more if START is not equal to END
|
1991-12-21 09:29:41 +00:00
|
|
|
|
and the greater of them is not at the start of a line."
|
1994-10-16 08:20:07 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region start end)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(if (eq selective-display t)
|
|
|
|
|
(save-match-data
|
1993-03-29 19:09:05 +00:00
|
|
|
|
(let ((done 0))
|
2011-09-09 23:02:06 -04:00
|
|
|
|
(while (re-search-forward "[\n\C-m]" nil t 40)
|
|
|
|
|
(setq done (+ 40 done)))
|
|
|
|
|
(while (re-search-forward "[\n\C-m]" nil t 1)
|
|
|
|
|
(setq done (+ 1 done)))
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(if (and (/= start end)
|
1993-11-24 04:35:28 +00:00
|
|
|
|
(not (bolp)))
|
|
|
|
|
(1+ done)
|
1994-10-16 08:20:07 +00:00
|
|
|
|
done)))
|
|
|
|
|
(- (buffer-size) (forward-line (buffer-size)))))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun line-number-at-pos (&optional pos)
|
|
|
|
|
"Return (narrowed) buffer line number at position POS.
|
2006-08-20 12:16:58 +00:00
|
|
|
|
If POS is nil, use current buffer location.
|
|
|
|
|
Counting starts at (point-min), so the value refers
|
|
|
|
|
to the contents of the accessible portion of the buffer."
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(let ((opoint (or pos (point))) start)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(setq start (point))
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
(forward-line 0)
|
|
|
|
|
(1+ (count-lines start (point))))))
|
|
|
|
|
|
1997-02-20 05:35:12 +00:00
|
|
|
|
(defun what-cursor-position (&optional detail)
|
|
|
|
|
"Print info on cursor position (on screen and within buffer).
|
1998-12-30 20:41:24 +00:00
|
|
|
|
Also describe the character after point, and give its character code
|
1999-02-25 13:25:07 +00:00
|
|
|
|
in octal, decimal and hex.
|
|
|
|
|
|
|
|
|
|
For a non-ASCII multibyte character, also give its encoding in the
|
|
|
|
|
buffer's selected coding system if the coding system encodes the
|
|
|
|
|
character safely. If the character is encoded into one byte, that
|
|
|
|
|
code is shown in hex. If the character is encoded into more than one
|
|
|
|
|
byte, just \"...\" is shown.
|
1998-08-02 01:06:57 +00:00
|
|
|
|
|
2000-05-13 00:28:57 +00:00
|
|
|
|
In addition, with prefix argument, show details about that character
|
2002-06-17 16:15:09 +00:00
|
|
|
|
in *Help* buffer. See also the command `describe-char'."
|
1997-02-20 05:35:12 +00:00
|
|
|
|
(interactive "P")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(let* ((char (following-char))
|
2011-12-05 19:46:27 +02:00
|
|
|
|
(bidi-fixer
|
|
|
|
|
(cond ((memq char '(?\x202a ?\x202b ?\x202d ?\x202e))
|
|
|
|
|
;; If the character is one of LRE, LRO, RLE, RLO, it
|
|
|
|
|
;; will start a directional embedding, which could
|
|
|
|
|
;; completely disrupt the rest of the line (e.g., RLO
|
|
|
|
|
;; will display the rest of the line right-to-left).
|
|
|
|
|
;; So we put an invisible PDF character after these
|
|
|
|
|
;; characters, to end the embedding, which eliminates
|
|
|
|
|
;; any effects on the rest of the line.
|
|
|
|
|
(propertize (string ?\x202c) 'invisible t))
|
|
|
|
|
;; Strong right-to-left characters cause reordering of
|
|
|
|
|
;; the following numerical characters which show the
|
|
|
|
|
;; codepoint, so append LRM to countermand that.
|
|
|
|
|
((memq (get-char-code-property char 'bidi-class) '(R AL))
|
|
|
|
|
(propertize (string ?\x200e) 'invisible t))
|
|
|
|
|
(t
|
|
|
|
|
"")))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(beg (point-min))
|
|
|
|
|
(end (point-max))
|
|
|
|
|
(pos (point))
|
|
|
|
|
(total (buffer-size))
|
|
|
|
|
(percent (if (> total 50000)
|
|
|
|
|
;; Avoid overflow from multiplying by 100!
|
|
|
|
|
(/ (+ (/ total 200) (1- pos)) (max (/ total 100) 1))
|
|
|
|
|
(/ (+ (/ total 2) (* 100 (1- pos))) (max total 1))))
|
|
|
|
|
(hscroll (if (= (window-hscroll) 0)
|
|
|
|
|
""
|
|
|
|
|
(format " Hscroll=%d" (window-hscroll))))
|
|
|
|
|
(col (current-column)))
|
|
|
|
|
(if (= pos end)
|
|
|
|
|
(if (or (/= beg 1) (/= end (1+ total)))
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(message "point=%d of %d (%d%%) <%d-%d> column=%d%s"
|
1991-12-21 09:29:41 +00:00
|
|
|
|
pos total percent beg end col hscroll)
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(message "point=%d of %d (EOB) column=%d%s"
|
2005-11-12 00:10:56 +00:00
|
|
|
|
pos total col hscroll))
|
1999-02-25 13:25:07 +00:00
|
|
|
|
(let ((coding buffer-file-coding-system)
|
2005-10-06 06:57:41 +00:00
|
|
|
|
encoded encoding-msg display-prop under-display)
|
1999-02-25 13:25:07 +00:00
|
|
|
|
(if (or (not coding)
|
|
|
|
|
(eq (coding-system-type coding) t))
|
2009-08-28 04:21:14 +00:00
|
|
|
|
(setq coding (default-value 'buffer-file-coding-system)))
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(if (eq (char-charset char) 'eight-bit)
|
1999-03-22 04:12:42 +00:00
|
|
|
|
(setq encoding-msg
|
2006-01-16 08:37:27 +00:00
|
|
|
|
(format "(%d, #o%o, #x%x, raw-byte)" char char char))
|
2005-10-06 06:57:41 +00:00
|
|
|
|
;; Check if the character is displayed with some `display'
|
|
|
|
|
;; text property. In that case, set under-display to the
|
|
|
|
|
;; buffer substring covered by that property.
|
2011-09-22 19:49:57 +03:00
|
|
|
|
(setq display-prop (get-char-property pos 'display))
|
2005-10-06 06:57:41 +00:00
|
|
|
|
(if display-prop
|
2011-09-22 19:49:57 +03:00
|
|
|
|
(let ((to (or (next-single-char-property-change pos 'display)
|
2005-10-06 06:57:41 +00:00
|
|
|
|
(point-max))))
|
|
|
|
|
(if (< to (+ pos 4))
|
|
|
|
|
(setq under-display "")
|
|
|
|
|
(setq under-display "..."
|
|
|
|
|
to (+ pos 4)))
|
|
|
|
|
(setq under-display
|
|
|
|
|
(concat (buffer-substring-no-properties pos to)
|
|
|
|
|
under-display)))
|
|
|
|
|
(setq encoded (and (>= char 128) (encode-coding-char char coding))))
|
1999-03-22 04:12:42 +00:00
|
|
|
|
(setq encoding-msg
|
2005-10-06 06:57:41 +00:00
|
|
|
|
(if display-prop
|
|
|
|
|
(if (not (stringp display-prop))
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(format "(%d, #o%o, #x%x, part of display \"%s\")"
|
2005-10-06 06:57:41 +00:00
|
|
|
|
char char char under-display)
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(format "(%d, #o%o, #x%x, part of display \"%s\"->\"%s\")"
|
2005-10-06 06:57:41 +00:00
|
|
|
|
char char char under-display display-prop))
|
|
|
|
|
(if encoded
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(format "(%d, #o%o, #x%x, file %s)"
|
2005-10-06 06:57:41 +00:00
|
|
|
|
char char char
|
|
|
|
|
(if (> (length encoded) 1)
|
|
|
|
|
"..."
|
|
|
|
|
(encoded-string-description encoded coding)))
|
2005-11-20 07:43:01 +00:00
|
|
|
|
(format "(%d, #o%o, #x%x)" char char char)))))
|
1998-12-27 04:09:09 +00:00
|
|
|
|
(if detail
|
2000-05-13 00:28:57 +00:00
|
|
|
|
;; We show the detailed information about CHAR.
|
2002-06-17 16:15:09 +00:00
|
|
|
|
(describe-char (point)))
|
2000-05-13 00:28:57 +00:00
|
|
|
|
(if (or (/= beg 1) (/= end (1+ total)))
|
2011-10-13 13:58:54 +02:00
|
|
|
|
(message "Char: %s%s %s point=%d of %d (%d%%) <%d-%d> column=%d%s"
|
1998-08-02 01:06:57 +00:00
|
|
|
|
(if (< char 256)
|
|
|
|
|
(single-key-description char)
|
1999-12-15 00:39:33 +00:00
|
|
|
|
(buffer-substring-no-properties (point) (1+ (point))))
|
2011-12-05 19:46:27 +02:00
|
|
|
|
bidi-fixer
|
|
|
|
|
encoding-msg pos total percent beg end col hscroll)
|
2011-10-13 13:58:54 +02:00
|
|
|
|
(message "Char: %s%s %s point=%d of %d (%d%%) column=%d%s"
|
2005-10-06 06:57:41 +00:00
|
|
|
|
(if enable-multibyte-characters
|
|
|
|
|
(if (< char 128)
|
|
|
|
|
(single-key-description char)
|
|
|
|
|
(buffer-substring-no-properties (point) (1+ (point))))
|
|
|
|
|
(single-key-description char))
|
2011-12-05 19:46:27 +02:00
|
|
|
|
bidi-fixer encoding-msg pos total percent col hscroll))))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2006-10-18 10:58:39 +00:00
|
|
|
|
;; Initialize read-expression-map. It is defined at C level.
|
2013-05-04 15:27:41 -04:00
|
|
|
|
(defvar read-expression-map
|
|
|
|
|
(let ((m (make-sparse-keymap)))
|
|
|
|
|
(define-key m "\M-\t" 'completion-at-point)
|
|
|
|
|
;; Might as well bind TAB to completion, since inserting a TAB char is
|
|
|
|
|
;; much too rarely useful.
|
|
|
|
|
(define-key m "\t" 'completion-at-point)
|
|
|
|
|
(set-keymap-parent m minibuffer-local-map)
|
|
|
|
|
m))
|
|
|
|
|
|
|
|
|
|
(defun read-minibuffer (prompt &optional initial-contents)
|
|
|
|
|
"Return a Lisp object read using the minibuffer, unevaluated.
|
|
|
|
|
Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS
|
|
|
|
|
is a string to insert in the minibuffer before reading.
|
|
|
|
|
\(INITIAL-CONTENTS can also be a cons of a string and an integer.
|
|
|
|
|
Such arguments are used as in `read-from-minibuffer'.)"
|
|
|
|
|
;; Used for interactive spec `x'.
|
|
|
|
|
(read-from-minibuffer prompt initial-contents minibuffer-local-map
|
2013-09-10 00:21:19 -07:00
|
|
|
|
t 'minibuffer-history))
|
2013-05-04 15:27:41 -04:00
|
|
|
|
|
|
|
|
|
(defun eval-minibuffer (prompt &optional initial-contents)
|
|
|
|
|
"Return value of Lisp expression read using the minibuffer.
|
|
|
|
|
Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS
|
|
|
|
|
is a string to insert in the minibuffer before reading.
|
|
|
|
|
\(INITIAL-CONTENTS can also be a cons of a string and an integer.
|
|
|
|
|
Such arguments are used as in `read-from-minibuffer'.)"
|
|
|
|
|
;; Used for interactive spec `X'.
|
2013-05-24 22:21:49 -04:00
|
|
|
|
(eval (read--expression prompt initial-contents)))
|
1992-09-14 06:53:22 +00:00
|
|
|
|
|
2007-03-08 14:43:08 +00:00
|
|
|
|
(defvar minibuffer-completing-symbol nil
|
|
|
|
|
"Non-nil means completing a Lisp symbol in the minibuffer.")
|
2011-06-01 16:32:04 -03:00
|
|
|
|
(make-obsolete-variable 'minibuffer-completing-symbol nil "24.1" 'get)
|
2007-03-08 14:43:08 +00:00
|
|
|
|
|
2009-01-01 03:36:43 +00:00
|
|
|
|
(defvar minibuffer-default nil
|
|
|
|
|
"The current default value or list of default values in the minibuffer.
|
|
|
|
|
The functions `read-from-minibuffer' and `completing-read' bind
|
|
|
|
|
this variable locally.")
|
|
|
|
|
|
1999-09-14 07:00:04 +00:00
|
|
|
|
(defcustom eval-expression-print-level 4
|
2005-06-04 22:04:29 +00:00
|
|
|
|
"Value for `print-level' while printing value in `eval-expression'.
|
2001-12-18 23:39:21 +00:00
|
|
|
|
A value of nil means no limit."
|
1999-09-14 07:00:04 +00:00
|
|
|
|
:group 'lisp
|
2001-12-18 15:53:57 +00:00
|
|
|
|
:type '(choice (const :tag "No Limit" nil) integer)
|
1999-09-14 07:00:04 +00:00
|
|
|
|
:version "21.1")
|
|
|
|
|
|
|
|
|
|
(defcustom eval-expression-print-length 12
|
2005-06-04 22:04:29 +00:00
|
|
|
|
"Value for `print-length' while printing value in `eval-expression'.
|
2001-12-18 23:39:21 +00:00
|
|
|
|
A value of nil means no limit."
|
1999-09-14 07:00:04 +00:00
|
|
|
|
:group 'lisp
|
2001-12-18 15:53:57 +00:00
|
|
|
|
:type '(choice (const :tag "No Limit" nil) integer)
|
1999-09-14 07:00:04 +00:00
|
|
|
|
:version "21.1")
|
|
|
|
|
|
|
|
|
|
(defcustom eval-expression-debug-on-error t
|
2005-06-04 22:04:29 +00:00
|
|
|
|
"If non-nil set `debug-on-error' to t in `eval-expression'.
|
2000-01-12 13:06:52 +00:00
|
|
|
|
If nil, don't change the value of `debug-on-error'."
|
1999-09-14 07:00:04 +00:00
|
|
|
|
:group 'lisp
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "21.1")
|
|
|
|
|
|
2004-05-28 21:00:14 +00:00
|
|
|
|
(defun eval-expression-print-format (value)
|
|
|
|
|
"Format VALUE as a result of evaluated expression.
|
|
|
|
|
Return a formatted string which is displayed in the echo area
|
|
|
|
|
in addition to the value printed by prin1 in functions which
|
|
|
|
|
display the result of expression evaluation."
|
|
|
|
|
(if (and (integerp value)
|
2013-12-19 23:02:46 +02:00
|
|
|
|
(or (eq standard-output t)
|
|
|
|
|
(zerop (prefix-numeric-value current-prefix-arg))))
|
2004-05-28 21:00:14 +00:00
|
|
|
|
(let ((char-string
|
2013-12-19 23:02:46 +02:00
|
|
|
|
(if (and (characterp value)
|
|
|
|
|
(char-displayable-p value))
|
|
|
|
|
(prin1-char value))))
|
2004-05-28 21:00:14 +00:00
|
|
|
|
(if char-string
|
2005-11-01 07:18:10 +00:00
|
|
|
|
(format " (#o%o, #x%x, %s)" value value char-string)
|
|
|
|
|
(format " (#o%o, #x%x)" value value)))))
|
2004-05-28 21:00:14 +00:00
|
|
|
|
|
2013-03-17 23:00:37 +08:00
|
|
|
|
(defvar eval-expression-minibuffer-setup-hook nil
|
|
|
|
|
"Hook run by `eval-expression' when entering the minibuffer.")
|
|
|
|
|
|
2013-05-24 22:21:49 -04:00
|
|
|
|
(defun read--expression (prompt &optional initial-contents)
|
|
|
|
|
(let ((minibuffer-completing-symbol t))
|
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(add-hook 'completion-at-point-functions
|
|
|
|
|
#'lisp-completion-at-point nil t)
|
|
|
|
|
(run-hooks 'eval-expression-minibuffer-setup-hook))
|
|
|
|
|
(read-from-minibuffer prompt initial-contents
|
|
|
|
|
read-expression-map t
|
|
|
|
|
'read-expression-history))))
|
|
|
|
|
|
1993-07-26 18:32:07 +00:00
|
|
|
|
;; We define this, rather than making `eval' interactive,
|
2006-07-05 07:44:35 +00:00
|
|
|
|
;; for the sake of completion of names like eval-region, eval-buffer.
|
2013-02-15 18:47:50 -05:00
|
|
|
|
(defun eval-expression (exp &optional insert-value)
|
|
|
|
|
"Evaluate EXP and print value in the echo area.
|
2014-01-22 23:53:56 -08:00
|
|
|
|
When called interactively, read an Emacs Lisp expression and evaluate it.
|
2001-02-10 06:45:56 +00:00
|
|
|
|
Value is also consed on to front of the variable `values'.
|
2014-01-22 23:53:56 -08:00
|
|
|
|
Optional argument INSERT-VALUE non-nil (interactively, with prefix
|
|
|
|
|
argument) means insert the result into the current buffer instead of
|
|
|
|
|
printing it in the echo area.
|
|
|
|
|
|
|
|
|
|
Normally, this function truncates long output according to the value
|
|
|
|
|
of the variables `eval-expression-print-length' and
|
|
|
|
|
`eval-expression-print-level'. With a prefix argument of zero,
|
|
|
|
|
however, there is no such truncation. Such a prefix argument
|
|
|
|
|
also causes integers to be printed in several additional formats
|
|
|
|
|
\(octal, hexadecimal, and character).
|
2006-04-07 23:30:42 +00:00
|
|
|
|
|
2014-01-29 23:48:06 -08:00
|
|
|
|
Runs the hook `eval-expression-minibuffer-setup-hook' on entering the
|
|
|
|
|
minibuffer.
|
|
|
|
|
|
2006-04-07 23:30:42 +00:00
|
|
|
|
If `eval-expression-debug-on-error' is non-nil, which is the default,
|
|
|
|
|
this command arranges for all errors to enter the debugger."
|
1993-10-25 06:07:23 +00:00
|
|
|
|
(interactive
|
2013-05-24 22:21:49 -04:00
|
|
|
|
(list (read--expression "Eval: ")
|
1997-08-24 21:28:21 +00:00
|
|
|
|
current-prefix-arg))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2000-01-12 13:06:52 +00:00
|
|
|
|
(if (null eval-expression-debug-on-error)
|
2013-02-15 18:47:50 -05:00
|
|
|
|
(push (eval exp lexical-binding) values)
|
2000-01-12 13:06:52 +00:00
|
|
|
|
(let ((old-value (make-symbol "t")) new-value)
|
|
|
|
|
;; Bind debug-on-error to something unique so that we can
|
2011-12-18 22:21:24 -08:00
|
|
|
|
;; detect when evalled code changes it.
|
2000-01-12 13:06:52 +00:00
|
|
|
|
(let ((debug-on-error old-value))
|
2013-02-15 18:47:50 -05:00
|
|
|
|
(push (eval exp lexical-binding) values)
|
2000-01-12 13:06:52 +00:00
|
|
|
|
(setq new-value debug-on-error))
|
2011-12-18 22:21:24 -08:00
|
|
|
|
;; If evalled code has changed the value of debug-on-error,
|
2000-01-12 13:06:52 +00:00
|
|
|
|
;; propagate that change to the global binding.
|
|
|
|
|
(unless (eq old-value new-value)
|
|
|
|
|
(setq debug-on-error new-value))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2013-12-19 23:02:46 +02:00
|
|
|
|
(let ((print-length (and (not (zerop (prefix-numeric-value insert-value)))
|
|
|
|
|
eval-expression-print-length))
|
|
|
|
|
(print-level (and (not (zerop (prefix-numeric-value insert-value)))
|
|
|
|
|
eval-expression-print-level))
|
2013-02-15 18:47:50 -05:00
|
|
|
|
(deactivate-mark))
|
|
|
|
|
(if insert-value
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(let ((standard-output (current-buffer)))
|
2013-12-19 23:02:46 +02:00
|
|
|
|
(prog1
|
|
|
|
|
(prin1 (car values))
|
|
|
|
|
(when (zerop (prefix-numeric-value insert-value))
|
|
|
|
|
(let ((str (eval-expression-print-format (car values))))
|
|
|
|
|
(if str (princ str)))))))
|
2004-05-28 21:00:14 +00:00
|
|
|
|
(prog1
|
|
|
|
|
(prin1 (car values) t)
|
|
|
|
|
(let ((str (eval-expression-print-format (car values))))
|
|
|
|
|
(if str (princ str t)))))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun edit-and-eval-command (prompt command)
|
|
|
|
|
"Prompting with PROMPT, let user edit COMMAND and eval result.
|
|
|
|
|
COMMAND is a Lisp expression. Let user edit that expression in
|
|
|
|
|
the minibuffer, then read and evaluate the result."
|
2002-09-24 18:40:59 +00:00
|
|
|
|
(let ((command
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(let ((print-level nil)
|
|
|
|
|
(minibuffer-history-sexp-flag (1+ (minibuffer-depth))))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(read-from-minibuffer prompt
|
|
|
|
|
(prin1-to-string command)
|
|
|
|
|
read-expression-map t
|
|
|
|
|
'command-history)
|
|
|
|
|
;; If command was added to command-history as a string,
|
|
|
|
|
;; get rid of that. We want only evaluable expressions there.
|
|
|
|
|
(if (stringp (car command-history))
|
|
|
|
|
(setq command-history (cdr command-history)))))))
|
1994-10-20 20:14:45 +00:00
|
|
|
|
|
|
|
|
|
;; If command to be redone does not match front of history,
|
|
|
|
|
;; add it to the history.
|
|
|
|
|
(or (equal command (car command-history))
|
|
|
|
|
(setq command-history (cons command command-history)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(eval command)))
|
|
|
|
|
|
1992-07-24 03:42:21 +00:00
|
|
|
|
(defun repeat-complex-command (arg)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Edit and re-evaluate last complex command, or ARGth from last.
|
|
|
|
|
A complex command is one which used the minibuffer.
|
|
|
|
|
The command is placed in the minibuffer as a Lisp form for editing.
|
|
|
|
|
The result is executed, repeating the command as changed.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
If the command has been changed or is not the most recent previous
|
|
|
|
|
command it is added to the front of the command history.
|
|
|
|
|
You can use the minibuffer history commands \
|
|
|
|
|
\\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element]
|
1992-07-24 22:37:33 +00:00
|
|
|
|
to get different commands to edit and resubmit."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "p")
|
1992-07-24 06:09:27 +00:00
|
|
|
|
(let ((elt (nth (1- arg) command-history))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
newcmd)
|
|
|
|
|
(if elt
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(progn
|
1993-10-05 01:19:12 +00:00
|
|
|
|
(setq newcmd
|
1997-01-01 03:37:37 +00:00
|
|
|
|
(let ((print-level nil)
|
|
|
|
|
(minibuffer-history-position arg)
|
1997-10-02 03:04:15 +00:00
|
|
|
|
(minibuffer-history-sexp-flag (1+ (minibuffer-depth))))
|
2002-09-24 18:40:59 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(read-from-minibuffer
|
|
|
|
|
"Redo: " (prin1-to-string elt) read-expression-map t
|
|
|
|
|
(cons 'command-history arg))
|
|
|
|
|
|
|
|
|
|
;; If command was added to command-history as a
|
|
|
|
|
;; string, get rid of that. We want only
|
|
|
|
|
;; evaluable expressions there.
|
|
|
|
|
(if (stringp (car command-history))
|
|
|
|
|
(setq command-history (cdr command-history))))))
|
1993-11-23 11:03:16 +00:00
|
|
|
|
|
|
|
|
|
;; If command to be redone does not match front of history,
|
|
|
|
|
;; add it to the history.
|
|
|
|
|
(or (equal newcmd (car command-history))
|
|
|
|
|
(setq command-history (cons newcmd command-history)))
|
2013-08-28 17:19:54 -04:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Trick called-interactively-p into thinking that `newcmd' is
|
|
|
|
|
;; an interactive call (bug#14136).
|
|
|
|
|
(add-hook 'called-interactively-p-functions
|
|
|
|
|
#'repeat-complex-command--called-interactively-skip)
|
|
|
|
|
(eval newcmd))
|
|
|
|
|
(remove-hook 'called-interactively-p-functions
|
|
|
|
|
#'repeat-complex-command--called-interactively-skip)))
|
2002-12-28 21:23:23 +00:00
|
|
|
|
(if command-history
|
|
|
|
|
(error "Argument %d is beyond length of command history" arg)
|
|
|
|
|
(error "There are no previous complex commands to repeat")))))
|
2010-08-23 00:27:59 +01:00
|
|
|
|
|
2013-08-28 17:19:54 -04:00
|
|
|
|
(defun repeat-complex-command--called-interactively-skip (i _frame1 frame2)
|
|
|
|
|
(and (eq 'eval (cadr frame2))
|
|
|
|
|
(eq 'repeat-complex-command
|
|
|
|
|
(cadr (backtrace-frame i #'called-interactively-p)))
|
|
|
|
|
1))
|
|
|
|
|
|
2013-02-20 11:37:06 -05:00
|
|
|
|
(defvar extended-command-history nil)
|
|
|
|
|
|
2010-08-23 00:27:59 +01:00
|
|
|
|
(defun read-extended-command ()
|
|
|
|
|
"Read command name to invoke in `execute-extended-command'."
|
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(set (make-local-variable 'minibuffer-default-add-function)
|
|
|
|
|
(lambda ()
|
|
|
|
|
;; Get a command name at point in the original buffer
|
|
|
|
|
;; to propose it after M-n.
|
|
|
|
|
(with-current-buffer (window-buffer (minibuffer-selected-window))
|
|
|
|
|
(and (commandp (function-called-at-point))
|
|
|
|
|
(format "%S" (function-called-at-point)))))))
|
|
|
|
|
;; Read a string, completing from and restricting to the set of
|
|
|
|
|
;; all defined commands. Don't provide any initial input.
|
|
|
|
|
;; Save the command read on the extended-command history list.
|
|
|
|
|
(completing-read
|
|
|
|
|
(concat (cond
|
|
|
|
|
((eq current-prefix-arg '-) "- ")
|
|
|
|
|
((and (consp current-prefix-arg)
|
|
|
|
|
(eq (car current-prefix-arg) 4)) "C-u ")
|
|
|
|
|
((and (consp current-prefix-arg)
|
|
|
|
|
(integerp (car current-prefix-arg)))
|
|
|
|
|
(format "%d " (car current-prefix-arg)))
|
|
|
|
|
((integerp current-prefix-arg)
|
|
|
|
|
(format "%d " current-prefix-arg)))
|
|
|
|
|
;; This isn't strictly correct if `execute-extended-command'
|
|
|
|
|
;; is bound to anything else (e.g. [menu]).
|
|
|
|
|
;; It could use (key-description (this-single-command-keys)),
|
|
|
|
|
;; but actually a prompt other than "M-x" would be confusing,
|
|
|
|
|
;; because "M-x" is a well-known prompt to read a command
|
|
|
|
|
;; and it serves as a shorthand for "Extended command: ".
|
|
|
|
|
"M-x ")
|
|
|
|
|
obarray 'commandp t nil 'extended-command-history)))
|
|
|
|
|
|
2012-05-01 12:10:02 -04:00
|
|
|
|
(defcustom suggest-key-bindings t
|
|
|
|
|
"Non-nil means show the equivalent key-binding when M-x command has one.
|
|
|
|
|
The value can be a length of time to show the message for.
|
|
|
|
|
If the value is non-nil and not a number, we wait 2 seconds."
|
|
|
|
|
:group 'keyboard
|
|
|
|
|
:type '(choice (const :tag "off" nil)
|
|
|
|
|
(integer :tag "time" 2)
|
|
|
|
|
(other :tag "on")))
|
|
|
|
|
|
|
|
|
|
(defun execute-extended-command (prefixarg &optional command-name)
|
|
|
|
|
;; Based on Fexecute_extended_command in keyboard.c of Emacs.
|
|
|
|
|
;; Aaron S. Hawley <aaron.s.hawley(at)gmail.com> 2009-08-24
|
2014-02-08 05:13:46 -08:00
|
|
|
|
"Read a command name, then read the arguments and call the command.
|
|
|
|
|
Interactively, to pass a prefix argument to the command you are
|
|
|
|
|
invoking, give a prefix argument to `execute-extended-command'.
|
2012-05-01 12:10:02 -04:00
|
|
|
|
Noninteractively, the argument PREFIXARG is the prefix argument to
|
2014-02-08 05:13:46 -08:00
|
|
|
|
give to the command you invoke."
|
2012-05-01 12:10:02 -04:00
|
|
|
|
(interactive (list current-prefix-arg (read-extended-command)))
|
|
|
|
|
;; Emacs<24 calling-convention was with a single `prefixarg' argument.
|
2013-01-09 16:23:14 -05:00
|
|
|
|
(if (null command-name)
|
|
|
|
|
(setq command-name (let ((current-prefix-arg prefixarg)) ; for prompt
|
|
|
|
|
(read-extended-command))))
|
2012-05-01 12:10:02 -04:00
|
|
|
|
(let* ((function (and (stringp command-name) (intern-soft command-name)))
|
|
|
|
|
(binding (and suggest-key-bindings
|
2012-06-02 15:21:34 -04:00
|
|
|
|
(not executing-kbd-macro)
|
|
|
|
|
(where-is-internal function overriding-local-map t))))
|
2012-05-01 12:10:02 -04:00
|
|
|
|
(unless (commandp function)
|
|
|
|
|
(error "`%s' is not a valid command name" command-name))
|
|
|
|
|
(setq this-command function)
|
2012-06-02 15:21:34 -04:00
|
|
|
|
;; Normally `real-this-command' should never be changed, but here we really
|
|
|
|
|
;; want to pretend that M-x <cmd> RET is nothing more than a "key
|
|
|
|
|
;; binding" for <cmd>, so the command the user really wanted to run is
|
|
|
|
|
;; `function' and not `execute-extended-command'. The difference is
|
|
|
|
|
;; visible in cases such as M-x <cmd> RET and then C-x z (bug#11506).
|
|
|
|
|
(setq real-this-command function)
|
2012-05-01 12:10:02 -04:00
|
|
|
|
(let ((prefix-arg prefixarg))
|
|
|
|
|
(command-execute function 'record))
|
|
|
|
|
;; If enabled, show which key runs this command.
|
|
|
|
|
(when binding
|
|
|
|
|
;; But first wait, and skip the message if there is input.
|
|
|
|
|
(let* ((waited
|
|
|
|
|
;; If this command displayed something in the echo area;
|
|
|
|
|
;; wait a few seconds, then display our suggestion message.
|
|
|
|
|
(sit-for (cond
|
|
|
|
|
((zerop (length (current-message))) 0)
|
|
|
|
|
((numberp suggest-key-bindings) suggest-key-bindings)
|
|
|
|
|
(t 2)))))
|
|
|
|
|
(when (and waited (not (consp unread-command-events)))
|
|
|
|
|
(with-temp-message
|
|
|
|
|
(format "You can run the command `%s' with %s"
|
|
|
|
|
function (key-description binding))
|
|
|
|
|
(sit-for (if (numberp suggest-key-bindings)
|
|
|
|
|
suggest-key-bindings
|
|
|
|
|
2))))))))
|
2013-02-20 11:37:06 -05:00
|
|
|
|
|
|
|
|
|
(defun command-execute (cmd &optional record-flag keys special)
|
|
|
|
|
;; BEWARE: Called directly from the C code.
|
|
|
|
|
"Execute CMD as an editor command.
|
|
|
|
|
CMD must be a symbol that satisfies the `commandp' predicate.
|
|
|
|
|
Optional second arg RECORD-FLAG non-nil
|
|
|
|
|
means unconditionally put this command in the variable `command-history'.
|
|
|
|
|
Otherwise, that is done only if an arg is read using the minibuffer.
|
|
|
|
|
The argument KEYS specifies the value to use instead of (this-command-keys)
|
|
|
|
|
when reading the arguments; if it is nil, (this-command-keys) is used.
|
|
|
|
|
The argument SPECIAL, if non-nil, means that this command is executing
|
|
|
|
|
a special event, so ignore the prefix argument and don't clear it."
|
|
|
|
|
(setq debug-on-next-call nil)
|
|
|
|
|
(let ((prefixarg (unless special
|
|
|
|
|
(prog1 prefix-arg
|
|
|
|
|
(setq current-prefix-arg prefix-arg)
|
|
|
|
|
(setq prefix-arg nil)))))
|
2014-04-01 23:51:59 -07:00
|
|
|
|
(if (and (symbolp cmd)
|
2014-04-01 23:53:10 -07:00
|
|
|
|
(get cmd 'disabled)
|
|
|
|
|
disabled-command-function)
|
2014-04-01 23:51:59 -07:00
|
|
|
|
;; FIXME: Weird calling convention!
|
|
|
|
|
(run-hooks 'disabled-command-function)
|
|
|
|
|
(let ((final cmd))
|
|
|
|
|
(while
|
|
|
|
|
(progn
|
|
|
|
|
(setq final (indirect-function final))
|
|
|
|
|
(if (autoloadp final)
|
|
|
|
|
(setq final (autoload-do-load final cmd)))))
|
|
|
|
|
(cond
|
|
|
|
|
((arrayp final)
|
|
|
|
|
;; If requested, place the macro in the command history. For
|
|
|
|
|
;; other sorts of commands, call-interactively takes care of this.
|
|
|
|
|
(when record-flag
|
|
|
|
|
(push `(execute-kbd-macro ,final ,prefixarg) command-history)
|
|
|
|
|
;; Don't keep command history around forever.
|
|
|
|
|
(when (and (numberp history-length) (> history-length 0))
|
|
|
|
|
(let ((cell (nthcdr history-length command-history)))
|
|
|
|
|
(if (consp cell) (setcdr cell nil)))))
|
|
|
|
|
(execute-kbd-macro final prefixarg))
|
|
|
|
|
(t
|
|
|
|
|
;; Pass `cmd' rather than `final', for the backtrace's sake.
|
|
|
|
|
(prog1 (call-interactively cmd record-flag keys)
|
|
|
|
|
(when (and (symbolp cmd)
|
|
|
|
|
(get cmd 'byte-obsolete-info)
|
|
|
|
|
(not (get cmd 'command-execute-obsolete-warned)))
|
|
|
|
|
(put cmd 'command-execute-obsolete-warned t)
|
|
|
|
|
(message "%s" (macroexp--obsolete-warning
|
|
|
|
|
cmd (get cmd 'byte-obsolete-info) "command"))))))))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(defvar minibuffer-history nil
|
|
|
|
|
"Default minibuffer history list.
|
|
|
|
|
This is used for all minibuffer input
|
2007-12-22 17:12:30 +00:00
|
|
|
|
except when an alternate history list is specified.
|
|
|
|
|
|
|
|
|
|
Maximum length of the history list is determined by the value
|
|
|
|
|
of `history-length', which see.")
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(defvar minibuffer-history-sexp-flag nil
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"Control whether history list elements are expressions or strings.
|
|
|
|
|
If the value of this variable equals current minibuffer depth,
|
|
|
|
|
they are expressions; otherwise they are strings.
|
2005-12-23 21:50:38 +00:00
|
|
|
|
\(That convention is designed to do the right thing for
|
2004-04-16 12:51:06 +00:00
|
|
|
|
recursive uses of the minibuffer.)")
|
1992-07-26 19:54:20 +00:00
|
|
|
|
(setq minibuffer-history-variable 'minibuffer-history)
|
2006-05-06 23:57:11 +00:00
|
|
|
|
(setq minibuffer-history-position nil) ;; Defvar is in C code.
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(defvar minibuffer-history-search-history nil)
|
1992-07-26 19:54:20 +00:00
|
|
|
|
|
1997-05-05 11:54:37 +00:00
|
|
|
|
(defvar minibuffer-text-before-history nil
|
|
|
|
|
"Text that was in this minibuffer before any history commands.
|
|
|
|
|
This is nil if there have not yet been any history commands
|
|
|
|
|
in this use of the minibuffer.")
|
|
|
|
|
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'minibuffer-history-initialize)
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-initialize ()
|
|
|
|
|
(setq minibuffer-text-before-history nil))
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun minibuffer-avoid-prompt (_new _old)
|
2000-11-21 15:58:33 +00:00
|
|
|
|
"A point-motion hook for the minibuffer, that moves point out of the prompt."
|
|
|
|
|
(constrain-to-field nil (point-max)))
|
|
|
|
|
|
1998-05-26 20:55:22 +00:00
|
|
|
|
(defcustom minibuffer-history-case-insensitive-variables nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Minibuffer history variables for which matching should ignore case.
|
1998-05-26 20:55:22 +00:00
|
|
|
|
If a history variable is a member of this list, then the
|
|
|
|
|
\\[previous-matching-history-element] and \\[next-matching-history-element]\
|
|
|
|
|
commands ignore case when searching it, regardless of `case-fold-search'."
|
|
|
|
|
:type '(repeat variable)
|
|
|
|
|
:group 'minibuffer)
|
|
|
|
|
|
1992-07-26 19:54:20 +00:00
|
|
|
|
(defun previous-matching-history-element (regexp n)
|
1992-09-14 06:53:22 +00:00
|
|
|
|
"Find the previous history element that matches REGEXP.
|
|
|
|
|
\(Previous history elements refer to earlier actions.)
|
|
|
|
|
With prefix argument N, search for Nth previous match.
|
1997-12-22 21:33:35 +00:00
|
|
|
|
If N is negative, find the next or Nth next match.
|
2001-02-06 19:39:07 +00:00
|
|
|
|
Normally, history elements are matched case-insensitively if
|
|
|
|
|
`case-fold-search' is non-nil, but an uppercase letter in REGEXP
|
|
|
|
|
makes the search case-sensitive.
|
1998-05-26 20:55:22 +00:00
|
|
|
|
See also `minibuffer-history-case-insensitive-variables'."
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(interactive
|
1993-05-06 18:54:32 +00:00
|
|
|
|
(let* ((enable-recursive-minibuffers t)
|
|
|
|
|
(regexp (read-from-minibuffer "Previous element matching (regexp): "
|
|
|
|
|
nil
|
|
|
|
|
minibuffer-local-map
|
|
|
|
|
nil
|
2004-06-13 22:00:17 +00:00
|
|
|
|
'minibuffer-history-search-history
|
|
|
|
|
(car minibuffer-history-search-history))))
|
1993-05-06 18:54:32 +00:00
|
|
|
|
;; Use the last regexp specified, by default, if input is empty.
|
|
|
|
|
(list (if (string= regexp "")
|
1995-05-27 00:40:31 +00:00
|
|
|
|
(if minibuffer-history-search-history
|
|
|
|
|
(car minibuffer-history-search-history)
|
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 history search regexp"))
|
1993-05-06 18:54:32 +00:00
|
|
|
|
regexp)
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(prefix-numeric-value current-prefix-arg))))
|
2000-10-26 04:35:48 +00:00
|
|
|
|
(unless (zerop n)
|
|
|
|
|
(if (and (zerop minibuffer-history-position)
|
|
|
|
|
(null minibuffer-text-before-history))
|
2001-10-05 12:28:31 +00:00
|
|
|
|
(setq minibuffer-text-before-history
|
2001-10-05 15:16:24 +00:00
|
|
|
|
(minibuffer-contents-no-properties)))
|
2000-10-26 04:35:48 +00:00
|
|
|
|
(let ((history (symbol-value minibuffer-history-variable))
|
|
|
|
|
(case-fold-search
|
|
|
|
|
(if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped
|
|
|
|
|
;; On some systems, ignore case for file names.
|
|
|
|
|
(if (memq minibuffer-history-variable
|
|
|
|
|
minibuffer-history-case-insensitive-variables)
|
|
|
|
|
t
|
|
|
|
|
;; Respect the user's setting for case-fold-search:
|
|
|
|
|
case-fold-search)
|
|
|
|
|
nil))
|
|
|
|
|
prevpos
|
|
|
|
|
match-string
|
|
|
|
|
match-offset
|
|
|
|
|
(pos minibuffer-history-position))
|
|
|
|
|
(while (/= n 0)
|
|
|
|
|
(setq prevpos pos)
|
|
|
|
|
(setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
|
|
|
|
|
(when (= pos prevpos)
|
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 (if (= pos 1)
|
|
|
|
|
"No later matching history item"
|
|
|
|
|
"No earlier matching history item")))
|
2000-10-26 04:35:48 +00:00
|
|
|
|
(setq match-string
|
|
|
|
|
(if (eq minibuffer-history-sexp-flag (minibuffer-depth))
|
1994-09-14 09:01:02 +00:00
|
|
|
|
(let ((print-level nil))
|
2000-10-26 04:35:48 +00:00
|
|
|
|
(prin1-to-string (nth (1- pos) history)))
|
|
|
|
|
(nth (1- pos) history)))
|
|
|
|
|
(setq match-offset
|
|
|
|
|
(if (< n 0)
|
|
|
|
|
(and (string-match regexp match-string)
|
|
|
|
|
(match-end 0))
|
|
|
|
|
(and (string-match (concat ".*\\(" regexp "\\)") match-string)
|
|
|
|
|
(match-beginning 1))))
|
|
|
|
|
(when match-offset
|
|
|
|
|
(setq n (+ n (if (< n 0) 1 -1)))))
|
|
|
|
|
(setq minibuffer-history-position pos)
|
|
|
|
|
(goto-char (point-max))
|
2001-10-05 12:28:31 +00:00
|
|
|
|
(delete-minibuffer-contents)
|
2000-10-26 04:35:48 +00:00
|
|
|
|
(insert match-string)
|
2001-10-05 15:16:24 +00:00
|
|
|
|
(goto-char (+ (minibuffer-prompt-end) match-offset))))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(if (memq (car (car command-history)) '(previous-matching-history-element
|
|
|
|
|
next-matching-history-element))
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(setq command-history (cdr command-history))))
|
1992-07-26 19:54:20 +00:00
|
|
|
|
|
|
|
|
|
(defun next-matching-history-element (regexp n)
|
1992-09-14 06:53:22 +00:00
|
|
|
|
"Find the next history element that matches REGEXP.
|
|
|
|
|
\(The next history element refers to a more recent action.)
|
|
|
|
|
With prefix argument N, search for Nth next match.
|
1997-12-22 21:33:35 +00:00
|
|
|
|
If N is negative, find the previous or Nth previous match.
|
2001-02-06 19:39:07 +00:00
|
|
|
|
Normally, history elements are matched case-insensitively if
|
|
|
|
|
`case-fold-search' is non-nil, but an uppercase letter in REGEXP
|
|
|
|
|
makes the search case-sensitive."
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(interactive
|
1993-05-06 18:54:32 +00:00
|
|
|
|
(let* ((enable-recursive-minibuffers t)
|
|
|
|
|
(regexp (read-from-minibuffer "Next element matching (regexp): "
|
|
|
|
|
nil
|
|
|
|
|
minibuffer-local-map
|
|
|
|
|
nil
|
2004-12-27 16:34:43 +00:00
|
|
|
|
'minibuffer-history-search-history
|
|
|
|
|
(car minibuffer-history-search-history))))
|
1993-05-06 18:54:32 +00:00
|
|
|
|
;; Use the last regexp specified, by default, if input is empty.
|
|
|
|
|
(list (if (string= regexp "")
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(if minibuffer-history-search-history
|
|
|
|
|
(car minibuffer-history-search-history)
|
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 history search regexp"))
|
1993-05-06 18:54:32 +00:00
|
|
|
|
regexp)
|
1992-09-14 06:53:22 +00:00
|
|
|
|
(prefix-numeric-value current-prefix-arg))))
|
1992-07-26 19:54:20 +00:00
|
|
|
|
(previous-matching-history-element regexp (- n)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2000-10-03 17:32:34 +00:00
|
|
|
|
(defvar minibuffer-temporary-goal-position nil)
|
|
|
|
|
|
2008-03-29 22:56:17 +00:00
|
|
|
|
(defvar minibuffer-default-add-function 'minibuffer-default-add-completions
|
2008-11-17 00:45:25 +00:00
|
|
|
|
"Function run by `goto-history-element' before consuming default values.
|
|
|
|
|
This is useful to dynamically add more elements to the list of default values
|
2008-03-29 22:56:17 +00:00
|
|
|
|
when `goto-history-element' reaches the end of this list.
|
|
|
|
|
Before calling this function `goto-history-element' sets the variable
|
|
|
|
|
`minibuffer-default-add-done' to t, so it will call this function only
|
|
|
|
|
once. In special cases, when this function needs to be called more
|
|
|
|
|
than once, it can set `minibuffer-default-add-done' to nil explicitly,
|
|
|
|
|
overriding the setting of this variable to t in `goto-history-element'.")
|
|
|
|
|
|
|
|
|
|
(defvar minibuffer-default-add-done nil
|
|
|
|
|
"When nil, add more elements to the end of the list of default values.
|
|
|
|
|
The value nil causes `goto-history-element' to add more elements to
|
|
|
|
|
the list of defaults when it reaches the end of this list. It does
|
|
|
|
|
this by calling a function defined by `minibuffer-default-add-function'.")
|
|
|
|
|
|
|
|
|
|
(make-variable-buffer-local 'minibuffer-default-add-done)
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-default-add-completions ()
|
|
|
|
|
"Return a list of all completions without the default value.
|
|
|
|
|
This function is used to add all elements of the completion table to
|
|
|
|
|
the end of the list of defaults just after the default value."
|
|
|
|
|
(let ((def minibuffer-default)
|
|
|
|
|
(all (all-completions ""
|
|
|
|
|
minibuffer-completion-table
|
2009-11-13 14:50:17 +00:00
|
|
|
|
minibuffer-completion-predicate)))
|
2008-03-29 22:56:17 +00:00
|
|
|
|
(if (listp def)
|
|
|
|
|
(append def all)
|
|
|
|
|
(cons def (delete def all)))))
|
|
|
|
|
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(defun goto-history-element (nabs)
|
|
|
|
|
"Puts element of the minibuffer history in the minibuffer.
|
|
|
|
|
The argument NABS specifies the absolute history position."
|
|
|
|
|
(interactive "p")
|
2008-03-29 22:56:17 +00:00
|
|
|
|
(when (and (not minibuffer-default-add-done)
|
|
|
|
|
(functionp minibuffer-default-add-function)
|
|
|
|
|
(< nabs (- (if (listp minibuffer-default)
|
|
|
|
|
(length minibuffer-default)
|
|
|
|
|
1))))
|
|
|
|
|
(setq minibuffer-default-add-done t
|
|
|
|
|
minibuffer-default (funcall minibuffer-default-add-function)))
|
2007-10-22 00:17:55 +00:00
|
|
|
|
(let ((minimum (if minibuffer-default
|
|
|
|
|
(- (if (listp minibuffer-default)
|
|
|
|
|
(length minibuffer-default)
|
|
|
|
|
1))
|
|
|
|
|
0))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
elt minibuffer-returned-to-present)
|
|
|
|
|
(if (and (zerop minibuffer-history-position)
|
|
|
|
|
(null minibuffer-text-before-history))
|
|
|
|
|
(setq minibuffer-text-before-history
|
|
|
|
|
(minibuffer-contents-no-properties)))
|
|
|
|
|
(if (< nabs minimum)
|
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 (if minibuffer-default
|
|
|
|
|
"End of defaults; no next item"
|
|
|
|
|
"End of history; no default available")))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(if (> nabs (length (symbol-value minibuffer-history-variable)))
|
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 "Beginning of history; no preceding item"))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(unless (memq last-command '(next-history-element
|
|
|
|
|
previous-history-element))
|
|
|
|
|
(let ((prompt-end (minibuffer-prompt-end)))
|
|
|
|
|
(set (make-local-variable 'minibuffer-temporary-goal-position)
|
|
|
|
|
(cond ((<= (point) prompt-end) prompt-end)
|
|
|
|
|
((eobp) nil)
|
|
|
|
|
(t (point))))))
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(delete-minibuffer-contents)
|
|
|
|
|
(setq minibuffer-history-position nabs)
|
2007-10-22 00:17:55 +00:00
|
|
|
|
(cond ((< nabs 0)
|
|
|
|
|
(setq elt (if (listp minibuffer-default)
|
|
|
|
|
(nth (1- (abs nabs)) minibuffer-default)
|
|
|
|
|
minibuffer-default)))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
((= nabs 0)
|
|
|
|
|
(setq elt (or minibuffer-text-before-history ""))
|
|
|
|
|
(setq minibuffer-returned-to-present t)
|
|
|
|
|
(setq minibuffer-text-before-history nil))
|
|
|
|
|
(t (setq elt (nth (1- minibuffer-history-position)
|
|
|
|
|
(symbol-value minibuffer-history-variable)))))
|
|
|
|
|
(insert
|
|
|
|
|
(if (and (eq minibuffer-history-sexp-flag (minibuffer-depth))
|
|
|
|
|
(not minibuffer-returned-to-present))
|
|
|
|
|
(let ((print-level nil))
|
|
|
|
|
(prin1-to-string elt))
|
|
|
|
|
elt))
|
|
|
|
|
(goto-char (or minibuffer-temporary-goal-position (point-max)))))
|
|
|
|
|
|
1992-07-24 03:42:21 +00:00
|
|
|
|
(defun next-history-element (n)
|
2006-05-04 01:00:24 +00:00
|
|
|
|
"Puts next element of the minibuffer history in the minibuffer.
|
|
|
|
|
With argument N, it uses the Nth following element."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "p")
|
1995-02-12 08:27:38 +00:00
|
|
|
|
(or (zerop n)
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(goto-history-element (- minibuffer-history-position n))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1992-07-24 03:42:21 +00:00
|
|
|
|
(defun previous-history-element (n)
|
2006-05-04 01:00:24 +00:00
|
|
|
|
"Puts previous element of the minibuffer history in the minibuffer.
|
|
|
|
|
With argument N, it uses the Nth previous element."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "p")
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(or (zerop n)
|
|
|
|
|
(goto-history-element (+ minibuffer-history-position n))))
|
1993-01-25 00:45:01 +00:00
|
|
|
|
|
|
|
|
|
(defun next-complete-history-element (n)
|
1999-10-17 12:50:04 +00:00
|
|
|
|
"Get next history element which completes the minibuffer before the point.
|
|
|
|
|
The contents of the minibuffer after the point are deleted, and replaced
|
|
|
|
|
by the new completion."
|
1993-01-25 00:45:01 +00:00
|
|
|
|
(interactive "p")
|
1993-01-28 20:22:03 +00:00
|
|
|
|
(let ((point-at-start (point)))
|
|
|
|
|
(next-matching-history-element
|
1999-10-17 12:50:04 +00:00
|
|
|
|
(concat
|
2001-10-05 12:28:31 +00:00
|
|
|
|
"^" (regexp-quote (buffer-substring (minibuffer-prompt-end) (point))))
|
1999-10-17 12:50:04 +00:00
|
|
|
|
n)
|
1993-01-28 20:22:03 +00:00
|
|
|
|
;; next-matching-history-element always puts us at (point-min).
|
|
|
|
|
;; Move to the position we were at before changing the buffer contents.
|
2011-12-04 00:02:42 -08:00
|
|
|
|
;; This is still sensible, because the text before point has not changed.
|
1993-01-28 20:22:03 +00:00
|
|
|
|
(goto-char point-at-start)))
|
1993-01-25 00:45:01 +00:00
|
|
|
|
|
|
|
|
|
(defun previous-complete-history-element (n)
|
1993-12-24 02:44:13 +00:00
|
|
|
|
"\
|
1999-10-17 12:50:04 +00:00
|
|
|
|
Get previous history element which completes the minibuffer before the point.
|
|
|
|
|
The contents of the minibuffer after the point are deleted, and replaced
|
|
|
|
|
by the new completion."
|
1993-01-25 00:45:01 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(next-complete-history-element (- n)))
|
1999-10-17 12:50:04 +00:00
|
|
|
|
|
2001-10-05 12:28:31 +00:00
|
|
|
|
;; For compatibility with the old subr of the same name.
|
1999-10-17 12:50:04 +00:00
|
|
|
|
(defun minibuffer-prompt-width ()
|
|
|
|
|
"Return the display width of the minibuffer prompt.
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
Return 0 if current buffer is not a minibuffer."
|
1999-10-17 12:50:04 +00:00
|
|
|
|
;; Return the width of everything before the field at the end of
|
|
|
|
|
;; the buffer; this should be 0 for normal buffers.
|
2001-10-05 12:28:31 +00:00
|
|
|
|
(1- (minibuffer-prompt-end)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2007-07-23 20:29:55 +00:00
|
|
|
|
;; isearch minibuffer history
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'minibuffer-history-isearch-setup)
|
|
|
|
|
|
|
|
|
|
(defvar minibuffer-history-isearch-message-overlay)
|
|
|
|
|
(make-variable-buffer-local 'minibuffer-history-isearch-message-overlay)
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-setup ()
|
|
|
|
|
"Set up a minibuffer for using isearch to search the minibuffer history.
|
|
|
|
|
Intended to be added to `minibuffer-setup-hook'."
|
|
|
|
|
(set (make-local-variable 'isearch-search-fun-function)
|
|
|
|
|
'minibuffer-history-isearch-search)
|
|
|
|
|
(set (make-local-variable 'isearch-message-function)
|
|
|
|
|
'minibuffer-history-isearch-message)
|
|
|
|
|
(set (make-local-variable 'isearch-wrap-function)
|
|
|
|
|
'minibuffer-history-isearch-wrap)
|
|
|
|
|
(set (make-local-variable 'isearch-push-state-function)
|
|
|
|
|
'minibuffer-history-isearch-push-state)
|
|
|
|
|
(add-hook 'isearch-mode-end-hook 'minibuffer-history-isearch-end nil t))
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-end ()
|
|
|
|
|
"Clean up the minibuffer after terminating isearch in the minibuffer."
|
|
|
|
|
(if minibuffer-history-isearch-message-overlay
|
|
|
|
|
(delete-overlay minibuffer-history-isearch-message-overlay)))
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-search ()
|
|
|
|
|
"Return the proper search function, for isearch in minibuffer history."
|
2012-05-29 12:09:38 +03:00
|
|
|
|
(lambda (string bound noerror)
|
|
|
|
|
(let ((search-fun
|
|
|
|
|
;; Use standard functions to search within minibuffer text
|
|
|
|
|
(isearch-search-fun-default))
|
|
|
|
|
found)
|
|
|
|
|
;; Avoid lazy-highlighting matches in the minibuffer prompt when
|
|
|
|
|
;; searching forward. Lazy-highlight calls this lambda with the
|
|
|
|
|
;; bound arg, so skip the minibuffer prompt.
|
|
|
|
|
(if (and bound isearch-forward (< (point) (minibuffer-prompt-end)))
|
|
|
|
|
(goto-char (minibuffer-prompt-end)))
|
|
|
|
|
(or
|
|
|
|
|
;; 1. First try searching in the initial minibuffer text
|
|
|
|
|
(funcall search-fun string
|
|
|
|
|
(if isearch-forward bound (minibuffer-prompt-end))
|
|
|
|
|
noerror)
|
|
|
|
|
;; 2. If the above search fails, start putting next/prev history
|
|
|
|
|
;; elements in the minibuffer successively, and search the string
|
|
|
|
|
;; in them. Do this only when bound is nil (i.e. not while
|
|
|
|
|
;; lazy-highlighting search strings in the current minibuffer text).
|
|
|
|
|
(unless bound
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(while (not found)
|
|
|
|
|
(cond (isearch-forward
|
|
|
|
|
(next-history-element 1)
|
|
|
|
|
(goto-char (minibuffer-prompt-end)))
|
|
|
|
|
(t
|
|
|
|
|
(previous-history-element 1)
|
|
|
|
|
(goto-char (point-max))))
|
|
|
|
|
(setq isearch-barrier (point) isearch-opoint (point))
|
|
|
|
|
;; After putting the next/prev history element, search
|
|
|
|
|
;; the string in them again, until next-history-element
|
|
|
|
|
;; or previous-history-element raises an error at the
|
|
|
|
|
;; beginning/end of history.
|
|
|
|
|
(setq found (funcall search-fun string
|
|
|
|
|
(unless isearch-forward
|
|
|
|
|
;; For backward search, don't search
|
|
|
|
|
;; in the minibuffer prompt
|
|
|
|
|
(minibuffer-prompt-end))
|
|
|
|
|
noerror)))
|
|
|
|
|
;; Return point of the new search result
|
|
|
|
|
(point))
|
|
|
|
|
;; Return nil when next(prev)-history-element fails
|
|
|
|
|
(error nil)))))))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-message (&optional c-q-hack ellipsis)
|
|
|
|
|
"Display the minibuffer history search prompt.
|
|
|
|
|
If there are no search errors, this function displays an overlay with
|
|
|
|
|
the isearch prompt which replaces the original minibuffer prompt.
|
|
|
|
|
Otherwise, it displays the standard isearch message returned from
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
the function `isearch-message'."
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(if (not (and (minibufferp) isearch-success (not isearch-error)))
|
|
|
|
|
;; Use standard function `isearch-message' when not in the minibuffer,
|
|
|
|
|
;; or search fails, or has an error (like incomplete regexp).
|
|
|
|
|
;; This function overwrites minibuffer text with isearch message,
|
|
|
|
|
;; so it's possible to see what is wrong in the search string.
|
|
|
|
|
(isearch-message c-q-hack ellipsis)
|
|
|
|
|
;; Otherwise, put the overlay with the standard isearch prompt over
|
|
|
|
|
;; the initial minibuffer prompt.
|
|
|
|
|
(if (overlayp minibuffer-history-isearch-message-overlay)
|
|
|
|
|
(move-overlay minibuffer-history-isearch-message-overlay
|
|
|
|
|
(point-min) (minibuffer-prompt-end))
|
|
|
|
|
(setq minibuffer-history-isearch-message-overlay
|
|
|
|
|
(make-overlay (point-min) (minibuffer-prompt-end)))
|
|
|
|
|
(overlay-put minibuffer-history-isearch-message-overlay 'evaporate t))
|
|
|
|
|
(overlay-put minibuffer-history-isearch-message-overlay
|
|
|
|
|
'display (isearch-message-prefix c-q-hack ellipsis))
|
|
|
|
|
;; And clear any previous isearch message.
|
|
|
|
|
(message "")))
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-wrap ()
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Wrap the minibuffer history search when search fails.
|
2007-07-23 20:29:55 +00:00
|
|
|
|
Move point to the first history element for a forward search,
|
|
|
|
|
or to the last history element for a backward search."
|
2012-05-29 12:09:38 +03:00
|
|
|
|
;; When `minibuffer-history-isearch-search' fails on reaching the
|
|
|
|
|
;; beginning/end of the history, wrap the search to the first/last
|
|
|
|
|
;; minibuffer history element.
|
|
|
|
|
(if isearch-forward
|
|
|
|
|
(goto-history-element (length (symbol-value minibuffer-history-variable)))
|
|
|
|
|
(goto-history-element 0))
|
|
|
|
|
(setq isearch-success t)
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(goto-char (if isearch-forward (minibuffer-prompt-end) (point-max))))
|
|
|
|
|
|
|
|
|
|
(defun minibuffer-history-isearch-push-state ()
|
|
|
|
|
"Save a function restoring the state of minibuffer history search.
|
|
|
|
|
Save `minibuffer-history-position' to the additional state parameter
|
|
|
|
|
in the search status stack."
|
2013-01-08 15:15:15 -05:00
|
|
|
|
(let ((pos minibuffer-history-position))
|
|
|
|
|
(lambda (cmd)
|
|
|
|
|
(minibuffer-history-isearch-pop-state cmd pos))))
|
2007-07-23 20:29:55 +00:00
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun minibuffer-history-isearch-pop-state (_cmd hist-pos)
|
2007-07-23 20:29:55 +00:00
|
|
|
|
"Restore the minibuffer history search state.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
Go to the history element by the absolute history position HIST-POS."
|
2007-07-23 20:29:55 +00:00
|
|
|
|
(goto-history-element hist-pos))
|
|
|
|
|
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
;Put this on C-x u, so we can force that rather than C-_ into startup msg
|
2009-09-11 00:58:59 +00:00
|
|
|
|
(define-obsolete-function-alias 'advertised-undo 'undo "23.2")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(defconst undo-equiv-table (make-hash-table :test 'eq :weakness t)
|
2005-04-11 18:09:59 +00:00
|
|
|
|
"Table mapping redo records to the corresponding undo one.
|
|
|
|
|
A redo record for undo-in-region maps to t.
|
|
|
|
|
A redo record for ordinary undo maps to the following (earlier) undo.")
|
2003-05-13 19:45:01 +00:00
|
|
|
|
|
|
|
|
|
(defvar undo-in-region nil
|
|
|
|
|
"Non-nil if `pending-undo-list' is not just a tail of `buffer-undo-list'.")
|
|
|
|
|
|
|
|
|
|
(defvar undo-no-redo nil
|
|
|
|
|
"If t, `undo' doesn't go through redo entries.")
|
|
|
|
|
|
2005-01-29 17:24:41 +00:00
|
|
|
|
(defvar pending-undo-list nil
|
|
|
|
|
"Within a run of consecutive undo commands, list remaining to be undone.
|
2005-06-16 14:31:44 +00:00
|
|
|
|
If t, we undid all the way to the end of it.")
|
2005-01-29 17:24:41 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun undo (&optional arg)
|
|
|
|
|
"Undo some previous changes.
|
|
|
|
|
Repeat this command to undo more changes.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
A numeric ARG serves as a repeat count.
|
1998-03-14 08:19:27 +00:00
|
|
|
|
|
2000-10-26 07:44:46 +00:00
|
|
|
|
In Transient Mark mode when the mark is active, only undo changes within
|
2003-05-13 19:45:01 +00:00
|
|
|
|
the current region. Similarly, when not in Transient Mark mode, just \\[universal-argument]
|
2000-10-26 07:44:46 +00:00
|
|
|
|
as an argument limits undo to changes within the current region."
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(interactive "*P")
|
2001-12-13 07:43:28 +00:00
|
|
|
|
;; Make last-command indicate for the next command that this was an undo.
|
|
|
|
|
;; That way, another undo will undo more.
|
|
|
|
|
;; If we get to the end of the undo history and get an error,
|
|
|
|
|
;; another undo command will find the undo history empty
|
|
|
|
|
;; and will get another error. To begin undoing the undos,
|
|
|
|
|
;; you must type some other command.
|
2012-09-22 11:07:39 +08:00
|
|
|
|
(let* ((modified (buffer-modified-p))
|
|
|
|
|
;; For an indirect buffer, look in the base buffer for the
|
|
|
|
|
;; auto-save data.
|
|
|
|
|
(base-buffer (or (buffer-base-buffer) (current-buffer)))
|
|
|
|
|
(recent-save (with-current-buffer base-buffer
|
|
|
|
|
(recent-auto-save-p)))
|
|
|
|
|
message)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
;; If we get an error in undo-start,
|
|
|
|
|
;; the next command should not be a "consecutive undo".
|
|
|
|
|
;; So set `this-command' to something other than `undo'.
|
|
|
|
|
(setq this-command 'undo-start)
|
|
|
|
|
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(unless (and (eq last-command 'undo)
|
2005-01-29 17:24:41 +00:00
|
|
|
|
(or (eq pending-undo-list t)
|
|
|
|
|
;; If something (a timer or filter?) changed the buffer
|
|
|
|
|
;; since the previous command, don't continue the undo seq.
|
|
|
|
|
(let ((list buffer-undo-list))
|
|
|
|
|
(while (eq (car list) nil)
|
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
;; If the last undo record made was made by undo
|
|
|
|
|
;; it shows nothing else happened in between.
|
|
|
|
|
(gethash list undo-equiv-table))))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(setq undo-in-region
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(or (region-active-p) (and arg (not (numberp arg)))))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(if undo-in-region
|
2000-10-26 07:44:46 +00:00
|
|
|
|
(undo-start (region-beginning) (region-end))
|
|
|
|
|
(undo-start))
|
|
|
|
|
;; get rid of initial undo boundary
|
|
|
|
|
(undo-more 1))
|
2004-04-16 08:45:40 +00:00
|
|
|
|
;; If we got this far, the next command should be a consecutive undo.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(setq this-command 'undo)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
;; Check to see whether we're hitting a redo record, and if
|
|
|
|
|
;; so, ask the user whether she wants to skip the redo/undo pair.
|
|
|
|
|
(let ((equiv (gethash pending-undo-list undo-equiv-table)))
|
|
|
|
|
(or (eq (selected-window) (minibuffer-window))
|
2012-09-01 17:56:03 -07:00
|
|
|
|
(setq message (format "%s%s!"
|
|
|
|
|
(if (or undo-no-redo (not equiv))
|
|
|
|
|
"Undo" "Redo")
|
|
|
|
|
(if undo-in-region " in region" ""))))
|
2005-04-13 17:40:53 +00:00
|
|
|
|
(when (and (consp equiv) undo-no-redo)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
;; The equiv entry might point to another redo record if we have done
|
|
|
|
|
;; undo-redo-undo-redo-... so skip to the very last equiv.
|
|
|
|
|
(while (let ((next (gethash equiv undo-equiv-table)))
|
|
|
|
|
(if next (setq equiv next))))
|
|
|
|
|
(setq pending-undo-list equiv)))
|
2000-10-26 07:44:46 +00:00
|
|
|
|
(undo-more
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(if (numberp arg)
|
2000-10-26 07:44:46 +00:00
|
|
|
|
(prefix-numeric-value arg)
|
|
|
|
|
1))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
;; Record the fact that the just-generated undo records come from an
|
2005-04-11 18:09:59 +00:00
|
|
|
|
;; undo operation--that is, they are redo records.
|
|
|
|
|
;; In the ordinary case (not within a region), map the redo
|
|
|
|
|
;; record to the following undos.
|
2003-05-13 19:45:01 +00:00
|
|
|
|
;; I don't know how to do that in the undo-in-region case.
|
2009-03-14 01:51:34 +00:00
|
|
|
|
(let ((list buffer-undo-list))
|
|
|
|
|
;; Strip any leading undo boundaries there might be, like we do
|
|
|
|
|
;; above when checking.
|
|
|
|
|
(while (eq (car list) nil)
|
|
|
|
|
(setq list (cdr list)))
|
2014-04-12 15:20:44 -04:00
|
|
|
|
(puthash list
|
|
|
|
|
;; Prevent identity mapping. This can happen if
|
|
|
|
|
;; consecutive nils are erroneously in undo list.
|
|
|
|
|
(if (or undo-in-region (eq list pending-undo-list))
|
|
|
|
|
t
|
|
|
|
|
pending-undo-list)
|
2009-03-14 01:51:34 +00:00
|
|
|
|
undo-equiv-table))
|
1994-03-16 23:41:32 +00:00
|
|
|
|
;; Don't specify a position in the undo record for the undo command.
|
|
|
|
|
;; Instead, undoing this should move point to where the change is.
|
|
|
|
|
(let ((tail buffer-undo-list)
|
2001-09-06 08:49:34 +00:00
|
|
|
|
(prev nil))
|
|
|
|
|
(while (car tail)
|
|
|
|
|
(when (integerp (car tail))
|
|
|
|
|
(let ((pos (car tail)))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(if prev
|
|
|
|
|
(setcdr prev (cdr tail))
|
|
|
|
|
(setq buffer-undo-list (cdr tail)))
|
2001-09-06 08:49:34 +00:00
|
|
|
|
(setq tail (cdr tail))
|
|
|
|
|
(while (car tail)
|
|
|
|
|
(if (eq pos (car tail))
|
|
|
|
|
(if prev
|
|
|
|
|
(setcdr prev (cdr tail))
|
|
|
|
|
(setq buffer-undo-list (cdr tail)))
|
|
|
|
|
(setq prev tail))
|
|
|
|
|
(setq tail (cdr tail)))
|
|
|
|
|
(setq tail nil)))
|
|
|
|
|
(setq prev tail tail (cdr tail))))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
;; Record what the current undo list says,
|
|
|
|
|
;; so the next command can tell if the buffer was modified in between.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(and modified (not (buffer-modified-p))
|
2012-09-22 11:07:39 +08:00
|
|
|
|
(with-current-buffer base-buffer
|
|
|
|
|
(delete-auto-save-file-if-necessary recent-save)))
|
2005-10-29 19:48:22 +00:00
|
|
|
|
;; Display a message announcing success.
|
|
|
|
|
(if message
|
2007-12-06 00:17:56 +00:00
|
|
|
|
(message "%s" message))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2004-12-27 16:34:43 +00:00
|
|
|
|
(defun buffer-disable-undo (&optional buffer)
|
|
|
|
|
"Make BUFFER stop keeping undo information.
|
|
|
|
|
No argument or nil as argument means do this for the current buffer."
|
|
|
|
|
(interactive)
|
2004-12-28 05:11:26 +00:00
|
|
|
|
(with-current-buffer (if buffer (get-buffer buffer) (current-buffer))
|
2004-12-31 15:13:00 +00:00
|
|
|
|
(setq buffer-undo-list t)))
|
2004-12-27 16:34:43 +00:00
|
|
|
|
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(defun undo-only (&optional arg)
|
|
|
|
|
"Undo some previous changes.
|
|
|
|
|
Repeat this command to undo more changes.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
A numeric ARG serves as a repeat count.
|
2003-05-13 19:45:01 +00:00
|
|
|
|
Contrary to `undo', this will not redo a previous undo."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(let ((undo-no-redo t)) (undo arg)))
|
|
|
|
|
|
1998-07-09 04:49:24 +00:00
|
|
|
|
(defvar undo-in-progress nil
|
|
|
|
|
"Non-nil while performing an undo.
|
|
|
|
|
Some change-hooks test this variable to do something different.")
|
|
|
|
|
|
2005-06-16 14:31:44 +00:00
|
|
|
|
(defun undo-more (n)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Undo back N undo-boundaries beyond what was already undone recently.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
Call `undo-start' to get ready to undo recent changes,
|
|
|
|
|
then call `undo-more' one or more times to undo them."
|
2005-01-29 17:24:41 +00:00
|
|
|
|
(or (listp pending-undo-list)
|
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 (concat "No further undo information"
|
|
|
|
|
(and undo-in-region " for region"))))
|
1998-07-09 04:49:24 +00:00
|
|
|
|
(let ((undo-in-progress t))
|
2008-10-21 21:14:04 +00:00
|
|
|
|
;; Note: The following, while pulling elements off
|
|
|
|
|
;; `pending-undo-list' will call primitive change functions which
|
|
|
|
|
;; will push more elements onto `buffer-undo-list'.
|
2005-06-16 14:31:44 +00:00
|
|
|
|
(setq pending-undo-list (primitive-undo n pending-undo-list))
|
2005-01-29 17:24:41 +00:00
|
|
|
|
(if (null pending-undo-list)
|
|
|
|
|
(setq pending-undo-list t))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2013-01-08 14:13:31 -05:00
|
|
|
|
(defun primitive-undo (n list)
|
|
|
|
|
"Undo N records from the front of the list LIST.
|
|
|
|
|
Return what remains of the list."
|
|
|
|
|
|
|
|
|
|
;; This is a good feature, but would make undo-start
|
|
|
|
|
;; unable to do what is expected.
|
|
|
|
|
;;(when (null (car (list)))
|
|
|
|
|
;; ;; If the head of the list is a boundary, it is the boundary
|
|
|
|
|
;; ;; preceding this command. Get rid of it and don't count it.
|
|
|
|
|
;; (setq list (cdr list))))
|
|
|
|
|
|
|
|
|
|
(let ((arg n)
|
|
|
|
|
;; In a writable buffer, enable undoing read-only text that is
|
|
|
|
|
;; so because of text properties.
|
|
|
|
|
(inhibit-read-only t)
|
|
|
|
|
;; Don't let `intangible' properties interfere with undo.
|
|
|
|
|
(inhibit-point-motion-hooks t)
|
|
|
|
|
;; We use oldlist only to check for EQ. ++kfs
|
|
|
|
|
(oldlist buffer-undo-list)
|
|
|
|
|
(did-apply nil)
|
|
|
|
|
(next nil))
|
|
|
|
|
(while (> arg 0)
|
2013-01-08 15:15:15 -05:00
|
|
|
|
(while (setq next (pop list)) ;Exit inner loop at undo boundary.
|
2013-01-08 14:13:31 -05:00
|
|
|
|
;; Handle an integer by setting point to that value.
|
2013-01-08 15:15:15 -05:00
|
|
|
|
(pcase next
|
|
|
|
|
((pred integerp) (goto-char next))
|
|
|
|
|
;; Element (t . TIME) records previous modtime.
|
|
|
|
|
;; Preserve any flag of NONEXISTENT_MODTIME_NSECS or
|
|
|
|
|
;; UNKNOWN_MODTIME_NSECS.
|
|
|
|
|
(`(t . ,time)
|
|
|
|
|
;; If this records an obsolete save
|
|
|
|
|
;; (not matching the actual disk file)
|
|
|
|
|
;; then don't mark unmodified.
|
|
|
|
|
(when (or (equal time (visited-file-modtime))
|
|
|
|
|
(and (consp time)
|
|
|
|
|
(equal (list (car time) (cdr time))
|
|
|
|
|
(visited-file-modtime))))
|
|
|
|
|
(when (fboundp 'unlock-buffer)
|
|
|
|
|
(unlock-buffer))
|
|
|
|
|
(set-buffer-modified-p nil)))
|
|
|
|
|
;; Element (nil PROP VAL BEG . END) is property change.
|
|
|
|
|
(`(nil . ,(or `(,prop ,val ,beg . ,end) pcase--dontcare))
|
|
|
|
|
(when (or (> (point-min) beg) (< (point-max) end))
|
|
|
|
|
(error "Changes to be undone are outside visible portion of buffer"))
|
|
|
|
|
(put-text-property beg end prop val))
|
|
|
|
|
;; Element (BEG . END) means range was inserted.
|
|
|
|
|
(`(,(and beg (pred integerp)) . ,(and end (pred integerp)))
|
|
|
|
|
;; (and `(,beg . ,end) `(,(pred integerp) . ,(pred integerp)))
|
|
|
|
|
;; Ideally: `(,(pred integerp beg) . ,(pred integerp end))
|
|
|
|
|
(when (or (> (point-min) beg) (< (point-max) end))
|
|
|
|
|
(error "Changes to be undone are outside visible portion of buffer"))
|
|
|
|
|
;; Set point first thing, so that undoing this undo
|
|
|
|
|
;; does not send point back to where it is now.
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(delete-region beg end))
|
|
|
|
|
;; Element (apply FUN . ARGS) means call FUN to undo.
|
|
|
|
|
(`(apply . ,fun-args)
|
|
|
|
|
(let ((currbuff (current-buffer)))
|
|
|
|
|
(if (integerp (car fun-args))
|
|
|
|
|
;; Long format: (apply DELTA START END FUN . ARGS).
|
|
|
|
|
(pcase-let* ((`(,delta ,start ,end ,fun . ,args) fun-args)
|
|
|
|
|
(start-mark (copy-marker start nil))
|
|
|
|
|
(end-mark (copy-marker end t)))
|
|
|
|
|
(when (or (> (point-min) start) (< (point-max) end))
|
|
|
|
|
(error "Changes to be undone are outside visible portion of buffer"))
|
|
|
|
|
(apply fun args) ;; Use `save-current-buffer'?
|
|
|
|
|
;; Check that the function did what the entry
|
|
|
|
|
;; said it would do.
|
|
|
|
|
(unless (and (= start start-mark)
|
|
|
|
|
(= (+ delta end) end-mark))
|
|
|
|
|
(error "Changes to be undone by function different than announced"))
|
|
|
|
|
(set-marker start-mark nil)
|
|
|
|
|
(set-marker end-mark nil))
|
|
|
|
|
(apply fun-args))
|
|
|
|
|
(unless (eq currbuff (current-buffer))
|
|
|
|
|
(error "Undo function switched buffer"))
|
|
|
|
|
(setq did-apply t)))
|
|
|
|
|
;; Element (STRING . POS) means STRING was deleted.
|
|
|
|
|
(`(,(and string (pred stringp)) . ,(and pos (pred integerp)))
|
|
|
|
|
(when (let ((apos (abs pos)))
|
|
|
|
|
(or (< apos (point-min)) (> apos (point-max))))
|
|
|
|
|
(error "Changes to be undone are outside visible portion of buffer"))
|
2014-03-24 22:47:39 -04:00
|
|
|
|
(let (valid-marker-adjustments)
|
|
|
|
|
;; Check that marker adjustments which were recorded
|
|
|
|
|
;; with the (STRING . POS) record are still valid, ie
|
|
|
|
|
;; the markers haven't moved. We check their validity
|
|
|
|
|
;; before reinserting the string so as we don't need to
|
|
|
|
|
;; mind marker insertion-type.
|
|
|
|
|
(while (and (markerp (car-safe (car list)))
|
|
|
|
|
(integerp (cdr-safe (car list))))
|
|
|
|
|
(let* ((marker-adj (pop list))
|
|
|
|
|
(m (car marker-adj)))
|
|
|
|
|
(and (eq (marker-buffer m) (current-buffer))
|
|
|
|
|
(= pos m)
|
|
|
|
|
(push marker-adj valid-marker-adjustments))))
|
|
|
|
|
;; Insert string and adjust point
|
|
|
|
|
(if (< pos 0)
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (- pos))
|
|
|
|
|
(insert string))
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(insert string)
|
|
|
|
|
(goto-char pos))
|
|
|
|
|
;; Adjust the valid marker adjustments
|
|
|
|
|
(dolist (adj valid-marker-adjustments)
|
|
|
|
|
(set-marker (car adj)
|
|
|
|
|
(- (car adj) (cdr adj))))))
|
2013-01-08 15:15:15 -05:00
|
|
|
|
;; (MARKER . OFFSET) means a marker MARKER was adjusted by OFFSET.
|
|
|
|
|
(`(,(and marker (pred markerp)) . ,(and offset (pred integerp)))
|
2014-03-24 22:47:39 -04:00
|
|
|
|
(warn "Encountered %S entry in undo list with no matching (TEXT . POS) entry"
|
|
|
|
|
next)
|
|
|
|
|
;; Even though these elements are not expected in the undo
|
|
|
|
|
;; list, adjust them to be conservative for the 24.4
|
|
|
|
|
;; release. (Bug#16818)
|
2014-03-25 19:30:08 -04:00
|
|
|
|
(when (marker-buffer marker)
|
|
|
|
|
(set-marker marker
|
|
|
|
|
(- marker offset)
|
|
|
|
|
(marker-buffer marker))))
|
2013-01-08 15:15:15 -05:00
|
|
|
|
(_ (error "Unrecognized entry in undo list %S" next))))
|
2013-01-08 14:13:31 -05:00
|
|
|
|
(setq arg (1- arg)))
|
|
|
|
|
;; Make sure an apply entry produces at least one undo entry,
|
|
|
|
|
;; so the test in `undo' for continuing an undo series
|
|
|
|
|
;; will work right.
|
|
|
|
|
(if (and did-apply
|
|
|
|
|
(eq oldlist buffer-undo-list))
|
|
|
|
|
(setq buffer-undo-list
|
|
|
|
|
(cons (list 'apply 'cdr nil) buffer-undo-list))))
|
|
|
|
|
list)
|
|
|
|
|
|
1998-03-14 08:19:27 +00:00
|
|
|
|
;; Deep copy of a list
|
|
|
|
|
(defun undo-copy-list (list)
|
|
|
|
|
"Make a copy of undo list LIST."
|
|
|
|
|
(mapcar 'undo-copy-list-1 list))
|
|
|
|
|
|
|
|
|
|
(defun undo-copy-list-1 (elt)
|
|
|
|
|
(if (consp elt)
|
|
|
|
|
(cons (car elt) (undo-copy-list-1 (cdr elt)))
|
|
|
|
|
elt))
|
|
|
|
|
|
|
|
|
|
(defun undo-start (&optional beg end)
|
|
|
|
|
"Set `pending-undo-list' to the front of the undo list.
|
|
|
|
|
The next call to `undo-more' will undo the most recently made change.
|
|
|
|
|
If BEG and END are specified, then only undo elements
|
|
|
|
|
that apply to text between BEG and END are used; other undo elements
|
|
|
|
|
are ignored. If BEG and END are nil, all undo elements are used."
|
|
|
|
|
(if (eq buffer-undo-list t)
|
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 undo information in this buffer"))
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(setq pending-undo-list
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(if (and beg end (not (= beg end)))
|
|
|
|
|
(undo-make-selective-list (min beg end) (max beg end))
|
|
|
|
|
buffer-undo-list)))
|
|
|
|
|
|
|
|
|
|
(defun undo-make-selective-list (start end)
|
|
|
|
|
"Return a list of undo elements for the region START to END.
|
|
|
|
|
The elements come from `buffer-undo-list', but we keep only
|
|
|
|
|
the elements inside this region, and discard those outside this region.
|
|
|
|
|
If we find an element that crosses an edge of this region,
|
|
|
|
|
we stop and ignore all further elements."
|
|
|
|
|
(let ((undo-list-copy (undo-copy-list buffer-undo-list))
|
|
|
|
|
(undo-list (list nil))
|
|
|
|
|
some-rejected
|
2011-04-19 15:44:55 +02:00
|
|
|
|
undo-elt temp-undo-list delta)
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(while undo-list-copy
|
|
|
|
|
(setq undo-elt (car undo-list-copy))
|
|
|
|
|
(let ((keep-this
|
|
|
|
|
(cond ((and (consp undo-elt) (eq (car undo-elt) t))
|
|
|
|
|
;; This is a "was unmodified" element.
|
|
|
|
|
;; Keep it if we have kept everything thus far.
|
|
|
|
|
(not some-rejected))
|
2014-03-24 22:47:39 -04:00
|
|
|
|
;; Skip over marker adjustments, instead relying on
|
|
|
|
|
;; finding them after (TEXT . POS) elements
|
|
|
|
|
((markerp (car-safe undo-elt))
|
|
|
|
|
nil)
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(t
|
|
|
|
|
(undo-elt-in-region undo-elt start end)))))
|
|
|
|
|
(if keep-this
|
|
|
|
|
(progn
|
|
|
|
|
(setq end (+ end (cdr (undo-delta undo-elt))))
|
|
|
|
|
;; Don't put two nils together in the list
|
2014-03-24 22:47:39 -04:00
|
|
|
|
(when (not (and (eq (car undo-list) nil)
|
|
|
|
|
(eq undo-elt nil)))
|
|
|
|
|
(setq undo-list (cons undo-elt undo-list))
|
|
|
|
|
;; If (TEXT . POS), "keep" its subsequent (MARKER
|
|
|
|
|
;; . ADJUSTMENT) whose markers haven't moved.
|
|
|
|
|
(when (and (stringp (car-safe undo-elt))
|
|
|
|
|
(integerp (cdr-safe undo-elt)))
|
|
|
|
|
(let ((list-i (cdr undo-list-copy)))
|
|
|
|
|
(while (markerp (car-safe (car list-i)))
|
|
|
|
|
(let* ((adj-elt (pop list-i))
|
|
|
|
|
(m (car adj-elt)))
|
|
|
|
|
(and (eq (marker-buffer m) (current-buffer))
|
|
|
|
|
(= (cdr undo-elt) m)
|
|
|
|
|
(push adj-elt undo-list))))))))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(if (undo-elt-crosses-region undo-elt start end)
|
|
|
|
|
(setq undo-list-copy nil)
|
|
|
|
|
(setq some-rejected t)
|
|
|
|
|
(setq temp-undo-list (cdr undo-list-copy))
|
|
|
|
|
(setq delta (undo-delta undo-elt))
|
|
|
|
|
|
|
|
|
|
(when (/= (cdr delta) 0)
|
|
|
|
|
(let ((position (car delta))
|
|
|
|
|
(offset (cdr delta)))
|
|
|
|
|
|
2001-10-31 00:57:04 +00:00
|
|
|
|
;; Loop down the earlier events adjusting their buffer
|
|
|
|
|
;; positions to reflect the fact that a change to the buffer
|
|
|
|
|
;; isn't being undone. We only need to process those element
|
|
|
|
|
;; types which undo-elt-in-region will return as being in
|
|
|
|
|
;; the region since only those types can ever get into the
|
|
|
|
|
;; output
|
1998-03-14 08:19:27 +00:00
|
|
|
|
|
|
|
|
|
(while temp-undo-list
|
|
|
|
|
(setq undo-elt (car temp-undo-list))
|
|
|
|
|
(cond ((integerp undo-elt)
|
|
|
|
|
(if (>= undo-elt position)
|
|
|
|
|
(setcar temp-undo-list (- undo-elt offset))))
|
|
|
|
|
((atom undo-elt) nil)
|
|
|
|
|
((stringp (car undo-elt))
|
|
|
|
|
;; (TEXT . POSITION)
|
|
|
|
|
(let ((text-pos (abs (cdr undo-elt)))
|
|
|
|
|
(point-at-end (< (cdr undo-elt) 0 )))
|
|
|
|
|
(if (>= text-pos position)
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(setcdr undo-elt (* (if point-at-end -1 1)
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(- text-pos offset))))))
|
|
|
|
|
((integerp (car undo-elt))
|
|
|
|
|
;; (BEGIN . END)
|
|
|
|
|
(when (>= (car undo-elt) position)
|
|
|
|
|
(setcar undo-elt (- (car undo-elt) offset))
|
|
|
|
|
(setcdr undo-elt (- (cdr undo-elt) offset))))
|
|
|
|
|
((null (car undo-elt))
|
|
|
|
|
;; (nil PROPERTY VALUE BEG . END)
|
|
|
|
|
(let ((tail (nthcdr 3 undo-elt)))
|
|
|
|
|
(when (>= (car tail) position)
|
|
|
|
|
(setcar tail (- (car tail) offset))
|
|
|
|
|
(setcdr tail (- (cdr tail) offset))))))
|
|
|
|
|
(setq temp-undo-list (cdr temp-undo-list))))))))
|
|
|
|
|
(setq undo-list-copy (cdr undo-list-copy)))
|
|
|
|
|
(nreverse undo-list)))
|
|
|
|
|
|
|
|
|
|
(defun undo-elt-in-region (undo-elt start end)
|
|
|
|
|
"Determine whether UNDO-ELT falls inside the region START ... END.
|
2014-03-24 22:47:39 -04:00
|
|
|
|
If it crosses the edge, we return nil.
|
|
|
|
|
|
|
|
|
|
Generally this function is not useful for determining
|
|
|
|
|
whether (MARKER . ADJUSTMENT) undo elements are in the region,
|
|
|
|
|
because markers can be arbitrarily relocated. Instead, pass the
|
|
|
|
|
marker adjustment's corresponding (TEXT . POS) element."
|
1998-03-14 08:19:27 +00:00
|
|
|
|
(cond ((integerp undo-elt)
|
|
|
|
|
(and (>= undo-elt start)
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(<= undo-elt end)))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
((eq undo-elt nil)
|
|
|
|
|
t)
|
|
|
|
|
((atom undo-elt)
|
|
|
|
|
nil)
|
|
|
|
|
((stringp (car undo-elt))
|
|
|
|
|
;; (TEXT . POSITION)
|
|
|
|
|
(and (>= (abs (cdr undo-elt)) start)
|
2014-03-02 12:37:32 -05:00
|
|
|
|
(<= (abs (cdr undo-elt)) end)))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
((and (consp undo-elt) (markerp (car undo-elt)))
|
2014-03-24 22:47:39 -04:00
|
|
|
|
;; (MARKER . ADJUSTMENT)
|
|
|
|
|
(<= start (car undo-elt) end))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
((null (car undo-elt))
|
|
|
|
|
;; (nil PROPERTY VALUE BEG . END)
|
|
|
|
|
(let ((tail (nthcdr 3 undo-elt)))
|
|
|
|
|
(and (>= (car tail) start)
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(<= (cdr tail) end))))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
((integerp (car undo-elt))
|
|
|
|
|
;; (BEGIN . END)
|
|
|
|
|
(and (>= (car undo-elt) start)
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(<= (cdr undo-elt) end)))))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
|
|
|
|
|
(defun undo-elt-crosses-region (undo-elt start end)
|
|
|
|
|
"Test whether UNDO-ELT crosses one edge of that region START ... END.
|
|
|
|
|
This assumes we have already decided that UNDO-ELT
|
|
|
|
|
is not *inside* the region START...END."
|
|
|
|
|
(cond ((atom undo-elt) nil)
|
|
|
|
|
((null (car undo-elt))
|
|
|
|
|
;; (nil PROPERTY VALUE BEG . END)
|
|
|
|
|
(let ((tail (nthcdr 3 undo-elt)))
|
2006-10-02 02:30:06 +00:00
|
|
|
|
(and (< (car tail) end)
|
|
|
|
|
(> (cdr tail) start))))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
((integerp (car undo-elt))
|
|
|
|
|
;; (BEGIN . END)
|
2006-10-02 02:30:06 +00:00
|
|
|
|
(and (< (car undo-elt) end)
|
|
|
|
|
(> (cdr undo-elt) start)))))
|
1998-03-14 08:19:27 +00:00
|
|
|
|
|
|
|
|
|
;; Return the first affected buffer position and the delta for an undo element
|
|
|
|
|
;; delta is defined as the change in subsequent buffer positions if we *did*
|
|
|
|
|
;; the undo.
|
|
|
|
|
(defun undo-delta (undo-elt)
|
|
|
|
|
(if (consp undo-elt)
|
|
|
|
|
(cond ((stringp (car undo-elt))
|
|
|
|
|
;; (TEXT . POSITION)
|
|
|
|
|
(cons (abs (cdr undo-elt)) (length (car undo-elt))))
|
|
|
|
|
((integerp (car undo-elt))
|
|
|
|
|
;; (BEGIN . END)
|
|
|
|
|
(cons (car undo-elt) (- (car undo-elt) (cdr undo-elt))))
|
|
|
|
|
(t
|
|
|
|
|
'(0 . 0)))
|
|
|
|
|
'(0 . 0)))
|
2004-12-21 11:37:52 +00:00
|
|
|
|
|
2006-07-11 19:15:33 +00:00
|
|
|
|
(defcustom undo-ask-before-discard nil
|
2005-01-30 00:32:39 +00:00
|
|
|
|
"If non-nil ask about discarding undo info for the current command.
|
|
|
|
|
Normally, Emacs discards the undo info for the current command if
|
|
|
|
|
it exceeds `undo-outer-limit'. But if you set this option
|
|
|
|
|
non-nil, it asks in the echo area whether to discard the info.
|
2006-10-11 06:27:08 +00:00
|
|
|
|
If you answer no, there is a slight risk that Emacs might crash, so
|
2005-01-30 00:32:39 +00:00
|
|
|
|
only do it if you really want to undo the command.
|
|
|
|
|
|
|
|
|
|
This option is mainly intended for debugging. You have to be
|
|
|
|
|
careful if you use it for other purposes. Garbage collection is
|
|
|
|
|
inhibited while the question is asked, meaning that Emacs might
|
|
|
|
|
leak memory. So you should make sure that you do not wait
|
|
|
|
|
excessively long before answering the question."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'undo
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1")
|
2005-01-30 00:32:39 +00:00
|
|
|
|
|
2004-12-29 01:33:04 +00:00
|
|
|
|
(defvar undo-extra-outer-limit nil
|
|
|
|
|
"If non-nil, an extra level of size that's ok in an undo item.
|
|
|
|
|
We don't ask the user about truncating the undo list until the
|
2005-01-30 00:32:39 +00:00
|
|
|
|
current item gets bigger than this amount.
|
|
|
|
|
|
|
|
|
|
This variable only matters if `undo-ask-before-discard' is non-nil.")
|
2004-12-29 01:33:04 +00:00
|
|
|
|
(make-variable-buffer-local 'undo-extra-outer-limit)
|
|
|
|
|
|
2005-01-30 00:32:39 +00:00
|
|
|
|
;; When the first undo batch in an undo list is longer than
|
|
|
|
|
;; undo-outer-limit, this function gets called to warn the user that
|
|
|
|
|
;; the undo info for the current command was discarded. Garbage
|
|
|
|
|
;; collection is inhibited around the call, so it had better not do a
|
|
|
|
|
;; lot of consing.
|
2004-12-21 11:37:52 +00:00
|
|
|
|
(setq undo-outer-limit-function 'undo-outer-limit-truncate)
|
|
|
|
|
(defun undo-outer-limit-truncate (size)
|
2005-01-30 00:32:39 +00:00
|
|
|
|
(if undo-ask-before-discard
|
|
|
|
|
(when (or (null undo-extra-outer-limit)
|
|
|
|
|
(> size undo-extra-outer-limit))
|
|
|
|
|
;; Don't ask the question again unless it gets even bigger.
|
|
|
|
|
;; This applies, in particular, if the user quits from the question.
|
|
|
|
|
;; Such a quit quits out of GC, but something else will call GC
|
|
|
|
|
;; again momentarily. It will call this function again,
|
|
|
|
|
;; but we don't want to ask the question again.
|
|
|
|
|
(setq undo-extra-outer-limit (+ size 50000))
|
|
|
|
|
(if (let (use-dialog-box track-mouse executing-kbd-macro )
|
2006-05-01 20:17:24 +00:00
|
|
|
|
(yes-or-no-p (format "Buffer `%s' undo info is %d bytes long; discard it? "
|
2005-01-30 00:32:39 +00:00
|
|
|
|
(buffer-name) size)))
|
|
|
|
|
(progn (setq buffer-undo-list nil)
|
|
|
|
|
(setq undo-extra-outer-limit nil)
|
|
|
|
|
t)
|
|
|
|
|
nil))
|
|
|
|
|
(display-warning '(undo discard-info)
|
|
|
|
|
(concat
|
2006-05-01 20:17:24 +00:00
|
|
|
|
(format "Buffer `%s' undo info was %d bytes long.\n"
|
2005-01-30 00:32:39 +00:00
|
|
|
|
(buffer-name) size)
|
|
|
|
|
"The undo info was discarded because it exceeded \
|
|
|
|
|
`undo-outer-limit'.
|
|
|
|
|
|
|
|
|
|
This is normal if you executed a command that made a huge change
|
|
|
|
|
to the buffer. In that case, to prevent similar problems in the
|
|
|
|
|
future, set `undo-outer-limit' to a value that is large enough to
|
|
|
|
|
cover the maximum size of normal changes you expect a single
|
|
|
|
|
command to make, but not so large that it might exceed the
|
|
|
|
|
maximum memory allotted to Emacs.
|
|
|
|
|
|
|
|
|
|
If you did not execute any such command, the situation is
|
|
|
|
|
probably due to a bug and you should report it.
|
|
|
|
|
|
|
|
|
|
You can disable the popping up of this buffer by adding the entry
|
2009-03-14 17:43:16 +00:00
|
|
|
|
\(undo discard-info) to the user option `warning-suppress-types',
|
|
|
|
|
which is defined in the `warnings' library.\n")
|
2005-01-30 00:32:39 +00:00
|
|
|
|
:warning)
|
|
|
|
|
(setq buffer-undo-list nil)
|
|
|
|
|
t))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
|
2014-01-17 17:45:45 +01:00
|
|
|
|
(defcustom password-word-equivalents
|
|
|
|
|
'("password" "passphrase" "pass phrase"
|
2014-01-18 14:23:38 -08:00
|
|
|
|
; These are sorted according to the GNU en_US locale.
|
|
|
|
|
"암호" ; ko
|
|
|
|
|
"パスワード" ; ja
|
|
|
|
|
"ପ୍ରବେଶ ସଙ୍କେତ" ; or
|
|
|
|
|
"ពាក្យសម្ងាត់" ; km
|
|
|
|
|
"adgangskode" ; da
|
|
|
|
|
"contraseña" ; es
|
|
|
|
|
"contrasenya" ; ca
|
|
|
|
|
"geslo" ; sl
|
|
|
|
|
"hasło" ; pl
|
|
|
|
|
"heslo" ; cs, sk
|
|
|
|
|
"iphasiwedi" ; zu
|
|
|
|
|
"jelszó" ; hu
|
|
|
|
|
"lösenord" ; sv
|
|
|
|
|
"lozinka" ; hr, sr
|
|
|
|
|
"mật khẩu" ; vi
|
|
|
|
|
"mot de passe" ; fr
|
|
|
|
|
"parola" ; tr
|
|
|
|
|
"pasahitza" ; eu
|
|
|
|
|
"passord" ; nb
|
|
|
|
|
"passwort" ; de
|
|
|
|
|
"pasvorto" ; eo
|
|
|
|
|
"salasana" ; fi
|
|
|
|
|
"senha" ; pt
|
|
|
|
|
"slaptažodis" ; lt
|
|
|
|
|
"wachtwoord" ; nl
|
|
|
|
|
"كلمة السر" ; ar
|
|
|
|
|
"ססמה" ; he
|
|
|
|
|
"лозинка" ; sr
|
|
|
|
|
"пароль" ; kk, ru, uk
|
|
|
|
|
"गुप्तशब्द" ; mr
|
|
|
|
|
"शब्दकूट" ; hi
|
|
|
|
|
"પાસવર્ડ" ; gu
|
|
|
|
|
"సంకేతపదము" ; te
|
|
|
|
|
"ਪਾਸਵਰਡ" ; pa
|
|
|
|
|
"ಗುಪ್ತಪದ" ; kn
|
|
|
|
|
"கடவுச்சொல்" ; ta
|
|
|
|
|
"അടയാളവാക്ക്" ; ml
|
|
|
|
|
"গুপ্তশব্দ" ; as
|
|
|
|
|
"পাসওয়ার্ড" ; bn_IN
|
|
|
|
|
"රහස්පදය" ; si
|
|
|
|
|
"密码" ; zh_CN
|
|
|
|
|
"密碼" ; zh_TW
|
2014-01-17 17:45:45 +01:00
|
|
|
|
)
|
|
|
|
|
"List of words equivalent to \"password\".
|
|
|
|
|
This is used by Shell mode and other parts of Emacs to recognize
|
|
|
|
|
password prompts, including prompts in languages other than
|
|
|
|
|
English. Different case choices should not be assumed to be
|
|
|
|
|
included; callers should bind `case-fold-search' to t."
|
|
|
|
|
:type '(repeat string)
|
|
|
|
|
:version "24.4"
|
|
|
|
|
:group 'processes)
|
|
|
|
|
|
1993-07-31 06:10:44 +00:00
|
|
|
|
(defvar shell-command-history nil
|
2007-12-22 17:12:30 +00:00
|
|
|
|
"History list for some commands that read shell commands.
|
|
|
|
|
|
|
|
|
|
Maximum length of the history list is determined by the value
|
|
|
|
|
of `history-length', which see.")
|
1993-07-31 06:10:44 +00:00
|
|
|
|
|
2009-11-12 06:55:39 +00:00
|
|
|
|
(defvar shell-command-switch (purecopy "-c")
|
1994-11-01 05:50:57 +00:00
|
|
|
|
"Switch used to have the shell execute its command line argument.")
|
|
|
|
|
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(defvar shell-command-default-error-buffer nil
|
2012-04-09 21:05:48 +08:00
|
|
|
|
"Buffer name for `shell-command' and `shell-command-on-region' error output.
|
2002-06-29 18:16:27 +00:00
|
|
|
|
This buffer is used when `shell-command' or `shell-command-on-region'
|
1999-03-01 03:19:32 +00:00
|
|
|
|
is run interactively. A value of nil means that output to stderr and
|
|
|
|
|
stdout will be intermixed in the output stream.")
|
|
|
|
|
|
2008-04-22 19:50:11 +00:00
|
|
|
|
(declare-function mailcap-file-default-commands "mailcap" (files))
|
2009-11-11 00:11:40 +00:00
|
|
|
|
(declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
|
2008-04-22 19:50:11 +00:00
|
|
|
|
|
|
|
|
|
(defun minibuffer-default-add-shell-commands ()
|
2009-01-01 09:14:42 +00:00
|
|
|
|
"Return a list of all commands associated with the current file.
|
2008-10-19 15:01:46 +00:00
|
|
|
|
This function is used to add all related commands retrieved by `mailcap'
|
2008-04-22 19:50:11 +00:00
|
|
|
|
to the end of the list of defaults just after the default value."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((filename (if (listp minibuffer-default)
|
|
|
|
|
(car minibuffer-default)
|
|
|
|
|
minibuffer-default))
|
|
|
|
|
(commands (and filename (require 'mailcap nil t)
|
|
|
|
|
(mailcap-file-default-commands (list filename)))))
|
|
|
|
|
(setq commands (mapcar (lambda (command)
|
|
|
|
|
(concat command " " filename))
|
|
|
|
|
commands))
|
|
|
|
|
(if (listp minibuffer-default)
|
|
|
|
|
(append minibuffer-default commands)
|
|
|
|
|
(cons minibuffer-default commands))))
|
|
|
|
|
|
2011-05-12 09:55:10 -03:00
|
|
|
|
(declare-function shell-completion-vars "shell" ())
|
2008-10-12 22:45:27 +00:00
|
|
|
|
|
2008-03-20 19:48:07 +00:00
|
|
|
|
(defvar minibuffer-local-shell-command-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map minibuffer-local-map)
|
2011-05-02 22:52:52 -03:00
|
|
|
|
(define-key map "\t" 'completion-at-point)
|
2008-03-20 19:48:07 +00:00
|
|
|
|
map)
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Keymap used for completing shell commands in minibuffer.")
|
2008-03-20 19:48:07 +00:00
|
|
|
|
|
|
|
|
|
(defun read-shell-command (prompt &optional initial-contents hist &rest args)
|
|
|
|
|
"Read a shell command from the minibuffer.
|
|
|
|
|
The arguments are the same as the ones of `read-from-minibuffer',
|
|
|
|
|
except READ and KEYMAP are missing and HIST defaults
|
|
|
|
|
to `shell-command-history'."
|
2011-05-02 22:52:52 -03:00
|
|
|
|
(require 'shell)
|
2008-07-31 16:51:21 +00:00
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
2011-05-12 09:55:10 -03:00
|
|
|
|
(shell-completion-vars)
|
2008-07-31 16:51:21 +00:00
|
|
|
|
(set (make-local-variable 'minibuffer-default-add-function)
|
|
|
|
|
'minibuffer-default-add-shell-commands))
|
|
|
|
|
(apply 'read-from-minibuffer prompt initial-contents
|
|
|
|
|
minibuffer-local-shell-command-map
|
|
|
|
|
nil
|
|
|
|
|
(or hist 'shell-command-history)
|
|
|
|
|
args)))
|
2008-03-20 19:48:07 +00:00
|
|
|
|
|
2012-07-29 03:03:26 +03:00
|
|
|
|
(defcustom async-shell-command-buffer 'confirm-new-buffer
|
|
|
|
|
"What to do when the output buffer is used by another shell command.
|
|
|
|
|
This option specifies how to resolve the conflict where a new command
|
|
|
|
|
wants to direct its output to the buffer `*Async Shell Command*',
|
|
|
|
|
but this buffer is already taken by another running shell command.
|
|
|
|
|
|
|
|
|
|
The value `confirm-kill-process' is used to ask for confirmation before
|
|
|
|
|
killing the already running process and running a new process
|
|
|
|
|
in the same buffer, `confirm-new-buffer' for confirmation before running
|
|
|
|
|
the command in a new buffer with a name other than the default buffer name,
|
|
|
|
|
`new-buffer' for doing the same without confirmation,
|
|
|
|
|
`confirm-rename-buffer' for confirmation before renaming the existing
|
|
|
|
|
output buffer and running a new command in the default buffer,
|
|
|
|
|
`rename-buffer' for doing the same without confirmation."
|
|
|
|
|
:type '(choice (const :tag "Confirm killing of running command"
|
|
|
|
|
confirm-kill-process)
|
|
|
|
|
(const :tag "Confirm creation of a new buffer"
|
|
|
|
|
confirm-new-buffer)
|
|
|
|
|
(const :tag "Create a new buffer"
|
|
|
|
|
new-buffer)
|
|
|
|
|
(const :tag "Confirm renaming of existing buffer"
|
|
|
|
|
confirm-rename-buffer)
|
|
|
|
|
(const :tag "Rename the existing buffer"
|
|
|
|
|
rename-buffer))
|
|
|
|
|
:group 'shell
|
2012-08-15 09:29:11 -07:00
|
|
|
|
:version "24.3")
|
2012-07-29 03:03:26 +03:00
|
|
|
|
|
2009-07-02 22:47:52 +00:00
|
|
|
|
(defun async-shell-command (command &optional output-buffer error-buffer)
|
|
|
|
|
"Execute string COMMAND asynchronously in background.
|
|
|
|
|
|
2012-07-17 21:40:15 +03:00
|
|
|
|
Like `shell-command', but adds `&' at the end of COMMAND
|
|
|
|
|
to execute it asynchronously.
|
|
|
|
|
|
2010-05-17 15:27:26 -04:00
|
|
|
|
The output appears in the buffer `*Async Shell Command*'.
|
2012-07-17 21:40:15 +03:00
|
|
|
|
That buffer is in shell mode.
|
2010-05-17 15:27:26 -04:00
|
|
|
|
|
2013-12-03 03:19:24 +02:00
|
|
|
|
You can configure `async-shell-command-buffer' to specify what to do in
|
|
|
|
|
case when `*Async Shell Command*' buffer is already taken by another
|
|
|
|
|
running shell command. To run COMMAND without displaying the output
|
|
|
|
|
in a window you can configure `display-buffer-alist' to use the action
|
|
|
|
|
`display-buffer-no-window' for the buffer `*Async Shell Command*'.
|
|
|
|
|
|
2010-05-17 15:27:26 -04:00
|
|
|
|
In Elisp, you will often be better served by calling `start-process'
|
|
|
|
|
directly, since it offers more control and does not impose the use of a
|
|
|
|
|
shell (with its need to quote arguments)."
|
2009-07-02 22:47:52 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
|
|
|
|
(read-shell-command "Async shell command: " nil nil
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(let ((filename
|
|
|
|
|
(cond
|
|
|
|
|
(buffer-file-name)
|
|
|
|
|
((eq major-mode 'dired-mode)
|
|
|
|
|
(dired-get-filename nil t)))))
|
|
|
|
|
(and filename (file-relative-name filename))))
|
2009-07-02 22:47:52 +00:00
|
|
|
|
current-prefix-arg
|
|
|
|
|
shell-command-default-error-buffer))
|
|
|
|
|
(unless (string-match "&[ \t]*\\'" command)
|
|
|
|
|
(setq command (concat command " &")))
|
|
|
|
|
(shell-command command output-buffer error-buffer))
|
|
|
|
|
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(defun shell-command (command &optional output-buffer error-buffer)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Execute string COMMAND in inferior shell; display output, if any.
|
2000-11-25 08:48:13 +00:00
|
|
|
|
With prefix argument, insert the COMMAND's output at point.
|
1995-03-21 05:14:38 +00:00
|
|
|
|
|
2012-07-17 21:40:15 +03:00
|
|
|
|
If COMMAND ends in `&', execute it asynchronously.
|
1995-03-21 05:14:38 +00:00
|
|
|
|
The output appears in the buffer `*Async Shell Command*'.
|
2012-07-17 21:40:15 +03:00
|
|
|
|
That buffer is in shell mode. You can also use
|
|
|
|
|
`async-shell-command' that automatically adds `&'.
|
1995-03-21 05:14:38 +00:00
|
|
|
|
|
2000-11-08 17:35:57 +00:00
|
|
|
|
Otherwise, COMMAND is executed synchronously. The output appears in
|
|
|
|
|
the buffer `*Shell Command Output*'. If the output is short enough to
|
|
|
|
|
display in the echo area (which is determined by the variables
|
|
|
|
|
`resize-mini-windows' and `max-mini-window-height'), it is shown
|
|
|
|
|
there, but it is nonetheless available in buffer `*Shell Command
|
2001-10-31 00:57:04 +00:00
|
|
|
|
Output*' even though that buffer is not automatically displayed.
|
1994-10-15 10:16:09 +00:00
|
|
|
|
|
1997-08-04 00:51:07 +00:00
|
|
|
|
To specify a coding system for converting non-ASCII characters
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
in the shell command output, use \\[universal-coding-system-argument] \
|
1997-08-04 00:51:07 +00:00
|
|
|
|
before this command.
|
|
|
|
|
|
|
|
|
|
Noninteractive callers can specify coding systems by binding
|
|
|
|
|
`coding-system-for-read' and `coding-system-for-write'.
|
|
|
|
|
|
1994-10-15 10:16:09 +00:00
|
|
|
|
The optional second argument OUTPUT-BUFFER, if non-nil,
|
|
|
|
|
says to put the output in some other buffer.
|
|
|
|
|
If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
|
|
|
|
|
If OUTPUT-BUFFER is not a buffer and not nil,
|
|
|
|
|
insert output in current buffer. (This cannot be done asynchronously.)
|
2009-11-14 16:07:44 +00:00
|
|
|
|
In either case, the buffer is first erased, and the output is
|
|
|
|
|
inserted after point (leaving mark after it).
|
1999-03-01 03:19:32 +00:00
|
|
|
|
|
2001-12-13 07:43:28 +00:00
|
|
|
|
If the command terminates without error, but generates output,
|
|
|
|
|
and you did not specify \"insert it in the current buffer\",
|
|
|
|
|
the output can be displayed in the echo area or in its buffer.
|
|
|
|
|
If the output is short enough to display in the echo area
|
|
|
|
|
\(determined by the variable `max-mini-window-height' if
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
`resize-mini-windows' is non-nil), it is shown there.
|
|
|
|
|
Otherwise,the buffer containing the output is displayed.
|
2001-12-13 07:43:28 +00:00
|
|
|
|
|
|
|
|
|
If there is output and an error, and you did not specify \"insert it
|
|
|
|
|
in the current buffer\", a message about the error goes at the end
|
|
|
|
|
of the output.
|
|
|
|
|
|
|
|
|
|
If there is no output, or if output is inserted in the current buffer,
|
|
|
|
|
then `*Shell Command Output*' is deleted.
|
|
|
|
|
|
1999-03-01 03:19:32 +00:00
|
|
|
|
If the optional third argument ERROR-BUFFER is non-nil, it is a buffer
|
|
|
|
|
or buffer name to which to direct the command's standard error output.
|
|
|
|
|
If it is nil, error output is mingled with regular output.
|
|
|
|
|
In an interactive call, the variable `shell-command-default-error-buffer'
|
2010-05-17 15:27:26 -04:00
|
|
|
|
specifies the value of ERROR-BUFFER.
|
|
|
|
|
|
|
|
|
|
In Elisp, you will often be better served by calling `call-process' or
|
|
|
|
|
`start-process' directly, since it offers more control and does not impose
|
|
|
|
|
the use of a shell (with its need to quote arguments)."
|
1999-03-01 03:19:32 +00:00
|
|
|
|
|
2008-04-22 19:50:11 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list
|
2008-07-31 16:51:21 +00:00
|
|
|
|
(read-shell-command "Shell command: " nil nil
|
2009-11-11 00:11:40 +00:00
|
|
|
|
(let ((filename
|
|
|
|
|
(cond
|
|
|
|
|
(buffer-file-name)
|
|
|
|
|
((eq major-mode 'dired-mode)
|
|
|
|
|
(dired-get-filename nil t)))))
|
|
|
|
|
(and filename (file-relative-name filename))))
|
2008-04-22 19:50:11 +00:00
|
|
|
|
current-prefix-arg
|
|
|
|
|
shell-command-default-error-buffer))
|
1996-02-21 21:25:30 +00:00
|
|
|
|
;; Look for a handler in case default-directory is a remote file name.
|
|
|
|
|
(let ((handler
|
|
|
|
|
(find-file-name-handler (directory-file-name default-directory)
|
|
|
|
|
'shell-command)))
|
|
|
|
|
(if handler
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(funcall handler 'shell-command command output-buffer error-buffer)
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(if (and output-buffer
|
|
|
|
|
(not (or (bufferp output-buffer) (stringp output-buffer))))
|
2001-12-13 07:43:28 +00:00
|
|
|
|
;; Output goes in current buffer.
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(let ((error-file
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(if error-buffer
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(make-temp-file
|
1999-09-02 12:05:07 +00:00
|
|
|
|
(expand-file-name "scor"
|
|
|
|
|
(or small-temporary-file-directory
|
|
|
|
|
temporary-file-directory)))
|
1999-03-01 03:19:32 +00:00
|
|
|
|
nil)))
|
|
|
|
|
(barf-if-buffer-read-only)
|
1999-06-10 01:19:33 +00:00
|
|
|
|
(push-mark nil t)
|
1999-03-01 03:19:32 +00:00
|
|
|
|
;; We do not use -f for csh; we will not support broken use of
|
|
|
|
|
;; .cshrcs. Even the BSD csh manual says to use
|
|
|
|
|
;; "if ($?prompt) exit" before things which are not useful
|
|
|
|
|
;; non-interactively. Besides, if someone wants their other
|
|
|
|
|
;; aliases for shell commands then they can still have them.
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(call-process shell-file-name nil
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(if error-file
|
|
|
|
|
(list t error-file)
|
|
|
|
|
t)
|
|
|
|
|
nil shell-command-switch command)
|
|
|
|
|
(when (and error-file (file-exists-p error-file))
|
|
|
|
|
(if (< 0 (nth 7 (file-attributes error-file)))
|
|
|
|
|
(with-current-buffer (get-buffer-create error-buffer)
|
|
|
|
|
(let ((pos-from-end (- (point-max) (point))))
|
|
|
|
|
(or (bobp)
|
|
|
|
|
(insert "\f\n"))
|
|
|
|
|
;; Do no formatting while reading error file,
|
|
|
|
|
;; because that can run a shell command, and we
|
|
|
|
|
;; don't want that to cause an infinite recursion.
|
|
|
|
|
(format-insert-file error-file nil)
|
|
|
|
|
;; Put point after the inserted errors.
|
|
|
|
|
(goto-char (- (point-max) pos-from-end)))
|
|
|
|
|
(display-buffer (current-buffer))))
|
|
|
|
|
(delete-file error-file))
|
|
|
|
|
;; This is like exchange-point-and-mark, but doesn't
|
|
|
|
|
;; activate the mark. It is cleaner to avoid activation,
|
|
|
|
|
;; even though the command loop would deactivate the mark
|
|
|
|
|
;; because we inserted text.
|
|
|
|
|
(goto-char (prog1 (mark t)
|
|
|
|
|
(set-marker (mark-marker) (point)
|
|
|
|
|
(current-buffer)))))
|
2001-12-13 07:43:28 +00:00
|
|
|
|
;; Output goes in a separate buffer.
|
1996-02-21 21:25:30 +00:00
|
|
|
|
;; Preserve the match data in case called from a program.
|
|
|
|
|
(save-match-data
|
2002-06-26 08:59:32 +00:00
|
|
|
|
(if (string-match "[ \t]*&[ \t]*\\'" command)
|
1996-02-21 21:25:30 +00:00
|
|
|
|
;; Command ending with ampersand means asynchronous.
|
|
|
|
|
(let ((buffer (get-buffer-create
|
|
|
|
|
(or output-buffer "*Async Shell Command*")))
|
|
|
|
|
(directory default-directory)
|
|
|
|
|
proc)
|
|
|
|
|
;; Remove the ampersand.
|
|
|
|
|
(setq command (substring command 0 (match-beginning 0)))
|
2012-07-29 03:03:26 +03:00
|
|
|
|
;; Ask the user what to do with already running process.
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(setq proc (get-buffer-process buffer))
|
2012-07-29 03:03:26 +03:00
|
|
|
|
(when proc
|
|
|
|
|
(cond
|
|
|
|
|
((eq async-shell-command-buffer 'confirm-kill-process)
|
|
|
|
|
;; If will kill a process, query first.
|
|
|
|
|
(if (yes-or-no-p "A command is running in the default buffer. Kill it? ")
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(kill-process proc)
|
|
|
|
|
(error "Shell command in progress")))
|
2012-07-29 03:03:26 +03:00
|
|
|
|
((eq async-shell-command-buffer 'confirm-new-buffer)
|
|
|
|
|
;; If will create a new buffer, query first.
|
|
|
|
|
(if (yes-or-no-p "A command is running in the default buffer. Use a new buffer? ")
|
|
|
|
|
(setq buffer (generate-new-buffer
|
|
|
|
|
(or output-buffer "*Async Shell Command*")))
|
|
|
|
|
(error "Shell command in progress")))
|
|
|
|
|
((eq async-shell-command-buffer 'new-buffer)
|
|
|
|
|
;; It will create a new buffer.
|
|
|
|
|
(setq buffer (generate-new-buffer
|
|
|
|
|
(or output-buffer "*Async Shell Command*"))))
|
|
|
|
|
((eq async-shell-command-buffer 'confirm-rename-buffer)
|
|
|
|
|
;; If will rename the buffer, query first.
|
|
|
|
|
(if (yes-or-no-p "A command is running in the default buffer. Rename it? ")
|
|
|
|
|
(progn
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(rename-uniquely))
|
|
|
|
|
(setq buffer (get-buffer-create
|
|
|
|
|
(or output-buffer "*Async Shell Command*"))))
|
|
|
|
|
(error "Shell command in progress")))
|
|
|
|
|
((eq async-shell-command-buffer 'rename-buffer)
|
|
|
|
|
;; It will rename the buffer.
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(rename-uniquely))
|
|
|
|
|
(setq buffer (get-buffer-create
|
|
|
|
|
(or output-buffer "*Async Shell Command*"))))))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(with-current-buffer buffer
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(setq buffer-read-only nil)
|
2011-01-13 19:58:28 +01:00
|
|
|
|
;; Setting buffer-read-only to nil doesn't suffice
|
|
|
|
|
;; if some text has a non-nil read-only property,
|
|
|
|
|
;; which comint sometimes adds for prompts.
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(erase-buffer))
|
2013-12-03 03:19:24 +02:00
|
|
|
|
(display-buffer buffer '(nil (allow-no-window . t)))
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(setq default-directory directory)
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(setq proc (start-process "Shell" buffer shell-file-name
|
1996-02-21 21:25:30 +00:00
|
|
|
|
shell-command-switch command))
|
|
|
|
|
(setq mode-line-process '(":%s"))
|
2003-05-16 21:17:52 +00:00
|
|
|
|
(require 'shell) (shell-mode)
|
1996-02-21 21:25:30 +00:00
|
|
|
|
(set-process-sentinel proc 'shell-command-sentinel)
|
2009-09-10 00:54:36 +00:00
|
|
|
|
;; Use the comint filter for proper handling of carriage motion
|
|
|
|
|
;; (see `comint-inhibit-carriage-motion'),.
|
|
|
|
|
(set-process-filter proc 'comint-output-filter)
|
1996-02-21 21:25:30 +00:00
|
|
|
|
))
|
2009-09-10 00:54:36 +00:00
|
|
|
|
;; Otherwise, command is executed synchronously.
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(shell-command-on-region (point) (point) command
|
|
|
|
|
output-buffer nil error-buffer)))))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2000-10-06 11:35:56 +00:00
|
|
|
|
(defun display-message-or-buffer (message
|
|
|
|
|
&optional buffer-name not-this-window frame)
|
|
|
|
|
"Display MESSAGE in the echo area if possible, otherwise in a pop-up buffer.
|
|
|
|
|
MESSAGE may be either a string or a buffer.
|
|
|
|
|
|
|
|
|
|
A buffer is displayed using `display-buffer' if MESSAGE is too long for
|
2000-11-08 17:35:57 +00:00
|
|
|
|
the maximum height of the echo area, as defined by `max-mini-window-height'
|
|
|
|
|
if `resize-mini-windows' is non-nil.
|
2000-10-06 11:35:56 +00:00
|
|
|
|
|
2000-10-08 01:37:42 +00:00
|
|
|
|
Returns either the string shown in the echo area, or when a pop-up
|
|
|
|
|
buffer is used, the window used to display it.
|
|
|
|
|
|
2000-10-06 11:35:56 +00:00
|
|
|
|
If MESSAGE is a string, then the optional argument BUFFER-NAME is the
|
|
|
|
|
name of the buffer used to display it in the case where a pop-up buffer
|
|
|
|
|
is used, defaulting to `*Message*'. In the case where MESSAGE is a
|
|
|
|
|
string and it is displayed in the echo area, it is not specified whether
|
|
|
|
|
the contents are inserted into the buffer anyway.
|
|
|
|
|
|
|
|
|
|
Optional arguments NOT-THIS-WINDOW and FRAME are as for `display-buffer',
|
|
|
|
|
and only used if a buffer is displayed."
|
2007-03-19 18:28:31 +00:00
|
|
|
|
(cond ((and (stringp message) (not (string-match "\n" message)))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
;; Trivial case where we can use the echo area
|
|
|
|
|
(message "%s" message))
|
|
|
|
|
((and (stringp message)
|
2007-03-19 18:28:31 +00:00
|
|
|
|
(= (string-match "\n" message) (1- (length message))))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
;; Trivial case where we can just remove single trailing newline
|
|
|
|
|
(message "%s" (substring message 0 (1- (length message)))))
|
|
|
|
|
(t
|
|
|
|
|
;; General case
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(if (bufferp message)
|
|
|
|
|
message
|
|
|
|
|
(get-buffer-create (or buffer-name "*Message*")))
|
|
|
|
|
|
|
|
|
|
(unless (bufferp message)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert message))
|
|
|
|
|
|
|
|
|
|
(let ((lines
|
|
|
|
|
(if (= (buffer-size) 0)
|
|
|
|
|
0
|
2006-02-04 12:19:27 +00:00
|
|
|
|
(count-screen-lines nil nil nil (minibuffer-window)))))
|
2002-10-26 22:40:31 +00:00
|
|
|
|
(cond ((= lines 0))
|
|
|
|
|
((and (or (<= lines 1)
|
2002-06-26 08:59:32 +00:00
|
|
|
|
(<= lines
|
|
|
|
|
(if resize-mini-windows
|
|
|
|
|
(cond ((floatp max-mini-window-height)
|
|
|
|
|
(* (frame-height)
|
|
|
|
|
max-mini-window-height))
|
|
|
|
|
((integerp max-mini-window-height)
|
|
|
|
|
max-mini-window-height)
|
|
|
|
|
(t
|
|
|
|
|
1))
|
|
|
|
|
1)))
|
|
|
|
|
;; Don't use the echo area if the output buffer is
|
2011-11-17 01:09:20 -08:00
|
|
|
|
;; already displayed in the selected frame.
|
2002-06-29 18:13:06 +00:00
|
|
|
|
(not (get-buffer-window (current-buffer))))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
;; Echo area
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(when (bolp)
|
|
|
|
|
(backward-char 1))
|
|
|
|
|
(message "%s" (buffer-substring (point-min) (point))))
|
|
|
|
|
(t
|
|
|
|
|
;; Buffer
|
|
|
|
|
(goto-char (point-min))
|
2001-10-15 01:01:21 +00:00
|
|
|
|
(display-buffer (current-buffer)
|
|
|
|
|
not-this-window frame))))))))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
;; We have a sentinel to prevent insertion of a termination message
|
|
|
|
|
;; in the buffer itself.
|
|
|
|
|
(defun shell-command-sentinel (process signal)
|
1995-07-17 23:03:53 +00:00
|
|
|
|
(if (memq (process-status process) '(exit signal))
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(message "%s: %s."
|
1995-07-17 23:03:53 +00:00
|
|
|
|
(car (cdr (cdr (process-command process))))
|
|
|
|
|
(substring signal 0 -1))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1994-10-15 10:16:09 +00:00
|
|
|
|
(defun shell-command-on-region (start end command
|
1997-08-15 23:41:50 +00:00
|
|
|
|
&optional output-buffer replace
|
2004-08-22 16:59:57 +00:00
|
|
|
|
error-buffer display-error-buffer)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Execute string COMMAND in inferior shell with region as input.
|
|
|
|
|
Normally display output (if any) in temp buffer `*Shell Command Output*';
|
1999-01-23 21:50:18 +00:00
|
|
|
|
Prefix arg means replace the region with it. Return the exit code of
|
|
|
|
|
COMMAND.
|
1995-02-28 18:04:57 +00:00
|
|
|
|
|
1997-08-04 00:51:07 +00:00
|
|
|
|
To specify a coding system for converting non-ASCII characters
|
|
|
|
|
in the input and output to the shell command, use \\[universal-coding-system-argument]
|
|
|
|
|
before this command. By default, the input (from the current buffer)
|
2012-04-09 19:56:35 +03:00
|
|
|
|
is encoded using coding-system specified by `process-coding-system-alist',
|
|
|
|
|
falling back to `default-process-coding-system' if no match for COMMAND
|
|
|
|
|
is found in `process-coding-system-alist'.
|
1997-08-04 00:51:07 +00:00
|
|
|
|
|
2004-08-22 16:59:57 +00:00
|
|
|
|
Noninteractive callers can specify coding systems by binding
|
|
|
|
|
`coding-system-for-read' and `coding-system-for-write'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2001-12-13 07:43:28 +00:00
|
|
|
|
If the command generates output, the output may be displayed
|
|
|
|
|
in the echo area or in a buffer.
|
|
|
|
|
If the output is short enough to display in the echo area
|
|
|
|
|
\(determined by the variable `max-mini-window-height' if
|
2012-09-22 23:24:26 +08:00
|
|
|
|
`resize-mini-windows' is non-nil), it is shown there.
|
|
|
|
|
Otherwise it is displayed in the buffer `*Shell Command Output*'.
|
|
|
|
|
The output is available in that buffer in both cases.
|
2001-12-13 07:43:28 +00:00
|
|
|
|
|
|
|
|
|
If there is output and an error, a message about the error
|
2012-09-22 23:24:26 +08:00
|
|
|
|
appears at the end of the output. If there is no output, or if
|
|
|
|
|
output is inserted in the current buffer, the buffer `*Shell
|
|
|
|
|
Command Output*' is deleted.
|
|
|
|
|
|
|
|
|
|
Optional fourth arg OUTPUT-BUFFER specifies where to put the
|
2013-06-18 23:24:44 +03:00
|
|
|
|
command's output. If the value is a buffer or buffer name,
|
|
|
|
|
put the output there. If the value is nil, use the buffer
|
|
|
|
|
`*Shell Command Output*'. Any other value, excluding nil,
|
|
|
|
|
means to insert the output in the current buffer. In either case,
|
|
|
|
|
the output is inserted after point (leaving mark after it).
|
2012-09-22 23:24:26 +08:00
|
|
|
|
|
|
|
|
|
Optional fifth arg REPLACE, if non-nil, means to insert the
|
|
|
|
|
output in place of text from START to END, putting point and mark
|
1998-10-16 18:07:03 +00:00
|
|
|
|
around it.
|
|
|
|
|
|
2012-09-22 23:24:26 +08:00
|
|
|
|
Optional sixth arg ERROR-BUFFER, if non-nil, specifies a buffer
|
|
|
|
|
or buffer name to which to direct the command's standard error
|
|
|
|
|
output. If nil, error output is mingled with regular output.
|
|
|
|
|
When called interactively, `shell-command-default-error-buffer'
|
|
|
|
|
is used for ERROR-BUFFER.
|
|
|
|
|
|
|
|
|
|
Optional seventh arg DISPLAY-ERROR-BUFFER, if non-nil, means to
|
|
|
|
|
display the error buffer if there were any errors. When called
|
|
|
|
|
interactively, this is t."
|
2002-02-01 04:20:02 +00:00
|
|
|
|
(interactive (let (string)
|
|
|
|
|
(unless (mark)
|
|
|
|
|
(error "The mark is not set now, so there is no region"))
|
|
|
|
|
;; Do this before calling region-beginning
|
|
|
|
|
;; and region-end, in case subprocess output
|
|
|
|
|
;; relocates them while we are in the minibuffer.
|
2008-03-20 19:48:07 +00:00
|
|
|
|
(setq string (read-shell-command "Shell command on region: "))
|
1995-11-10 17:33:26 +00:00
|
|
|
|
;; call-interactively recognizes region-beginning and
|
|
|
|
|
;; region-end specially, leaving them in the history.
|
|
|
|
|
(list (region-beginning) (region-end)
|
1995-02-23 05:02:54 +00:00
|
|
|
|
string
|
|
|
|
|
current-prefix-arg
|
1999-01-18 00:25:23 +00:00
|
|
|
|
current-prefix-arg
|
2004-08-22 16:59:57 +00:00
|
|
|
|
shell-command-default-error-buffer
|
|
|
|
|
t)))
|
1997-08-15 23:41:50 +00:00
|
|
|
|
(let ((error-file
|
1999-09-02 12:05:07 +00:00
|
|
|
|
(if error-buffer
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(make-temp-file
|
1999-09-02 12:05:07 +00:00
|
|
|
|
(expand-file-name "scor"
|
|
|
|
|
(or small-temporary-file-directory
|
|
|
|
|
temporary-file-directory)))
|
1999-01-23 21:50:18 +00:00
|
|
|
|
nil))
|
|
|
|
|
exit-status)
|
1999-01-18 00:25:23 +00:00
|
|
|
|
(if (or replace
|
|
|
|
|
(and output-buffer
|
1999-02-26 03:48:07 +00:00
|
|
|
|
(not (or (bufferp output-buffer) (stringp output-buffer)))))
|
1999-01-18 00:25:23 +00:00
|
|
|
|
;; Replace specified region with output from command.
|
|
|
|
|
(let ((swap (and replace (< start end))))
|
|
|
|
|
;; Don't muck with mark unless REPLACE says we should.
|
|
|
|
|
(goto-char start)
|
2002-03-09 09:06:04 +00:00
|
|
|
|
(and replace (push-mark (point) 'nomsg))
|
1999-01-23 21:50:18 +00:00
|
|
|
|
(setq exit-status
|
2013-05-23 17:01:47 -04:00
|
|
|
|
(call-process-region start end shell-file-name replace
|
1999-01-23 21:50:18 +00:00
|
|
|
|
(if error-file
|
|
|
|
|
(list t error-file)
|
|
|
|
|
t)
|
|
|
|
|
nil shell-command-switch command))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
;; It is rude to delete a buffer which the command is not using.
|
|
|
|
|
;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
|
|
|
|
|
;; (and shell-buffer (not (eq shell-buffer (current-buffer)))
|
|
|
|
|
;; (kill-buffer shell-buffer)))
|
1999-01-18 00:25:23 +00:00
|
|
|
|
;; Don't muck with mark unless REPLACE says we should.
|
|
|
|
|
(and replace swap (exchange-point-and-mark)))
|
|
|
|
|
;; No prefix argument: put the output in a temp buffer,
|
|
|
|
|
;; replacing its entire contents.
|
|
|
|
|
(let ((buffer (get-buffer-create
|
2002-06-29 18:08:32 +00:00
|
|
|
|
(or output-buffer "*Shell Command Output*"))))
|
1999-01-18 00:25:23 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(if (eq buffer (current-buffer))
|
|
|
|
|
;; If the input is the same buffer as the output,
|
|
|
|
|
;; delete everything but the specified region,
|
|
|
|
|
;; then replace that region with the output.
|
|
|
|
|
(progn (setq buffer-read-only nil)
|
|
|
|
|
(delete-region (max start end) (point-max))
|
|
|
|
|
(delete-region (point-min) (min start end))
|
|
|
|
|
(setq exit-status
|
|
|
|
|
(call-process-region (point-min) (point-max)
|
1999-11-15 16:11:14 +00:00
|
|
|
|
shell-file-name t
|
1999-01-18 00:25:23 +00:00
|
|
|
|
(if error-file
|
|
|
|
|
(list t error-file)
|
|
|
|
|
t)
|
1999-01-23 21:50:18 +00:00
|
|
|
|
nil shell-command-switch
|
|
|
|
|
command)))
|
|
|
|
|
;; Clear the output buffer, then run the command with
|
|
|
|
|
;; output there.
|
2000-04-25 19:14:45 +00:00
|
|
|
|
(let ((directory default-directory))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
2000-04-25 19:14:45 +00:00
|
|
|
|
(setq buffer-read-only nil)
|
|
|
|
|
(if (not output-buffer)
|
|
|
|
|
(setq default-directory directory))
|
|
|
|
|
(erase-buffer)))
|
1999-01-18 00:25:23 +00:00
|
|
|
|
(setq exit-status
|
|
|
|
|
(call-process-region start end shell-file-name nil
|
|
|
|
|
(if error-file
|
|
|
|
|
(list buffer error-file)
|
|
|
|
|
buffer)
|
1999-01-23 21:50:18 +00:00
|
|
|
|
nil shell-command-switch command)))
|
2001-12-13 07:43:28 +00:00
|
|
|
|
;; Report the output.
|
2002-02-27 23:03:34 +00:00
|
|
|
|
(with-current-buffer buffer
|
2003-02-04 12:29:42 +00:00
|
|
|
|
(setq mode-line-process
|
2002-06-29 18:08:32 +00:00
|
|
|
|
(cond ((null exit-status)
|
|
|
|
|
" - Error")
|
|
|
|
|
((stringp exit-status)
|
|
|
|
|
(format " - Signal [%s]" exit-status))
|
|
|
|
|
((not (equal 0 exit-status))
|
|
|
|
|
(format " - Exit [%d]" exit-status)))))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
(if (with-current-buffer buffer (> (point-max) (point-min)))
|
|
|
|
|
;; There's some output, display it
|
2002-02-27 23:03:34 +00:00
|
|
|
|
(display-message-or-buffer buffer)
|
2000-10-06 11:35:56 +00:00
|
|
|
|
;; No output; error?
|
2002-02-20 22:33:01 +00:00
|
|
|
|
(let ((output
|
|
|
|
|
(if (and error-file
|
|
|
|
|
(< 0 (nth 7 (file-attributes error-file))))
|
2011-07-02 22:59:18 +02:00
|
|
|
|
(format "some error output%s"
|
|
|
|
|
(if shell-command-default-error-buffer
|
2011-07-06 21:44:09 +02:00
|
|
|
|
(format " to the \"%s\" buffer"
|
|
|
|
|
shell-command-default-error-buffer)
|
2011-07-02 22:59:18 +02:00
|
|
|
|
""))
|
2002-02-20 22:33:01 +00:00
|
|
|
|
"no output")))
|
2002-06-29 18:08:32 +00:00
|
|
|
|
(cond ((null exit-status)
|
|
|
|
|
(message "(Shell command failed with error)"))
|
|
|
|
|
((equal 0 exit-status)
|
|
|
|
|
(message "(Shell command succeeded with %s)"
|
|
|
|
|
output))
|
|
|
|
|
((stringp exit-status)
|
|
|
|
|
(message "(Shell command killed by signal %s)"
|
|
|
|
|
exit-status))
|
|
|
|
|
(t
|
|
|
|
|
(message "(Shell command failed with code %d and %s)"
|
|
|
|
|
exit-status output))))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
;; Don't kill: there might be useful info in the undo-log.
|
|
|
|
|
;; (kill-buffer buffer)
|
|
|
|
|
))))
|
2000-10-06 11:35:56 +00:00
|
|
|
|
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(when (and error-file (file-exists-p error-file))
|
|
|
|
|
(if (< 0 (nth 7 (file-attributes error-file)))
|
|
|
|
|
(with-current-buffer (get-buffer-create error-buffer)
|
|
|
|
|
(let ((pos-from-end (- (point-max) (point))))
|
|
|
|
|
(or (bobp)
|
|
|
|
|
(insert "\f\n"))
|
|
|
|
|
;; Do no formatting while reading error file,
|
|
|
|
|
;; because that can run a shell command, and we
|
|
|
|
|
;; don't want that to cause an infinite recursion.
|
|
|
|
|
(format-insert-file error-file nil)
|
|
|
|
|
;; Put point after the inserted errors.
|
|
|
|
|
(goto-char (- (point-max) pos-from-end)))
|
2004-08-22 16:59:57 +00:00
|
|
|
|
(and display-error-buffer
|
|
|
|
|
(display-buffer (current-buffer)))))
|
1999-03-01 03:19:32 +00:00
|
|
|
|
(delete-file error-file))
|
1999-01-23 21:50:18 +00:00
|
|
|
|
exit-status))
|
1999-11-15 16:11:14 +00:00
|
|
|
|
|
1996-09-24 20:04:48 +00:00
|
|
|
|
(defun shell-command-to-string (command)
|
|
|
|
|
"Execute shell command COMMAND and return its output as a string."
|
|
|
|
|
(with-output-to-string
|
1996-09-24 23:54:08 +00:00
|
|
|
|
(with-current-buffer
|
|
|
|
|
standard-output
|
2011-03-08 13:58:40 +01:00
|
|
|
|
(process-file shell-file-name nil t nil shell-command-switch command))))
|
2004-10-23 19:52:18 +00:00
|
|
|
|
|
|
|
|
|
(defun process-file (program &optional infile buffer display &rest args)
|
|
|
|
|
"Process files synchronously in a separate process.
|
|
|
|
|
Similar to `call-process', but may invoke a file handler based on
|
|
|
|
|
`default-directory'. The current working directory of the
|
|
|
|
|
subprocess is `default-directory'.
|
|
|
|
|
|
|
|
|
|
File names in INFILE and BUFFER are handled normally, but file
|
|
|
|
|
names in ARGS should be relative to `default-directory', as they
|
2014-02-21 14:22:14 +01:00
|
|
|
|
are passed to the process verbatim. (This is a difference to
|
2004-10-23 19:52:18 +00:00
|
|
|
|
`call-process' which does not support file handlers for INFILE
|
2014-02-21 14:22:14 +01:00
|
|
|
|
and BUFFER.)
|
2004-10-23 19:52:18 +00:00
|
|
|
|
|
|
|
|
|
Some file handlers might not support all variants, for example
|
|
|
|
|
they might behave as if DISPLAY was nil, regardless of the actual
|
|
|
|
|
value passed."
|
|
|
|
|
(let ((fh (find-file-name-handler default-directory 'process-file))
|
|
|
|
|
lc stderr-file)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(if fh (apply fh 'process-file program infile buffer display args)
|
2004-10-24 09:06:05 +00:00
|
|
|
|
(when infile (setq lc (file-local-copy infile)))
|
2004-10-23 19:52:18 +00:00
|
|
|
|
(setq stderr-file (when (and (consp buffer) (stringp (cadr buffer)))
|
2004-10-25 08:31:52 +00:00
|
|
|
|
(make-temp-file "emacs")))
|
|
|
|
|
(prog1
|
|
|
|
|
(apply 'call-process program
|
|
|
|
|
(or lc infile)
|
|
|
|
|
(if stderr-file (list (car buffer) stderr-file) buffer)
|
|
|
|
|
display args)
|
2012-12-21 09:10:26 +01:00
|
|
|
|
(when stderr-file (copy-file stderr-file (cadr buffer) t))))
|
2004-10-23 19:52:18 +00:00
|
|
|
|
(when stderr-file (delete-file stderr-file))
|
|
|
|
|
(when lc (delete-file lc)))))
|
|
|
|
|
|
2009-08-25 08:45:41 +00:00
|
|
|
|
(defvar process-file-side-effects t
|
|
|
|
|
"Whether a call of `process-file' changes remote files.
|
|
|
|
|
|
2012-04-14 18:37:16 -07:00
|
|
|
|
By default, this variable is always set to `t', meaning that a
|
2009-08-25 08:45:41 +00:00
|
|
|
|
call of `process-file' could potentially change any file on a
|
|
|
|
|
remote host. When set to `nil', a file handler could optimize
|
2012-04-14 18:37:16 -07:00
|
|
|
|
its behavior with respect to remote file attribute caching.
|
2009-08-25 08:45:41 +00:00
|
|
|
|
|
2012-04-14 18:37:16 -07:00
|
|
|
|
You should only ever change this variable with a let-binding;
|
|
|
|
|
never with `setq'.")
|
2009-08-25 08:45:41 +00:00
|
|
|
|
|
2007-07-07 11:17:51 +00:00
|
|
|
|
(defun start-file-process (name buffer program &rest program-args)
|
|
|
|
|
"Start a program in a subprocess. Return the process object for it.
|
2008-05-09 17:39:33 +00:00
|
|
|
|
|
2007-07-07 11:17:51 +00:00
|
|
|
|
Similar to `start-process', but may invoke a file handler based on
|
2008-05-09 17:39:33 +00:00
|
|
|
|
`default-directory'. See Info node `(elisp)Magic File Names'.
|
|
|
|
|
|
|
|
|
|
This handler ought to run PROGRAM, perhaps on the local host,
|
|
|
|
|
perhaps on a remote host that corresponds to `default-directory'.
|
|
|
|
|
In the latter case, the local part of `default-directory' becomes
|
|
|
|
|
the working directory of the process.
|
2007-07-07 11:17:51 +00:00
|
|
|
|
|
|
|
|
|
PROGRAM and PROGRAM-ARGS might be file names. They are not
|
2009-10-02 13:27:29 +00:00
|
|
|
|
objects of file handler invocation. File handlers might not
|
|
|
|
|
support pty association, if PROGRAM is nil."
|
2007-07-07 11:17:51 +00:00
|
|
|
|
(let ((fh (find-file-name-handler default-directory 'start-file-process)))
|
|
|
|
|
(if fh (apply fh 'start-file-process name buffer program program-args)
|
|
|
|
|
(apply 'start-process name buffer program program-args))))
|
2011-04-06 17:13:17 -04:00
|
|
|
|
|
|
|
|
|
;;;; Process menu
|
|
|
|
|
|
|
|
|
|
(defvar tabulated-list-format)
|
|
|
|
|
(defvar tabulated-list-entries)
|
|
|
|
|
(defvar tabulated-list-sort-key)
|
|
|
|
|
(declare-function tabulated-list-init-header "tabulated-list" ())
|
2011-05-04 23:35:41 -07:00
|
|
|
|
(declare-function tabulated-list-print "tabulated-list"
|
|
|
|
|
(&optional remember-pos))
|
2011-04-06 17:13:17 -04:00
|
|
|
|
|
|
|
|
|
(defvar process-menu-query-only nil)
|
|
|
|
|
|
|
|
|
|
(define-derived-mode process-menu-mode tabulated-list-mode "Process Menu"
|
|
|
|
|
"Major mode for listing the processes called by Emacs."
|
|
|
|
|
(setq tabulated-list-format [("Process" 15 t)
|
|
|
|
|
("Status" 7 t)
|
|
|
|
|
("Buffer" 15 t)
|
|
|
|
|
("TTY" 12 t)
|
|
|
|
|
("Command" 0 t)])
|
|
|
|
|
(make-local-variable 'process-menu-query-only)
|
|
|
|
|
(setq tabulated-list-sort-key (cons "Process" nil))
|
|
|
|
|
(add-hook 'tabulated-list-revert-hook 'list-processes--refresh nil t)
|
|
|
|
|
(tabulated-list-init-header))
|
|
|
|
|
|
|
|
|
|
(defun list-processes--refresh ()
|
2012-02-06 22:40:10 +08:00
|
|
|
|
"Recompute the list of processes for the Process List buffer.
|
|
|
|
|
Also, delete any process that is exited or signaled."
|
2011-04-06 17:13:17 -04:00
|
|
|
|
(setq tabulated-list-entries nil)
|
|
|
|
|
(dolist (p (process-list))
|
2012-02-06 22:40:10 +08:00
|
|
|
|
(cond ((memq (process-status p) '(exit signal closed))
|
|
|
|
|
(delete-process p))
|
|
|
|
|
((or (not process-menu-query-only)
|
|
|
|
|
(process-query-on-exit-flag p))
|
|
|
|
|
(let* ((buf (process-buffer p))
|
|
|
|
|
(type (process-type p))
|
|
|
|
|
(name (process-name p))
|
|
|
|
|
(status (symbol-name (process-status p)))
|
|
|
|
|
(buf-label (if (buffer-live-p buf)
|
|
|
|
|
`(,(buffer-name buf)
|
|
|
|
|
face link
|
|
|
|
|
help-echo ,(concat "Visit buffer `"
|
|
|
|
|
(buffer-name buf) "'")
|
|
|
|
|
follow-link t
|
|
|
|
|
process-buffer ,buf
|
|
|
|
|
action process-menu-visit-buffer)
|
|
|
|
|
"--"))
|
|
|
|
|
(tty (or (process-tty-name p) "--"))
|
|
|
|
|
(cmd
|
|
|
|
|
(if (memq type '(network serial))
|
|
|
|
|
(let ((contact (process-contact p t)))
|
|
|
|
|
(if (eq type 'network)
|
|
|
|
|
(format "(%s %s)"
|
|
|
|
|
(if (plist-get contact :type)
|
|
|
|
|
"datagram"
|
|
|
|
|
"network")
|
|
|
|
|
(if (plist-get contact :server)
|
|
|
|
|
(format "server on %s"
|
2012-08-04 10:08:11 +02:00
|
|
|
|
(or
|
|
|
|
|
(plist-get contact :host)
|
|
|
|
|
(plist-get contact :local)))
|
2012-02-06 22:40:10 +08:00
|
|
|
|
(format "connection to %s"
|
|
|
|
|
(plist-get contact :host))))
|
|
|
|
|
(format "(serial port %s%s)"
|
|
|
|
|
(or (plist-get contact :port) "?")
|
|
|
|
|
(let ((speed (plist-get contact :speed)))
|
|
|
|
|
(if speed
|
|
|
|
|
(format " at %s b/s" speed)
|
|
|
|
|
"")))))
|
|
|
|
|
(mapconcat 'identity (process-command p) " "))))
|
|
|
|
|
(push (list p (vector name status buf-label tty cmd))
|
|
|
|
|
tabulated-list-entries))))))
|
2011-04-06 17:13:17 -04:00
|
|
|
|
|
|
|
|
|
(defun process-menu-visit-buffer (button)
|
|
|
|
|
(display-buffer (button-get button 'process-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun list-processes (&optional query-only buffer)
|
2013-07-26 21:48:05 +03:00
|
|
|
|
"Display a list of all processes that are Emacs sub-processes.
|
2011-04-06 17:13:17 -04:00
|
|
|
|
If optional argument QUERY-ONLY is non-nil, only processes with
|
|
|
|
|
the query-on-exit flag set are listed.
|
|
|
|
|
Any process listed as exited or signaled is actually eliminated
|
|
|
|
|
after the listing is made.
|
|
|
|
|
Optional argument BUFFER specifies a buffer to use, instead of
|
2012-08-04 10:09:24 +02:00
|
|
|
|
\"*Process List*\".
|
2013-07-26 21:48:05 +03:00
|
|
|
|
The return value is always nil.
|
|
|
|
|
|
|
|
|
|
This function lists only processes that were launched by Emacs. To
|
|
|
|
|
see other processes running on the system, use `list-system-processes'."
|
2011-04-06 17:13:17 -04:00
|
|
|
|
(interactive)
|
2011-04-08 20:08:17 +03:00
|
|
|
|
(or (fboundp 'process-list)
|
|
|
|
|
(error "Asynchronous subprocesses are not supported on this system"))
|
2011-04-06 17:13:17 -04:00
|
|
|
|
(unless (bufferp buffer)
|
|
|
|
|
(setq buffer (get-buffer-create "*Process List*")))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(process-menu-mode)
|
|
|
|
|
(setq process-menu-query-only query-only)
|
|
|
|
|
(list-processes--refresh)
|
|
|
|
|
(tabulated-list-print))
|
2011-05-06 03:02:49 +02:00
|
|
|
|
(display-buffer buffer)
|
|
|
|
|
nil)
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1996-12-16 00:52:56 +00:00
|
|
|
|
(defvar universal-argument-map
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(let ((map (make-sparse-keymap))
|
|
|
|
|
(universal-argument-minus
|
|
|
|
|
;; For backward compatibility, minus with no modifiers is an ordinary
|
|
|
|
|
;; command if digits have already been entered.
|
|
|
|
|
`(menu-item "" negative-argument
|
|
|
|
|
:filter ,(lambda (cmd)
|
|
|
|
|
(if (integerp prefix-arg) nil cmd)))))
|
|
|
|
|
(define-key map [switch-frame]
|
|
|
|
|
(lambda (e) (interactive "e")
|
|
|
|
|
(handle-switch-frame e) (universal-argument--mode)))
|
1995-06-16 06:14:44 +00:00
|
|
|
|
(define-key map [?\C-u] 'universal-argument-more)
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(define-key map [?-] universal-argument-minus)
|
1995-06-16 06:14:44 +00:00
|
|
|
|
(define-key map [?0] 'digit-argument)
|
|
|
|
|
(define-key map [?1] 'digit-argument)
|
|
|
|
|
(define-key map [?2] 'digit-argument)
|
|
|
|
|
(define-key map [?3] 'digit-argument)
|
|
|
|
|
(define-key map [?4] 'digit-argument)
|
|
|
|
|
(define-key map [?5] 'digit-argument)
|
|
|
|
|
(define-key map [?6] 'digit-argument)
|
|
|
|
|
(define-key map [?7] 'digit-argument)
|
|
|
|
|
(define-key map [?8] 'digit-argument)
|
|
|
|
|
(define-key map [?9] 'digit-argument)
|
2000-07-20 20:35:05 +00:00
|
|
|
|
(define-key map [kp-0] 'digit-argument)
|
|
|
|
|
(define-key map [kp-1] 'digit-argument)
|
|
|
|
|
(define-key map [kp-2] 'digit-argument)
|
|
|
|
|
(define-key map [kp-3] 'digit-argument)
|
|
|
|
|
(define-key map [kp-4] 'digit-argument)
|
|
|
|
|
(define-key map [kp-5] 'digit-argument)
|
|
|
|
|
(define-key map [kp-6] 'digit-argument)
|
|
|
|
|
(define-key map [kp-7] 'digit-argument)
|
|
|
|
|
(define-key map [kp-8] 'digit-argument)
|
|
|
|
|
(define-key map [kp-9] 'digit-argument)
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(define-key map [kp-subtract] universal-argument-minus)
|
1995-06-16 06:14:44 +00:00
|
|
|
|
map)
|
|
|
|
|
"Keymap used while processing \\[universal-argument].")
|
|
|
|
|
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(defun universal-argument--mode ()
|
2013-12-23 11:59:10 +08:00
|
|
|
|
(set-transient-map universal-argument-map))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
1995-06-14 22:30:41 +00:00
|
|
|
|
(defun universal-argument ()
|
|
|
|
|
"Begin a numeric argument for the following command.
|
|
|
|
|
Digits or minus sign following \\[universal-argument] make up the numeric argument.
|
|
|
|
|
\\[universal-argument] following the digits or minus sign ends the argument.
|
|
|
|
|
\\[universal-argument] without digits or minus sign provides 4 as argument.
|
|
|
|
|
Repeating \\[universal-argument] without digits or minus sign
|
1996-10-08 21:35:03 +00:00
|
|
|
|
multiplies the argument by 4 each time.
|
|
|
|
|
For some commands, just \\[universal-argument] by itself serves as a flag
|
1996-10-15 03:19:56 +00:00
|
|
|
|
which is different in effect from any particular numeric argument.
|
|
|
|
|
These commands include \\[set-mark-command] and \\[start-kbd-macro]."
|
1995-06-16 06:14:44 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(setq prefix-arg (list 4))
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(universal-argument--mode))
|
1995-06-14 22:30:41 +00:00
|
|
|
|
|
1995-06-16 06:14:44 +00:00
|
|
|
|
(defun universal-argument-more (arg)
|
2013-09-10 13:13:48 -04:00
|
|
|
|
;; A subsequent C-u means to multiply the factor by 4 if we've typed
|
|
|
|
|
;; nothing but C-u's; otherwise it means to terminate the prefix arg.
|
1995-06-14 22:30:41 +00:00
|
|
|
|
(interactive "P")
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(setq prefix-arg (if (consp arg)
|
|
|
|
|
(list (* 4 (car arg)))
|
|
|
|
|
(if (eq arg '-)
|
|
|
|
|
(list -4)
|
|
|
|
|
arg)))
|
|
|
|
|
(when (consp prefix-arg) (universal-argument--mode)))
|
1995-06-14 22:30:41 +00:00
|
|
|
|
|
|
|
|
|
(defun negative-argument (arg)
|
|
|
|
|
"Begin a negative numeric argument for the next command.
|
|
|
|
|
\\[universal-argument] following digits or minus sign ends the argument."
|
|
|
|
|
(interactive "P")
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(setq prefix-arg (cond ((integerp arg) (- arg))
|
|
|
|
|
((eq arg '-) nil)
|
|
|
|
|
(t '-)))
|
|
|
|
|
(universal-argument--mode))
|
1995-06-16 06:14:44 +00:00
|
|
|
|
|
|
|
|
|
(defun digit-argument (arg)
|
|
|
|
|
"Part of the numeric argument for the next command.
|
|
|
|
|
\\[universal-argument] following digits or minus sign ends the argument."
|
|
|
|
|
(interactive "P")
|
2009-01-09 04:44:15 +00:00
|
|
|
|
(let* ((char (if (integerp last-command-event)
|
|
|
|
|
last-command-event
|
|
|
|
|
(get last-command-event 'ascii-character)))
|
2000-07-20 20:35:05 +00:00
|
|
|
|
(digit (- (logand char ?\177) ?0)))
|
2013-09-10 13:13:48 -04:00
|
|
|
|
(setq prefix-arg (cond ((integerp arg)
|
|
|
|
|
(+ (* arg 10)
|
|
|
|
|
(if (< arg 0) (- digit) digit)))
|
|
|
|
|
((eq arg '-)
|
|
|
|
|
;; Treat -0 as just -, so that -01 will work.
|
|
|
|
|
(if (zerop digit) '- (- digit)))
|
|
|
|
|
(t
|
|
|
|
|
digit))))
|
|
|
|
|
(universal-argument--mode))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2010-05-02 01:56:30 -04:00
|
|
|
|
|
|
|
|
|
(defvar filter-buffer-substring-functions nil
|
2014-05-26 18:53:45 -07:00
|
|
|
|
"This variable is a wrapper hook around `buffer-substring--filter'.")
|
2013-04-17 20:12:33 -04:00
|
|
|
|
(make-obsolete-variable 'filter-buffer-substring-functions
|
|
|
|
|
'filter-buffer-substring-function "24.4")
|
|
|
|
|
|
|
|
|
|
(defvar filter-buffer-substring-function #'buffer-substring--filter
|
|
|
|
|
"Function to perform the filtering in `filter-buffer-substring'.
|
2014-05-26 18:53:45 -07:00
|
|
|
|
The function is called with the same 3 arguments (BEG END DELETE)
|
|
|
|
|
that `filter-buffer-substring' received. It should return the
|
|
|
|
|
buffer substring between BEG and END, after filtering. If DELETE is
|
|
|
|
|
non-nil, it should delete the text between BEG and END from the buffer.")
|
2010-05-02 01:56:30 -04:00
|
|
|
|
|
2005-03-29 20:53:19 +00:00
|
|
|
|
(defvar buffer-substring-filters nil
|
2014-05-26 18:53:45 -07:00
|
|
|
|
"List of filter functions for `buffer-substring--filter'.
|
|
|
|
|
Each function must accept a single argument, a string, and return a string.
|
|
|
|
|
The buffer substring is passed to the first function in the list,
|
|
|
|
|
and the return value of each function is passed to the next.
|
2012-02-04 11:48:06 -08:00
|
|
|
|
As a special convention, point is set to the start of the buffer text
|
2014-05-26 18:53:45 -07:00
|
|
|
|
being operated on (i.e., the first argument of `buffer-substring--filter')
|
2012-02-04 11:48:06 -08:00
|
|
|
|
before these functions are called.")
|
2010-05-02 01:56:30 -04:00
|
|
|
|
(make-obsolete-variable 'buffer-substring-filters
|
2013-04-17 20:12:33 -04:00
|
|
|
|
'filter-buffer-substring-function "24.1")
|
2005-03-29 20:53:19 +00:00
|
|
|
|
|
2010-05-02 01:56:30 -04:00
|
|
|
|
(defun filter-buffer-substring (beg end &optional delete)
|
2005-03-29 20:53:19 +00:00
|
|
|
|
"Return the buffer substring between BEG and END, after filtering.
|
2014-05-26 18:53:45 -07:00
|
|
|
|
If DELETE is non-nil, delete the text between BEG and END from the buffer.
|
|
|
|
|
|
|
|
|
|
This calls the function that `filter-buffer-substring-function' specifies
|
|
|
|
|
\(passing the same three arguments that it received) to do the work,
|
|
|
|
|
and returns whatever it does. The default function does no filtering,
|
|
|
|
|
unless a hook has been set.
|
|
|
|
|
|
|
|
|
|
Use `filter-buffer-substring' instead of `buffer-substring',
|
|
|
|
|
`buffer-substring-no-properties', or `delete-and-extract-region' when
|
|
|
|
|
you want to allow filtering to take place. For example, major or minor
|
|
|
|
|
modes can use `filter-buffer-substring-function' to extract characters
|
|
|
|
|
that are special to a buffer, and should not be copied into other buffers."
|
2013-04-17 20:12:33 -04:00
|
|
|
|
(funcall filter-buffer-substring-function beg end delete))
|
|
|
|
|
|
|
|
|
|
(defun buffer-substring--filter (beg end &optional delete)
|
2014-05-26 18:53:45 -07:00
|
|
|
|
"Default function to use for `filter-buffer-substring-function'.
|
|
|
|
|
Its arguments and return value are as specified for `filter-buffer-substring'.
|
|
|
|
|
This respects the wrapper hook `filter-buffer-substring-functions',
|
|
|
|
|
and the abnormal hook `buffer-substring-filters'.
|
|
|
|
|
No filtering is done unless a hook says to."
|
2010-05-02 01:56:30 -04:00
|
|
|
|
(with-wrapper-hook filter-buffer-substring-functions (beg end delete)
|
|
|
|
|
(cond
|
|
|
|
|
((or delete buffer-substring-filters)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(let ((string (if delete (delete-and-extract-region beg end)
|
|
|
|
|
(buffer-substring beg end))))
|
|
|
|
|
(dolist (filter buffer-substring-filters)
|
|
|
|
|
(setq string (funcall filter string)))
|
|
|
|
|
string)))
|
|
|
|
|
(t
|
|
|
|
|
(buffer-substring beg end)))))
|
2006-04-09 23:03:48 +00:00
|
|
|
|
|
2005-03-29 20:53:19 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;;;; Window system cut and paste hooks.
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
|
|
|
|
(defvar interprogram-cut-function nil
|
|
|
|
|
"Function to call to make a killed region available to other programs.
|
2012-07-07 17:33:28 +08:00
|
|
|
|
Most window systems provide a facility for cutting and pasting
|
|
|
|
|
text between different programs, such as the clipboard on X and
|
|
|
|
|
MS-Windows, or the pasteboard on Nextstep/Mac OS.
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
2012-07-07 17:33:28 +08:00
|
|
|
|
This variable holds a function that Emacs calls whenever text is
|
|
|
|
|
put in the kill ring, to make the new kill available to other
|
|
|
|
|
programs. The function takes one argument, TEXT, which is a
|
|
|
|
|
string containing the text which should be made available.")
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
|
|
|
|
(defvar interprogram-paste-function nil
|
|
|
|
|
"Function to call to get text cut from other programs.
|
2012-07-07 17:33:28 +08:00
|
|
|
|
Most window systems provide a facility for cutting and pasting
|
|
|
|
|
text between different programs, such as the clipboard on X and
|
|
|
|
|
MS-Windows, or the pasteboard on Nextstep/Mac OS.
|
|
|
|
|
|
|
|
|
|
This variable holds a function that Emacs calls to obtain text
|
|
|
|
|
that other programs have provided for pasting. The function is
|
|
|
|
|
called with no arguments. If no other program has provided text
|
|
|
|
|
to paste, the function should return nil (in which case the
|
|
|
|
|
caller, usually `current-kill', should use the top of the Emacs
|
|
|
|
|
kill ring). If another program has provided text to paste, the
|
|
|
|
|
function should return that text as a string (in which case the
|
|
|
|
|
caller should put this string in the kill ring as the latest
|
|
|
|
|
kill).
|
|
|
|
|
|
|
|
|
|
The function may also return a list of strings if the window
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
system supports multiple selections. The first string will be
|
2012-07-07 17:33:28 +08:00
|
|
|
|
used as the pasted text, but the other will be placed in the kill
|
|
|
|
|
ring for easy access via `yank-pop'.
|
|
|
|
|
|
|
|
|
|
Note that the function should return a string only if a program
|
|
|
|
|
other than Emacs has provided a string for pasting; if Emacs
|
|
|
|
|
provided the most recent string, the function should return nil.
|
|
|
|
|
If it is difficult to tell whether Emacs or some other program
|
|
|
|
|
provided the current string, it is probably good enough to return
|
|
|
|
|
nil if the string is equal (according to `string=') to the last
|
|
|
|
|
text Emacs provided.")
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1992-06-12 22:23:00 +00:00
|
|
|
|
;;;; The kill ring data structure.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defvar kill-ring nil
|
1992-06-12 22:23:00 +00:00
|
|
|
|
"List of killed text sequences.
|
|
|
|
|
Since the kill ring is supposed to interact nicely with cut-and-paste
|
|
|
|
|
facilities offered by window systems, use of this variable should
|
|
|
|
|
interact nicely with `interprogram-cut-function' and
|
|
|
|
|
`interprogram-paste-function'. The functions `kill-new',
|
|
|
|
|
`kill-append', and `current-kill' are supposed to implement this
|
|
|
|
|
interaction; you may want to use them instead of manipulating the kill
|
|
|
|
|
ring directly.")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1998-10-19 18:26:28 +00:00
|
|
|
|
(defcustom kill-ring-max 60
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Maximum length of kill ring before oldest elements are thrown away."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'killing)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defvar kill-ring-yank-pointer nil
|
|
|
|
|
"The tail of the kill ring whose car is the last thing yanked.")
|
|
|
|
|
|
2009-08-26 20:55:39 +00:00
|
|
|
|
(defcustom save-interprogram-paste-before-kill nil
|
2010-02-16 09:40:45 -05:00
|
|
|
|
"Save clipboard strings into kill ring before replacing them.
|
2009-08-26 20:55:39 +00:00
|
|
|
|
When one selects something in another program to paste it into Emacs,
|
|
|
|
|
but kills something in Emacs before actually pasting it,
|
|
|
|
|
this selection is gone unless this variable is non-nil,
|
|
|
|
|
in which case the other program's selection is saved in the `kill-ring'
|
|
|
|
|
before the Emacs kill and one can still paste it using \\[yank] \\[yank-pop]."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing
|
|
|
|
|
:version "23.2")
|
|
|
|
|
|
2009-08-27 14:56:17 +00:00
|
|
|
|
(defcustom kill-do-not-save-duplicates nil
|
2012-03-13 02:21:35 +08:00
|
|
|
|
"Do not add a new string to `kill-ring' if it duplicates the last one.
|
|
|
|
|
The comparison is done using `equal-including-properties'."
|
2009-08-27 14:56:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing
|
|
|
|
|
:version "23.2")
|
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defun kill-new (string &optional replace)
|
1992-06-12 22:23:00 +00:00
|
|
|
|
"Make STRING the latest kill in the kill ring.
|
2002-03-31 16:28:07 +00:00
|
|
|
|
Set `kill-ring-yank-pointer' to point to it.
|
1994-09-15 21:30:21 +00:00
|
|
|
|
If `interprogram-cut-function' is non-nil, apply it to STRING.
|
|
|
|
|
Optional second argument REPLACE non-nil means that STRING will replace
|
2003-01-18 23:34:14 +00:00
|
|
|
|
the front of the kill ring, rather than being added to the list.
|
|
|
|
|
|
2009-08-26 20:55:39 +00:00
|
|
|
|
When `save-interprogram-paste-before-kill' and `interprogram-paste-function'
|
|
|
|
|
are non-nil, saves the interprogram paste string(s) into `kill-ring' before
|
|
|
|
|
STRING.
|
|
|
|
|
|
2003-01-27 21:44:48 +00:00
|
|
|
|
When the yank handler has a non-nil PARAM element, the original STRING
|
|
|
|
|
argument is not used by `insert-for-yank'. However, since Lisp code
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
may access and use elements from the kill ring directly, the STRING
|
2003-01-27 21:44:48 +00:00
|
|
|
|
argument should still be a \"useful\" string for such uses."
|
2010-06-04 21:38:11 +03:00
|
|
|
|
(unless (and kill-do-not-save-duplicates
|
2012-03-13 02:21:35 +08:00
|
|
|
|
;; Due to text properties such as 'yank-handler that
|
|
|
|
|
;; can alter the contents to yank, comparison using
|
|
|
|
|
;; `equal' is unsafe.
|
|
|
|
|
(equal-including-properties string (car kill-ring)))
|
2010-06-04 21:38:11 +03:00
|
|
|
|
(if (fboundp 'menu-bar-update-yank-menu)
|
|
|
|
|
(menu-bar-update-yank-menu string (and replace (car kill-ring)))))
|
2009-08-26 20:55:39 +00:00
|
|
|
|
(when save-interprogram-paste-before-kill
|
|
|
|
|
(let ((interprogram-paste (and interprogram-paste-function
|
|
|
|
|
(funcall interprogram-paste-function))))
|
|
|
|
|
(when interprogram-paste
|
2010-06-04 21:38:11 +03:00
|
|
|
|
(dolist (s (if (listp interprogram-paste)
|
|
|
|
|
(nreverse interprogram-paste)
|
|
|
|
|
(list interprogram-paste)))
|
|
|
|
|
(unless (and kill-do-not-save-duplicates
|
2012-03-13 02:21:35 +08:00
|
|
|
|
(equal-including-properties s (car kill-ring)))
|
2010-06-04 21:38:11 +03:00
|
|
|
|
(push s kill-ring))))))
|
|
|
|
|
(unless (and kill-do-not-save-duplicates
|
2012-03-13 02:21:35 +08:00
|
|
|
|
(equal-including-properties string (car kill-ring)))
|
2010-06-04 21:38:11 +03:00
|
|
|
|
(if (and replace kill-ring)
|
|
|
|
|
(setcar kill-ring string)
|
|
|
|
|
(push string kill-ring)
|
|
|
|
|
(if (> (length kill-ring) kill-ring-max)
|
|
|
|
|
(setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(setq kill-ring-yank-pointer kill-ring)
|
|
|
|
|
(if interprogram-cut-function
|
2010-09-02 12:54:43 +02:00
|
|
|
|
(funcall interprogram-cut-function string)))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defun kill-append (string before-p)
|
1992-06-12 22:23:00 +00:00
|
|
|
|
"Append STRING to the end of the latest kill in the kill ring.
|
|
|
|
|
If BEFORE-P is non-nil, prepend STRING to the kill.
|
2003-01-18 23:34:14 +00:00
|
|
|
|
If `interprogram-cut-function' is set, pass the resulting kill to it."
|
|
|
|
|
(let* ((cur (car kill-ring)))
|
|
|
|
|
(kill-new (if before-p (concat string cur) (concat cur string))
|
|
|
|
|
(or (= (length cur) 0)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(equal nil (get-text-property 0 'yank-handler cur))))))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
2007-12-25 20:19:13 +00:00
|
|
|
|
(defcustom yank-pop-change-selection nil
|
2012-07-07 17:33:28 +08:00
|
|
|
|
"Whether rotating the kill ring changes the window system selection.
|
|
|
|
|
If non-nil, whenever the kill ring is rotated (usually via the
|
|
|
|
|
`yank-pop' command), Emacs also calls `interprogram-cut-function'
|
|
|
|
|
to copy the new kill to the window system selection."
|
2007-12-25 20:19:13 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing
|
|
|
|
|
:version "23.1")
|
|
|
|
|
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(defun current-kill (n &optional do-not-move)
|
|
|
|
|
"Rotate the yanking point by N places, and then return that kill.
|
2011-07-16 20:39:01 +02:00
|
|
|
|
If N is zero and `interprogram-paste-function' is set to a
|
|
|
|
|
function that returns a string or a list of strings, and if that
|
|
|
|
|
function doesn't return nil, then that string (or list) is added
|
|
|
|
|
to the front of the kill ring and the string (or first string in
|
|
|
|
|
the list) is returned as the latest kill.
|
2007-12-25 20:19:13 +00:00
|
|
|
|
|
|
|
|
|
If N is not zero, and if `yank-pop-change-selection' is
|
|
|
|
|
non-nil, use `interprogram-cut-function' to transfer the
|
|
|
|
|
kill at the new yank point into the window system selection.
|
|
|
|
|
|
|
|
|
|
If optional arg DO-NOT-MOVE is non-nil, then don't actually
|
|
|
|
|
move the yanking point; just return the Nth kill forward."
|
|
|
|
|
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(let ((interprogram-paste (and (= n 0)
|
|
|
|
|
interprogram-paste-function
|
|
|
|
|
(funcall interprogram-paste-function))))
|
|
|
|
|
(if interprogram-paste
|
|
|
|
|
(progn
|
|
|
|
|
;; Disable the interprogram cut function when we add the new
|
|
|
|
|
;; text to the kill ring, so Emacs doesn't try to own the
|
|
|
|
|
;; selection, with identical text.
|
|
|
|
|
(let ((interprogram-cut-function nil))
|
2007-10-18 04:52:15 +00:00
|
|
|
|
(if (listp interprogram-paste)
|
|
|
|
|
(mapc 'kill-new (nreverse interprogram-paste))
|
|
|
|
|
(kill-new interprogram-paste)))
|
|
|
|
|
(car kill-ring))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(or kill-ring (error "Kill ring is empty"))
|
1993-08-10 04:14:17 +00:00
|
|
|
|
(let ((ARGth-kill-element
|
|
|
|
|
(nthcdr (mod (- n (length kill-ring-yank-pointer))
|
|
|
|
|
(length kill-ring))
|
|
|
|
|
kill-ring)))
|
2007-12-25 20:19:13 +00:00
|
|
|
|
(unless do-not-move
|
|
|
|
|
(setq kill-ring-yank-pointer ARGth-kill-element)
|
|
|
|
|
(when (and yank-pop-change-selection
|
|
|
|
|
(> n 0)
|
|
|
|
|
interprogram-cut-function)
|
|
|
|
|
(funcall interprogram-cut-function (car ARGth-kill-element))))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(car ARGth-kill-element)))))
|
1992-05-30 21:11:25 +00:00
|
|
|
|
|
|
|
|
|
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1992-06-12 22:23:00 +00:00
|
|
|
|
;;;; Commands for manipulating the kill ring.
|
1992-05-30 21:11:25 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom kill-read-only-ok nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Non-nil means don't signal an error for killing read-only text."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing)
|
1994-04-24 05:44:23 +00:00
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defun kill-region (beg end &optional region)
|
2006-03-11 15:09:48 +00:00
|
|
|
|
"Kill (\"cut\") text between point and mark.
|
|
|
|
|
This deletes the text from the buffer and saves it in the kill ring.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
The command \\[yank] can retrieve it from there.
|
2008-05-28 17:36:04 +00:00
|
|
|
|
\(If you want to save the region without killing it, use \\[kill-ring-save].)
|
2001-02-16 12:09:39 +00:00
|
|
|
|
|
|
|
|
|
If you want to append the killed region to the last killed text,
|
|
|
|
|
use \\[append-next-kill] before \\[kill-region].
|
|
|
|
|
|
1993-02-01 22:31:17 +00:00
|
|
|
|
If the buffer is read-only, Emacs will beep and refrain from deleting
|
|
|
|
|
the text, but put the text in the kill ring anyway. This means that
|
|
|
|
|
you can use the killing commands to copy text from a read-only buffer.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2010-08-14 19:21:40 -04:00
|
|
|
|
Lisp programs should use this function for killing text.
|
|
|
|
|
(To delete text, use `delete-region'.)
|
2004-06-07 20:52:16 +00:00
|
|
|
|
Supply two arguments, character positions indicating the stretch of text
|
1991-12-21 09:29:41 +00:00
|
|
|
|
to be killed.
|
|
|
|
|
Any command that calls this function is a \"kill command\".
|
|
|
|
|
If the previous command was also a kill command,
|
|
|
|
|
the text killed this time appends to the text killed last time
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
to make one entry in the kill ring.
|
|
|
|
|
|
|
|
|
|
The optional argument REGION if non-nil, indicates that we're not just killing
|
|
|
|
|
some text between BEG and END, but we're killing the region."
|
2013-12-17 23:48:26 +08:00
|
|
|
|
;; Pass mark first, then point, because the order matters when
|
|
|
|
|
;; calling `kill-append'.
|
|
|
|
|
(interactive (list (mark) (point) 'region))
|
2006-09-04 15:03:26 +00:00
|
|
|
|
(unless (and beg end)
|
|
|
|
|
(error "The mark is not set now, so there is no region"))
|
1997-11-19 21:36:56 +00:00
|
|
|
|
(condition-case nil
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(let ((string (if region
|
|
|
|
|
(funcall region-extract-function 'delete)
|
|
|
|
|
(filter-buffer-substring beg end 'delete))))
|
1999-12-07 06:30:44 +00:00
|
|
|
|
(when string ;STRING is nil if BEG = END
|
|
|
|
|
;; Add that string to the kill ring, one way or another.
|
|
|
|
|
(if (eq last-command 'kill-region)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(kill-append string (< end beg))
|
|
|
|
|
(kill-new string nil)))
|
2003-05-28 20:07:10 +00:00
|
|
|
|
(when (or string (eq last-command 'kill-region))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(setq this-command 'kill-region))
|
2012-12-21 11:49:28 +08:00
|
|
|
|
(setq deactivate-mark t)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
nil)
|
1997-11-19 21:36:56 +00:00
|
|
|
|
((buffer-read-only text-read-only)
|
|
|
|
|
;; The code above failed because the buffer, or some of the characters
|
|
|
|
|
;; in the region, are read-only.
|
|
|
|
|
;; We should beep, in case the user just isn't aware of this.
|
|
|
|
|
;; However, there's no harm in putting
|
|
|
|
|
;; the region's text in the kill ring, anyway.
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(copy-region-as-kill beg end region)
|
1998-05-19 05:22:50 +00:00
|
|
|
|
;; Set this-command now, so it will be set even if we get an error.
|
|
|
|
|
(setq this-command 'kill-region)
|
|
|
|
|
;; This should barf, if appropriate, and give us the correct error.
|
1997-11-19 21:36:56 +00:00
|
|
|
|
(if kill-read-only-ok
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(progn (message "Read only text copied to kill ring") nil)
|
1997-11-19 21:36:56 +00:00
|
|
|
|
;; Signal an error if the buffer is read-only.
|
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
;; If the buffer isn't read-only, the text is.
|
|
|
|
|
(signal 'text-read-only (list (current-buffer)))))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1994-11-09 22:10:55 +00:00
|
|
|
|
;; copy-region-as-kill no longer sets this-command, because it's confusing
|
|
|
|
|
;; to get two copies of the text when the user accidentally types M-w and
|
|
|
|
|
;; then corrects it with the intended C-w.
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defun copy-region-as-kill (beg end &optional region)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Save the region as if killed, but don't kill it.
|
1997-12-21 01:52:31 +00:00
|
|
|
|
In Transient Mark mode, deactivate the mark.
|
1992-04-19 08:53:55 +00:00
|
|
|
|
If `interprogram-cut-function' is non-nil, also save the text for a window
|
2007-09-23 15:22:47 +00:00
|
|
|
|
system cut and paste.
|
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
The optional argument REGION if non-nil, indicates that we're not just copying
|
|
|
|
|
some text between BEG and END, but we're copying the region.
|
|
|
|
|
|
2013-08-16 16:27:49 +08:00
|
|
|
|
This command's old key binding has been given to `kill-ring-save'."
|
2013-12-17 23:48:26 +08:00
|
|
|
|
;; Pass mark first, then point, because the order matters when
|
|
|
|
|
;; calling `kill-append'.
|
|
|
|
|
(interactive (list (mark) (point)
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)))
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(let ((str (if region
|
Cleanup namespace of dos-w32.el.
* lisp/dos-w32.el (minibuffer-history-case-insensitive-variables)
(path-separator, null-device, buffer-file-coding-system)
(lpr-headers-switches): Check system-type before modifying them.
(find-buffer-file-type-coding-system): Mark obsolete.
(w32-find-file-not-found-set-buffer-file-coding-system): Rename from
find-file-not-found-set-buffer-file-coding-system.
(w32-untranslated-filesystem-list, w32-untranslated-canonical-name):
(w32-add-untranslated-filesystem, w32-remove-untranslated-filesystem)
(w32-direct-print-region-use-command-dot-com, w32-untranslated-file-p):
(w32-direct-print-region-helper, w32-direct-print-region-function)
(w32-direct-ps-print-region-function): Rename by adding a "w32-" prefix.
* lisp/startup.el (normal-top-level-add-subdirs-to-load-path):
* lisp/ps-print.el (ps-print-region-function):
* lisp/lpr.el (print-region-function): Use new name.
* lisp/simple.el (copy-region-as-kill): Fix call to region-extract-function.
* lisp/emacs-lisp/bytecomp.el (byte-defop-compiler): Add new `2-and' handler.
(byte-compile-and-folded): New function.
(=, <, >, <=, >=): Use it.
2013-10-29 22:45:53 -04:00
|
|
|
|
(funcall region-extract-function nil)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(filter-buffer-substring beg end))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(if (eq last-command 'kill-region)
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(kill-append str (< end beg))
|
|
|
|
|
(kill-new str)))
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(setq deactivate-mark t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(defun kill-ring-save (beg end &optional region)
|
1993-03-11 07:07:17 +00:00
|
|
|
|
"Save the region as if killed, but don't kill it.
|
1997-12-21 01:52:31 +00:00
|
|
|
|
In Transient Mark mode, deactivate the mark.
|
1993-03-11 07:07:17 +00:00
|
|
|
|
If `interprogram-cut-function' is non-nil, also save the text for a window
|
1997-12-21 01:52:31 +00:00
|
|
|
|
system cut and paste.
|
|
|
|
|
|
2001-02-16 12:09:39 +00:00
|
|
|
|
If you want to append the killed line to the last killed text,
|
|
|
|
|
use \\[append-next-kill] before \\[kill-ring-save].
|
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
The optional argument REGION if non-nil, indicates that we're not just copying
|
|
|
|
|
some text between BEG and END, but we're copying the region.
|
|
|
|
|
|
1997-12-21 01:52:31 +00:00
|
|
|
|
This command is similar to `copy-region-as-kill', except that it gives
|
2013-08-16 16:27:49 +08:00
|
|
|
|
visual feedback indicating the extent of the region being copied."
|
2013-12-17 23:48:26 +08:00
|
|
|
|
;; Pass mark first, then point, because the order matters when
|
|
|
|
|
;; calling `kill-append'.
|
|
|
|
|
(interactive (list (mark) (point)
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)))
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(copy-region-as-kill beg end region)
|
2012-07-29 12:45:48 +08:00
|
|
|
|
;; This use of called-interactively-p is correct because the code it
|
|
|
|
|
;; controls just gives the user visual feedback.
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(if (called-interactively-p 'interactive)
|
2012-07-29 12:45:48 +08:00
|
|
|
|
(indicate-copied-region)))
|
|
|
|
|
|
|
|
|
|
(defun indicate-copied-region (&optional message-len)
|
|
|
|
|
"Indicate that the region text has been copied interactively.
|
|
|
|
|
If the mark is visible in the selected window, blink the cursor
|
|
|
|
|
between point and mark if there is currently no active region
|
|
|
|
|
highlighting.
|
|
|
|
|
|
|
|
|
|
If the mark lies outside the selected window, display an
|
|
|
|
|
informative message containing a sample of the copied text. The
|
|
|
|
|
optional argument MESSAGE-LEN, if non-nil, specifies the length
|
|
|
|
|
of this sample text; it defaults to 40."
|
|
|
|
|
(let ((mark (mark t))
|
|
|
|
|
(point (point))
|
|
|
|
|
;; Inhibit quitting so we can make a quit here
|
|
|
|
|
;; look like a C-g typed as a command.
|
|
|
|
|
(inhibit-quit t))
|
|
|
|
|
(if (pos-visible-in-window-p mark (selected-window))
|
|
|
|
|
;; Swap point-and-mark quickly so as to show the region that
|
|
|
|
|
;; was selected. Don't do it if the region is highlighted.
|
|
|
|
|
(unless (and (region-active-p)
|
|
|
|
|
(face-background 'region))
|
|
|
|
|
;; Swap point and mark.
|
|
|
|
|
(set-marker (mark-marker) (point) (current-buffer))
|
|
|
|
|
(goto-char mark)
|
|
|
|
|
(sit-for blink-matching-delay)
|
|
|
|
|
;; Swap back.
|
|
|
|
|
(set-marker (mark-marker) mark (current-buffer))
|
|
|
|
|
(goto-char point)
|
|
|
|
|
;; If user quit, deactivate the mark
|
|
|
|
|
;; as C-g would as a command.
|
|
|
|
|
(and quit-flag mark-active
|
|
|
|
|
(deactivate-mark)))
|
|
|
|
|
(let ((len (min (abs (- mark point))
|
|
|
|
|
(or message-len 40))))
|
|
|
|
|
(if (< point mark)
|
|
|
|
|
;; Don't say "killed"; that is misleading.
|
|
|
|
|
(message "Saved text until \"%s\""
|
|
|
|
|
(buffer-substring-no-properties (- mark len) mark))
|
|
|
|
|
(message "Saved text from \"%s\""
|
|
|
|
|
(buffer-substring-no-properties mark (+ mark len))))))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1999-05-31 18:06:22 +00:00
|
|
|
|
(defun append-next-kill (&optional interactive)
|
2013-12-18 10:43:47 +08:00
|
|
|
|
"Cause following command, if it kills, to add to previous kill.
|
|
|
|
|
If the next command kills forward from point, the kill is
|
|
|
|
|
appended to the previous killed text. If the command kills
|
|
|
|
|
backward, the kill is prepended. Kill commands that act on the
|
|
|
|
|
region, such as `kill-region', are regarded as killing forward if
|
|
|
|
|
point is after mark, and killing backward if point is before
|
|
|
|
|
mark.
|
|
|
|
|
|
|
|
|
|
If the next command is not a kill command, `append-next-kill' has
|
|
|
|
|
no effect.
|
|
|
|
|
|
1999-05-31 18:06:22 +00:00
|
|
|
|
The argument is used for internal purposes; do not supply one."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
;; We don't use (interactive-p), since that breaks kbd macros.
|
|
|
|
|
(if interactive
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setq this-command 'kill-region)
|
|
|
|
|
(message "If the next command is a kill, it will append"))
|
|
|
|
|
(setq last-command 'kill-region)))
|
2002-04-19 00:05:22 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;; Yanking.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2012-08-18 13:11:38 +08:00
|
|
|
|
(defcustom yank-handled-properties
|
|
|
|
|
'((font-lock-face . yank-handle-font-lock-face-property)
|
|
|
|
|
(category . yank-handle-category-property))
|
|
|
|
|
"List of special text property handling conditions for yanking.
|
|
|
|
|
Each element should have the form (PROP . FUN), where PROP is a
|
|
|
|
|
property symbol and FUN is a function. When the `yank' command
|
|
|
|
|
inserts text into the buffer, it scans the inserted text for
|
|
|
|
|
stretches of text that have `eq' values of the text property
|
|
|
|
|
PROP; for each such stretch of text, FUN is called with three
|
|
|
|
|
arguments: the property's value in that text, and the start and
|
|
|
|
|
end positions of the text.
|
|
|
|
|
|
|
|
|
|
This is done prior to removing the properties specified by
|
|
|
|
|
`yank-excluded-properties'."
|
|
|
|
|
:group 'killing
|
2013-12-28 00:21:33 -08:00
|
|
|
|
:type '(repeat (cons (symbol :tag "property symbol")
|
|
|
|
|
function))
|
2012-08-18 13:11:38 +08:00
|
|
|
|
:version "24.3")
|
|
|
|
|
|
2002-04-19 00:05:22 +00:00
|
|
|
|
;; This is actually used in subr.el but defcustom does not work there.
|
|
|
|
|
(defcustom yank-excluded-properties
|
2012-08-18 13:11:38 +08:00
|
|
|
|
'(category field follow-link fontified font-lock-face help-echo
|
|
|
|
|
intangible invisible keymap local-map mouse-face read-only
|
|
|
|
|
yank-handler)
|
2007-09-16 22:11:33 +00:00
|
|
|
|
"Text properties to discard when yanking.
|
2003-06-04 21:13:41 +00:00
|
|
|
|
The value should be a list of text properties to discard or t,
|
2012-08-18 13:11:38 +08:00
|
|
|
|
which means to discard all text properties.
|
|
|
|
|
|
|
|
|
|
See also `yank-handled-properties'."
|
2002-04-19 00:05:22 +00:00
|
|
|
|
:type '(choice (const :tag "All" t) (repeat symbol))
|
2004-06-10 04:20:02 +00:00
|
|
|
|
:group 'killing
|
2012-08-18 13:11:38 +08:00
|
|
|
|
:version "24.3")
|
2002-04-19 00:05:22 +00:00
|
|
|
|
|
2002-11-29 15:09:37 +00:00
|
|
|
|
(defvar yank-window-start nil)
|
2003-01-18 23:34:14 +00:00
|
|
|
|
(defvar yank-undo-function nil
|
2003-01-21 21:11:12 +00:00
|
|
|
|
"If non-nil, function used by `yank-pop' to delete last stretch of yanked text.
|
|
|
|
|
Function is called with two parameters, START and END corresponding to
|
|
|
|
|
the value of the mark and point; it is guaranteed that START <= END.
|
|
|
|
|
Normally set from the UNDO element of a yank-handler; see `insert-for-yank'.")
|
2002-11-29 15:09:37 +00:00
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun yank-pop (&optional arg)
|
1992-08-21 07:18:16 +00:00
|
|
|
|
"Replace just-yanked stretch of killed text with a different stretch.
|
|
|
|
|
This command is allowed only immediately after a `yank' or a `yank-pop'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
At such a time, the region contains a stretch of reinserted
|
1992-08-21 07:18:16 +00:00
|
|
|
|
previously-killed text. `yank-pop' deletes that text and inserts in its
|
1991-12-21 09:29:41 +00:00
|
|
|
|
place a different stretch of killed text.
|
|
|
|
|
|
|
|
|
|
With no argument, the previous kill is inserted.
|
1992-08-21 07:18:16 +00:00
|
|
|
|
With argument N, insert the Nth previous kill.
|
|
|
|
|
If N is negative, this is a more recent kill.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
The sequence of kills wraps around, so that after the oldest one
|
2005-05-22 20:58:52 +00:00
|
|
|
|
comes the newest one.
|
|
|
|
|
|
|
|
|
|
When this command inserts killed text into the buffer, it honors
|
|
|
|
|
`yank-excluded-properties' and `yank-handler' as described in the
|
|
|
|
|
doc string for `insert-for-yank-1', which see."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(if (not (eq last-command 'yank))
|
|
|
|
|
(error "Previous command was not a yank"))
|
|
|
|
|
(setq this-command 'yank)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(unless arg (setq arg 1))
|
1996-02-06 23:56:47 +00:00
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
|
(before (< (point) (mark t))))
|
2003-01-18 23:59:12 +00:00
|
|
|
|
(if before
|
|
|
|
|
(funcall (or yank-undo-function 'delete-region) (point) (mark t))
|
|
|
|
|
(funcall (or yank-undo-function 'delete-region) (mark t) (point)))
|
2003-01-18 23:34:14 +00:00
|
|
|
|
(setq yank-undo-function nil)
|
1993-05-16 15:39:39 +00:00
|
|
|
|
(set-marker (mark-marker) (point) (current-buffer))
|
2002-04-19 00:05:22 +00:00
|
|
|
|
(insert-for-yank (current-kill arg))
|
2002-11-29 15:09:37 +00:00
|
|
|
|
;; Set the window start back where it was in the yank command,
|
|
|
|
|
;; if possible.
|
|
|
|
|
(set-window-start (selected-window) yank-window-start t)
|
1993-05-16 15:39:39 +00:00
|
|
|
|
(if before
|
|
|
|
|
;; This is like exchange-point-and-mark, but doesn't activate the mark.
|
|
|
|
|
;; It is cleaner to avoid activation, even though the command
|
|
|
|
|
;; loop would deactivate the mark because we inserted text.
|
|
|
|
|
(goto-char (prog1 (mark t)
|
|
|
|
|
(set-marker (mark-marker) (point) (current-buffer))))))
|
1993-03-11 07:07:17 +00:00
|
|
|
|
nil)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun yank (&optional arg)
|
2006-03-11 17:01:47 +00:00
|
|
|
|
"Reinsert (\"paste\") the last stretch of killed text.
|
2012-08-18 13:11:38 +08:00
|
|
|
|
More precisely, reinsert the most recent kill, which is the
|
|
|
|
|
stretch of killed text most recently killed OR yanked. Put point
|
|
|
|
|
at the end, and set mark at the beginning without activating it.
|
|
|
|
|
With just \\[universal-argument] as argument, put point at beginning, and mark at end.
|
|
|
|
|
With argument N, reinsert the Nth most recent kill.
|
|
|
|
|
|
|
|
|
|
When this command inserts text into the buffer, it honors the
|
|
|
|
|
`yank-handled-properties' and `yank-excluded-properties'
|
|
|
|
|
variables, and the `yank-handler' text property. See
|
|
|
|
|
`insert-for-yank-1' for details.
|
2005-05-22 20:58:52 +00:00
|
|
|
|
|
2006-11-01 23:11:08 +00:00
|
|
|
|
See also the command `yank-pop' (\\[yank-pop])."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*P")
|
2002-11-29 15:09:37 +00:00
|
|
|
|
(setq yank-window-start (window-start))
|
1994-02-13 00:16:23 +00:00
|
|
|
|
;; If we don't get all the way thru, make last-command indicate that
|
|
|
|
|
;; for the following command.
|
|
|
|
|
(setq this-command t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(push-mark (point))
|
2002-04-19 00:05:22 +00:00
|
|
|
|
(insert-for-yank (current-kill (cond
|
|
|
|
|
((listp arg) 0)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
((eq arg '-) -2)
|
2002-04-19 00:05:22 +00:00
|
|
|
|
(t (1- arg)))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(if (consp arg)
|
1993-05-16 15:39:39 +00:00
|
|
|
|
;; This is like exchange-point-and-mark, but doesn't activate the mark.
|
|
|
|
|
;; It is cleaner to avoid activation, even though the command
|
|
|
|
|
;; loop would deactivate the mark because we inserted text.
|
|
|
|
|
(goto-char (prog1 (mark t)
|
|
|
|
|
(set-marker (mark-marker) (point) (current-buffer)))))
|
1994-02-13 00:16:23 +00:00
|
|
|
|
;; If we do get all the way thru, make this-command indicate that.
|
2003-01-18 23:34:14 +00:00
|
|
|
|
(if (eq this-command t)
|
|
|
|
|
(setq this-command 'yank))
|
1993-03-11 07:07:17 +00:00
|
|
|
|
nil)
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
|
|
|
|
(defun rotate-yank-pointer (arg)
|
|
|
|
|
"Rotate the yanking point in the kill ring.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With ARG, rotate that many kills forward (or backward, if negative)."
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(current-kill arg))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;; Some kill commands.
|
|
|
|
|
|
|
|
|
|
;; Internal subroutine of delete-char
|
|
|
|
|
(defun kill-forward-chars (arg)
|
|
|
|
|
(if (listp arg) (setq arg (car arg)))
|
|
|
|
|
(if (eq arg '-) (setq arg -1))
|
2009-03-19 14:45:02 +00:00
|
|
|
|
(kill-region (point) (+ (point) arg)))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
|
|
|
|
;; Internal subroutine of backward-delete-char
|
|
|
|
|
(defun kill-backward-chars (arg)
|
|
|
|
|
(if (listp arg) (setq arg (car arg)))
|
|
|
|
|
(if (eq arg '-) (setq arg -1))
|
2009-03-19 14:45:02 +00:00
|
|
|
|
(kill-region (point) (- (point) arg)))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
|
|
|
|
(defcustom backward-delete-char-untabify-method 'untabify
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"The method for untabifying when deleting backward.
|
1999-11-15 16:11:14 +00:00
|
|
|
|
Can be `untabify' -- turn a tab to many spaces, then delete one space;
|
|
|
|
|
`hungry' -- delete all whitespace, both tabs and spaces;
|
|
|
|
|
`all' -- delete all whitespace, including tabs, spaces and newlines;
|
1999-08-16 20:42:38 +00:00
|
|
|
|
nil -- just delete one character."
|
1999-11-15 16:11:14 +00:00
|
|
|
|
:type '(choice (const untabify) (const hungry) (const all) (const nil))
|
2001-01-16 10:51:35 +00:00
|
|
|
|
:version "20.3"
|
1999-08-16 20:42:38 +00:00
|
|
|
|
:group 'killing)
|
|
|
|
|
|
|
|
|
|
(defun backward-delete-char-untabify (arg &optional killp)
|
|
|
|
|
"Delete characters backward, changing tabs into spaces.
|
|
|
|
|
The exact behavior depends on `backward-delete-char-untabify-method'.
|
|
|
|
|
Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil.
|
|
|
|
|
Interactively, ARG is the prefix arg (default 1)
|
|
|
|
|
and KILLP is t if a prefix arg was specified."
|
|
|
|
|
(interactive "*p\nP")
|
|
|
|
|
(when (eq backward-delete-char-untabify-method 'untabify)
|
|
|
|
|
(let ((count arg))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (and (> count 0) (not (bobp)))
|
|
|
|
|
(if (= (preceding-char) ?\t)
|
|
|
|
|
(let ((col (current-column)))
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(setq col (- col (current-column)))
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
(insert-char ?\s col)
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(delete-char 1)))
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(setq count (1- count))))))
|
2011-03-22 16:15:21 +01:00
|
|
|
|
(let* ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t")
|
1999-11-15 16:11:14 +00:00
|
|
|
|
((eq backward-delete-char-untabify-method 'all)
|
2011-03-22 16:15:21 +01:00
|
|
|
|
" \t\n\r")))
|
|
|
|
|
(n (if skip
|
2012-03-05 23:53:34 +08:00
|
|
|
|
(let* ((oldpt (point))
|
|
|
|
|
(wh (- oldpt (save-excursion
|
|
|
|
|
(skip-chars-backward skip)
|
|
|
|
|
(constrain-to-field nil oldpt)))))
|
2011-03-22 16:15:21 +01:00
|
|
|
|
(+ arg (if (zerop wh) 0 (1- wh))))
|
|
|
|
|
arg)))
|
|
|
|
|
;; Avoid warning about delete-backward-char
|
|
|
|
|
(with-no-warnings (delete-backward-char n killp))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
|
|
|
|
(defun zap-to-char (arg char)
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
"Kill up to and including ARGth occurrence of CHAR.
|
1999-08-16 20:42:38 +00:00
|
|
|
|
Case is ignored if `case-fold-search' is non-nil in the current buffer.
|
|
|
|
|
Goes backward if ARG is negative; error if CHAR not found."
|
2012-04-10 04:23:21 +02:00
|
|
|
|
(interactive (list (prefix-numeric-value current-prefix-arg)
|
|
|
|
|
(read-char "Zap to char: " t)))
|
2009-02-14 09:06:30 +00:00
|
|
|
|
;; Avoid "obsolete" warnings for translation-table-for-input.
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(if (char-table-p translation-table-for-input)
|
|
|
|
|
(setq char (or (aref translation-table-for-input char) char))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(kill-region (point) (progn
|
|
|
|
|
(search-forward (char-to-string char) nil nil arg)
|
|
|
|
|
(point))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
;; kill-line and its subroutines.
|
|
|
|
|
|
|
|
|
|
(defcustom kill-whole-line nil
|
2012-07-02 18:42:45 -04:00
|
|
|
|
"If non-nil, `kill-line' with no arg at start of line kills the whole line."
|
1999-08-16 20:42:38 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'killing)
|
|
|
|
|
|
|
|
|
|
(defun kill-line (&optional arg)
|
|
|
|
|
"Kill the rest of the current line; if no nonblanks there, kill thru newline.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With prefix argument ARG, kill that many lines from point.
|
1999-08-16 20:42:38 +00:00
|
|
|
|
Negative arguments kill lines backward.
|
2000-10-08 06:10:40 +00:00
|
|
|
|
With zero argument, kills the text before point on the current line.
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
|
|
|
|
When calling from a program, nil means \"no arg\",
|
|
|
|
|
a number counts as a prefix arg.
|
|
|
|
|
|
|
|
|
|
To kill a whole line, when point is not at the beginning, type \
|
2007-02-17 23:06:12 +00:00
|
|
|
|
\\[move-beginning-of-line] \\[kill-line] \\[kill-line].
|
1999-08-16 20:42:38 +00:00
|
|
|
|
|
2011-09-23 12:52:23 +02:00
|
|
|
|
If `show-trailing-whitespace' is non-nil, this command will just
|
|
|
|
|
kill the rest of the current line, even if there are only
|
|
|
|
|
nonblanks there.
|
|
|
|
|
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
If option `kill-whole-line' is non-nil, then this command kills the whole line
|
1999-08-16 20:42:38 +00:00
|
|
|
|
including its terminating newline, when used at the beginning of a line
|
|
|
|
|
with no argument. As a consequence, you can always kill a whole line
|
2007-02-17 23:06:12 +00:00
|
|
|
|
by typing \\[move-beginning-of-line] \\[kill-line].
|
2001-02-06 06:54:56 +00:00
|
|
|
|
|
2001-02-16 12:09:39 +00:00
|
|
|
|
If you want to append the killed line to the last killed text,
|
|
|
|
|
use \\[append-next-kill] before \\[kill-line].
|
|
|
|
|
|
2001-02-06 06:54:56 +00:00
|
|
|
|
If the buffer is read-only, Emacs will beep and refrain from deleting
|
|
|
|
|
the line, but put the line in the kill ring anyway. This means that
|
2003-04-21 01:35:20 +00:00
|
|
|
|
you can use this command to copy text from a read-only buffer.
|
|
|
|
|
\(If the variable `kill-read-only-ok' is non-nil, then this won't
|
|
|
|
|
even beep.)"
|
2000-02-23 23:08:02 +00:00
|
|
|
|
(interactive "P")
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(kill-region (point)
|
|
|
|
|
;; It is better to move point to the other end of the kill
|
|
|
|
|
;; before killing. That way, in a read-only buffer, point
|
|
|
|
|
;; moves across the text that is copied to the kill ring.
|
|
|
|
|
;; The choice has no effect on undo now that undo records
|
|
|
|
|
;; the value of point from before the command was run.
|
|
|
|
|
(progn
|
|
|
|
|
(if arg
|
|
|
|
|
(forward-visible-line (prefix-numeric-value arg))
|
|
|
|
|
(if (eobp)
|
|
|
|
|
(signal 'end-of-buffer nil))
|
2002-09-01 13:29:34 +00:00
|
|
|
|
(let ((end
|
|
|
|
|
(save-excursion
|
|
|
|
|
(end-of-visible-line) (point))))
|
|
|
|
|
(if (or (save-excursion
|
2004-04-16 12:51:06 +00:00
|
|
|
|
;; If trailing whitespace is visible,
|
|
|
|
|
;; don't treat it as nothing.
|
|
|
|
|
(unless show-trailing-whitespace
|
|
|
|
|
(skip-chars-forward " \t" end))
|
2002-09-01 13:29:34 +00:00
|
|
|
|
(= (point) end))
|
|
|
|
|
(and kill-whole-line (bolp)))
|
|
|
|
|
(forward-visible-line 1)
|
|
|
|
|
(goto-char end))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(point))))
|
|
|
|
|
|
2003-05-19 15:47:14 +00:00
|
|
|
|
(defun kill-whole-line (&optional arg)
|
|
|
|
|
"Kill current line.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With prefix ARG, kill that many lines starting from the current line.
|
|
|
|
|
If ARG is negative, kill backward. Also kill the preceding newline.
|
2014-02-21 14:22:14 +01:00
|
|
|
|
\(This is meant to make \\[repeat] work well with negative arguments.)
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
If ARG is zero, kill current line but exclude the trailing newline."
|
2004-05-01 20:10:19 +00:00
|
|
|
|
(interactive "p")
|
2009-02-06 03:59:15 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2003-05-29 23:29:29 +00:00
|
|
|
|
(if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
|
|
|
|
|
(signal 'end-of-buffer nil))
|
|
|
|
|
(if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
|
|
|
|
|
(signal 'beginning-of-buffer nil))
|
|
|
|
|
(unless (eq last-command 'kill-region)
|
|
|
|
|
(kill-new "")
|
|
|
|
|
(setq last-command 'kill-region))
|
2003-05-19 15:47:14 +00:00
|
|
|
|
(cond ((zerop arg)
|
2003-05-29 23:29:29 +00:00
|
|
|
|
;; We need to kill in two steps, because the previous command
|
|
|
|
|
;; could have been a kill command, in which case the text
|
|
|
|
|
;; before point needs to be prepended to the current kill
|
|
|
|
|
;; ring entry and the text after point appended. Also, we
|
|
|
|
|
;; need to use save-excursion to avoid copying the same text
|
|
|
|
|
;; twice to the kill ring in read-only buffers.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(kill-region (point) (progn (forward-visible-line 0) (point))))
|
2003-05-19 15:47:14 +00:00
|
|
|
|
(kill-region (point) (progn (end-of-visible-line) (point))))
|
|
|
|
|
((< arg 0)
|
2003-05-29 23:29:29 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(kill-region (point) (progn (end-of-visible-line) (point))))
|
|
|
|
|
(kill-region (point)
|
|
|
|
|
(progn (forward-visible-line (1+ arg))
|
|
|
|
|
(unless (bobp) (backward-char))
|
|
|
|
|
(point))))
|
2003-05-19 15:47:14 +00:00
|
|
|
|
(t
|
2003-05-29 23:29:29 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(kill-region (point) (progn (forward-visible-line 0) (point))))
|
|
|
|
|
(kill-region (point)
|
|
|
|
|
(progn (forward-visible-line arg) (point))))))
|
2002-09-09 00:27:30 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(defun forward-visible-line (arg)
|
|
|
|
|
"Move forward by ARG lines, ignoring currently invisible newlines only.
|
|
|
|
|
If ARG is negative, move backward -ARG lines.
|
|
|
|
|
If ARG is zero, move to the beginning of the current line."
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(if (> arg 0)
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(progn
|
|
|
|
|
(while (> arg 0)
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(or (zerop (forward-line 1))
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(signal 'end-of-buffer nil))
|
|
|
|
|
;; If the newline we just skipped is invisible,
|
|
|
|
|
;; don't count it.
|
|
|
|
|
(let ((prop
|
|
|
|
|
(get-char-property (1- (point)) 'invisible)))
|
|
|
|
|
(if (if (eq buffer-invisibility-spec t)
|
|
|
|
|
prop
|
|
|
|
|
(or (memq prop buffer-invisibility-spec)
|
|
|
|
|
(assq prop buffer-invisibility-spec)))
|
|
|
|
|
(setq arg (1+ arg))))
|
|
|
|
|
(setq arg (1- arg)))
|
|
|
|
|
;; If invisible text follows, and it is a number of complete lines,
|
|
|
|
|
;; skip it.
|
|
|
|
|
(let ((opoint (point)))
|
|
|
|
|
(while (and (not (eobp))
|
|
|
|
|
(let ((prop
|
|
|
|
|
(get-char-property (point) 'invisible)))
|
|
|
|
|
(if (eq buffer-invisibility-spec t)
|
|
|
|
|
prop
|
|
|
|
|
(or (memq prop buffer-invisibility-spec)
|
|
|
|
|
(assq prop buffer-invisibility-spec)))))
|
|
|
|
|
(goto-char
|
|
|
|
|
(if (get-text-property (point) 'invisible)
|
|
|
|
|
(or (next-single-property-change (point) 'invisible)
|
|
|
|
|
(point-max))
|
|
|
|
|
(next-overlay-change (point)))))
|
|
|
|
|
(unless (bolp)
|
|
|
|
|
(goto-char opoint))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(let ((first t))
|
2003-05-25 01:34:37 +00:00
|
|
|
|
(while (or first (<= arg 0))
|
|
|
|
|
(if first
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(or (zerop (forward-line -1))
|
|
|
|
|
(signal 'beginning-of-buffer nil)))
|
2002-09-09 00:27:30 +00:00
|
|
|
|
;; If the newline we just moved to is invisible,
|
|
|
|
|
;; don't count it.
|
|
|
|
|
(unless (bobp)
|
|
|
|
|
(let ((prop
|
|
|
|
|
(get-char-property (1- (point)) 'invisible)))
|
2003-05-25 01:34:37 +00:00
|
|
|
|
(unless (if (eq buffer-invisibility-spec t)
|
|
|
|
|
prop
|
|
|
|
|
(or (memq prop buffer-invisibility-spec)
|
|
|
|
|
(assq prop buffer-invisibility-spec)))
|
|
|
|
|
(setq arg (1+ arg)))))
|
|
|
|
|
(setq first nil))
|
2002-09-09 00:27:30 +00:00
|
|
|
|
;; If invisible text follows, and it is a number of complete lines,
|
|
|
|
|
;; skip it.
|
|
|
|
|
(let ((opoint (point)))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(while (and (not (bobp))
|
|
|
|
|
(let ((prop
|
|
|
|
|
(get-char-property (1- (point)) 'invisible)))
|
|
|
|
|
(if (eq buffer-invisibility-spec t)
|
|
|
|
|
prop
|
|
|
|
|
(or (memq prop buffer-invisibility-spec)
|
|
|
|
|
(assq prop buffer-invisibility-spec)))))
|
|
|
|
|
(goto-char
|
|
|
|
|
(if (get-text-property (1- (point)) 'invisible)
|
|
|
|
|
(or (previous-single-property-change (point) 'invisible)
|
|
|
|
|
(point-min))
|
2002-09-09 00:27:30 +00:00
|
|
|
|
(previous-overlay-change (point)))))
|
|
|
|
|
(unless (bolp)
|
|
|
|
|
(goto-char opoint)))))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
((beginning-of-buffer end-of-buffer)
|
|
|
|
|
nil)))
|
1992-06-12 22:23:00 +00:00
|
|
|
|
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(defun end-of-visible-line ()
|
|
|
|
|
"Move to end of current visible line."
|
|
|
|
|
(end-of-line)
|
|
|
|
|
;; If the following character is currently invisible,
|
|
|
|
|
;; skip all characters with that same `invisible' property value,
|
|
|
|
|
;; then find the next newline.
|
|
|
|
|
(while (and (not (eobp))
|
2002-09-01 13:29:34 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-forward "^\n")
|
|
|
|
|
(let ((prop
|
|
|
|
|
(get-char-property (point) 'invisible)))
|
|
|
|
|
(if (eq buffer-invisibility-spec t)
|
|
|
|
|
prop
|
|
|
|
|
(or (memq prop buffer-invisibility-spec)
|
|
|
|
|
(assq prop buffer-invisibility-spec))))))
|
|
|
|
|
(skip-chars-forward "^\n")
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(if (get-text-property (point) 'invisible)
|
2012-03-22 15:38:05 +08:00
|
|
|
|
(goto-char (or (next-single-property-change (point) 'invisible)
|
|
|
|
|
(point-max)))
|
1999-08-16 20:42:38 +00:00
|
|
|
|
(goto-char (next-overlay-change (point))))
|
|
|
|
|
(end-of-line)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun insert-buffer (buffer)
|
|
|
|
|
"Insert after point the contents of BUFFER.
|
|
|
|
|
Puts mark after the inserted text.
|
1999-12-06 13:34:50 +00:00
|
|
|
|
BUFFER may be a buffer or a buffer name.
|
|
|
|
|
|
|
|
|
|
This function is meant for the user to run interactively.
|
2003-05-13 19:45:01 +00:00
|
|
|
|
Don't call it from programs: use `insert-buffer-substring' instead!"
|
1996-03-18 19:32:24 +00:00
|
|
|
|
(interactive
|
1996-03-18 18:50:25 +00:00
|
|
|
|
(list
|
|
|
|
|
(progn
|
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(read-buffer "Insert buffer: "
|
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
|
|
|
|
(if (eq (selected-window) (next-window))
|
1996-03-18 18:50:25 +00:00
|
|
|
|
(other-buffer (current-buffer))
|
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-buffer (next-window)))
|
1996-03-18 18:50:25 +00:00
|
|
|
|
t))))
|
2003-05-13 19:45:01 +00:00
|
|
|
|
(push-mark
|
|
|
|
|
(save-excursion
|
|
|
|
|
(insert-buffer-substring (get-buffer buffer))
|
|
|
|
|
(point)))
|
1993-03-02 07:33:17 +00:00
|
|
|
|
nil)
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'insert-buffer 'interactive-only 'insert-buffer-substring)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun append-to-buffer (buffer start end)
|
|
|
|
|
"Append to specified buffer the text of the region.
|
|
|
|
|
It is inserted into that buffer before its point.
|
|
|
|
|
|
|
|
|
|
When calling from a program, give three arguments:
|
|
|
|
|
BUFFER (or buffer name), START and END.
|
|
|
|
|
START and END specify the portion of the current buffer to be copied."
|
1992-06-12 22:23:00 +00:00
|
|
|
|
(interactive
|
1994-11-22 19:19:42 +00:00
|
|
|
|
(list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t))
|
1993-06-10 23:06:50 +00:00
|
|
|
|
(region-beginning) (region-end)))
|
2010-03-30 22:53:53 -04:00
|
|
|
|
(let* ((oldbuf (current-buffer))
|
|
|
|
|
(append-to (get-buffer-create buffer))
|
|
|
|
|
(windows (get-buffer-window-list append-to t t))
|
|
|
|
|
point)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(with-current-buffer append-to
|
|
|
|
|
(setq point (point))
|
|
|
|
|
(barf-if-buffer-read-only)
|
|
|
|
|
(insert-buffer-substring oldbuf start end)
|
|
|
|
|
(dolist (window windows)
|
|
|
|
|
(when (= (window-point window) point)
|
|
|
|
|
(set-window-point window (point))))))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun prepend-to-buffer (buffer start end)
|
|
|
|
|
"Prepend to specified buffer the text of the region.
|
|
|
|
|
It is inserted into that buffer after its point.
|
|
|
|
|
|
|
|
|
|
When calling from a program, give three arguments:
|
|
|
|
|
BUFFER (or buffer name), START and END.
|
|
|
|
|
START and END specify the portion of the current buffer to be copied."
|
|
|
|
|
(interactive "BPrepend to buffer: \nr")
|
|
|
|
|
(let ((oldbuf (current-buffer)))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create buffer)
|
1999-07-20 16:09:54 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(insert-buffer-substring oldbuf start end)))))
|
|
|
|
|
|
|
|
|
|
(defun copy-to-buffer (buffer start end)
|
|
|
|
|
"Copy to specified buffer the text of the region.
|
|
|
|
|
It is inserted into that buffer, replacing existing text there.
|
|
|
|
|
|
|
|
|
|
When calling from a program, give three arguments:
|
|
|
|
|
BUFFER (or buffer name), START and END.
|
|
|
|
|
START and END specify the portion of the current buffer to be copied."
|
|
|
|
|
(interactive "BCopy to buffer: \nr")
|
|
|
|
|
(let ((oldbuf (current-buffer)))
|
2005-11-01 07:18:10 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create buffer)
|
1999-07-20 16:09:54 +00:00
|
|
|
|
(barf-if-buffer-read-only)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(insert-buffer-substring oldbuf start end)))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
* lisp/subr.el (define-error): New function.
* doc/lispref/control.texi (Signaling Errors): Refer to define-error.
(Error Symbols): Add `define-error'.
* doc/lispref/errors.texi (Standard Errors): Don't refer to `error-conditions'.
* lisp/progmodes/ada-xref.el (ada-error-file-not-found): Rename from
error-file-not-found and define with define-error.
* lisp/emacs-lisp/cl-lib.el (cl-assertion-failed): Move here from subr.el
and define with define-error.
* lisp/userlock.el (file-locked, file-supersession):
* lisp/simple.el (mark-inactive):
* lisp/progmodes/js.el (js-moz-bad-rpc, js-js-error):
* lisp/progmodes/ada-mode.el (ada-mode-errors):
* lisp/play/life.el (life-extinct):
* lisp/nxml/xsd-regexp.el (xsdre-invalid-regexp, xsdre-parse-error):
* lisp/nxml/xmltok.el (xmltok-markup-declaration-parse-error):
* lisp/nxml/rng-util.el (rng-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-cmpct.el (rng-c-incorrect-schema):
* lisp/nxml/nxml-util.el (nxml-error, nxml-file-parse-error):
* lisp/nxml/nxml-rap.el (nxml-scan-error):
* lisp/nxml/nxml-outln.el (nxml-outline-error):
* lisp/net/soap-client.el (soap-error):
* lisp/net/gnutls.el (gnutls-error):
* lisp/net/ange-ftp.el (ftp-error):
* lisp/mpc.el (mpc-proc-error):
* lisp/json.el (json-error, json-readtable-error, json-unknown-keyword)
(json-number-format, json-string-escape, json-string-format)
(json-key-format, json-object-format):
* lisp/jka-compr.el (compression-error):
* lisp/international/quail.el (quail-error):
* lisp/international/kkc.el (kkc-error):
* lisp/emacs-lisp/ert.el (ert-test-failed):
* lisp/calc/calc.el (calc-error, inexact-result, math-overflow)
(math-underflow):
* lisp/bookmark.el (bookmark-error-no-filename):
* lisp/epg.el (epg-error): Define with define-error.
2013-08-09 17:22:44 -04:00
|
|
|
|
(define-error 'mark-inactive (purecopy "The mark is not active now"))
|
1993-07-08 21:46:22 +00:00
|
|
|
|
|
2005-03-06 20:16:01 +00:00
|
|
|
|
(defvar activate-mark-hook nil
|
|
|
|
|
"Hook run when the mark becomes active.
|
|
|
|
|
It is also run at the end of a command, if the mark is active and
|
2007-04-03 11:10:09 +00:00
|
|
|
|
it is possible that the region may have changed.")
|
2005-03-06 20:16:01 +00:00
|
|
|
|
|
|
|
|
|
(defvar deactivate-mark-hook nil
|
|
|
|
|
"Hook run when the mark becomes inactive.")
|
|
|
|
|
|
1993-03-09 05:40:33 +00:00
|
|
|
|
(defun mark (&optional force)
|
2006-01-05 15:59:50 +00:00
|
|
|
|
"Return this buffer's mark value as integer, or nil if never set.
|
|
|
|
|
|
|
|
|
|
In Transient Mark mode, this function signals an error if
|
|
|
|
|
the mark is not active. However, if `mark-even-if-inactive' is non-nil,
|
|
|
|
|
or the argument FORCE is non-nil, it disregards whether the mark
|
|
|
|
|
is active, and returns an integer or nil in the usual way.
|
1993-03-09 05:40:33 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
If you are using this in an editing command, you are most likely making
|
|
|
|
|
a mistake; see the documentation of `set-mark'."
|
1995-01-23 22:37:46 +00:00
|
|
|
|
(if (or force (not transient-mark-mode) mark-active mark-even-if-inactive)
|
1993-03-09 05:40:33 +00:00
|
|
|
|
(marker-position (mark-marker))
|
1993-07-08 21:46:22 +00:00
|
|
|
|
(signal 'mark-inactive nil)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2013-09-19 16:31:26 -04:00
|
|
|
|
;; Behind display-selections-p.
|
|
|
|
|
(declare-function x-selection-owner-p "xselect.c"
|
|
|
|
|
(&optional selection terminal))
|
|
|
|
|
(declare-function x-selection-exists-p "xselect.c"
|
|
|
|
|
(&optional selection terminal))
|
|
|
|
|
|
2013-04-18 09:15:08 -04:00
|
|
|
|
(defun deactivate-mark (&optional force)
|
2012-01-28 22:29:29 +08:00
|
|
|
|
"Deactivate the mark.
|
|
|
|
|
If Transient Mark mode is disabled, this function normally does
|
|
|
|
|
nothing; but if FORCE is non-nil, it deactivates the mark anyway.
|
|
|
|
|
|
|
|
|
|
Deactivating the mark sets `mark-active' to nil, updates the
|
|
|
|
|
primary selection according to `select-active-regions', and runs
|
|
|
|
|
`deactivate-mark-hook'.
|
|
|
|
|
|
|
|
|
|
If Transient Mark mode was temporarily enabled, reset the value
|
|
|
|
|
of the variable `transient-mark-mode'; if this causes Transient
|
|
|
|
|
Mark mode to be disabled, don't change `mark-active' to nil or
|
|
|
|
|
run `deactivate-mark-hook'."
|
2009-07-15 01:25:32 +00:00
|
|
|
|
(when (or transient-mark-mode force)
|
2010-08-15 22:33:17 -04:00
|
|
|
|
(when (and (if (eq select-active-regions 'only)
|
|
|
|
|
(eq (car-safe transient-mark-mode) 'only)
|
|
|
|
|
select-active-regions)
|
2010-08-07 15:39:04 -04:00
|
|
|
|
(region-active-p)
|
|
|
|
|
(display-selections-p))
|
|
|
|
|
;; The var `saved-region-selection', if non-nil, is the text in
|
|
|
|
|
;; the region prior to the last command modifying the buffer.
|
|
|
|
|
;; Set the selection to that, or to the current region.
|
|
|
|
|
(cond (saved-region-selection
|
|
|
|
|
(x-set-selection 'PRIMARY saved-region-selection)
|
|
|
|
|
(setq saved-region-selection nil))
|
2012-07-08 14:09:21 +08:00
|
|
|
|
;; If another program has acquired the selection, region
|
|
|
|
|
;; deactivation should not clobber it (Bug#11772).
|
|
|
|
|
((and (/= (region-beginning) (region-end))
|
|
|
|
|
(or (x-selection-owner-p 'PRIMARY)
|
|
|
|
|
(null (x-selection-exists-p 'PRIMARY))))
|
2010-08-07 15:39:04 -04:00
|
|
|
|
(x-set-selection 'PRIMARY
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
(funcall region-extract-function nil)))))
|
2014-01-08 20:59:19 -05:00
|
|
|
|
(when mark-active (force-mode-line-update)) ;Refresh toolbar (bug#16382).
|
2014-05-27 10:59:08 -04:00
|
|
|
|
(cond
|
|
|
|
|
((eq (car-safe transient-mark-mode) 'only)
|
|
|
|
|
(setq transient-mark-mode (cdr transient-mark-mode)))
|
|
|
|
|
((eq transient-mark-mode 'lambda)
|
|
|
|
|
(setq transient-mark-mode nil)))
|
|
|
|
|
(setq mark-active nil)
|
|
|
|
|
(run-hooks 'deactivate-mark-hook)
|
2014-03-19 15:12:50 -04:00
|
|
|
|
(redisplay--update-region-highlight (selected-window))))
|
1993-07-08 22:37:42 +00:00
|
|
|
|
|
2014-01-08 20:59:19 -05:00
|
|
|
|
(defun activate-mark (&optional no-tmm)
|
|
|
|
|
"Activate the mark.
|
|
|
|
|
If NO-TMM is non-nil, leave `transient-mark-mode' alone."
|
2008-03-26 03:40:40 +00:00
|
|
|
|
(when (mark t)
|
2014-03-11 13:10:07 -04:00
|
|
|
|
(unless (region-active-p)
|
|
|
|
|
(force-mode-line-update) ;Refresh toolbar (bug#16382).
|
|
|
|
|
(setq mark-active t)
|
|
|
|
|
(unless (or transient-mark-mode no-tmm)
|
|
|
|
|
(setq transient-mark-mode 'lambda))
|
|
|
|
|
(run-hooks 'activate-mark-hook))))
|
2007-12-25 20:02:45 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun set-mark (pos)
|
|
|
|
|
"Set this buffer's mark to POS. Don't use this function!
|
|
|
|
|
That is to say, don't use this function unless you want
|
|
|
|
|
the user to see that the mark has moved, and you want the previous
|
|
|
|
|
mark position to be lost.
|
|
|
|
|
|
|
|
|
|
Normally, when a new mark is set, the old one should go on the stack.
|
2005-03-29 23:17:30 +00:00
|
|
|
|
This is why most applications should use `push-mark', not `set-mark'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1992-08-21 07:18:16 +00:00
|
|
|
|
Novice Emacs Lisp programmers often try to use the mark for the wrong
|
1991-12-21 09:29:41 +00:00
|
|
|
|
purposes. The mark saves a location for the user's convenience.
|
|
|
|
|
Most editing commands should not alter the mark.
|
|
|
|
|
To remember a location for internal use in the Lisp program,
|
|
|
|
|
store it in a Lisp variable. Example:
|
|
|
|
|
|
|
|
|
|
(let ((beg (point))) (forward-line 1) (delete-region beg (point)))."
|
1993-07-26 07:31:11 +00:00
|
|
|
|
(if pos
|
2014-03-11 13:10:07 -04:00
|
|
|
|
(progn
|
|
|
|
|
(set-marker (mark-marker) pos (current-buffer))
|
|
|
|
|
(activate-mark 'no-tmm))
|
1994-08-30 00:36:48 +00:00
|
|
|
|
;; Normally we never clear mark-active except in Transient Mark mode.
|
2009-07-15 01:25:32 +00:00
|
|
|
|
;; But when we actually clear out the mark value too, we must
|
|
|
|
|
;; clear mark-active in any mode.
|
2014-03-11 13:10:07 -04:00
|
|
|
|
(deactivate-mark t)
|
|
|
|
|
;; `deactivate-mark' sometimes leaves mark-active non-nil, but
|
|
|
|
|
;; it should never be nil if the mark is nil.
|
|
|
|
|
(setq mark-active nil)
|
|
|
|
|
(set-marker (mark-marker) nil)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2007-12-23 21:46:25 +00:00
|
|
|
|
(defcustom use-empty-active-region nil
|
2008-11-27 17:01:50 +00:00
|
|
|
|
"Whether \"region-aware\" commands should act on empty regions.
|
|
|
|
|
If nil, region-aware commands treat empty regions as inactive.
|
|
|
|
|
If non-nil, region-aware commands treat the region as active as
|
|
|
|
|
long as the mark is active, even if the region is empty.
|
|
|
|
|
|
2008-11-27 17:07:25 +00:00
|
|
|
|
Region-aware commands are those that act on the region if it is
|
|
|
|
|
active and Transient Mark mode is enabled, and on the text near
|
|
|
|
|
point otherwise."
|
2007-12-23 21:46:25 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "23.1"
|
|
|
|
|
:group 'editing-basics)
|
|
|
|
|
|
2007-12-25 22:12:56 +00:00
|
|
|
|
(defun use-region-p ()
|
2008-11-27 17:01:50 +00:00
|
|
|
|
"Return t if the region is active and it is appropriate to act on it.
|
|
|
|
|
This is used by commands that act specially on the region under
|
2009-07-18 17:39:35 +00:00
|
|
|
|
Transient Mark mode.
|
2008-11-27 17:01:50 +00:00
|
|
|
|
|
2010-07-10 15:32:53 -04:00
|
|
|
|
The return value is t if Transient Mark mode is enabled and the
|
2010-07-10 18:41:55 -04:00
|
|
|
|
mark is active; furthermore, if `use-empty-active-region' is nil,
|
|
|
|
|
the region must not be empty. Otherwise, the return value is nil.
|
2009-07-18 17:39:35 +00:00
|
|
|
|
|
|
|
|
|
For some commands, it may be appropriate to ignore the value of
|
|
|
|
|
`use-empty-active-region'; in that case, use `region-active-p'."
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(and (region-active-p)
|
2007-12-23 21:46:25 +00:00
|
|
|
|
(or use-empty-active-region (> (region-end) (region-beginning)))))
|
|
|
|
|
|
2007-12-25 22:43:44 +00:00
|
|
|
|
(defun region-active-p ()
|
2007-12-25 23:00:51 +00:00
|
|
|
|
"Return t if Transient Mark mode is enabled and the mark is active.
|
2008-11-27 17:01:50 +00:00
|
|
|
|
|
2009-07-18 17:39:35 +00:00
|
|
|
|
Some commands act specially on the region when Transient Mark
|
|
|
|
|
mode is enabled. Usually, such commands should use
|
|
|
|
|
`use-region-p' instead of this function, because `use-region-p'
|
|
|
|
|
also checks the value of `use-empty-active-region'."
|
2014-04-23 08:52:22 -04:00
|
|
|
|
(and transient-mark-mode mark-active
|
|
|
|
|
;; FIXME: Somehow we sometimes end up with mark-active non-nil but
|
|
|
|
|
;; without the mark being set (e.g. bug#17324). We really should fix
|
|
|
|
|
;; that problem, but in the mean time, let's make sure we don't say the
|
|
|
|
|
;; region is active when there's no mark.
|
|
|
|
|
(mark)))
|
2007-12-25 22:43:44 +00:00
|
|
|
|
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
|
|
|
|
|
(defvar redisplay-unhighlight-region-function
|
|
|
|
|
(lambda (rol) (when (overlayp rol) (delete-overlay rol))))
|
|
|
|
|
|
|
|
|
|
(defvar redisplay-highlight-region-function
|
|
|
|
|
(lambda (start end window rol)
|
|
|
|
|
(if (not (overlayp rol))
|
|
|
|
|
(let ((nrol (make-overlay start end)))
|
|
|
|
|
(funcall redisplay-unhighlight-region-function rol)
|
|
|
|
|
(overlay-put nrol 'window window)
|
|
|
|
|
(overlay-put nrol 'face 'region)
|
2014-03-23 18:30:47 -04:00
|
|
|
|
;; Normal priority so that a large region doesn't hide all the
|
|
|
|
|
;; overlays within it, but high secondary priority so that if it
|
|
|
|
|
;; ends/starts in the middle of a small overlay, that small overlay
|
|
|
|
|
;; won't hide the region's boundaries.
|
|
|
|
|
(overlay-put nrol 'priority '(nil . 100))
|
Add pre-redisplay-function and rectangular region
* lisp/rect.el: Use lexical-binding. Add new rectangular region support.
(rectangle-mark): New command.
(rectangle--region): New var.
(deactivate-mark-hook): Reset rectangle--region.
(rectangle--extract-region, rectangle--insert-for-yank)
(rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay): New functions.
(region-extract-function, redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): Use them to handle
rectangular region.
* lisp/simple.el (region-extract-function): New var.
(delete-backward-char, delete-forward-char, deactivate-mark): Use it.
(kill-new, kill-append): Remove obsolete `yank-handler' argument.
(kill-region): Replace obsolete `yank-handler' arg with `region'.
(copy-region-as-kill, kill-ring-save): Add `region' argument.
(redisplay-unhighlight-region-function)
(redisplay-highlight-region-function): New vars.
(redisplay--update-region-highlight): New function.
(pre-redisplay-function): Use it.
(exchange-point-and-mark): Don't deactivate the mark before
reactivate-it anyway.
* lisp/comint.el (comint-kill-region): Remove yank-handler argument.
* lisp/delsel.el (delete-backward-char, backward-delete-char-untabify)
(delete-char): Remove property, since it's now part of their
default behavior.
(self-insert-iso): Remove property since this command doesn't exist.
* src/xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
(syms_of_xdisp): Declare pre-redisplay-function.
(markpos_of_region): Remove function.
(init_iterator, compute_stop_pos, handle_face_prop)
(face_before_or_after_it_pos, reseat_to_string)
(get_next_display_element, window_buffer_changed)
(redisplay_internal, try_cursor_movement, redisplay_window)
(try_window_reusing_current_matrix, try_window_id, display_line)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(display_string, mouse_face_from_buffer_pos): Remove region handling.
* src/window.h (struct window): Remove field `region_showing'.
* src/dispextern.h (struct it): Remove region_beg/end_charpos.
(face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Update prototypes.
* src/xfaces.c (face_at_buffer_position, face_for_overlay_string)
(face_at_string_position): Remove `region_beg' and `region_end' args.
* src/fontset.c (Finternal_char_font):
* src/font.c (font_at, font_range): Adjust calls accordingly.
* src/insdel.c (Qregion_extract_function): New var.
(syms_of_insdel): Initialize it.
(prepare_to_modify_buffer_1): Use it.
2013-10-29 12:11:50 -04:00
|
|
|
|
nrol)
|
|
|
|
|
(unless (and (eq (overlay-buffer rol) (current-buffer))
|
|
|
|
|
(eq (overlay-start rol) start)
|
|
|
|
|
(eq (overlay-end rol) end))
|
|
|
|
|
(move-overlay rol start end (current-buffer)))
|
|
|
|
|
rol)))
|
|
|
|
|
|
|
|
|
|
(defun redisplay--update-region-highlight (window)
|
|
|
|
|
(with-current-buffer (window-buffer window)
|
|
|
|
|
(let ((rol (window-parameter window 'internal-region-overlay)))
|
|
|
|
|
(if (not (region-active-p))
|
|
|
|
|
(funcall redisplay-unhighlight-region-function rol)
|
|
|
|
|
(let* ((pt (window-point window))
|
|
|
|
|
(mark (mark))
|
|
|
|
|
(start (min pt mark))
|
|
|
|
|
(end (max pt mark))
|
|
|
|
|
(new
|
|
|
|
|
(funcall redisplay-highlight-region-function
|
|
|
|
|
start end window rol)))
|
|
|
|
|
(unless (equal new rol)
|
|
|
|
|
(set-window-parameter window 'internal-region-overlay
|
|
|
|
|
new)))))))
|
|
|
|
|
|
|
|
|
|
(defun redisplay--update-region-highlights (windows)
|
|
|
|
|
(with-demoted-errors "redisplay--update-region-highlights: %S"
|
|
|
|
|
(if (null windows)
|
|
|
|
|
(redisplay--update-region-highlight (selected-window))
|
|
|
|
|
(unless (listp windows) (setq windows (window-list-1 nil nil t)))
|
|
|
|
|
(if highlight-nonselected-windows
|
|
|
|
|
(mapc #'redisplay--update-region-highlight windows)
|
|
|
|
|
(let ((msw (and (window-minibuffer-p) (minibuffer-selected-window))))
|
|
|
|
|
(dolist (w windows)
|
|
|
|
|
(if (or (eq w (selected-window)) (eq w msw))
|
|
|
|
|
(redisplay--update-region-highlight w)
|
|
|
|
|
(funcall redisplay-unhighlight-region-function
|
|
|
|
|
(window-parameter w 'internal-region-overlay)))))))))
|
|
|
|
|
|
|
|
|
|
(add-function :before pre-redisplay-function
|
|
|
|
|
#'redisplay--update-region-highlights)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defvar-local mark-ring nil
|
1994-09-03 23:33:50 +00:00
|
|
|
|
"The list of former marks of the current buffer, most recent first.")
|
|
|
|
|
(put 'mark-ring 'permanent-local t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom mark-ring-max 16
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Maximum size of mark ring. Start discarding off end if gets this big."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'editing-basics)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1994-02-07 02:24:01 +00:00
|
|
|
|
(defvar global-mark-ring nil
|
|
|
|
|
"The list of saved global marks, most recent first.")
|
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom global-mark-ring-max 16
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Maximum size of global mark ring. \
|
1997-05-05 11:57:31 +00:00
|
|
|
|
Start discarding off end if gets this big."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'editing-basics)
|
1994-02-07 02:24:01 +00:00
|
|
|
|
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(defun pop-to-mark-command ()
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
"Jump to mark, and pop a new position for mark off the ring.
|
2014-02-21 14:22:14 +01:00
|
|
|
|
\(Does not affect global mark ring)."
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(if (null (mark t))
|
|
|
|
|
(error "No mark set in this buffer")
|
2007-04-21 08:55:15 +00:00
|
|
|
|
(if (= (point) (mark t))
|
|
|
|
|
(message "Mark popped"))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(goto-char (mark t))
|
|
|
|
|
(pop-mark)))
|
|
|
|
|
|
2002-05-27 12:13:56 +00:00
|
|
|
|
(defun push-mark-command (arg &optional nomsg)
|
2002-04-14 17:27:55 +00:00
|
|
|
|
"Set mark at where point is.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
If no prefix ARG and mark is already set there, just activate it.
|
2002-05-27 12:13:56 +00:00
|
|
|
|
Display `Mark set' unless the optional second arg NOMSG is non-nil."
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(interactive "P")
|
2014-01-08 20:59:19 -05:00
|
|
|
|
(let ((mark (mark t)))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(if (or arg (null mark) (/= mark (point)))
|
2002-05-27 12:13:56 +00:00
|
|
|
|
(push-mark nil nomsg t)
|
2014-01-08 20:59:19 -05:00
|
|
|
|
(activate-mark 'no-tmm)
|
2002-05-27 12:13:56 +00:00
|
|
|
|
(unless nomsg
|
|
|
|
|
(message "Mark activated")))))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
|
2005-11-03 21:41:20 +00:00
|
|
|
|
(defcustom set-mark-command-repeat-pop nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Non-nil means repeating \\[set-mark-command] after popping mark pops it again.
|
2007-04-23 21:16:31 +00:00
|
|
|
|
That means that C-u \\[set-mark-command] \\[set-mark-command]
|
|
|
|
|
will pop the mark twice, and
|
|
|
|
|
C-u \\[set-mark-command] \\[set-mark-command] \\[set-mark-command]
|
|
|
|
|
will pop the mark three times.
|
|
|
|
|
|
2007-05-16 11:26:41 +00:00
|
|
|
|
A value of nil means \\[set-mark-command]'s behavior does not change
|
2007-04-23 21:16:31 +00:00
|
|
|
|
after C-u \\[set-mark-command]."
|
2005-11-03 21:41:20 +00:00
|
|
|
|
:type 'boolean
|
2007-04-23 21:19:11 +00:00
|
|
|
|
:group 'editing-basics)
|
2005-11-03 21:41:20 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun set-mark-command (arg)
|
2007-04-21 08:55:15 +00:00
|
|
|
|
"Set the mark where point is, or jump to the mark.
|
|
|
|
|
Setting the mark also alters the region, which is the text
|
|
|
|
|
between point and mark; this is the closest equivalent in
|
|
|
|
|
Emacs to what some editors call the \"selection\".
|
2007-04-09 07:51:37 +00:00
|
|
|
|
|
2007-04-21 08:55:15 +00:00
|
|
|
|
With no prefix argument, set the mark at point, and push the
|
|
|
|
|
old mark position on local mark ring. Also push the old mark on
|
|
|
|
|
global mark ring, if the previous mark was set in another buffer.
|
2007-04-09 07:51:37 +00:00
|
|
|
|
|
2008-03-11 02:00:08 +00:00
|
|
|
|
When Transient Mark Mode is off, immediately repeating this
|
|
|
|
|
command activates `transient-mark-mode' temporarily.
|
2003-03-21 23:49:23 +00:00
|
|
|
|
|
2014-02-21 14:22:14 +01:00
|
|
|
|
With prefix argument (e.g., \\[universal-argument] \\[set-mark-command]), \
|
2007-04-21 08:55:15 +00:00
|
|
|
|
jump to the mark, and set the mark from
|
2014-02-21 14:22:14 +01:00
|
|
|
|
position popped off the local mark ring (this does not affect the global
|
|
|
|
|
mark ring). Use \\[pop-global-mark] to jump to a mark popped off the global
|
|
|
|
|
mark ring (see `pop-global-mark').
|
2003-03-24 11:00:39 +00:00
|
|
|
|
|
2006-01-20 01:22:07 +00:00
|
|
|
|
If `set-mark-command-repeat-pop' is non-nil, repeating
|
2007-04-09 07:51:37 +00:00
|
|
|
|
the \\[set-mark-command] command with no prefix argument pops the next position
|
2006-01-20 01:22:07 +00:00
|
|
|
|
off the local (or global) mark ring and jumps there.
|
2003-03-21 23:49:23 +00:00
|
|
|
|
|
2007-04-21 08:55:15 +00:00
|
|
|
|
With \\[universal-argument] \\[universal-argument] as prefix
|
|
|
|
|
argument, unconditionally set mark where point is, even if
|
|
|
|
|
`set-mark-command-repeat-pop' is non-nil.
|
2006-03-20 15:08:28 +00:00
|
|
|
|
|
1992-08-21 07:18:16 +00:00
|
|
|
|
Novice Emacs Lisp programmers often try to use the mark for the wrong
|
1991-12-21 09:29:41 +00:00
|
|
|
|
purposes. See the documentation of `set-mark' for more information."
|
|
|
|
|
(interactive "P")
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(cond ((eq transient-mark-mode 'lambda)
|
|
|
|
|
(setq transient-mark-mode nil))
|
|
|
|
|
((eq (car-safe transient-mark-mode) 'only)
|
|
|
|
|
(deactivate-mark)))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(cond
|
2003-03-24 11:00:39 +00:00
|
|
|
|
((and (consp arg) (> (prefix-numeric-value arg) 4))
|
|
|
|
|
(push-mark-command nil))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
((not (eq this-command 'set-mark-command))
|
2002-04-18 22:16:50 +00:00
|
|
|
|
(if arg
|
|
|
|
|
(pop-to-mark-command)
|
|
|
|
|
(push-mark-command t)))
|
2005-11-03 21:41:20 +00:00
|
|
|
|
((and set-mark-command-repeat-pop
|
|
|
|
|
(eq last-command 'pop-to-mark-command))
|
2003-03-21 23:49:23 +00:00
|
|
|
|
(setq this-command 'pop-to-mark-command)
|
|
|
|
|
(pop-to-mark-command))
|
2005-11-03 21:41:20 +00:00
|
|
|
|
((and set-mark-command-repeat-pop
|
|
|
|
|
(eq last-command 'pop-global-mark)
|
|
|
|
|
(not arg))
|
2003-03-21 23:49:23 +00:00
|
|
|
|
(setq this-command 'pop-global-mark)
|
|
|
|
|
(pop-global-mark))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(arg
|
2002-04-18 22:16:50 +00:00
|
|
|
|
(setq this-command 'pop-to-mark-command)
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(pop-to-mark-command))
|
2008-03-26 03:40:40 +00:00
|
|
|
|
((eq last-command 'set-mark-command)
|
|
|
|
|
(if (region-active-p)
|
|
|
|
|
(progn
|
|
|
|
|
(deactivate-mark)
|
|
|
|
|
(message "Mark deactivated"))
|
|
|
|
|
(activate-mark)
|
|
|
|
|
(message "Mark activated")))
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(t
|
2012-12-09 11:40:09 +08:00
|
|
|
|
(push-mark-command nil))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1993-05-16 15:39:39 +00:00
|
|
|
|
(defun push-mark (&optional location nomsg activate)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Set mark at LOCATION (point, by default) and push old mark on mark ring.
|
1994-02-07 04:48:18 +00:00
|
|
|
|
If the last global mark pushed was not in the current buffer,
|
|
|
|
|
also push LOCATION on the global mark ring.
|
1993-05-16 15:39:39 +00:00
|
|
|
|
Display `Mark set' unless the optional second arg NOMSG is non-nil.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1992-08-21 07:18:16 +00:00
|
|
|
|
Novice Emacs Lisp programmers often try to use the mark for the wrong
|
1993-05-15 20:55:02 +00:00
|
|
|
|
purposes. See the documentation of `set-mark' for more information.
|
|
|
|
|
|
2007-05-18 22:56:08 +00:00
|
|
|
|
In Transient Mark mode, activate mark if optional third arg ACTIVATE non-nil."
|
2003-07-25 12:18:04 +00:00
|
|
|
|
(unless (null (mark t))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(setq mark-ring (cons (copy-marker (mark-marker)) mark-ring))
|
2003-07-25 12:18:04 +00:00
|
|
|
|
(when (> (length mark-ring) mark-ring-max)
|
|
|
|
|
(move-marker (car (nthcdr mark-ring-max mark-ring)) nil)
|
|
|
|
|
(setcdr (nthcdr (1- mark-ring-max) mark-ring) nil)))
|
1993-05-15 20:55:02 +00:00
|
|
|
|
(set-marker (mark-marker) (or location (point)) (current-buffer))
|
1994-02-07 02:24:01 +00:00
|
|
|
|
;; Now push the mark on the global mark ring.
|
1994-02-07 04:48:18 +00:00
|
|
|
|
(if (and global-mark-ring
|
1994-02-07 18:40:13 +00:00
|
|
|
|
(eq (marker-buffer (car global-mark-ring)) (current-buffer)))
|
1994-02-07 04:48:18 +00:00
|
|
|
|
;; The last global mark pushed was in this same buffer.
|
|
|
|
|
;; Don't push another one.
|
|
|
|
|
nil
|
|
|
|
|
(setq global-mark-ring (cons (copy-marker (mark-marker)) global-mark-ring))
|
2003-07-25 12:18:04 +00:00
|
|
|
|
(when (> (length global-mark-ring) global-mark-ring-max)
|
|
|
|
|
(move-marker (car (nthcdr global-mark-ring-max global-mark-ring)) nil)
|
|
|
|
|
(setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil)))
|
1996-05-29 17:17:34 +00:00
|
|
|
|
(or nomsg executing-kbd-macro (> (minibuffer-depth) 0)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(message "Mark set"))
|
1993-05-16 23:09:57 +00:00
|
|
|
|
(if (or activate (not transient-mark-mode))
|
|
|
|
|
(set-mark (mark t)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defun pop-mark ()
|
|
|
|
|
"Pop off mark ring into the buffer's actual mark.
|
|
|
|
|
Does not set point. Does nothing if mark ring is empty."
|
2003-07-25 12:18:04 +00:00
|
|
|
|
(when mark-ring
|
|
|
|
|
(setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker)))))
|
|
|
|
|
(set-marker (mark-marker) (+ 0 (car mark-ring)) (current-buffer))
|
|
|
|
|
(move-marker (car mark-ring) nil)
|
|
|
|
|
(if (null (mark t)) (ding))
|
2005-01-12 00:42:57 +00:00
|
|
|
|
(setq mark-ring (cdr mark-ring)))
|
|
|
|
|
(deactivate-mark))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2010-08-04 20:04:29 +02:00
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(defun exchange-point-and-mark (&optional arg)
|
1993-03-09 05:40:33 +00:00
|
|
|
|
"Put the mark where point is now, and point where the mark is now.
|
|
|
|
|
This command works even when the mark is not active,
|
2002-04-14 17:27:55 +00:00
|
|
|
|
and it reactivates the mark.
|
2008-04-02 20:16:10 +00:00
|
|
|
|
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
If Transient Mark mode is on, a prefix ARG deactivates the mark
|
2008-04-02 20:16:10 +00:00
|
|
|
|
if it is active, and otherwise avoids reactivating it. If
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
Transient Mark mode is off, a prefix ARG enables Transient Mark
|
2008-04-02 20:16:10 +00:00
|
|
|
|
mode temporarily."
|
2002-04-14 17:27:55 +00:00
|
|
|
|
(interactive "P")
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(let ((omark (mark t))
|
|
|
|
|
(temp-highlight (eq (car-safe transient-mark-mode) 'only)))
|
2008-03-26 03:40:40 +00:00
|
|
|
|
(if (null omark)
|
|
|
|
|
(error "No mark set in this buffer"))
|
|
|
|
|
(set-mark (point))
|
|
|
|
|
(goto-char omark)
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(cond (temp-highlight
|
|
|
|
|
(setq transient-mark-mode (cons 'only transient-mark-mode)))
|
|
|
|
|
((or (and arg (region-active-p)) ; (xor arg (not (region-active-p)))
|
|
|
|
|
(not (or arg (region-active-p))))
|
|
|
|
|
(deactivate-mark))
|
|
|
|
|
(t (activate-mark)))
|
2008-03-26 03:40:40 +00:00
|
|
|
|
nil))
|
1993-05-15 18:47:18 +00:00
|
|
|
|
|
2009-03-27 16:50:14 +00:00
|
|
|
|
(defcustom shift-select-mode t
|
2009-03-26 17:07:54 +00:00
|
|
|
|
"When non-nil, shifted motion keys activate the mark momentarily.
|
|
|
|
|
|
|
|
|
|
While the mark is activated in this way, any shift-translated point
|
|
|
|
|
motion key extends the region, and if Transient Mark mode was off, it
|
|
|
|
|
is temporarily turned on. Furthermore, the mark will be deactivated
|
|
|
|
|
by any subsequent point motion key that was not shift-translated, or
|
|
|
|
|
by any action that normally deactivates the mark in Transient Mark mode.
|
|
|
|
|
|
|
|
|
|
See `this-command-keys-shift-translated' for the meaning of
|
2009-03-27 16:50:14 +00:00
|
|
|
|
shift-translation."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'editing-basics)
|
2009-03-26 17:07:54 +00:00
|
|
|
|
|
|
|
|
|
(defun handle-shift-selection ()
|
2009-04-06 01:21:48 +00:00
|
|
|
|
"Activate/deactivate mark depending on invocation thru shift translation.
|
|
|
|
|
This function is called by `call-interactively' when a command
|
|
|
|
|
with a `^' character in its `interactive' spec is invoked, before
|
|
|
|
|
running the command itself.
|
|
|
|
|
|
|
|
|
|
If `shift-select-mode' is enabled and the command was invoked
|
|
|
|
|
through shift translation, set the mark and activate the region
|
|
|
|
|
temporarily, unless it was already set in this way. See
|
|
|
|
|
`this-command-keys-shift-translated' for the meaning of shift
|
|
|
|
|
translation.
|
|
|
|
|
|
|
|
|
|
Otherwise, if the region has been activated temporarily,
|
|
|
|
|
deactivate it, and restore the variable `transient-mark-mode' to
|
|
|
|
|
its earlier value."
|
2009-03-26 17:07:54 +00:00
|
|
|
|
(cond ((and shift-select-mode this-command-keys-shift-translated)
|
2010-08-07 15:39:04 -04:00
|
|
|
|
(unless (and mark-active
|
|
|
|
|
(eq (car-safe transient-mark-mode) 'only))
|
2010-07-17 16:21:51 -04:00
|
|
|
|
(setq transient-mark-mode
|
2009-03-26 17:07:54 +00:00
|
|
|
|
(cons 'only
|
|
|
|
|
(unless (eq transient-mark-mode 'lambda)
|
|
|
|
|
transient-mark-mode)))
|
|
|
|
|
(push-mark nil nil t)))
|
|
|
|
|
((eq (car-safe transient-mark-mode) 'only)
|
|
|
|
|
(setq transient-mark-mode (cdr transient-mark-mode))
|
|
|
|
|
(deactivate-mark))))
|
2008-04-02 20:16:10 +00:00
|
|
|
|
|
2002-09-11 20:46:33 +00:00
|
|
|
|
(define-minor-mode transient-mark-mode
|
1993-05-15 18:47:18 +00:00
|
|
|
|
"Toggle Transient Mark mode.
|
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
|
|
|
|
With a prefix argument ARG, enable Transient Mark mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
Transient Mark mode if ARG is omitted or nil.
|
1993-05-15 18:47:18 +00:00
|
|
|
|
|
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
|
|
|
|
Transient Mark mode is a global minor mode. When enabled, the
|
|
|
|
|
region is highlighted whenever the mark is active. The mark is
|
|
|
|
|
\"deactivated\" by changing the buffer, and after certain other
|
|
|
|
|
operations that set the mark but whose main purpose is something
|
|
|
|
|
else--for example, incremental search, \\[beginning-of-buffer], and \\[end-of-buffer].
|
2001-01-27 11:45:54 +00:00
|
|
|
|
|
2001-03-30 11:37:52 +00:00
|
|
|
|
You can also deactivate the mark by typing \\[keyboard-quit] or
|
|
|
|
|
\\[keyboard-escape-quit].
|
2001-03-30 08:35:49 +00:00
|
|
|
|
|
2012-11-28 15:16:45 +08:00
|
|
|
|
Many commands change their behavior when Transient Mark mode is
|
|
|
|
|
in effect and the mark is active, by acting on the region instead
|
|
|
|
|
of their usual default part of the buffer's text. Examples of
|
|
|
|
|
such commands include \\[comment-dwim], \\[flush-lines], \\[keep-lines],
|
2004-12-13 03:08:52 +00:00
|
|
|
|
\\[query-replace], \\[query-replace-regexp], \\[ispell], and \\[undo].
|
2012-11-28 15:16:45 +08:00
|
|
|
|
To see the documentation of commands which are sensitive to the
|
|
|
|
|
Transient Mark mode, invoke \\[apropos-documentation] and type \"transient\"
|
|
|
|
|
or \"mark.*active\" at the prompt."
|
2008-03-03 02:16:29 +00:00
|
|
|
|
:global t
|
2010-10-28 20:29:29 -07:00
|
|
|
|
;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
|
|
|
|
|
:variable transient-mark-mode)
|
2008-04-02 20:16:10 +00:00
|
|
|
|
|
2005-05-01 18:54:00 +00:00
|
|
|
|
(defvar widen-automatically t
|
|
|
|
|
"Non-nil means it is ok for commands to call `widen' when they want to.
|
|
|
|
|
Some commands will do this in order to go to positions outside
|
|
|
|
|
the current accessible part of the buffer.
|
|
|
|
|
|
|
|
|
|
If `widen-automatically' is nil, these commands will do something else
|
|
|
|
|
as a fallback, and won't change the buffer bounds.")
|
|
|
|
|
|
2010-04-14 11:24:17 -04:00
|
|
|
|
(defvar non-essential nil
|
|
|
|
|
"Whether the currently executing code is performing an essential task.
|
|
|
|
|
This variable should be non-nil only when running code which should not
|
|
|
|
|
disturb the user. E.g. it can be used to prevent Tramp from prompting the
|
|
|
|
|
user for a password when we are simply scanning a set of files in the
|
|
|
|
|
background or displaying possible completions before the user even asked
|
|
|
|
|
for it.")
|
|
|
|
|
|
1994-02-07 02:24:01 +00:00
|
|
|
|
(defun pop-global-mark ()
|
|
|
|
|
"Pop off global mark ring and jump to the top location."
|
|
|
|
|
(interactive)
|
1994-06-14 00:34:43 +00:00
|
|
|
|
;; Pop entries which refer to non-existent buffers.
|
|
|
|
|
(while (and global-mark-ring (not (marker-buffer (car global-mark-ring))))
|
|
|
|
|
(setq global-mark-ring (cdr global-mark-ring)))
|
1994-02-07 02:24:01 +00:00
|
|
|
|
(or global-mark-ring
|
|
|
|
|
(error "No global mark set"))
|
|
|
|
|
(let* ((marker (car global-mark-ring))
|
|
|
|
|
(buffer (marker-buffer marker))
|
|
|
|
|
(position (marker-position marker)))
|
1995-01-05 23:53:01 +00:00
|
|
|
|
(setq global-mark-ring (nconc (cdr global-mark-ring)
|
|
|
|
|
(list (car global-mark-ring))))
|
1994-02-07 02:24:01 +00:00
|
|
|
|
(set-buffer buffer)
|
|
|
|
|
(or (and (>= position (point-min))
|
|
|
|
|
(<= position (point-max)))
|
2005-05-01 18:54:00 +00:00
|
|
|
|
(if widen-automatically
|
2005-08-11 13:58:59 +00:00
|
|
|
|
(widen)
|
|
|
|
|
(error "Global mark position is outside accessible part of buffer")))
|
1994-02-07 02:24:01 +00:00
|
|
|
|
(goto-char position)
|
|
|
|
|
(switch-to-buffer buffer)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2000-12-02 10:14:48 +00:00
|
|
|
|
(defcustom next-line-add-newlines nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"If non-nil, `next-line' inserts newline to avoid `end of buffer' error."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'boolean
|
2001-01-16 12:13:43 +00:00
|
|
|
|
:version "21.1"
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:group 'editing-basics)
|
1993-04-23 06:50:37 +00:00
|
|
|
|
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(defun next-line (&optional arg try-vscroll)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Move cursor vertically down ARG lines.
|
2005-03-13 23:20:49 +00:00
|
|
|
|
Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
|
2013-07-12 11:33:14 +03:00
|
|
|
|
Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
|
|
|
|
|
lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
|
|
|
|
|
function will not vscroll.
|
|
|
|
|
|
2013-07-12 11:35:42 +03:00
|
|
|
|
ARG defaults to 1.
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
If there is no character in the target line exactly under the current column,
|
|
|
|
|
the cursor is positioned after the character in that line which spans this
|
|
|
|
|
column, or at the end of the line if it is not long enough.
|
1993-04-23 06:50:37 +00:00
|
|
|
|
If there is no line in the buffer after this one, behavior depends on the
|
1994-12-23 17:25:50 +00:00
|
|
|
|
value of `next-line-add-newlines'. If non-nil, it inserts a newline character
|
|
|
|
|
to create a line, and moves the cursor to that line. Otherwise it moves the
|
1995-07-30 00:46:23 +00:00
|
|
|
|
cursor to the end of the buffer.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2008-07-11 18:11:06 +00:00
|
|
|
|
If the variable `line-move-visual' is non-nil, this command moves
|
|
|
|
|
by display lines. Otherwise, it moves by buffer lines, without
|
|
|
|
|
taking variable-width characters or continued lines into account.
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
The command \\[set-goal-column] can be used to create
|
1997-07-04 04:47:05 +00:00
|
|
|
|
a semipermanent goal column for this command.
|
|
|
|
|
Then instead of trying to move exactly vertically (or as close as possible),
|
|
|
|
|
this command moves to the specified goal column (or as close as possible).
|
|
|
|
|
The goal column is stored in the variable `goal-column', which is nil
|
2011-09-16 20:15:16 +03:00
|
|
|
|
when there is no goal column. Note that setting `goal-column'
|
|
|
|
|
overrides `line-move-visual' and causes this command to move by buffer
|
|
|
|
|
lines rather than by display lines.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
If you are thinking of using this in a Lisp program, consider
|
|
|
|
|
using `forward-line' instead. It is usually easier to use
|
|
|
|
|
and more reliable (no dependence on goal column, etc.)."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p\np")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(or arg (setq arg 1))
|
1994-01-26 17:19:32 +00:00
|
|
|
|
(if (and next-line-add-newlines (= arg 1))
|
2001-01-26 09:23:17 +00:00
|
|
|
|
(if (save-excursion (end-of-line) (eobp))
|
|
|
|
|
;; When adding a newline, don't expand an abbrev.
|
|
|
|
|
(let ((abbrev-mode nil))
|
2001-02-05 10:16:47 +00:00
|
|
|
|
(end-of-line)
|
2005-11-29 23:54:47 +00:00
|
|
|
|
(insert (if use-hard-newlines hard-newline "\n")))
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(line-move arg nil nil try-vscroll))
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(if (called-interactively-p 'interactive)
|
2010-03-31 18:16:12 +03:00
|
|
|
|
(condition-case err
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(line-move arg nil nil try-vscroll)
|
2010-03-31 18:16:12 +03:00
|
|
|
|
((beginning-of-buffer end-of-buffer)
|
|
|
|
|
(signal (car err) (cdr err))))
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(line-move arg nil nil try-vscroll)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
nil)
|
2013-11-30 00:42:28 -08:00
|
|
|
|
(put 'next-line 'interactive-only 'forward-line)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(defun previous-line (&optional arg try-vscroll)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
"Move cursor vertically up ARG lines.
|
2005-03-13 23:20:49 +00:00
|
|
|
|
Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
|
2013-07-12 11:33:14 +03:00
|
|
|
|
Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
|
|
|
|
|
lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
|
|
|
|
|
function will not vscroll.
|
|
|
|
|
|
2013-07-12 11:35:42 +03:00
|
|
|
|
ARG defaults to 1.
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
If there is no character in the target line exactly over the current column,
|
|
|
|
|
the cursor is positioned after the character in that line which spans this
|
|
|
|
|
column, or at the end of the line if it is not long enough.
|
|
|
|
|
|
2008-07-11 18:11:06 +00:00
|
|
|
|
If the variable `line-move-visual' is non-nil, this command moves
|
|
|
|
|
by display lines. Otherwise, it moves by buffer lines, without
|
|
|
|
|
taking variable-width characters or continued lines into account.
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
The command \\[set-goal-column] can be used to create
|
1997-07-04 04:47:05 +00:00
|
|
|
|
a semipermanent goal column for this command.
|
|
|
|
|
Then instead of trying to move exactly vertically (or as close as possible),
|
|
|
|
|
this command moves to the specified goal column (or as close as possible).
|
|
|
|
|
The goal column is stored in the variable `goal-column', which is nil
|
2011-09-16 20:15:16 +03:00
|
|
|
|
when there is no goal column. Note that setting `goal-column'
|
|
|
|
|
overrides `line-move-visual' and causes this command to move by buffer
|
|
|
|
|
lines rather than by display lines.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
If you are thinking of using this in a Lisp program, consider using
|
1992-11-07 06:13:23 +00:00
|
|
|
|
`forward-line' with a negative argument instead. It is usually easier
|
1991-12-21 09:29:41 +00:00
|
|
|
|
to use and more reliable (no dependence on goal column, etc.)."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p\np")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(if (called-interactively-p 'interactive)
|
2010-03-31 18:16:12 +03:00
|
|
|
|
(condition-case err
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(line-move (- arg) nil nil try-vscroll)
|
2010-03-31 18:16:12 +03:00
|
|
|
|
((beginning-of-buffer end-of-buffer)
|
|
|
|
|
(signal (car err) (cdr err))))
|
2005-03-13 23:20:49 +00:00
|
|
|
|
(line-move (- arg) nil nil try-vscroll))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
nil)
|
2013-11-25 19:16:32 +02:00
|
|
|
|
(put 'previous-line 'interactive-only
|
2013-11-30 00:42:28 -08:00
|
|
|
|
"use `forward-line' with negative argument instead.")
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom track-eol nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Non-nil means vertical motion starting at end of line keeps to ends of lines.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
This means moving to the end of each line moved onto.
|
2008-07-11 18:07:01 +00:00
|
|
|
|
The beginning of a blank line does not count as the end of a line.
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
This has no effect when the variable `line-move-visual' is non-nil."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'editing-basics)
|
|
|
|
|
|
|
|
|
|
(defcustom goal-column nil
|
2011-09-16 20:15:16 +03:00
|
|
|
|
"Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil.
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
A non-nil setting overrides the variable `line-move-visual', which see."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type '(choice integer
|
|
|
|
|
(const :tag "None" nil))
|
|
|
|
|
:group 'editing-basics)
|
1992-10-23 08:54:08 +00:00
|
|
|
|
(make-variable-buffer-local 'goal-column)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defvar temporary-goal-column 0
|
|
|
|
|
"Current goal column for vertical motion.
|
2008-07-11 18:07:01 +00:00
|
|
|
|
It is the column where point was at the start of the current run
|
2009-07-11 16:36:05 +00:00
|
|
|
|
of vertical motion commands.
|
|
|
|
|
|
Disambiguate function and variable references in docstrings.
* lisp/comint.el (comint-history-isearch-message): Fix ambiguous doc
string cross-reference(s).
* lisp/ffap.el (ffap-string-at-point-region, ffap-next)
(ffap-string-at-point, ffap-string-around)
(ffap-copy-string-as-kill, ffap-highlight-overlay)
(ffap-literally): Fix ambiguous doc string cross-reference(s).
* lisp/font-lock.el (font-lock-keywords-alist)
(font-lock-removed-keywords-alist): Fix ambiguous doc string
cross-reference(s).
* lisp/help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for
a cross-reference to a function.
* lisp/info.el (Info-find-emacs-command-nodes): Fix ambiguous doc
string cross-reference(s).
* lisp/isearch.el (isearch-message-function, isearch-fail-pos): Fix
ambiguous doc string cross-reference(s).
* lisp/misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
doc string cross-reference(s).
* lisp/newcomment.el (comment-box): Fix ambiguous doc string
cross-reference(s).
* lisp/printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
(pr-setting-database): Fix ambiguous doc string
cross-reference(s).
* lisp/ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
(ps-n-up-filling-database): Fix ambiguous doc string
cross-reference(s).
* lisp/server.el (server-buffer, server-log): Fix ambiguous doc string
cross-reference(s).
* lisp/simple.el (newline, delete-backward-char, delete-forward-char)
(minibuffer-history-isearch-message, kill-line, track-eol)
(temporary-goal-column): Fix ambiguous doc string
cross-reference(s).
* lisp/whitespace.el (whitespace-point)
(whitespace-font-lock-refontify, whitespace-bob-marker)
(whitespace-eob-marker): Fix ambiguous doc string
cross-reference(s).
* lisp/calc/calc.el (calc-highlight-selections-with-faces)
(calc-dispatch): Fix ambiguous doc string cross-reference(s).
* lisp/emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix
ambiguous doc string cross-reference(s).
* lisp/gnus/gnus-start.el (gnus-check-new-newsgroups): Fix ambiguous doc string
cross-reference(s).
* lisp/gnus/gnus-sum.el (gnus-summary-newsgroup-prefix): Fix ambiguous doc string
cross-reference(s).
* lisp/international/mule.el (add-to-coding-system-list): Fix ambiguous
doc string cross-reference(s).
* lisp/progmodes/cc-fonts.el (c-font-lock-keywords-3)
(c++-font-lock-keywords-3, objc-font-lock-keywords-3)
(java-font-lock-keywords-3, idl-font-lock-keywords-3)
(pike-font-lock-keywords-3): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/compile.el (compile): Fix ambiguous doc string
cross-reference(s).
* lisp/progmodes/etags.el (tags-table-files)
(tags-table-files-function, tags-included-tables-function): Fix
ambiguous doc string cross-reference(s).
* lisp/progmodes/gdb-mi.el (gdb, gdb-setup-windows)
(gdb-restore-windows): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/flyspell.el (flyspell-mark-duplications-flag)
(flyspell-default-deplacement-commands): Fix ambiguous doc string
cross-reference(s).
* lisp/textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
string cross-reference(s).
* lisp/textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
cross-reference(s).
* lisp/vc/compare-w.el (compare-ignore-whitespace)
(compare-ignore-case, compare-windows-dehighlight): Fix ambiguous
doc string cross-reference(s).
* lisp/vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
* src/insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix
ambiguous doc string cross-reference(s).
* src/keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
doc string cross-reference(s).
* src/window.c (Fwindow_point, syms_of_window): Fix ambiguous doc
string cross-reference(s).
Fixes: debbugs:12686
2013-01-11 18:08:55 -05:00
|
|
|
|
When moving by visual lines via the function `line-move-visual', it is a cons
|
2009-07-11 16:36:05 +00:00
|
|
|
|
cell (COL . HSCROLL), where COL is the x-position, in pixels,
|
|
|
|
|
divided by the default column width, and HSCROLL is the number of
|
|
|
|
|
columns by which window is scrolled from left margin.
|
|
|
|
|
|
|
|
|
|
When the `track-eol' feature is doing its job, the value is
|
2008-07-11 18:07:01 +00:00
|
|
|
|
`most-positive-fixnum'.")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(defcustom line-move-ignore-invisible t
|
2014-05-17 11:58:17 +03:00
|
|
|
|
"Non-nil means commands that move by lines ignore invisible newlines.
|
|
|
|
|
When this option is non-nil, \\[next-line], \\[previous-line], \\[move-end-of-line], and \\[move-beginning-of-line] behave
|
|
|
|
|
as if newlines that are invisible didn't exist, and count
|
|
|
|
|
only visible newlines. Thus, moving across across 2 newlines
|
|
|
|
|
one of which is invisible will be counted as a one-line move.
|
|
|
|
|
Also, a non-nil value causes invisible text to be ignored when
|
|
|
|
|
counting columns for the purposes of keeping point in the same
|
|
|
|
|
column by \\[next-line] and \\[previous-line].
|
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
Outline mode sets this."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'editing-basics)
|
1995-03-10 03:27:46 +00:00
|
|
|
|
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(defcustom line-move-visual t
|
2008-07-11 18:07:01 +00:00
|
|
|
|
"When non-nil, `line-move' moves point by visual lines.
|
|
|
|
|
This movement is based on where the cursor is displayed on the
|
|
|
|
|
screen, instead of relying on buffer contents alone. It takes
|
2011-01-22 14:29:10 -05:00
|
|
|
|
into account variable-width characters and line continuation.
|
2011-09-16 20:15:16 +03:00
|
|
|
|
If nil, `line-move' moves point by logical lines.
|
|
|
|
|
A non-nil setting of `goal-column' overrides the value of this variable
|
2011-09-29 16:03:42 +03:00
|
|
|
|
and forces movement by logical lines.
|
2011-11-19 21:49:56 +02:00
|
|
|
|
A window that is horizontally scrolled also forces movement by logical
|
|
|
|
|
lines."
|
2008-07-17 23:37:50 +00:00
|
|
|
|
:type 'boolean
|
2011-01-22 14:29:10 -05:00
|
|
|
|
:group 'editing-basics
|
|
|
|
|
:version "23.1")
|
2008-07-11 18:07:01 +00:00
|
|
|
|
|
2013-09-17 19:50:04 -07:00
|
|
|
|
;; Only used if display-graphic-p.
|
|
|
|
|
(declare-function font-info "font.c" (name &optional frame))
|
|
|
|
|
|
2013-07-07 18:49:03 +03:00
|
|
|
|
(defun default-font-height ()
|
|
|
|
|
"Return the height in pixels of the current buffer's default face font."
|
2013-07-13 10:26:43 +03:00
|
|
|
|
(let ((default-font (face-font 'default)))
|
|
|
|
|
(cond
|
|
|
|
|
((and (display-multi-font-p)
|
|
|
|
|
;; Avoid calling font-info if the frame's default font was
|
|
|
|
|
;; not changed since the frame was created. That's because
|
|
|
|
|
;; font-info is expensive for some fonts, see bug #14838.
|
|
|
|
|
(not (string= (frame-parameter nil 'font) default-font)))
|
|
|
|
|
(aref (font-info default-font) 3))
|
|
|
|
|
(t (frame-char-height)))))
|
2013-07-07 18:49:03 +03:00
|
|
|
|
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(defun default-line-height ()
|
|
|
|
|
"Return the pixel height of current buffer's default-face text line.
|
|
|
|
|
|
|
|
|
|
The value includes `line-spacing', if any, defined for the buffer
|
|
|
|
|
or the frame."
|
|
|
|
|
(let ((dfh (default-font-height))
|
|
|
|
|
(lsp (if (display-graphic-p)
|
|
|
|
|
(or line-spacing
|
|
|
|
|
(default-value 'line-spacing)
|
|
|
|
|
(frame-parameter nil 'line-spacing)
|
|
|
|
|
0)
|
|
|
|
|
0)))
|
|
|
|
|
(if (floatp lsp)
|
2014-08-05 16:34:06 +03:00
|
|
|
|
(setq lsp (truncate (* (frame-char-height) lsp))))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(+ dfh lsp)))
|
|
|
|
|
|
2013-07-07 18:49:03 +03:00
|
|
|
|
(defun window-screen-lines ()
|
|
|
|
|
"Return the number of screen lines in the text area of the selected window.
|
|
|
|
|
|
|
|
|
|
This is different from `window-text-height' in that this function counts
|
|
|
|
|
lines in units of the height of the font used by the default face displayed
|
2013-07-10 19:18:17 +03:00
|
|
|
|
in the window, not in units of the frame's default font, and also accounts
|
|
|
|
|
for `line-spacing', if any, defined for the window's buffer or frame.
|
2013-07-07 18:49:03 +03:00
|
|
|
|
|
|
|
|
|
The value is a floating-point number."
|
2014-08-05 16:34:06 +03:00
|
|
|
|
(let ((edges (window-inside-pixel-edges))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(dlh (default-line-height)))
|
2014-08-05 16:34:06 +03:00
|
|
|
|
(/ (float (- (nth 3 edges) (nth 1 edges))) dlh)))
|
2013-07-07 18:49:03 +03:00
|
|
|
|
|
2006-09-05 22:52:29 +00:00
|
|
|
|
;; Returns non-nil if partial move was done.
|
|
|
|
|
(defun line-move-partial (arg noerror to-end)
|
|
|
|
|
(if (< arg 0)
|
|
|
|
|
;; Move backward (up).
|
|
|
|
|
;; If already vscrolled, reduce vscroll
|
2013-07-07 18:49:03 +03:00
|
|
|
|
(let ((vs (window-vscroll nil t))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(dlh (default-line-height)))
|
|
|
|
|
(when (> vs dlh)
|
|
|
|
|
(set-window-vscroll nil (- vs dlh) t)))
|
2006-09-05 22:52:29 +00:00
|
|
|
|
|
|
|
|
|
;; Move forward (down).
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(let* ((lh (window-line-height -1))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(rowh (car lh))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(vpos (nth 1 lh))
|
|
|
|
|
(ypos (nth 2 lh))
|
|
|
|
|
(rbot (nth 3 lh))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(this-lh (window-line-height))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(this-height (car this-lh))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(this-ypos (nth 2 this-lh))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(dlh (default-line-height))
|
|
|
|
|
(wslines (window-screen-lines))
|
2013-07-17 19:47:49 +03:00
|
|
|
|
(edges (window-inside-pixel-edges))
|
|
|
|
|
(winh (- (nth 3 edges) (nth 1 edges) 1))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
py vs last-line)
|
|
|
|
|
(if (> (mod wslines 1.0) 0.0)
|
|
|
|
|
(setq wslines (round (+ wslines 0.5))))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(when (or (null lh)
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(>= rbot dlh)
|
|
|
|
|
(<= ypos (- dlh))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(null this-lh)
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(<= this-ypos (- dlh)))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(unless lh
|
2006-09-20 09:45:19 +00:00
|
|
|
|
(let ((wend (pos-visible-in-window-p t nil t)))
|
|
|
|
|
(setq rbot (nth 3 wend)
|
2013-07-08 20:30:50 +03:00
|
|
|
|
rowh (nth 4 wend)
|
2006-09-20 09:45:19 +00:00
|
|
|
|
vpos (nth 5 wend))))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(unless this-lh
|
|
|
|
|
(let ((wstart (pos-visible-in-window-p nil nil t)))
|
|
|
|
|
(setq this-ypos (nth 2 wstart)
|
|
|
|
|
this-height (nth 4 wstart))))
|
|
|
|
|
(setq py
|
|
|
|
|
(or (nth 1 this-lh)
|
2013-07-06 20:38:24 +03:00
|
|
|
|
(let ((ppos (posn-at-point))
|
|
|
|
|
col-row)
|
|
|
|
|
(setq col-row (posn-actual-col-row ppos))
|
|
|
|
|
(if col-row
|
|
|
|
|
(- (cdr col-row) (window-vscroll))
|
|
|
|
|
(cdr (posn-col-row ppos))))))
|
2013-07-10 19:18:17 +03:00
|
|
|
|
;; VPOS > 0 means the last line is only partially visible.
|
|
|
|
|
;; But if the part that is visible is at least as tall as the
|
|
|
|
|
;; default font, that means the line is actually fully
|
|
|
|
|
;; readable, and something like line-spacing is hidden. So in
|
|
|
|
|
;; that case we accept the last line in the window as still
|
|
|
|
|
;; visible, and consider the margin as starting one line
|
|
|
|
|
;; later.
|
|
|
|
|
(if (and vpos (> vpos 0))
|
|
|
|
|
(if (and rowh
|
|
|
|
|
(>= rowh (default-font-height))
|
|
|
|
|
(< rowh dlh))
|
|
|
|
|
(setq last-line (min (- wslines scroll-margin) vpos))
|
|
|
|
|
(setq last-line (min (- wslines scroll-margin 1) (1- vpos)))))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(cond
|
2013-06-15 12:34:20 +03:00
|
|
|
|
;; If last line of window is fully visible, and vscrolling
|
|
|
|
|
;; more would make this line invisible, move forward.
|
2013-07-08 20:30:50 +03:00
|
|
|
|
((and (or (< (setq vs (window-vscroll nil t)) dlh)
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(null this-height)
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(<= this-height dlh))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(or (null rbot) (= rbot 0)))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
nil)
|
2013-06-15 12:34:20 +03:00
|
|
|
|
;; If cursor is not in the bottom scroll margin, and the
|
|
|
|
|
;; current line is is not too tall, move forward.
|
2013-07-17 19:47:49 +03:00
|
|
|
|
((and (or (null this-height) (<= this-height winh))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
vpos
|
|
|
|
|
(> vpos 0)
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(< py last-line))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
nil)
|
|
|
|
|
;; When already vscrolled, we vscroll some more if we can,
|
|
|
|
|
;; or clear vscroll and move forward at end of tall image.
|
2013-06-15 12:34:20 +03:00
|
|
|
|
((> vs 0)
|
|
|
|
|
(when (or (and rbot (> rbot 0))
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(and this-height (> this-height dlh)))
|
|
|
|
|
(set-window-vscroll nil (+ vs dlh) t)))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
;; If cursor just entered the bottom scroll margin, move forward,
|
2013-07-08 20:30:50 +03:00
|
|
|
|
;; but also optionally vscroll one line so redisplay won't recenter.
|
2013-06-15 12:34:20 +03:00
|
|
|
|
((and vpos
|
|
|
|
|
(> vpos 0)
|
2013-07-10 19:18:17 +03:00
|
|
|
|
(= py last-line))
|
2013-07-08 20:30:50 +03:00
|
|
|
|
;; Don't vscroll if the partially-visible line at window
|
2013-07-17 19:47:49 +03:00
|
|
|
|
;; bottom is not too tall (a.k.a. "just one more text
|
2013-07-08 20:30:50 +03:00
|
|
|
|
;; line"): in that case, we do want redisplay to behave
|
|
|
|
|
;; normally, i.e. recenter or whatever.
|
|
|
|
|
;;
|
|
|
|
|
;; Note: ROWH + RBOT from the value returned by
|
|
|
|
|
;; pos-visible-in-window-p give the total height of the
|
|
|
|
|
;; partially-visible glyph row at the end of the window. As
|
|
|
|
|
;; we are dealing with floats, we disregard sub-pixel
|
|
|
|
|
;; discrepancies between that and DLH.
|
2013-07-17 19:47:49 +03:00
|
|
|
|
(if (and rowh rbot (>= (- (+ rowh rbot) winh) 1))
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(set-window-vscroll nil dlh t))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(line-move-1 arg noerror to-end)
|
|
|
|
|
t)
|
|
|
|
|
;; If there are lines above the last line, scroll-up one line.
|
2013-06-15 12:34:20 +03:00
|
|
|
|
((and vpos (> vpos 0))
|
2006-09-18 11:13:04 +00:00
|
|
|
|
(scroll-up 1)
|
|
|
|
|
t)
|
|
|
|
|
;; Finally, start vscroll.
|
|
|
|
|
(t
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(set-window-vscroll nil dlh t)))))))
|
2006-09-05 22:52:29 +00:00
|
|
|
|
|
|
|
|
|
|
2005-06-08 15:35:05 +00:00
|
|
|
|
;; This is like line-move-1 except that it also performs
|
|
|
|
|
;; vertical scrolling of tall images if appropriate.
|
|
|
|
|
;; That is not really a clean thing to do, since it mixes
|
|
|
|
|
;; scrolling with cursor motion. But so far we don't have
|
|
|
|
|
;; a cleaner solution to the problem of making C-n do something
|
|
|
|
|
;; useful given a tall image.
|
2005-02-19 23:30:29 +00:00
|
|
|
|
(defun line-move (arg &optional noerror to-end try-vscroll)
|
2014-02-07 22:28:12 -08:00
|
|
|
|
"Move forward ARG lines.
|
|
|
|
|
If NOERROR, don't signal an error if we can't move ARG lines.
|
|
|
|
|
TO-END is unused.
|
|
|
|
|
TRY-VSCROLL controls whether to vscroll tall lines: if either
|
|
|
|
|
`auto-window-vscroll' or TRY-VSCROLL is nil, this function will
|
|
|
|
|
not vscroll."
|
2012-04-18 15:00:52 +08:00
|
|
|
|
(if noninteractive
|
|
|
|
|
(forward-line arg)
|
|
|
|
|
(unless (and auto-window-vscroll try-vscroll
|
|
|
|
|
;; Only vscroll for single line moves
|
|
|
|
|
(= (abs arg) 1)
|
2012-11-20 19:44:04 +02:00
|
|
|
|
;; Under scroll-conservatively, the display engine
|
|
|
|
|
;; does this better.
|
|
|
|
|
(zerop scroll-conservatively)
|
2012-04-18 15:00:52 +08:00
|
|
|
|
;; But don't vscroll in a keyboard macro.
|
|
|
|
|
(not defining-kbd-macro)
|
|
|
|
|
(not executing-kbd-macro)
|
|
|
|
|
(line-move-partial arg noerror to-end))
|
|
|
|
|
(set-window-vscroll nil 0 t)
|
|
|
|
|
(if (and line-move-visual
|
|
|
|
|
;; Display-based column are incompatible with goal-column.
|
|
|
|
|
(not goal-column)
|
|
|
|
|
;; When the text in the window is scrolled to the left,
|
|
|
|
|
;; display-based motion doesn't make sense (because each
|
|
|
|
|
;; logical line occupies exactly one screen line).
|
2013-10-25 12:45:51 +03:00
|
|
|
|
(not (> (window-hscroll) 0))
|
|
|
|
|
;; Likewise when the text _was_ scrolled to the left
|
|
|
|
|
;; when the current run of vertical motion commands
|
|
|
|
|
;; started.
|
|
|
|
|
(not (and (memq last-command
|
|
|
|
|
`(next-line previous-line ,this-command))
|
|
|
|
|
auto-hscroll-mode
|
|
|
|
|
(numberp temporary-goal-column)
|
|
|
|
|
(>= temporary-goal-column
|
|
|
|
|
(- (window-width) hscroll-margin)))))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(prog1 (line-move-visual arg noerror)
|
|
|
|
|
;; If we moved into a tall line, set vscroll to make
|
|
|
|
|
;; scrolling through tall images more smooth.
|
2013-07-07 18:49:03 +03:00
|
|
|
|
(let ((lh (line-pixel-height))
|
2013-07-17 19:47:49 +03:00
|
|
|
|
(edges (window-inside-pixel-edges))
|
|
|
|
|
(dlh (default-line-height))
|
|
|
|
|
winh)
|
|
|
|
|
(setq winh (- (nth 3 edges) (nth 1 edges) 1))
|
2013-06-15 12:34:20 +03:00
|
|
|
|
(if (and (< arg 0)
|
|
|
|
|
(< (point) (window-start))
|
2013-07-17 19:47:49 +03:00
|
|
|
|
(> lh winh))
|
2013-07-07 18:49:03 +03:00
|
|
|
|
(set-window-vscroll
|
|
|
|
|
nil
|
2013-07-08 20:30:50 +03:00
|
|
|
|
(- lh dlh) t))))
|
2012-04-18 15:00:52 +08:00
|
|
|
|
(line-move-1 arg noerror to-end)))))
|
2008-07-11 18:07:01 +00:00
|
|
|
|
|
|
|
|
|
;; Display-based alternative to line-move-1.
|
|
|
|
|
;; Arg says how many lines to move. The value is t if we can move the
|
|
|
|
|
;; specified number of lines.
|
|
|
|
|
(defun line-move-visual (arg &optional noerror)
|
2014-02-07 22:28:12 -08:00
|
|
|
|
"Move ARG lines forward.
|
|
|
|
|
If NOERROR, don't signal an error if we can't move that many lines."
|
2009-07-31 02:14:43 +00:00
|
|
|
|
(let ((opoint (point))
|
2009-07-11 16:36:05 +00:00
|
|
|
|
(hscroll (window-hscroll))
|
2009-07-31 02:14:43 +00:00
|
|
|
|
target-hscroll)
|
2009-07-11 16:36:05 +00:00
|
|
|
|
;; Check if the previous command was a line-motion command, or if
|
|
|
|
|
;; we were called from some other command.
|
2009-07-31 02:14:43 +00:00
|
|
|
|
(if (and (consp temporary-goal-column)
|
|
|
|
|
(memq last-command `(next-line previous-line ,this-command)))
|
|
|
|
|
;; If so, there's no need to reset `temporary-goal-column',
|
|
|
|
|
;; but we may need to hscroll.
|
|
|
|
|
(if (or (/= (cdr temporary-goal-column) hscroll)
|
|
|
|
|
(> (cdr temporary-goal-column) 0))
|
|
|
|
|
(setq target-hscroll (cdr temporary-goal-column)))
|
|
|
|
|
;; Otherwise, we should reset `temporary-goal-column'.
|
|
|
|
|
(let ((posn (posn-at-point)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Handle the `overflow-newline-into-fringe' case:
|
|
|
|
|
((eq (nth 1 posn) 'right-fringe)
|
|
|
|
|
(setq temporary-goal-column (cons (- (window-width) 1) hscroll)))
|
|
|
|
|
((car (posn-x-y posn))
|
|
|
|
|
(setq temporary-goal-column
|
|
|
|
|
(cons (/ (float (car (posn-x-y posn)))
|
|
|
|
|
(frame-char-width)) hscroll))))))
|
|
|
|
|
(if target-hscroll
|
|
|
|
|
(set-window-hscroll (selected-window) target-hscroll))
|
2013-05-08 21:05:40 +03:00
|
|
|
|
;; vertical-motion can move more than it was asked to if it moves
|
|
|
|
|
;; across display strings with newlines. We don't want to ring
|
|
|
|
|
;; the bell and announce beginning/end of buffer in that case.
|
|
|
|
|
(or (and (or (and (>= arg 0)
|
|
|
|
|
(>= (vertical-motion
|
|
|
|
|
(cons (or goal-column
|
|
|
|
|
(if (consp temporary-goal-column)
|
|
|
|
|
(car temporary-goal-column)
|
|
|
|
|
temporary-goal-column))
|
|
|
|
|
arg))
|
|
|
|
|
arg))
|
|
|
|
|
(and (< arg 0)
|
|
|
|
|
(<= (vertical-motion
|
|
|
|
|
(cons (or goal-column
|
|
|
|
|
(if (consp temporary-goal-column)
|
|
|
|
|
(car temporary-goal-column)
|
|
|
|
|
temporary-goal-column))
|
|
|
|
|
arg))
|
|
|
|
|
arg)))
|
2009-04-25 15:27:45 +00:00
|
|
|
|
(or (>= arg 0)
|
|
|
|
|
(/= (point) opoint)
|
|
|
|
|
;; If the goal column lies on a display string,
|
|
|
|
|
;; `vertical-motion' advances the cursor to the end
|
|
|
|
|
;; of the string. For arg < 0, this can cause the
|
|
|
|
|
;; cursor to get stuck. (Bug#3020).
|
|
|
|
|
(= (vertical-motion arg) arg)))
|
|
|
|
|
(unless noerror
|
|
|
|
|
(signal (if (< arg 0) 'beginning-of-buffer 'end-of-buffer)
|
|
|
|
|
nil)))))
|
2005-01-22 01:44:56 +00:00
|
|
|
|
|
1995-04-09 09:34:05 +00:00
|
|
|
|
;; This is the guts of next-line and previous-line.
|
|
|
|
|
;; Arg says how many lines to move.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
;; The value is t if we can move the specified number of lines.
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun line-move-1 (arg &optional noerror _to-end)
|
1995-04-18 07:01:34 +00:00
|
|
|
|
;; Don't run any point-motion hooks, and disregard intangibility,
|
|
|
|
|
;; for intermediate positions.
|
|
|
|
|
(let ((inhibit-point-motion-hooks t)
|
|
|
|
|
(opoint (point))
|
2006-09-19 21:34:01 +00:00
|
|
|
|
(orig-arg arg))
|
2009-07-11 16:36:05 +00:00
|
|
|
|
(if (consp temporary-goal-column)
|
|
|
|
|
(setq temporary-goal-column (+ (car temporary-goal-column)
|
|
|
|
|
(cdr temporary-goal-column))))
|
1995-04-18 07:01:34 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2002-04-11 23:44:06 +00:00
|
|
|
|
(if (not (memq last-command '(next-line previous-line)))
|
1995-04-18 07:01:34 +00:00
|
|
|
|
(setq temporary-goal-column
|
|
|
|
|
(if (and track-eol (eolp)
|
|
|
|
|
;; Don't count beg of empty line as end of line
|
|
|
|
|
;; unless we just did explicit end-of-line.
|
2006-06-21 12:01:57 +00:00
|
|
|
|
(or (not (bolp)) (eq last-command 'move-end-of-line)))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
most-positive-fixnum
|
1995-04-18 07:01:34 +00:00
|
|
|
|
(current-column))))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(if (not (or (integerp selective-display)
|
|
|
|
|
line-move-ignore-invisible))
|
1995-04-18 07:01:34 +00:00
|
|
|
|
;; Use just newline characters.
|
2002-01-13 04:02:49 +00:00
|
|
|
|
;; Set ARG to 0 if we move as many lines as requested.
|
1995-04-18 07:01:34 +00:00
|
|
|
|
(or (if (> arg 0)
|
|
|
|
|
(progn (if (> arg 1) (forward-line (1- arg)))
|
|
|
|
|
;; This way of moving forward ARG lines
|
|
|
|
|
;; verifies that we have a newline after the last one.
|
|
|
|
|
;; It doesn't get confused by intangible text.
|
|
|
|
|
(end-of-line)
|
2002-01-13 04:02:49 +00:00
|
|
|
|
(if (zerop (forward-line 1))
|
|
|
|
|
(setq arg 0)))
|
1995-04-18 07:01:34 +00:00
|
|
|
|
(and (zerop (forward-line arg))
|
2002-01-13 04:02:49 +00:00
|
|
|
|
(bolp)
|
|
|
|
|
(setq arg 0)))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(unless noerror
|
|
|
|
|
(signal (if (< arg 0)
|
|
|
|
|
'beginning-of-buffer
|
|
|
|
|
'end-of-buffer)
|
|
|
|
|
nil)))
|
1995-04-18 07:01:34 +00:00
|
|
|
|
;; Move by arg lines, but ignore invisible ones.
|
2007-03-17 19:44:21 +00:00
|
|
|
|
(let (done)
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(while (and (> arg 0) (not done))
|
|
|
|
|
;; If the following character is currently invisible,
|
|
|
|
|
;; skip all characters with that same `invisible' property value.
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(while (and (not (eobp)) (invisible-p (point)))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(goto-char (next-char-property-change (point))))
|
2006-09-19 21:34:01 +00:00
|
|
|
|
;; Move a line.
|
|
|
|
|
;; We don't use `end-of-line', since we want to escape
|
2010-09-25 14:04:35 +02:00
|
|
|
|
;; from field boundaries occurring exactly at point.
|
2007-03-17 19:44:21 +00:00
|
|
|
|
(goto-char (constrain-to-field
|
|
|
|
|
(let ((inhibit-field-text-motion t))
|
|
|
|
|
(line-end-position))
|
|
|
|
|
(point) t t
|
|
|
|
|
'inhibit-line-move-field-capture))
|
2005-04-26 18:31:19 +00:00
|
|
|
|
;; If there's no invisibility here, move over the newline.
|
2005-07-13 13:45:30 +00:00
|
|
|
|
(cond
|
|
|
|
|
((eobp)
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'end-of-buffer nil)
|
|
|
|
|
(setq done t)))
|
|
|
|
|
((and (> arg 1) ;; Use vertical-motion for last move
|
|
|
|
|
(not (integerp selective-display))
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(not (invisible-p (point))))
|
2005-07-13 13:45:30 +00:00
|
|
|
|
;; We avoid vertical-motion when possible
|
|
|
|
|
;; because that has to fontify.
|
|
|
|
|
(forward-line 1))
|
|
|
|
|
;; Otherwise move a more sophisticated way.
|
|
|
|
|
((zerop (vertical-motion 1))
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'end-of-buffer nil)
|
|
|
|
|
(setq done t))))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(unless done
|
|
|
|
|
(setq arg (1- arg))))
|
2005-05-05 22:43:06 +00:00
|
|
|
|
;; The logic of this is the same as the loop above,
|
2005-04-26 18:31:19 +00:00
|
|
|
|
;; it just goes in the other direction.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(while (and (< arg 0) (not done))
|
2006-10-18 04:58:29 +00:00
|
|
|
|
;; For completely consistency with the forward-motion
|
|
|
|
|
;; case, we should call beginning-of-line here.
|
|
|
|
|
;; However, if point is inside a field and on a
|
|
|
|
|
;; continued line, the call to (vertical-motion -1)
|
|
|
|
|
;; below won't move us back far enough; then we return
|
|
|
|
|
;; to the same column in line-move-finish, and point
|
|
|
|
|
;; gets stuck -- cyd
|
|
|
|
|
(forward-line 0)
|
2005-07-13 13:45:30 +00:00
|
|
|
|
(cond
|
|
|
|
|
((bobp)
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'beginning-of-buffer nil)
|
|
|
|
|
(setq done t)))
|
|
|
|
|
((and (< arg -1) ;; Use vertical-motion for last move
|
|
|
|
|
(not (integerp selective-display))
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(not (invisible-p (1- (point)))))
|
2005-07-13 13:45:30 +00:00
|
|
|
|
(forward-line -1))
|
|
|
|
|
((zerop (vertical-motion -1))
|
|
|
|
|
(if (not noerror)
|
|
|
|
|
(signal 'beginning-of-buffer nil)
|
|
|
|
|
(setq done t))))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(unless done
|
|
|
|
|
(setq arg (1+ arg))
|
|
|
|
|
(while (and ;; Don't move over previous invis lines
|
|
|
|
|
;; if our target is the middle of this line.
|
|
|
|
|
(or (zerop (or goal-column temporary-goal-column))
|
|
|
|
|
(< arg 0))
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(not (bobp)) (invisible-p (1- (point))))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(goto-char (previous-char-property-change (point))))))))
|
|
|
|
|
;; This is the value the function returns.
|
|
|
|
|
(= arg 0))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
|
2002-01-13 04:02:49 +00:00
|
|
|
|
(cond ((> arg 0)
|
2008-06-03 22:56:56 +00:00
|
|
|
|
;; If we did not move down as far as desired, at least go
|
|
|
|
|
;; to end of line. Be sure to call point-entered and
|
|
|
|
|
;; point-left-hooks.
|
|
|
|
|
(let* ((npoint (prog1 (line-end-position)
|
|
|
|
|
(goto-char opoint)))
|
|
|
|
|
(inhibit-point-motion-hooks nil))
|
|
|
|
|
(goto-char npoint)))
|
2002-01-13 04:02:49 +00:00
|
|
|
|
((< arg 0)
|
2005-07-22 18:43:24 +00:00
|
|
|
|
;; If we did not move up as far as desired,
|
|
|
|
|
;; at least go to beginning of line.
|
2008-06-03 22:56:56 +00:00
|
|
|
|
(let* ((npoint (prog1 (line-beginning-position)
|
|
|
|
|
(goto-char opoint)))
|
|
|
|
|
(inhibit-point-motion-hooks nil))
|
|
|
|
|
(goto-char npoint)))
|
2002-01-13 04:02:49 +00:00
|
|
|
|
(t
|
2004-11-20 19:08:45 +00:00
|
|
|
|
(line-move-finish (or goal-column temporary-goal-column)
|
2006-09-19 21:34:01 +00:00
|
|
|
|
opoint (> orig-arg 0)))))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2004-11-20 19:08:45 +00:00
|
|
|
|
(defun line-move-finish (column opoint forward)
|
2001-12-28 05:15:59 +00:00
|
|
|
|
(let ((repeat t))
|
|
|
|
|
(while repeat
|
|
|
|
|
;; Set REPEAT to t to repeat the whole thing.
|
|
|
|
|
(setq repeat nil)
|
|
|
|
|
|
2002-04-22 22:35:46 +00:00
|
|
|
|
(let (new
|
2006-09-24 21:58:12 +00:00
|
|
|
|
(old (point))
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 13:23:42 -07:00
|
|
|
|
(line-beg (line-beginning-position))
|
2002-04-22 22:35:46 +00:00
|
|
|
|
(line-end
|
|
|
|
|
;; Compute the end of the line
|
2004-11-20 19:08:45 +00:00
|
|
|
|
;; ignoring effectively invisible newlines.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(save-excursion
|
2005-10-23 18:26:38 +00:00
|
|
|
|
;; Like end-of-line but ignores fields.
|
|
|
|
|
(skip-chars-forward "^\n")
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(while (and (not (eobp)) (invisible-p (point)))
|
2004-11-20 19:08:45 +00:00
|
|
|
|
(goto-char (next-char-property-change (point)))
|
2005-10-23 18:26:38 +00:00
|
|
|
|
(skip-chars-forward "^\n"))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(point))))
|
2002-04-22 22:35:46 +00:00
|
|
|
|
|
|
|
|
|
;; Move to the desired column.
|
2009-07-31 01:34:26 +00:00
|
|
|
|
(line-move-to-column (truncate column))
|
2006-09-24 21:58:12 +00:00
|
|
|
|
|
|
|
|
|
;; Corner case: suppose we start out in a field boundary in
|
|
|
|
|
;; the middle of a continued line. When we get to
|
|
|
|
|
;; line-move-finish, point is at the start of a new *screen*
|
|
|
|
|
;; line but the same text line; then line-move-to-column would
|
2014-02-21 14:22:14 +01:00
|
|
|
|
;; move us backwards. Test using C-n with point on the "x" in
|
2006-09-24 21:58:12 +00:00
|
|
|
|
;; (insert "a" (propertize "x" 'field t) (make-string 89 ?y))
|
|
|
|
|
(and forward
|
|
|
|
|
(< (point) old)
|
|
|
|
|
(goto-char old))
|
|
|
|
|
|
2002-04-22 22:35:46 +00:00
|
|
|
|
(setq new (point))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
|
|
|
|
|
;; Process intangibility within a line.
|
2006-05-23 00:49:55 +00:00
|
|
|
|
;; With inhibit-point-motion-hooks bound to nil, a call to
|
|
|
|
|
;; goto-char moves point past intangible text.
|
|
|
|
|
|
|
|
|
|
;; However, inhibit-point-motion-hooks controls both the
|
|
|
|
|
;; intangibility and the point-entered/point-left hooks. The
|
|
|
|
|
;; following hack avoids calling the point-* hooks
|
|
|
|
|
;; unnecessarily. Note that we move *forward* past intangible
|
|
|
|
|
;; text when the initial and final points are the same.
|
2006-05-12 17:39:59 +00:00
|
|
|
|
(goto-char new)
|
2001-12-28 05:15:59 +00:00
|
|
|
|
(let ((inhibit-point-motion-hooks nil))
|
|
|
|
|
(goto-char new)
|
|
|
|
|
|
|
|
|
|
;; If intangibility moves us to a different (later) place
|
|
|
|
|
;; in the same line, use that as the destination.
|
|
|
|
|
(if (<= (point) line-end)
|
2002-04-22 22:35:46 +00:00
|
|
|
|
(setq new (point))
|
|
|
|
|
;; If that position is "too late",
|
|
|
|
|
;; try the previous allowable position.
|
|
|
|
|
;; See if it is ok.
|
|
|
|
|
(backward-char)
|
2004-11-20 19:08:45 +00:00
|
|
|
|
(if (if forward
|
|
|
|
|
;; If going forward, don't accept the previous
|
|
|
|
|
;; allowable position if it is before the target line.
|
2004-12-14 00:51:02 +00:00
|
|
|
|
(< line-beg (point))
|
2004-11-20 19:08:45 +00:00
|
|
|
|
;; If going backward, don't accept the previous
|
|
|
|
|
;; allowable position if it is still after the target line.
|
|
|
|
|
(<= (point) line-end))
|
2002-04-22 22:35:46 +00:00
|
|
|
|
(setq new (point))
|
|
|
|
|
;; As a last resort, use the end of the line.
|
|
|
|
|
(setq new line-end))))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
|
|
|
|
|
;; Now move to the updated destination, processing fields
|
|
|
|
|
;; as well as intangibility.
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
(let ((inhibit-point-motion-hooks nil))
|
|
|
|
|
(goto-char
|
2006-09-29 18:18:42 +00:00
|
|
|
|
;; Ignore field boundaries if the initial and final
|
|
|
|
|
;; positions have the same `field' property, even if the
|
|
|
|
|
;; fields are non-contiguous. This seems to be "nicer"
|
|
|
|
|
;; behavior in many situations.
|
|
|
|
|
(if (eq (get-char-property new 'field)
|
|
|
|
|
(get-char-property opoint 'field))
|
|
|
|
|
new
|
|
|
|
|
(constrain-to-field new opoint t t
|
|
|
|
|
'inhibit-line-move-field-capture))))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
|
2002-04-22 22:35:46 +00:00
|
|
|
|
;; If all this moved us to a different line,
|
2001-12-28 05:15:59 +00:00
|
|
|
|
;; retry everything within that new line.
|
|
|
|
|
(when (or (< (point) line-beg) (> (point) line-end))
|
|
|
|
|
;; Repeat the intangibility and field processing.
|
|
|
|
|
(setq repeat t))))))
|
|
|
|
|
|
|
|
|
|
(defun line-move-to-column (col)
|
|
|
|
|
"Try to find column COL, considering invisibility.
|
|
|
|
|
This function works only in certain cases,
|
|
|
|
|
because what we really need is for `move-to-column'
|
|
|
|
|
and `current-column' to be able to ignore invisible text."
|
2002-03-28 18:27:23 +00:00
|
|
|
|
(if (zerop col)
|
|
|
|
|
(beginning-of-line)
|
2006-09-16 14:14:53 +00:00
|
|
|
|
(move-to-column col))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
|
|
|
|
|
(when (and line-move-ignore-invisible
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(not (bolp)) (invisible-p (1- (point))))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
(let ((normal-location (point))
|
|
|
|
|
(normal-column (current-column)))
|
|
|
|
|
;; If the following character is currently invisible,
|
|
|
|
|
;; skip all characters with that same `invisible' property value.
|
|
|
|
|
(while (and (not (eobp))
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(invisible-p (point)))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
(goto-char (next-char-property-change (point))))
|
|
|
|
|
;; Have we advanced to a larger column position?
|
|
|
|
|
(if (> (current-column) normal-column)
|
|
|
|
|
;; We have made some progress towards the desired column.
|
|
|
|
|
;; See if we can make any further progress.
|
|
|
|
|
(line-move-to-column (+ (current-column) (- col normal-column)))
|
|
|
|
|
;; Otherwise, go to the place we originally found
|
|
|
|
|
;; and move back over invisible text.
|
|
|
|
|
;; that will get us to the same place on the screen
|
|
|
|
|
;; but with a more reasonable buffer position.
|
|
|
|
|
(goto-char normal-location)
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 13:23:42 -07:00
|
|
|
|
(let ((line-beg (line-beginning-position)))
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(while (and (not (bolp)) (invisible-p (1- (point))))
|
2001-12-28 05:15:59 +00:00
|
|
|
|
(goto-char (previous-char-property-change (point) line-beg))))))))
|
|
|
|
|
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(defun move-end-of-line (arg)
|
2006-01-05 15:59:50 +00:00
|
|
|
|
"Move point to end of current line as displayed.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
With argument ARG not nil or 1, move forward ARG - 1 lines first.
|
|
|
|
|
If point reaches the beginning or end of buffer, it stops there.
|
2009-01-04 08:03:23 +00:00
|
|
|
|
|
|
|
|
|
To ignore the effects of the `intangible' text or overlay
|
|
|
|
|
property, bind `inhibit-point-motion-hooks' to t.
|
|
|
|
|
If there is an image in the current line, this function
|
|
|
|
|
disregards newlines that are part of the text on which the image
|
|
|
|
|
rests."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(let (done)
|
|
|
|
|
(while (not done)
|
|
|
|
|
(let ((newpos
|
|
|
|
|
(save-excursion
|
2008-07-11 18:07:01 +00:00
|
|
|
|
(let ((goal-column 0)
|
|
|
|
|
(line-move-visual nil))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(and (line-move arg t)
|
2010-05-19 20:16:07 +03:00
|
|
|
|
;; With bidi reordering, we may not be at bol,
|
|
|
|
|
;; so make sure we are.
|
|
|
|
|
(skip-chars-backward "^\n")
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(not (bobp))
|
|
|
|
|
(progn
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(while (and (not (bobp)) (invisible-p (1- (point))))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(goto-char (previous-single-char-property-change
|
|
|
|
|
(point) 'invisible)))
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(backward-char 1)))
|
|
|
|
|
(point)))))
|
|
|
|
|
(goto-char newpos)
|
|
|
|
|
(if (and (> (point) newpos)
|
|
|
|
|
(eq (preceding-char) ?\n))
|
|
|
|
|
(backward-char 1)
|
|
|
|
|
(if (and (> (point) newpos) (not (eobp))
|
|
|
|
|
(not (eq (following-char) ?\n)))
|
2008-07-11 18:07:01 +00:00
|
|
|
|
;; If we skipped something intangible and now we're not
|
|
|
|
|
;; really at eol, keep going.
|
2004-11-08 16:59:43 +00:00
|
|
|
|
(setq arg 1)
|
|
|
|
|
(setq done t)))))))
|
|
|
|
|
|
2005-03-07 11:12:31 +00:00
|
|
|
|
(defun move-beginning-of-line (arg)
|
2006-01-05 15:59:50 +00:00
|
|
|
|
"Move point to beginning of current line as displayed.
|
|
|
|
|
\(If there's an image in the line, this disregards newlines
|
|
|
|
|
which are part of the text that the image rests on.)
|
|
|
|
|
|
2005-03-07 11:12:31 +00:00
|
|
|
|
With argument ARG not nil or 1, move forward ARG - 1 lines first.
|
|
|
|
|
If point reaches the beginning or end of buffer, it stops there.
|
2006-01-05 15:59:50 +00:00
|
|
|
|
To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p")
|
2005-03-07 11:12:31 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2006-04-09 23:03:48 +00:00
|
|
|
|
|
2006-08-16 05:07:22 +00:00
|
|
|
|
(let ((orig (point))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
first-vis first-vis-field-value)
|
2006-01-26 17:56:54 +00:00
|
|
|
|
|
|
|
|
|
;; Move by lines, if ARG is not 1 (the default).
|
|
|
|
|
(if (/= arg 1)
|
2008-07-11 18:07:01 +00:00
|
|
|
|
(let ((line-move-visual nil))
|
|
|
|
|
(line-move (1- arg) t)))
|
2006-01-26 17:56:54 +00:00
|
|
|
|
|
2011-12-18 22:21:24 -08:00
|
|
|
|
;; Move to beginning-of-line, ignoring fields and invisible text.
|
2006-01-26 17:56:54 +00:00
|
|
|
|
(skip-chars-backward "^\n")
|
2007-08-25 20:20:26 +00:00
|
|
|
|
(while (and (not (bobp)) (invisible-p (1- (point))))
|
2006-02-02 04:21:10 +00:00
|
|
|
|
(goto-char (previous-char-property-change (point)))
|
2006-01-26 17:56:54 +00:00
|
|
|
|
(skip-chars-backward "^\n"))
|
2006-08-16 05:07:22 +00:00
|
|
|
|
|
2014-01-20 14:15:10 -05:00
|
|
|
|
;; Now find first visible char in the line.
|
|
|
|
|
(while (and (< (point) orig) (invisible-p (point)))
|
|
|
|
|
(goto-char (next-char-property-change (point) orig)))
|
2006-08-16 05:07:22 +00:00
|
|
|
|
(setq first-vis (point))
|
|
|
|
|
|
|
|
|
|
;; See if fields would stop us from reaching FIRST-VIS.
|
|
|
|
|
(setq first-vis-field-value
|
|
|
|
|
(constrain-to-field first-vis orig (/= arg 1) t nil))
|
|
|
|
|
|
|
|
|
|
(goto-char (if (/= first-vis-field-value first-vis)
|
|
|
|
|
;; If yes, obey them.
|
|
|
|
|
first-vis-field-value
|
|
|
|
|
;; Otherwise, move to START with attention to fields.
|
|
|
|
|
;; (It is possible that fields never matter in this case.)
|
|
|
|
|
(constrain-to-field (point) orig
|
|
|
|
|
(/= arg 1) t nil)))))
|
2005-03-07 11:12:31 +00:00
|
|
|
|
|
|
|
|
|
|
2009-08-19 02:31:59 +00:00
|
|
|
|
;; Many people have said they rarely use this feature, and often type
|
|
|
|
|
;; it by accident. Maybe it shouldn't even be on a key.
|
1993-01-14 14:50:16 +00:00
|
|
|
|
(put 'set-goal-column 'disabled t)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun set-goal-column (arg)
|
|
|
|
|
"Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
|
|
|
|
|
Those commands will move to this position in the line moved to
|
|
|
|
|
rather than trying to keep the same horizontal position.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With a non-nil argument ARG, clears out the goal column
|
1992-10-23 08:54:08 +00:00
|
|
|
|
so that \\[next-line] and \\[previous-line] resume vertical motion.
|
|
|
|
|
The goal column is stored in the variable `goal-column'."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
(progn
|
|
|
|
|
(setq goal-column nil)
|
|
|
|
|
(message "No goal column"))
|
|
|
|
|
(setq goal-column (current-column))
|
2005-09-18 12:25:02 +00:00
|
|
|
|
;; The older method below can be erroneous if `set-goal-column' is bound
|
|
|
|
|
;; to a sequence containing %
|
|
|
|
|
;;(message (substitute-command-keys
|
|
|
|
|
;;"Goal column %d (use \\[set-goal-column] with an arg to unset it)")
|
|
|
|
|
;;goal-column)
|
|
|
|
|
(message "%s"
|
2005-11-12 00:10:56 +00:00
|
|
|
|
(concat
|
2005-09-18 12:25:02 +00:00
|
|
|
|
(format "Goal column %d " goal-column)
|
|
|
|
|
(substitute-command-keys
|
|
|
|
|
"(use \\[set-goal-column] with an arg to unset it)")))
|
2005-11-12 00:10:56 +00:00
|
|
|
|
|
2005-09-18 12:25:02 +00:00
|
|
|
|
)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
nil)
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2008-07-17 23:37:50 +00:00
|
|
|
|
;;; Editing based on visual lines, as opposed to logical lines.
|
|
|
|
|
|
|
|
|
|
(defun end-of-visual-line (&optional n)
|
|
|
|
|
"Move point to end of current visual line.
|
|
|
|
|
With argument N not nil or 1, move forward N - 1 visual lines first.
|
|
|
|
|
If point reaches the beginning or end of buffer, it stops there.
|
|
|
|
|
To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
|
|
|
|
|
(interactive "^p")
|
|
|
|
|
(or n (setq n 1))
|
|
|
|
|
(if (/= n 1)
|
|
|
|
|
(let ((line-move-visual t))
|
|
|
|
|
(line-move (1- n) t)))
|
2009-12-06 18:48:48 +00:00
|
|
|
|
;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't
|
|
|
|
|
;; constrain to field boundaries, so we don't either.
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(vertical-motion (cons (window-width) 0)))
|
|
|
|
|
|
|
|
|
|
(defun beginning-of-visual-line (&optional n)
|
|
|
|
|
"Move point to beginning of current visual line.
|
|
|
|
|
With argument N not nil or 1, move forward N - 1 visual lines first.
|
|
|
|
|
If point reaches the beginning or end of buffer, it stops there.
|
|
|
|
|
To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
|
|
|
|
|
(interactive "^p")
|
|
|
|
|
(or n (setq n 1))
|
2009-12-06 18:48:48 +00:00
|
|
|
|
(let ((opoint (point)))
|
|
|
|
|
(if (/= n 1)
|
|
|
|
|
(let ((line-move-visual t))
|
|
|
|
|
(line-move (1- n) t)))
|
|
|
|
|
(vertical-motion 0)
|
|
|
|
|
;; Constrain to field boundaries, like `move-beginning-of-line'.
|
|
|
|
|
(goto-char (constrain-to-field (point) opoint (/= n 1)))))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
|
|
|
|
|
(defun kill-visual-line (&optional arg)
|
|
|
|
|
"Kill the rest of the visual line.
|
2009-06-13 18:56:07 +00:00
|
|
|
|
With prefix argument ARG, kill that many visual lines from point.
|
|
|
|
|
If ARG is negative, kill visual lines backward.
|
|
|
|
|
If ARG is zero, kill the text before point on the current visual
|
|
|
|
|
line.
|
2008-07-17 23:37:50 +00:00
|
|
|
|
|
|
|
|
|
If you want to append the killed line to the last killed text,
|
|
|
|
|
use \\[append-next-kill] before \\[kill-line].
|
|
|
|
|
|
|
|
|
|
If the buffer is read-only, Emacs will beep and refrain from deleting
|
|
|
|
|
the line, but put the line in the kill ring anyway. This means that
|
|
|
|
|
you can use this command to copy text from a read-only buffer.
|
|
|
|
|
\(If the variable `kill-read-only-ok' is non-nil, then this won't
|
|
|
|
|
even beep.)"
|
|
|
|
|
(interactive "P")
|
2009-06-13 18:56:07 +00:00
|
|
|
|
;; Like in `kill-line', it's better to move point to the other end
|
|
|
|
|
;; of the kill before killing.
|
2009-07-15 02:05:32 +00:00
|
|
|
|
(let ((opoint (point))
|
|
|
|
|
(kill-whole-line (and kill-whole-line (bolp))))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(if arg
|
|
|
|
|
(vertical-motion (prefix-numeric-value arg))
|
2009-06-13 18:56:07 +00:00
|
|
|
|
(end-of-visual-line 1)
|
|
|
|
|
(if (= (point) opoint)
|
|
|
|
|
(vertical-motion 1)
|
|
|
|
|
;; Skip any trailing whitespace at the end of the visual line.
|
|
|
|
|
;; We used to do this only if `show-trailing-whitespace' is
|
|
|
|
|
;; nil, but that's wrong; the correct thing would be to check
|
|
|
|
|
;; whether the trailing whitespace is highlighted. But, it's
|
|
|
|
|
;; OK to just do this unconditionally.
|
|
|
|
|
(skip-chars-forward " \t")))
|
2009-07-15 02:05:32 +00:00
|
|
|
|
(kill-region opoint (if (and kill-whole-line (looking-at "\n"))
|
|
|
|
|
(1+ (point))
|
|
|
|
|
(point)))))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
|
|
|
|
|
(defun next-logical-line (&optional arg try-vscroll)
|
|
|
|
|
"Move cursor vertically down ARG lines.
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
This is identical to `next-line', except that it always moves
|
2008-07-17 23:37:50 +00:00
|
|
|
|
by logical lines instead of visual lines, ignoring the value of
|
|
|
|
|
the variable `line-move-visual'."
|
|
|
|
|
(interactive "^p\np")
|
|
|
|
|
(let ((line-move-visual nil))
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(next-line arg try-vscroll))))
|
|
|
|
|
|
|
|
|
|
(defun previous-logical-line (&optional arg try-vscroll)
|
|
|
|
|
"Move cursor vertically up ARG lines.
|
|
|
|
|
This is identical to `previous-line', except that it always moves
|
|
|
|
|
by logical lines instead of visual lines, ignoring the value of
|
|
|
|
|
the variable `line-move-visual'."
|
|
|
|
|
(interactive "^p\np")
|
|
|
|
|
(let ((line-move-visual nil))
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(previous-line arg try-vscroll))))
|
|
|
|
|
|
2008-07-21 03:50:17 +00:00
|
|
|
|
(defgroup visual-line nil
|
|
|
|
|
"Editing based on visual lines."
|
|
|
|
|
:group 'convenience
|
|
|
|
|
:version "23.1")
|
|
|
|
|
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(defvar visual-line-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [remap kill-line] 'kill-visual-line)
|
|
|
|
|
(define-key map [remap move-beginning-of-line] 'beginning-of-visual-line)
|
|
|
|
|
(define-key map [remap move-end-of-line] 'end-of-visual-line)
|
2009-01-04 08:30:58 +00:00
|
|
|
|
;; These keybindings interfere with xterm function keys. Are
|
|
|
|
|
;; there any other suitable bindings?
|
|
|
|
|
;; (define-key map "\M-[" 'previous-logical-line)
|
|
|
|
|
;; (define-key map "\M-]" 'next-logical-line)
|
2008-07-17 23:37:50 +00:00
|
|
|
|
map))
|
|
|
|
|
|
2008-07-21 03:50:17 +00:00
|
|
|
|
(defcustom visual-line-fringe-indicators '(nil nil)
|
|
|
|
|
"How fringe indicators are shown for wrapped lines in `visual-line-mode'.
|
|
|
|
|
The value should be a list of the form (LEFT RIGHT), where LEFT
|
|
|
|
|
and RIGHT are symbols representing the bitmaps to display, to
|
|
|
|
|
indicate wrapped lines, in the left and right fringes respectively.
|
|
|
|
|
See also `fringe-indicator-alist'.
|
|
|
|
|
The default is not to display fringe indicators for wrapped lines.
|
|
|
|
|
This variable does not affect fringe indicators displayed for
|
|
|
|
|
other purposes."
|
|
|
|
|
:type '(list (choice (const :tag "Hide left indicator" nil)
|
|
|
|
|
(const :tag "Left curly arrow" left-curly-arrow)
|
|
|
|
|
(symbol :tag "Other bitmap"))
|
|
|
|
|
(choice (const :tag "Hide right indicator" nil)
|
|
|
|
|
(const :tag "Right curly arrow" right-curly-arrow)
|
|
|
|
|
(symbol :tag "Other bitmap")))
|
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
(dolist (buf (buffer-list))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(when (and (boundp 'visual-line-mode)
|
|
|
|
|
(symbol-value 'visual-line-mode))
|
|
|
|
|
(setq fringe-indicator-alist
|
|
|
|
|
(cons (cons 'continuation value)
|
|
|
|
|
(assq-delete-all
|
|
|
|
|
'continuation
|
|
|
|
|
(copy-tree fringe-indicator-alist)))))))
|
|
|
|
|
(set-default symbol value)))
|
|
|
|
|
|
2008-08-12 19:39:50 +00:00
|
|
|
|
(defvar visual-line--saved-state nil)
|
|
|
|
|
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(define-minor-mode visual-line-mode
|
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
|
|
|
|
"Toggle visual line based editing (Visual Line mode).
|
|
|
|
|
With a prefix argument ARG, enable Visual Line mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
When Visual Line mode is enabled, `word-wrap' is turned on in
|
|
|
|
|
this buffer, and simple editing commands are redefined to act on
|
|
|
|
|
visual lines, not logical lines. See Info node `Visual Line
|
|
|
|
|
Mode' for details."
|
2008-07-17 23:37:50 +00:00
|
|
|
|
:keymap visual-line-mode-map
|
2008-07-21 03:50:17 +00:00
|
|
|
|
:group 'visual-line
|
2010-02-03 21:02:56 -08:00
|
|
|
|
:lighter " Wrap"
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(if visual-line-mode
|
|
|
|
|
(progn
|
2008-08-12 19:39:50 +00:00
|
|
|
|
(set (make-local-variable 'visual-line--saved-state) nil)
|
|
|
|
|
;; Save the local values of some variables, to be restored if
|
|
|
|
|
;; visual-line-mode is turned off.
|
|
|
|
|
(dolist (var '(line-move-visual truncate-lines
|
|
|
|
|
truncate-partial-width-windows
|
|
|
|
|
word-wrap fringe-indicator-alist))
|
|
|
|
|
(if (local-variable-p var)
|
2008-08-12 19:41:18 +00:00
|
|
|
|
(push (cons var (symbol-value var))
|
2008-08-12 19:39:50 +00:00
|
|
|
|
visual-line--saved-state)))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(set (make-local-variable 'line-move-visual) t)
|
2008-07-21 18:14:23 +00:00
|
|
|
|
(set (make-local-variable 'truncate-partial-width-windows) nil)
|
|
|
|
|
(setq truncate-lines nil
|
|
|
|
|
word-wrap t
|
|
|
|
|
fringe-indicator-alist
|
2008-07-21 03:50:17 +00:00
|
|
|
|
(cons (cons 'continuation visual-line-fringe-indicators)
|
|
|
|
|
fringe-indicator-alist)))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
(kill-local-variable 'line-move-visual)
|
2008-07-21 03:50:17 +00:00
|
|
|
|
(kill-local-variable 'word-wrap)
|
2008-07-21 18:14:23 +00:00
|
|
|
|
(kill-local-variable 'truncate-lines)
|
|
|
|
|
(kill-local-variable 'truncate-partial-width-windows)
|
2008-08-12 19:39:50 +00:00
|
|
|
|
(kill-local-variable 'fringe-indicator-alist)
|
|
|
|
|
(dolist (saved visual-line--saved-state)
|
|
|
|
|
(set (make-local-variable (car saved)) (cdr saved)))
|
|
|
|
|
(kill-local-variable 'visual-line--saved-state)))
|
2008-07-17 23:37:50 +00:00
|
|
|
|
|
|
|
|
|
(defun turn-on-visual-line-mode ()
|
|
|
|
|
(visual-line-mode 1))
|
|
|
|
|
|
|
|
|
|
(define-globalized-minor-mode global-visual-line-mode
|
2013-07-25 21:55:06 -04:00
|
|
|
|
visual-line-mode turn-on-visual-line-mode)
|
2010-04-06 02:44:24 +03:00
|
|
|
|
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun transpose-chars (arg)
|
|
|
|
|
"Interchange characters around point, moving forward one character.
|
|
|
|
|
With prefix arg ARG, effect is to take character before point
|
|
|
|
|
and drag it forward past ARG other characters (backward if ARG negative).
|
|
|
|
|
If no argument and at end of line, the previous two chars are exchanged."
|
|
|
|
|
(interactive "*P")
|
|
|
|
|
(and (null arg) (eolp) (forward-char -1))
|
|
|
|
|
(transpose-subr 'forward-char (prefix-numeric-value arg)))
|
|
|
|
|
|
|
|
|
|
(defun transpose-words (arg)
|
|
|
|
|
"Interchange words around point, leaving point at end of them.
|
|
|
|
|
With prefix arg ARG, effect is to take word before or around point
|
|
|
|
|
and drag it forward past ARG other words (backward if ARG negative).
|
|
|
|
|
If ARG is zero, the words around or after point and around or after mark
|
|
|
|
|
are interchanged."
|
2002-04-11 23:44:06 +00:00
|
|
|
|
;; FIXME: `foo a!nd bar' should transpose into `bar and foo'.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(transpose-subr 'forward-word arg))
|
|
|
|
|
|
|
|
|
|
(defun transpose-sexps (arg)
|
|
|
|
|
"Like \\[transpose-words] but applies to sexps.
|
|
|
|
|
Does not work on a sexp that point is in the middle of
|
|
|
|
|
if it is a list or string."
|
|
|
|
|
(interactive "*p")
|
2002-04-11 23:44:06 +00:00
|
|
|
|
(transpose-subr
|
|
|
|
|
(lambda (arg)
|
|
|
|
|
;; Here we should try to simulate the behavior of
|
|
|
|
|
;; (cons (progn (forward-sexp x) (point))
|
|
|
|
|
;; (progn (forward-sexp (- x)) (point)))
|
|
|
|
|
;; Except that we don't want to rely on the second forward-sexp
|
|
|
|
|
;; putting us back to where we want to be, since forward-sexp-function
|
|
|
|
|
;; might do funny things like infix-precedence.
|
|
|
|
|
(if (if (> arg 0)
|
|
|
|
|
(looking-at "\\sw\\|\\s_")
|
|
|
|
|
(and (not (bobp))
|
|
|
|
|
(save-excursion (forward-char -1) (looking-at "\\sw\\|\\s_"))))
|
|
|
|
|
;; Jumping over a symbol. We might be inside it, mind you.
|
|
|
|
|
(progn (funcall (if (> arg 0)
|
|
|
|
|
'skip-syntax-backward 'skip-syntax-forward)
|
|
|
|
|
"w_")
|
|
|
|
|
(cons (save-excursion (forward-sexp arg) (point)) (point)))
|
|
|
|
|
;; Otherwise, we're between sexps. Take a step back before jumping
|
|
|
|
|
;; to make sure we'll obey the same precedence no matter which direction
|
|
|
|
|
;; we're going.
|
|
|
|
|
(funcall (if (> arg 0) 'skip-syntax-backward 'skip-syntax-forward) " .")
|
|
|
|
|
(cons (save-excursion (forward-sexp arg) (point))
|
|
|
|
|
(progn (while (or (forward-comment (if (> arg 0) 1 -1))
|
|
|
|
|
(not (zerop (funcall (if (> arg 0)
|
|
|
|
|
'skip-syntax-forward
|
|
|
|
|
'skip-syntax-backward)
|
|
|
|
|
".")))))
|
|
|
|
|
(point)))))
|
|
|
|
|
arg 'special))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun transpose-lines (arg)
|
|
|
|
|
"Exchange current line and previous line, leaving point after both.
|
|
|
|
|
With argument ARG, takes previous line and moves it past ARG lines.
|
|
|
|
|
With argument 0, interchanges line point is in with line mark is in."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(transpose-subr (function
|
|
|
|
|
(lambda (arg)
|
1997-12-17 13:54:03 +00:00
|
|
|
|
(if (> arg 0)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(progn
|
1997-12-17 13:54:03 +00:00
|
|
|
|
;; Move forward over ARG lines,
|
|
|
|
|
;; but create newlines if necessary.
|
|
|
|
|
(setq arg (forward-line arg))
|
|
|
|
|
(if (/= (preceding-char) ?\n)
|
|
|
|
|
(setq arg (1+ arg)))
|
|
|
|
|
(if (> arg 0)
|
|
|
|
|
(newline arg)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(forward-line arg))))
|
|
|
|
|
arg))
|
|
|
|
|
|
2010-02-13 11:29:25 -08:00
|
|
|
|
;; FIXME seems to leave point BEFORE the current object when ARG = 0,
|
|
|
|
|
;; which seems inconsistent with the ARG /= 0 case.
|
|
|
|
|
;; FIXME document SPECIAL.
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(defun transpose-subr (mover arg &optional special)
|
2010-02-13 11:29:25 -08:00
|
|
|
|
"Subroutine to do the work of transposing objects.
|
|
|
|
|
Works for lines, sentences, paragraphs, etc. MOVER is a function that
|
|
|
|
|
moves forward by units of the given object (e.g. forward-sentence,
|
|
|
|
|
forward-paragraph). If ARG is zero, exchanges the current object
|
|
|
|
|
with the one containing mark. If ARG is an integer, moves the
|
|
|
|
|
current object past ARG following (if ARG is positive) or
|
|
|
|
|
preceding (if ARG is negative) objects, leaving point after the
|
|
|
|
|
current object."
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(let ((aux (if special mover
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(cons (progn (funcall mover x) (point))
|
|
|
|
|
(progn (funcall mover (- x)) (point))))))
|
|
|
|
|
pos1 pos2)
|
|
|
|
|
(cond
|
|
|
|
|
((= arg 0)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(setq pos1 (funcall aux 1))
|
2009-10-26 14:59:12 +00:00
|
|
|
|
(goto-char (or (mark) (error "No mark set in this buffer")))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(setq pos2 (funcall aux 1))
|
|
|
|
|
(transpose-subr-1 pos1 pos2))
|
|
|
|
|
(exchange-point-and-mark))
|
|
|
|
|
((> arg 0)
|
|
|
|
|
(setq pos1 (funcall aux -1))
|
|
|
|
|
(setq pos2 (funcall aux arg))
|
|
|
|
|
(transpose-subr-1 pos1 pos2)
|
|
|
|
|
(goto-char (car pos2)))
|
|
|
|
|
(t
|
|
|
|
|
(setq pos1 (funcall aux -1))
|
|
|
|
|
(goto-char (car pos1))
|
|
|
|
|
(setq pos2 (funcall aux arg))
|
|
|
|
|
(transpose-subr-1 pos1 pos2)))))
|
|
|
|
|
|
|
|
|
|
(defun transpose-subr-1 (pos1 pos2)
|
|
|
|
|
(when (> (car pos1) (cdr pos1)) (setq pos1 (cons (cdr pos1) (car pos1))))
|
|
|
|
|
(when (> (car pos2) (cdr pos2)) (setq pos2 (cons (cdr pos2) (car pos2))))
|
|
|
|
|
(when (> (car pos1) (car pos2))
|
|
|
|
|
(let ((swap pos1))
|
|
|
|
|
(setq pos1 pos2 pos2 swap)))
|
|
|
|
|
(if (> (cdr pos1) (car pos2)) (error "Don't have two things to transpose"))
|
2002-02-06 15:08:45 +00:00
|
|
|
|
(atomic-change-group
|
2012-12-21 13:42:59 +08:00
|
|
|
|
;; This sequence of insertions attempts to preserve marker
|
|
|
|
|
;; positions at the start and end of the transposed objects.
|
|
|
|
|
(let* ((word (buffer-substring (car pos2) (cdr pos2)))
|
|
|
|
|
(len1 (- (cdr pos1) (car pos1)))
|
|
|
|
|
(len2 (length word))
|
|
|
|
|
(boundary (make-marker)))
|
|
|
|
|
(set-marker boundary (car pos2))
|
|
|
|
|
(goto-char (cdr pos1))
|
|
|
|
|
(insert-before-markers word)
|
|
|
|
|
(setq word (delete-and-extract-region (car pos1) (+ (car pos1) len1)))
|
|
|
|
|
(goto-char boundary)
|
|
|
|
|
(insert word)
|
|
|
|
|
(goto-char (+ boundary len1))
|
|
|
|
|
(delete-region (point) (+ (point) len2))
|
|
|
|
|
(set-marker boundary nil))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun backward-word (&optional arg)
|
2001-09-04 08:37:35 +00:00
|
|
|
|
"Move backward until encountering the beginning of a word.
|
2013-08-13 22:26:39 +08:00
|
|
|
|
With argument ARG, do this that many times.
|
|
|
|
|
If ARG is omitted or nil, move point backward one word."
|
2008-04-02 20:16:10 +00:00
|
|
|
|
(interactive "^p")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(forward-word (- (or arg 1))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2004-12-29 01:33:04 +00:00
|
|
|
|
(defun mark-word (&optional arg allow-extend)
|
2004-12-13 03:08:52 +00:00
|
|
|
|
"Set mark ARG words away from point.
|
|
|
|
|
The place mark goes is the same place \\[forward-word] would
|
|
|
|
|
move to with the same argument.
|
2004-12-29 01:33:04 +00:00
|
|
|
|
Interactively, if this command is repeated
|
2005-01-06 22:00:36 +00:00
|
|
|
|
or (in Transient Mark mode) if the mark is active,
|
2004-12-13 03:08:52 +00:00
|
|
|
|
it marks the next ARG words after the ones already marked."
|
2004-12-29 01:33:04 +00:00
|
|
|
|
(interactive "P\np")
|
|
|
|
|
(cond ((and allow-extend
|
|
|
|
|
(or (and (eq last-command this-command) (mark t))
|
2008-04-03 02:16:17 +00:00
|
|
|
|
(region-active-p)))
|
2004-12-13 03:08:52 +00:00
|
|
|
|
(setq arg (if arg (prefix-numeric-value arg)
|
|
|
|
|
(if (< (mark) (point)) -1 1)))
|
2002-02-15 08:53:15 +00:00
|
|
|
|
(set-mark
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (mark))
|
|
|
|
|
(forward-word arg)
|
|
|
|
|
(point))))
|
|
|
|
|
(t
|
|
|
|
|
(push-mark
|
|
|
|
|
(save-excursion
|
2004-12-13 03:08:52 +00:00
|
|
|
|
(forward-word (prefix-numeric-value arg))
|
2002-02-15 08:53:15 +00:00
|
|
|
|
(point))
|
|
|
|
|
nil t))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun kill-word (arg)
|
|
|
|
|
"Kill characters forward until encountering the end of a word.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With argument ARG, do this that many times."
|
2000-02-23 23:08:02 +00:00
|
|
|
|
(interactive "p")
|
1999-08-25 21:12:15 +00:00
|
|
|
|
(kill-region (point) (progn (forward-word arg) (point))))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun backward-kill-word (arg)
|
2007-01-05 20:24:50 +00:00
|
|
|
|
"Kill characters backward until encountering the beginning of a word.
|
* simple.el (quoted-insert, minibuffer-history-isearch-pop-state, undo)
(undo-only, rotate-yank-pointer, kill-whole-line, push-mark-command)
(exchange-point-and-mark, set-goal-column, kill-line, backward-word)
(kill-word, backward-kill-word): Doc fixes.
(shell-command, repeat-complex-command): Reflow docstrings.
(zap-to-char, pop-to-mark-command): Fix typos in docstrings.
2008-11-17 01:54:02 +00:00
|
|
|
|
With argument ARG, do this that many times."
|
2000-02-23 23:08:02 +00:00
|
|
|
|
(interactive "p")
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(kill-word (- arg)))
|
1993-03-29 04:58:31 +00:00
|
|
|
|
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(defun current-word (&optional strict really-word)
|
|
|
|
|
"Return the symbol or word that point is on (or a nearby one) as a string.
|
|
|
|
|
The return value includes no text properties.
|
1994-03-03 18:27:51 +00:00
|
|
|
|
If optional arg STRICT is non-nil, return nil unless point is within
|
2004-07-09 16:08:17 +00:00
|
|
|
|
or adjacent to a symbol or word. In all cases the value can be nil
|
|
|
|
|
if there is no word nearby.
|
2003-07-07 21:00:26 +00:00
|
|
|
|
The function, belying its name, normally finds a symbol.
|
|
|
|
|
If optional arg REALLY-WORD is non-nil, it finds just a word."
|
1993-03-29 04:58:31 +00:00
|
|
|
|
(save-excursion
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(let* ((oldpoint (point)) (start (point)) (end (point))
|
2003-07-18 22:46:08 +00:00
|
|
|
|
(syntaxes (if really-word "w" "w_"))
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(not-syntaxes (concat "^" syntaxes)))
|
|
|
|
|
(skip-syntax-backward syntaxes) (setq start (point))
|
1993-03-29 04:58:31 +00:00
|
|
|
|
(goto-char oldpoint)
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(skip-syntax-forward syntaxes) (setq end (point))
|
|
|
|
|
(when (and (eq start oldpoint) (eq end oldpoint)
|
|
|
|
|
;; Point is neither within nor adjacent to a word.
|
|
|
|
|
(not strict))
|
|
|
|
|
;; Look for preceding word in same line.
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
|
(skip-syntax-backward not-syntaxes (line-beginning-position))
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(if (bolp)
|
|
|
|
|
;; No preceding word in same line.
|
|
|
|
|
;; Look for following word in same line.
|
|
|
|
|
(progn
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
|
(skip-syntax-forward not-syntaxes (line-end-position))
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(setq start (point))
|
|
|
|
|
(skip-syntax-forward syntaxes)
|
|
|
|
|
(setq end (point)))
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(skip-syntax-backward syntaxes)
|
|
|
|
|
(setq start (point))))
|
|
|
|
|
;; If we found something nonempty, return it as a string.
|
|
|
|
|
(unless (= start end)
|
1997-06-22 09:16:07 +00:00
|
|
|
|
(buffer-substring-no-properties start end)))))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom fill-prefix nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"String for filling to insert at front of new line, or nil for none."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type '(choice (const :tag "None" nil)
|
|
|
|
|
string)
|
|
|
|
|
:group 'fill)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(make-variable-buffer-local 'fill-prefix)
|
2008-03-14 17:42:18 +00:00
|
|
|
|
(put 'fill-prefix 'safe-local-variable 'string-or-null-p)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom auto-fill-inhibit-regexp nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Regexp to match lines which should not be auto-filled."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type '(choice (const :tag "None" nil)
|
|
|
|
|
regexp)
|
|
|
|
|
:group 'fill)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
|
|
|
|
(defun do-auto-fill ()
|
2011-01-22 13:02:49 -08:00
|
|
|
|
"The default value for `normal-auto-fill-function'.
|
|
|
|
|
This is the default auto-fill function, some major modes use a different one.
|
|
|
|
|
Returns t if it really did any work."
|
2004-05-19 19:10:19 +00:00
|
|
|
|
(let (fc justify give-up
|
1995-07-28 02:38:16 +00:00
|
|
|
|
(fill-prefix fill-prefix))
|
1995-01-19 04:26:55 +00:00
|
|
|
|
(if (or (not (setq justify (current-justification)))
|
1995-06-29 03:18:29 +00:00
|
|
|
|
(null (setq fc (current-fill-column)))
|
|
|
|
|
(and (eq justify 'left)
|
|
|
|
|
(<= (current-column) fc))
|
2004-05-19 19:10:19 +00:00
|
|
|
|
(and auto-fill-inhibit-regexp
|
|
|
|
|
(save-excursion (beginning-of-line)
|
1995-01-19 04:21:56 +00:00
|
|
|
|
(looking-at auto-fill-inhibit-regexp))))
|
|
|
|
|
nil ;; Auto-filling not required
|
1995-02-23 18:38:42 +00:00
|
|
|
|
(if (memq justify '(full center right))
|
|
|
|
|
(save-excursion (unjustify-current-line)))
|
1995-07-28 02:38:16 +00:00
|
|
|
|
|
|
|
|
|
;; Choose a fill-prefix automatically.
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(when (and adaptive-fill-mode
|
|
|
|
|
(or (null fill-prefix) (string= fill-prefix "")))
|
|
|
|
|
(let ((prefix
|
|
|
|
|
(fill-context-prefix
|
2011-06-01 12:52:35 -03:00
|
|
|
|
(save-excursion (fill-forward-paragraph -1) (point))
|
|
|
|
|
(save-excursion (fill-forward-paragraph 1) (point)))))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(and prefix (not (equal prefix ""))
|
|
|
|
|
;; Use auto-indentation rather than a guessed empty prefix.
|
2002-09-10 01:24:12 +00:00
|
|
|
|
(not (and fill-indent-according-to-mode
|
2002-09-09 22:09:14 +00:00
|
|
|
|
(string-match "\\`[ \t]*\\'" prefix)))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(setq fill-prefix prefix))))
|
2003-02-04 12:29:42 +00:00
|
|
|
|
|
1995-01-19 04:21:56 +00:00
|
|
|
|
(while (and (not give-up) (> (current-column) fc))
|
1995-07-30 00:46:23 +00:00
|
|
|
|
;; Determine where to split the line.
|
1997-08-14 03:55:49 +00:00
|
|
|
|
(let* (after-prefix
|
|
|
|
|
(fill-point
|
2004-05-19 19:10:19 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq after-prefix (point))
|
|
|
|
|
(and fill-prefix
|
|
|
|
|
(looking-at (regexp-quote fill-prefix))
|
|
|
|
|
(setq after-prefix (match-end 0)))
|
|
|
|
|
(move-to-column (1+ fc))
|
|
|
|
|
(fill-move-to-break-point after-prefix)
|
|
|
|
|
(point))))
|
1997-08-14 03:55:49 +00:00
|
|
|
|
|
|
|
|
|
;; See whether the place we found is any good.
|
1995-07-30 00:46:23 +00:00
|
|
|
|
(if (save-excursion
|
|
|
|
|
(goto-char fill-point)
|
2002-04-11 23:44:06 +00:00
|
|
|
|
(or (bolp)
|
|
|
|
|
;; There is no use breaking at end of line.
|
|
|
|
|
(save-excursion (skip-chars-forward " ") (eolp))
|
|
|
|
|
;; It is futile to split at the end of the prefix
|
|
|
|
|
;; since we would just insert the prefix again.
|
|
|
|
|
(and after-prefix (<= (point) after-prefix))
|
|
|
|
|
;; Don't split right after a comment starter
|
|
|
|
|
;; since we would just make another comment starter.
|
|
|
|
|
(and comment-start-skip
|
|
|
|
|
(let ((limit (point)))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(and (re-search-forward comment-start-skip
|
|
|
|
|
limit t)
|
|
|
|
|
(eq (point) limit))))))
|
|
|
|
|
;; No good place to break => stop trying.
|
|
|
|
|
(setq give-up t)
|
|
|
|
|
;; Ok, we have a useful place to break the line. Do it.
|
|
|
|
|
(let ((prev-column (current-column)))
|
|
|
|
|
;; If point is at the fill-point, do not `save-excursion'.
|
|
|
|
|
;; Otherwise, if a comment prefix or fill-prefix is inserted,
|
|
|
|
|
;; point will end up before it rather than after it.
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(= (point) fill-point))
|
2007-08-07 03:04:23 +00:00
|
|
|
|
(default-indent-new-line t)
|
2002-04-11 23:44:06 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char fill-point)
|
2007-08-07 03:04:23 +00:00
|
|
|
|
(default-indent-new-line t)))
|
2002-04-11 23:44:06 +00:00
|
|
|
|
;; Now do justification, if required
|
|
|
|
|
(if (not (eq justify 'left))
|
1995-07-30 00:46:23 +00:00
|
|
|
|
(save-excursion
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(end-of-line 0)
|
|
|
|
|
(justify-current-line justify nil t)))
|
2002-04-11 23:44:06 +00:00
|
|
|
|
;; If making the new line didn't reduce the hpos of
|
|
|
|
|
;; the end of the line, then give up now;
|
|
|
|
|
;; trying again will not help.
|
|
|
|
|
(if (>= (current-column) prev-column)
|
|
|
|
|
(setq give-up t))))))
|
1996-08-07 19:45:46 +00:00
|
|
|
|
;; Justify last line.
|
1996-05-21 14:31:40 +00:00
|
|
|
|
(justify-current-line justify t t)
|
1999-11-15 16:11:14 +00:00
|
|
|
|
t)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
2007-08-07 03:04:23 +00:00
|
|
|
|
(defvar comment-line-break-function 'comment-indent-new-line
|
2012-04-09 21:05:48 +08:00
|
|
|
|
"Mode-specific function which line breaks and continues a comment.
|
2007-08-07 03:04:23 +00:00
|
|
|
|
This function is called during auto-filling when a comment syntax
|
|
|
|
|
is defined.
|
|
|
|
|
The function should take a single optional argument, which is a flag
|
|
|
|
|
indicating whether it should use soft newlines.")
|
|
|
|
|
|
|
|
|
|
(defun default-indent-new-line (&optional soft)
|
|
|
|
|
"Break line at point and indent.
|
|
|
|
|
If a comment syntax is defined, call `comment-indent-new-line'.
|
|
|
|
|
|
|
|
|
|
The inserted newline is marked hard if variable `use-hard-newlines' is true,
|
|
|
|
|
unless optional argument SOFT is non-nil."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if comment-start
|
|
|
|
|
(funcall comment-line-break-function soft)
|
|
|
|
|
;; Insert the newline before removing empty space so that markers
|
|
|
|
|
;; get preserved better.
|
|
|
|
|
(if soft (insert-and-inherit ?\n) (newline 1))
|
|
|
|
|
(save-excursion (forward-char -1) (delete-horizontal-space))
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
|
|
|
|
|
(if (and fill-prefix (not adaptive-fill-mode))
|
|
|
|
|
;; Blindly trust a non-adaptive fill-prefix.
|
|
|
|
|
(progn
|
|
|
|
|
(indent-to-left-margin)
|
|
|
|
|
(insert-before-markers-and-inherit fill-prefix))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
;; If there's an adaptive prefix, use it unless we're inside
|
|
|
|
|
;; a comment and the prefix is not a comment starter.
|
|
|
|
|
(fill-prefix
|
|
|
|
|
(indent-to-left-margin)
|
|
|
|
|
(insert-and-inherit fill-prefix))
|
|
|
|
|
;; If we're not inside a comment, just try to indent.
|
|
|
|
|
(t (indent-according-to-mode))))))
|
|
|
|
|
|
1996-08-07 19:45:46 +00:00
|
|
|
|
(defvar normal-auto-fill-function 'do-auto-fill
|
|
|
|
|
"The function to use for `auto-fill-function' if Auto Fill mode is turned on.
|
|
|
|
|
Some major modes set this.")
|
|
|
|
|
|
2005-03-16 13:11:34 +00:00
|
|
|
|
(put 'auto-fill-function :minor-mode-function 'auto-fill-mode)
|
2009-04-02 01:56:43 +00:00
|
|
|
|
;; `functions' and `hooks' are usually unsafe to set, but setting
|
|
|
|
|
;; auto-fill-function to nil in a file-local setting is safe and
|
|
|
|
|
;; can be useful to prevent auto-filling.
|
|
|
|
|
(put 'auto-fill-function 'safe-local-variable 'null)
|
2011-07-16 20:42:38 +02:00
|
|
|
|
|
2010-05-04 23:45:21 -04:00
|
|
|
|
(define-minor-mode auto-fill-mode
|
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
|
|
|
|
"Toggle automatic line breaking (Auto Fill mode).
|
|
|
|
|
With a prefix argument ARG, enable Auto Fill mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
When Auto Fill mode is enabled, inserting a space at a column
|
|
|
|
|
beyond `current-fill-column' automatically breaks the line at a
|
|
|
|
|
previous space.
|
1996-08-07 19:45:46 +00:00
|
|
|
|
|
2011-07-16 20:42:38 +02:00
|
|
|
|
When `auto-fill-mode' is on, the `auto-fill-function' variable is
|
|
|
|
|
non-`nil'.
|
|
|
|
|
|
1996-08-07 19:45:46 +00:00
|
|
|
|
The value of `normal-auto-fill-function' specifies the function to use
|
|
|
|
|
for `auto-fill-function' when turning Auto Fill mode on."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
:variable (auto-fill-function
|
|
|
|
|
. (lambda (v) (setq auto-fill-function
|
|
|
|
|
(if v normal-auto-fill-function)))))
|
1994-04-16 02:06:17 +00:00
|
|
|
|
|
|
|
|
|
;; This holds a document string used to document auto-fill-mode.
|
|
|
|
|
(defun auto-fill-function ()
|
|
|
|
|
"Automatically break line at a previous space, in insertion of text."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defun turn-on-auto-fill ()
|
|
|
|
|
"Unconditionally turn on Auto Fill mode."
|
|
|
|
|
(auto-fill-mode 1))
|
2000-06-20 18:24:59 +00:00
|
|
|
|
|
|
|
|
|
(defun turn-off-auto-fill ()
|
|
|
|
|
"Unconditionally turn off Auto Fill mode."
|
|
|
|
|
(auto-fill-mode -1))
|
|
|
|
|
|
1999-02-18 07:24:11 +00:00
|
|
|
|
(custom-add-option 'text-mode-hook 'turn-on-auto-fill)
|
1994-04-16 02:06:17 +00:00
|
|
|
|
|
|
|
|
|
(defun set-fill-column (arg)
|
1996-06-14 02:11:11 +00:00
|
|
|
|
"Set `fill-column' to specified argument.
|
1998-10-13 15:47:40 +00:00
|
|
|
|
Use \\[universal-argument] followed by a number to specify a column.
|
1996-06-14 02:11:11 +00:00
|
|
|
|
Just \\[universal-argument] as argument means to use the current column."
|
2008-04-04 16:16:23 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (or current-prefix-arg
|
|
|
|
|
;; We used to use current-column silently, but C-x f is too easily
|
|
|
|
|
;; typed as a typo for C-x C-f, so we turned it into an error and
|
|
|
|
|
;; now an interactive prompt.
|
|
|
|
|
(read-number "Set fill-column to: " (current-column)))))
|
1997-05-19 02:52:50 +00:00
|
|
|
|
(if (consp arg)
|
|
|
|
|
(setq arg (current-column)))
|
|
|
|
|
(if (not (integerp arg))
|
|
|
|
|
;; Disallow missing argument; it's probably a typo for C-x C-f.
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
(error "set-fill-column requires an explicit argument")
|
1997-05-19 02:52:50 +00:00
|
|
|
|
(message "Fill column set to %d (was %d)" arg fill-column)
|
|
|
|
|
(setq fill-column arg)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun set-selective-display (arg)
|
1992-08-21 07:18:16 +00:00
|
|
|
|
"Set `selective-display' to ARG; clear it if no arg.
|
|
|
|
|
When the value of `selective-display' is a number > 0,
|
|
|
|
|
lines whose indentation is >= that value are not displayed.
|
|
|
|
|
The variable `selective-display' has a separate value for each buffer."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(if (eq selective-display t)
|
|
|
|
|
(error "selective-display already in use for marked lines"))
|
1992-05-30 21:11:25 +00:00
|
|
|
|
(let ((current-vpos
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region (point-min) (point))
|
|
|
|
|
(goto-char (window-start))
|
|
|
|
|
(vertical-motion (window-height)))))
|
|
|
|
|
(setq selective-display
|
|
|
|
|
(and arg (prefix-numeric-value arg)))
|
|
|
|
|
(recenter current-vpos))
|
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
|
|
|
|
(set-window-start (selected-window) (window-start))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(princ "selective-display set to " t)
|
|
|
|
|
(prin1 selective-display t)
|
|
|
|
|
(princ "." t))
|
|
|
|
|
|
2002-11-18 04:55:28 +00:00
|
|
|
|
(defvaralias 'indicate-unused-lines 'indicate-empty-lines)
|
|
|
|
|
|
2006-05-26 12:40:59 +00:00
|
|
|
|
(defun toggle-truncate-lines (&optional arg)
|
2011-07-13 18:39:49 +02:00
|
|
|
|
"Toggle truncating of long lines for the current buffer.
|
|
|
|
|
When truncating is off, long lines are folded.
|
2007-08-08 07:40:09 +00:00
|
|
|
|
With prefix argument ARG, truncate long lines if ARG is positive,
|
2011-07-13 18:39:49 +02:00
|
|
|
|
otherwise fold them. Note that in side-by-side windows, this
|
|
|
|
|
command has no effect if `truncate-partial-width-windows' is
|
|
|
|
|
non-nil."
|
2002-07-04 13:36:12 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(setq truncate-lines
|
|
|
|
|
(if (null arg)
|
|
|
|
|
(not truncate-lines)
|
2002-08-13 01:48:42 +00:00
|
|
|
|
(> (prefix-numeric-value arg) 0)))
|
|
|
|
|
(force-mode-line-update)
|
2002-10-26 22:40:31 +00:00
|
|
|
|
(unless truncate-lines
|
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
|
(walk-windows (lambda (window)
|
|
|
|
|
(if (eq buffer (window-buffer window))
|
|
|
|
|
(set-window-hscroll window 0)))
|
|
|
|
|
nil t)))
|
2002-08-13 01:48:42 +00:00
|
|
|
|
(message "Truncate long lines %s"
|
|
|
|
|
(if truncate-lines "enabled" "disabled")))
|
2002-07-04 13:36:12 +00:00
|
|
|
|
|
2009-02-08 00:47:15 +00:00
|
|
|
|
(defun toggle-word-wrap (&optional arg)
|
|
|
|
|
"Toggle whether to use word-wrapping for continuation lines.
|
|
|
|
|
With prefix argument ARG, wrap continuation lines at word boundaries
|
|
|
|
|
if ARG is positive, otherwise wrap them at the right screen edge.
|
|
|
|
|
This command toggles the value of `word-wrap'. It has no effect
|
|
|
|
|
if long lines are truncated."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(setq word-wrap
|
|
|
|
|
(if (null arg)
|
|
|
|
|
(not word-wrap)
|
|
|
|
|
(> (prefix-numeric-value arg) 0)))
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(message "Word wrapping %s"
|
|
|
|
|
(if word-wrap "enabled" "disabled")))
|
|
|
|
|
|
2009-10-30 02:00:11 +00:00
|
|
|
|
(defvar overwrite-mode-textual (purecopy " Ovwrt")
|
1993-03-16 18:18:47 +00:00
|
|
|
|
"The string displayed in the mode line when in overwrite mode.")
|
2009-10-30 02:00:11 +00:00
|
|
|
|
(defvar overwrite-mode-binary (purecopy " Bin Ovwrt")
|
1993-03-16 18:18:47 +00:00
|
|
|
|
"The string displayed in the mode line when in binary overwrite mode.")
|
|
|
|
|
|
2010-05-04 23:45:21 -04:00
|
|
|
|
(define-minor-mode overwrite-mode
|
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
|
|
|
|
"Toggle Overwrite mode.
|
|
|
|
|
With a prefix argument ARG, enable Overwrite mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
When Overwrite mode is enabled, printing characters typed in
|
|
|
|
|
replace existing text on a one-for-one basis, rather than pushing
|
|
|
|
|
it to the right. At the end of a line, such characters extend
|
|
|
|
|
the line. Before a tab, such characters insert until the tab is
|
|
|
|
|
filled in. \\[quoted-insert] still inserts characters in
|
|
|
|
|
overwrite mode; this is supposed to make it easier to insert
|
|
|
|
|
characters when necessary."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
:variable (overwrite-mode
|
|
|
|
|
. (lambda (v) (setq overwrite-mode (if v 'overwrite-mode-textual)))))
|
1993-03-16 18:18:47 +00:00
|
|
|
|
|
2010-05-04 23:45:21 -04:00
|
|
|
|
(define-minor-mode binary-overwrite-mode
|
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
|
|
|
|
"Toggle Binary Overwrite mode.
|
|
|
|
|
With a prefix argument ARG, enable Binary Overwrite mode if ARG
|
|
|
|
|
is positive, and disable it otherwise. If called from Lisp,
|
|
|
|
|
enable the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
When Binary Overwrite mode is enabled, printing characters typed
|
|
|
|
|
in replace existing text. Newlines are not treated specially, so
|
|
|
|
|
typing at the end of a line joins the line to the next, with the
|
|
|
|
|
typed character between them. Typing before a tab character
|
|
|
|
|
simply replaces the tab with the character typed.
|
|
|
|
|
\\[quoted-insert] replaces the text at the cursor, just as
|
|
|
|
|
ordinary typing characters do.
|
|
|
|
|
|
|
|
|
|
Note that Binary Overwrite mode is not its own minor mode; it is
|
|
|
|
|
a specialization of overwrite mode, entered by setting the
|
1993-03-16 18:18:47 +00:00
|
|
|
|
`overwrite-mode' variable to `overwrite-mode-binary'."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
:variable (overwrite-mode
|
|
|
|
|
. (lambda (v) (setq overwrite-mode (if v 'overwrite-mode-binary)))))
|
2000-11-22 20:59:39 +00:00
|
|
|
|
|
2002-09-11 20:46:33 +00:00
|
|
|
|
(define-minor-mode line-number-mode
|
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
|
|
|
|
"Toggle line number display in the mode line (Line Number mode).
|
|
|
|
|
With a prefix argument ARG, enable Line Number mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
1998-11-07 02:08:40 +00:00
|
|
|
|
|
2001-08-22 18:30:36 +00:00
|
|
|
|
Line numbers do not appear for very large buffers and buffers
|
|
|
|
|
with very long lines; see variables `line-number-display-limit'
|
|
|
|
|
and `line-number-display-limit-width'."
|
2006-09-14 23:55:31 +00:00
|
|
|
|
:init-value t :global t :group 'mode-line)
|
1995-07-17 23:03:53 +00:00
|
|
|
|
|
2002-09-11 20:46:33 +00:00
|
|
|
|
(define-minor-mode column-number-mode
|
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
|
|
|
|
"Toggle column number display in the mode line (Column Number mode).
|
|
|
|
|
With a prefix argument ARG, enable Column Number mode if ARG is
|
|
|
|
|
positive, and disable it otherwise.
|
|
|
|
|
|
|
|
|
|
If called from Lisp, enable the mode if ARG is omitted or nil."
|
2006-09-14 23:55:31 +00:00
|
|
|
|
:global t :group 'mode-line)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
(define-minor-mode size-indication-mode
|
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
|
|
|
|
"Toggle buffer size display in the mode line (Size Indication mode).
|
|
|
|
|
With a prefix argument ARG, enable Size Indication mode if ARG is
|
|
|
|
|
positive, and disable it otherwise.
|
|
|
|
|
|
|
|
|
|
If called from Lisp, enable the mode if ARG is omitted or nil."
|
2006-09-14 23:55:31 +00:00
|
|
|
|
:global t :group 'mode-line)
|
2010-05-07 08:49:14 -04:00
|
|
|
|
|
|
|
|
|
(define-minor-mode auto-save-mode
|
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
|
|
|
|
"Toggle auto-saving in the current buffer (Auto Save mode).
|
|
|
|
|
With a prefix argument ARG, enable Auto Save mode if ARG is
|
|
|
|
|
positive, and disable it otherwise.
|
|
|
|
|
|
|
|
|
|
If called from Lisp, enable the mode if ARG is omitted or nil."
|
2010-05-07 08:49:14 -04:00
|
|
|
|
:variable ((and buffer-auto-save-file-name
|
|
|
|
|
;; If auto-save is off because buffer has shrunk,
|
|
|
|
|
;; then toggling should turn it on.
|
|
|
|
|
(>= buffer-saved-size 0))
|
|
|
|
|
. (lambda (val)
|
|
|
|
|
(setq buffer-auto-save-file-name
|
|
|
|
|
(cond
|
|
|
|
|
((null val) nil)
|
|
|
|
|
((and buffer-file-name auto-save-visited-file-name
|
|
|
|
|
(not buffer-read-only))
|
|
|
|
|
buffer-file-name)
|
|
|
|
|
(t (make-auto-save-file-name))))))
|
|
|
|
|
;; If -1 was stored here, to temporarily turn off saving,
|
|
|
|
|
;; turn it back on.
|
|
|
|
|
(and (< buffer-saved-size 0)
|
|
|
|
|
(setq buffer-saved-size 0)))
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1997-06-19 09:04:09 +00:00
|
|
|
|
(defgroup paren-blinking nil
|
1997-06-22 09:16:07 +00:00
|
|
|
|
"Blinking matching of parens and expressions."
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:prefix "blink-matching-"
|
|
|
|
|
:group 'paren-matching)
|
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom blink-matching-paren t
|
2014-03-14 20:01:39 +02:00
|
|
|
|
"Non-nil means show matching open-paren when close-paren is inserted.
|
|
|
|
|
If t, highlight the paren. If `jump', move cursor to its position."
|
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Disable" nil)
|
|
|
|
|
(const :tag "Highlight" t)
|
|
|
|
|
(const :tag "Move cursor" jump))
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:group 'paren-blinking)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom blink-matching-paren-on-screen t
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Non-nil means show matching open-paren when it is on screen.
|
2007-02-06 09:35:04 +00:00
|
|
|
|
If nil, don't show it (but the open-paren can still be shown
|
2005-11-27 15:53:16 +00:00
|
|
|
|
when it is off screen).
|
|
|
|
|
|
2005-11-27 16:59:57 +00:00
|
|
|
|
This variable has no effect if `blink-matching-paren' is nil.
|
2005-11-27 17:02:13 +00:00
|
|
|
|
\(In that case, the open-paren is never shown.)
|
2005-11-27 16:59:57 +00:00
|
|
|
|
It is also ignored if `show-paren-mode' is enabled."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'boolean
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:group 'paren-blinking)
|
1995-12-21 18:08:12 +00:00
|
|
|
|
|
2009-07-22 02:35:45 +00:00
|
|
|
|
(defcustom blink-matching-paren-distance (* 100 1024)
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"If non-nil, maximum distance to search backwards for matching open-paren.
|
2005-08-27 12:30:36 +00:00
|
|
|
|
If nil, search stops at the beginning of the accessible portion of the buffer."
|
2009-07-22 02:35:45 +00:00
|
|
|
|
:version "23.2" ; 25->100k
|
2005-08-27 12:30:36 +00:00
|
|
|
|
:type '(choice (const nil) integer)
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:group 'paren-blinking)
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom blink-matching-delay 1
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Time in seconds to delay after showing a matching paren."
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:type 'number
|
|
|
|
|
:group 'paren-blinking)
|
1994-11-01 04:22:00 +00:00
|
|
|
|
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(defcustom blink-matching-paren-dont-ignore-comments nil
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"If nil, `blink-matching-paren' ignores comments.
|
2006-02-12 20:31:12 +00:00
|
|
|
|
More precisely, when looking for the matching parenthesis,
|
|
|
|
|
it skips the contents of comments that end before point."
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:type 'boolean
|
1997-06-19 09:04:09 +00:00
|
|
|
|
:group 'paren-blinking)
|
1995-08-19 16:59:43 +00:00
|
|
|
|
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(defun blink-matching-check-mismatch (start end)
|
|
|
|
|
"Return whether or not START...END are matching parens.
|
|
|
|
|
END is the current point and START is the blink position.
|
|
|
|
|
START might be nil if no matching starter was found.
|
|
|
|
|
Returns non-nil if we find there is a mismatch."
|
|
|
|
|
(let* ((end-syntax (syntax-after (1- end)))
|
|
|
|
|
(matching-paren (and (consp end-syntax)
|
|
|
|
|
(eq (syntax-class end-syntax) 5)
|
|
|
|
|
(cdr end-syntax))))
|
|
|
|
|
;; For self-matched chars like " and $, we can't know when they're
|
|
|
|
|
;; mismatched or unmatched, so we can only do it for parens.
|
|
|
|
|
(when matching-paren
|
|
|
|
|
(not (and start
|
|
|
|
|
(or
|
|
|
|
|
(eq (char-after start) matching-paren)
|
|
|
|
|
;; The cdr might hold a new paren-class info rather than
|
|
|
|
|
;; a matching-char info, in which case the two CDRs
|
|
|
|
|
;; should match.
|
|
|
|
|
(eq matching-paren (cdr-safe (syntax-after start)))))))))
|
|
|
|
|
|
|
|
|
|
(defvar blink-matching-check-function #'blink-matching-check-mismatch
|
|
|
|
|
"Function to check parentheses mismatches.
|
|
|
|
|
The function takes two arguments (START and END) where START is the
|
|
|
|
|
position just before the opening token and END is the position right after.
|
|
|
|
|
START can be nil, if it was not found.
|
|
|
|
|
The function should return non-nil if the two tokens do not match.")
|
|
|
|
|
|
2013-12-13 06:14:17 +02:00
|
|
|
|
(defvar blink-matching--overlay
|
|
|
|
|
(let ((ol (make-overlay (point) (point) nil t)))
|
|
|
|
|
(overlay-put ol 'face 'show-paren-match)
|
|
|
|
|
(delete-overlay ol)
|
|
|
|
|
ol)
|
|
|
|
|
"Overlay used to highlight the matching paren.")
|
|
|
|
|
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun blink-matching-open ()
|
2013-12-13 06:14:17 +02:00
|
|
|
|
"Momentarily highlight the beginning of the sexp before point."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive)
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(when (and (not (bobp))
|
|
|
|
|
blink-matching-paren)
|
2005-09-09 01:11:34 +00:00
|
|
|
|
(let* ((oldpos (point))
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(message-log-max nil) ; Don't log messages about paren matching.
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(blinkpos
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
2011-07-13 12:15:07 -04:00
|
|
|
|
(if blink-matching-paren-distance
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(max (minibuffer-prompt-end) ;(point-min) unless minibuf.
|
|
|
|
|
(- (point) blink-matching-paren-distance))
|
|
|
|
|
oldpos))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(let ((parse-sexp-ignore-comments
|
|
|
|
|
(and parse-sexp-ignore-comments
|
|
|
|
|
(not blink-matching-paren-dont-ignore-comments))))
|
|
|
|
|
(condition-case ()
|
2010-08-19 11:37:40 +02:00
|
|
|
|
(progn
|
|
|
|
|
(forward-sexp -1)
|
2010-09-02 23:57:08 +02:00
|
|
|
|
;; backward-sexp skips backward over prefix chars,
|
|
|
|
|
;; so move back to the matching paren.
|
|
|
|
|
(while (and (< (point) (1- oldpos))
|
2010-09-20 23:45:09 +02:00
|
|
|
|
(let ((code (syntax-after (point))))
|
|
|
|
|
(or (eq (syntax-class code) 6)
|
|
|
|
|
(eq (logand 1048576 (car code))
|
|
|
|
|
1048576))))
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(forward-char 1))
|
2010-08-19 11:37:40 +02:00
|
|
|
|
(point))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(error nil))))))
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(mismatch (funcall blink-matching-check-function blinkpos oldpos)))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(cond
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(mismatch
|
|
|
|
|
(if blinkpos
|
2009-01-14 23:10:10 +00:00
|
|
|
|
(if (minibufferp)
|
2011-07-13 12:15:07 -04:00
|
|
|
|
(minibuffer-message "Mismatched parentheses")
|
|
|
|
|
(message "Mismatched parentheses"))
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(if (minibufferp)
|
2011-07-13 12:15:07 -04:00
|
|
|
|
(minibuffer-message "No matching parenthesis found")
|
|
|
|
|
(message "No matching parenthesis found"))))
|
2010-09-08 18:14:44 +02:00
|
|
|
|
((not blinkpos) nil)
|
2007-09-16 22:11:33 +00:00
|
|
|
|
((pos-visible-in-window-p blinkpos)
|
2014-03-14 20:01:39 +02:00
|
|
|
|
;; Matching open within window, temporarily move to or highlight
|
|
|
|
|
;; char after blinkpos but only if `blink-matching-paren-on-screen'
|
2013-12-13 06:14:17 +02:00
|
|
|
|
;; is non-nil.
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(and blink-matching-paren-on-screen
|
|
|
|
|
(not show-paren-mode)
|
2014-03-14 20:01:39 +02:00
|
|
|
|
(if (eq blink-matching-paren 'jump)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char blinkpos)
|
2013-12-13 06:14:17 +02:00
|
|
|
|
(sit-for blink-matching-delay))
|
2014-03-14 20:01:39 +02:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(move-overlay blink-matching--overlay blinkpos (1+ blinkpos)
|
|
|
|
|
(current-buffer))
|
|
|
|
|
(sit-for blink-matching-delay))
|
|
|
|
|
(delete-overlay blink-matching--overlay)))))
|
2007-09-16 22:11:33 +00:00
|
|
|
|
(t
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char blinkpos)
|
|
|
|
|
(let ((open-paren-line-string
|
|
|
|
|
;; Show what precedes the open in its line, if anything.
|
|
|
|
|
(cond
|
|
|
|
|
((save-excursion (skip-chars-backward " \t") (not (bolp)))
|
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
|
(1+ blinkpos)))
|
|
|
|
|
;; Show what follows the open in its line, if anything.
|
|
|
|
|
((save-excursion
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(not (eolp)))
|
|
|
|
|
(buffer-substring blinkpos
|
|
|
|
|
(line-end-position)))
|
|
|
|
|
;; Otherwise show the previous nonblank line,
|
|
|
|
|
;; if there is one.
|
|
|
|
|
((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
|
|
|
|
|
(concat
|
|
|
|
|
(buffer-substring (progn
|
|
|
|
|
(skip-chars-backward "\n \t")
|
|
|
|
|
(line-beginning-position))
|
|
|
|
|
(progn (end-of-line)
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(point)))
|
|
|
|
|
;; Replace the newline and other whitespace with `...'.
|
|
|
|
|
"..."
|
|
|
|
|
(buffer-substring blinkpos (1+ blinkpos))))
|
|
|
|
|
;; There is nothing to show except the char itself.
|
|
|
|
|
(t (buffer-substring blinkpos (1+ blinkpos))))))
|
|
|
|
|
(message "Matches %s"
|
|
|
|
|
(substring-no-properties open-paren-line-string)))))))))
|
|
|
|
|
|
2010-09-01 16:41:17 +02:00
|
|
|
|
(defvar blink-paren-function 'blink-matching-open
|
|
|
|
|
"Function called, if non-nil, whenever a close parenthesis is inserted.
|
|
|
|
|
More precisely, a char with closeparen syntax is self-inserted.")
|
|
|
|
|
|
|
|
|
|
(defun blink-paren-post-self-insert-function ()
|
|
|
|
|
(when (and (eq (char-before) last-command-event) ; Sanity check.
|
|
|
|
|
(memq (char-syntax last-command-event) '(?\) ?\$))
|
|
|
|
|
blink-paren-function
|
|
|
|
|
(not executing-kbd-macro)
|
2010-09-02 23:57:08 +02:00
|
|
|
|
(not noninteractive)
|
|
|
|
|
;; Verify an even number of quoting characters precede the close.
|
|
|
|
|
(= 1 (logand 1 (- (point)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(skip-syntax-backward "/\\")
|
|
|
|
|
(point))))))
|
2010-09-01 16:41:17 +02:00
|
|
|
|
(funcall blink-paren-function)))
|
|
|
|
|
|
2013-12-26 22:02:49 +00:00
|
|
|
|
(put 'blink-paren-post-self-insert-function 'priority 100)
|
|
|
|
|
|
2010-09-01 16:41:17 +02:00
|
|
|
|
(add-hook 'post-self-insert-hook #'blink-paren-post-self-insert-function
|
|
|
|
|
;; Most likely, this hook is nil, so this arg doesn't matter,
|
|
|
|
|
;; but I use it as a reminder that this function usually
|
2013-12-26 22:02:49 +00:00
|
|
|
|
;; likes to be run after others since it does
|
|
|
|
|
;; `sit-for'. That's also the reason it get a `priority' prop
|
|
|
|
|
;; of 100.
|
2010-09-01 16:41:17 +02:00
|
|
|
|
'append)
|
2002-03-29 23:16:11 +00:00
|
|
|
|
|
1993-05-15 20:55:02 +00:00
|
|
|
|
;; This executes C-g typed while Emacs is waiting for a command.
|
|
|
|
|
;; Quitting out of a program does not go through here;
|
|
|
|
|
;; that happens in the QUIT macro at the C code level.
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(defun keyboard-quit ()
|
1998-06-01 03:04:39 +00:00
|
|
|
|
"Signal a `quit' condition.
|
1993-03-09 05:40:33 +00:00
|
|
|
|
During execution of Lisp code, this character causes a quit directly.
|
|
|
|
|
At top-level, as an editor command, this simply beeps."
|
1991-12-21 09:29:41 +00:00
|
|
|
|
(interactive)
|
2010-08-07 15:39:04 -04:00
|
|
|
|
;; Avoid adding the region to the window selection.
|
|
|
|
|
(setq saved-region-selection nil)
|
|
|
|
|
(let (select-active-regions)
|
|
|
|
|
(deactivate-mark))
|
2004-11-01 23:03:12 +00:00
|
|
|
|
(if (fboundp 'kmacro-keyboard-quit)
|
|
|
|
|
(kmacro-keyboard-quit))
|
2014-06-01 18:19:14 +03:00
|
|
|
|
;; Force the next redisplay cycle to remove the "Def" indicator from
|
|
|
|
|
;; all the mode lines.
|
|
|
|
|
(if defining-kbd-macro
|
|
|
|
|
(force-mode-line-update t))
|
2002-09-09 22:45:03 +00:00
|
|
|
|
(setq defining-kbd-macro nil)
|
2011-06-01 12:52:35 -03:00
|
|
|
|
(let ((debug-on-quit nil))
|
|
|
|
|
(signal 'quit nil)))
|
1991-12-21 09:29:41 +00:00
|
|
|
|
|
1994-12-15 02:02:04 +00:00
|
|
|
|
(defvar buffer-quit-function nil
|
|
|
|
|
"Function to call to \"quit\" the current buffer, or nil if none.
|
|
|
|
|
\\[keyboard-escape-quit] calls this function when its more local actions
|
2011-12-04 00:02:42 -08:00
|
|
|
|
\(such as canceling a prefix argument, minibuffer or region) do not apply.")
|
1994-12-15 02:02:04 +00:00
|
|
|
|
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(defun keyboard-escape-quit ()
|
|
|
|
|
"Exit the current \"mode\" (in a generalized sense of the word).
|
|
|
|
|
This command can exit an interactive command such as `query-replace',
|
|
|
|
|
can clear out a prefix argument or a region,
|
|
|
|
|
can get out of the minibuffer or other recursive edit,
|
1994-12-15 02:02:04 +00:00
|
|
|
|
cancel the use of the current buffer (for special-purpose buffers),
|
|
|
|
|
or go back to just one window (by deleting all but the selected window)."
|
1994-11-28 19:44:16 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(cond ((eq last-command 'mode-exited) nil)
|
2010-03-31 18:02:53 +03:00
|
|
|
|
((region-active-p)
|
|
|
|
|
(deactivate-mark))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
((> (minibuffer-depth) 0)
|
|
|
|
|
(abort-recursive-edit))
|
|
|
|
|
(current-prefix-arg
|
|
|
|
|
nil)
|
1997-04-10 06:29:59 +00:00
|
|
|
|
((> (recursion-depth) 0)
|
|
|
|
|
(exit-recursive-edit))
|
1994-12-15 02:02:04 +00:00
|
|
|
|
(buffer-quit-function
|
|
|
|
|
(funcall buffer-quit-function))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
((not (one-window-p t))
|
1997-04-10 06:29:59 +00:00
|
|
|
|
(delete-other-windows))
|
|
|
|
|
((string-match "^ \\*" (buffer-name (current-buffer)))
|
|
|
|
|
(bury-buffer))))
|
1994-11-28 19:44:16 +00:00
|
|
|
|
|
2002-03-29 23:16:11 +00:00
|
|
|
|
(defun play-sound-file (file &optional volume device)
|
|
|
|
|
"Play sound stored in FILE.
|
|
|
|
|
VOLUME and DEVICE correspond to the keywords of the sound
|
|
|
|
|
specification for `play-sound'."
|
|
|
|
|
(interactive "fPlay sound file: ")
|
|
|
|
|
(let ((sound (list :file file)))
|
|
|
|
|
(if volume
|
|
|
|
|
(plist-put sound :volume volume))
|
|
|
|
|
(if device
|
|
|
|
|
(plist-put sound :device device))
|
|
|
|
|
(push 'sound sound)
|
|
|
|
|
(play-sound sound)))
|
|
|
|
|
|
2005-01-15 18:08:46 +00:00
|
|
|
|
|
2000-01-07 12:53:36 +00:00
|
|
|
|
(defcustom read-mail-command 'rmail
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Your preference for a mail reading package.
|
2000-09-12 17:59:26 +00:00
|
|
|
|
This is used by some keybindings which support reading mail.
|
|
|
|
|
See also `mail-user-agent' concerning sending mail."
|
2009-11-14 04:18:10 +00:00
|
|
|
|
:type '(radio (function-item :tag "Rmail" :format "%t\n" rmail)
|
|
|
|
|
(function-item :tag "Gnus" :format "%t\n" gnus)
|
|
|
|
|
(function-item :tag "Emacs interface to MH"
|
|
|
|
|
:format "%t\n" mh-rmail)
|
|
|
|
|
(function :tag "Other"))
|
2000-01-07 12:53:36 +00:00
|
|
|
|
:version "21.1"
|
|
|
|
|
:group 'mail)
|
|
|
|
|
|
2009-07-14 19:57:58 +00:00
|
|
|
|
(defcustom mail-user-agent 'message-user-agent
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
"Your preference for a mail composition package.
|
2000-09-12 17:59:26 +00:00
|
|
|
|
Various Emacs Lisp packages (e.g. Reporter) require you to compose an
|
1996-08-30 16:59:20 +00:00
|
|
|
|
outgoing email message. This variable lets you specify which
|
|
|
|
|
mail-sending package you prefer.
|
|
|
|
|
|
|
|
|
|
Valid values include:
|
|
|
|
|
|
2009-07-19 00:33:11 +00:00
|
|
|
|
`message-user-agent' -- use the Message package.
|
|
|
|
|
See Info node `(message)'.
|
|
|
|
|
`sendmail-user-agent' -- use the Mail package.
|
2000-09-12 17:59:26 +00:00
|
|
|
|
See Info node `(emacs)Sending Mail'.
|
|
|
|
|
`mh-e-user-agent' -- use the Emacs interface to the MH mail system.
|
|
|
|
|
See Info node `(mh-e)'.
|
|
|
|
|
`gnus-user-agent' -- like `message-user-agent', but with Gnus
|
2012-02-13 20:42:58 +01:00
|
|
|
|
paraphernalia if Gnus is running, particularly
|
|
|
|
|
the Gcc: header for archiving.
|
1996-08-30 16:59:20 +00:00
|
|
|
|
|
|
|
|
|
Additional valid symbols may be available; check with the author of
|
2000-12-18 17:09:42 +00:00
|
|
|
|
your package for details. The function should return non-nil if it
|
|
|
|
|
succeeds.
|
2000-09-12 17:59:26 +00:00
|
|
|
|
|
|
|
|
|
See also `read-mail-command' concerning reading mail."
|
2009-07-19 00:33:11 +00:00
|
|
|
|
:type '(radio (function-item :tag "Message package"
|
|
|
|
|
:format "%t\n"
|
|
|
|
|
message-user-agent)
|
|
|
|
|
(function-item :tag "Mail package"
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:format "%t\n"
|
|
|
|
|
sendmail-user-agent)
|
|
|
|
|
(function-item :tag "Emacs interface to MH"
|
|
|
|
|
:format "%t\n"
|
|
|
|
|
mh-e-user-agent)
|
2009-07-19 00:33:11 +00:00
|
|
|
|
(function-item :tag "Message with full Gnus features"
|
2000-09-12 17:59:26 +00:00
|
|
|
|
:format "%t\n"
|
|
|
|
|
gnus-user-agent)
|
1997-05-05 11:57:31 +00:00
|
|
|
|
(function :tag "Other"))
|
2009-07-19 00:33:11 +00:00
|
|
|
|
:version "23.2" ; sendmail->message
|
1997-05-05 11:57:31 +00:00
|
|
|
|
:group 'mail)
|
1996-08-30 16:59:20 +00:00
|
|
|
|
|
2009-12-07 16:09:05 +00:00
|
|
|
|
(defcustom compose-mail-user-agent-warnings t
|
|
|
|
|
"If non-nil, `compose-mail' warns about changes in `mail-user-agent'.
|
|
|
|
|
If the value of `mail-user-agent' is the default, and the user
|
|
|
|
|
appears to have customizations applying to the old default,
|
|
|
|
|
`compose-mail' issues a warning."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "23.2"
|
|
|
|
|
:group 'mail)
|
|
|
|
|
|
1998-05-02 06:50:44 +00:00
|
|
|
|
(defun rfc822-goto-eoh ()
|
2011-02-16 23:43:53 -08:00
|
|
|
|
"If the buffer starts with a mail header, move point to the header's end.
|
|
|
|
|
Otherwise, moves to `point-min'.
|
|
|
|
|
The end of the header is the start of the next line, if there is one,
|
|
|
|
|
else the end of the last line. This function obeys RFC822."
|
1998-05-02 06:50:44 +00:00
|
|
|
|
(goto-char (point-min))
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(when (re-search-forward
|
|
|
|
|
"^\\([:\n]\\|[^: \t\n]+[ \t\n]\\)" nil 'move)
|
|
|
|
|
(goto-char (match-beginning 0))))
|
1998-05-02 06:50:44 +00:00
|
|
|
|
|
2011-09-03 13:00:13 +03:00
|
|
|
|
;; Used by Rmail (e.g., rmail-forward).
|
|
|
|
|
(defvar mail-encode-mml nil
|
|
|
|
|
"If non-nil, mail-user-agent's `sendfunc' command should mml-encode
|
|
|
|
|
the outgoing message before sending it.")
|
|
|
|
|
|
1996-12-07 21:30:17 +00:00
|
|
|
|
(defun compose-mail (&optional to subject other-headers continue
|
2011-01-12 23:23:41 -05:00
|
|
|
|
switch-function yank-action send-actions
|
|
|
|
|
return-action)
|
1996-12-07 21:30:17 +00:00
|
|
|
|
"Start composing a mail message to send.
|
|
|
|
|
This uses the user's chosen mail composition package
|
|
|
|
|
as selected with the variable `mail-user-agent'.
|
|
|
|
|
The optional arguments TO and SUBJECT specify recipients
|
|
|
|
|
and the initial Subject field, respectively.
|
|
|
|
|
|
|
|
|
|
OTHER-HEADERS is an alist specifying additional
|
|
|
|
|
header fields. Elements look like (HEADER . VALUE) where both
|
|
|
|
|
HEADER and VALUE are strings.
|
|
|
|
|
|
|
|
|
|
CONTINUE, if non-nil, says to continue editing a message already
|
2009-03-10 05:01:43 +00:00
|
|
|
|
being composed. Interactively, CONTINUE is the prefix argument.
|
1996-12-07 21:30:17 +00:00
|
|
|
|
|
|
|
|
|
SWITCH-FUNCTION, if non-nil, is a function to use to
|
|
|
|
|
switch to and display the buffer used for mail composition.
|
|
|
|
|
|
|
|
|
|
YANK-ACTION, if non-nil, is an action to perform, if and when necessary,
|
1996-12-18 16:32:43 +00:00
|
|
|
|
to insert the raw text of the message being replied to.
|
|
|
|
|
It has the form (FUNCTION . ARGS). The user agent will apply
|
|
|
|
|
FUNCTION to ARGS, to insert the raw text of the original message.
|
|
|
|
|
\(The user agent will also run `mail-citation-hook', *after* the
|
|
|
|
|
original text has been inserted in this way.)
|
1996-12-07 21:30:17 +00:00
|
|
|
|
|
|
|
|
|
SEND-ACTIONS is a list of actions to call when the message is sent.
|
2011-01-12 23:23:41 -05:00
|
|
|
|
Each action has the form (FUNCTION . ARGS).
|
|
|
|
|
|
|
|
|
|
RETURN-ACTION, if non-nil, is an action for returning to the
|
|
|
|
|
caller. It has the form (FUNCTION . ARGS). The function is
|
|
|
|
|
called after the mail has been sent or put aside, and the mail
|
|
|
|
|
buffer buried."
|
1997-04-29 02:07:02 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list nil nil nil current-prefix-arg))
|
2009-12-07 16:09:05 +00:00
|
|
|
|
|
|
|
|
|
;; In Emacs 23.2, the default value of `mail-user-agent' changed
|
|
|
|
|
;; from sendmail-user-agent to message-user-agent. Some users may
|
|
|
|
|
;; encounter incompatibilities. This hack tries to detect problems
|
|
|
|
|
;; and warn about them.
|
|
|
|
|
(and compose-mail-user-agent-warnings
|
|
|
|
|
(eq mail-user-agent 'message-user-agent)
|
|
|
|
|
(let (warn-vars)
|
|
|
|
|
(dolist (var '(mail-mode-hook mail-send-hook mail-setup-hook
|
|
|
|
|
mail-yank-hooks mail-archive-file-name
|
|
|
|
|
mail-default-reply-to mail-mailing-lists
|
2009-12-12 17:01:03 +00:00
|
|
|
|
mail-self-blind))
|
2009-12-07 16:09:05 +00:00
|
|
|
|
(and (boundp var)
|
|
|
|
|
(symbol-value var)
|
|
|
|
|
(push var warn-vars)))
|
|
|
|
|
(when warn-vars
|
|
|
|
|
(display-warning 'mail
|
|
|
|
|
(format "\
|
|
|
|
|
The default mail mode is now Message mode.
|
|
|
|
|
You have the following Mail mode variable%s customized:
|
|
|
|
|
\n %s\n\nTo use Mail mode, set `mail-user-agent' to sendmail-user-agent.
|
2010-06-21 19:26:46 -04:00
|
|
|
|
To disable this warning, set `compose-mail-user-agent-warnings' to nil."
|
2009-12-07 16:09:05 +00:00
|
|
|
|
(if (> (length warn-vars) 1) "s" "")
|
|
|
|
|
(mapconcat 'symbol-name
|
|
|
|
|
warn-vars " "))))))
|
|
|
|
|
|
2007-03-28 18:36:01 +00:00
|
|
|
|
(let ((function (get mail-user-agent 'composefunc)))
|
2011-01-12 23:23:41 -05:00
|
|
|
|
(funcall function to subject other-headers continue switch-function
|
|
|
|
|
yank-action send-actions return-action)))
|
1997-04-29 02:07:02 +00:00
|
|
|
|
|
|
|
|
|
(defun compose-mail-other-window (&optional to subject other-headers continue
|
2011-01-12 23:23:41 -05:00
|
|
|
|
yank-action send-actions
|
|
|
|
|
return-action)
|
1997-04-29 02:07:02 +00:00
|
|
|
|
"Like \\[compose-mail], but edit the outgoing message in another window."
|
2011-01-12 23:23:41 -05:00
|
|
|
|
(interactive (list nil nil nil current-prefix-arg))
|
1997-04-29 02:07:02 +00:00
|
|
|
|
(compose-mail to subject other-headers continue
|
2011-01-12 23:23:41 -05:00
|
|
|
|
'switch-to-buffer-other-window yank-action send-actions
|
|
|
|
|
return-action))
|
1997-04-29 02:07:02 +00:00
|
|
|
|
|
|
|
|
|
(defun compose-mail-other-frame (&optional to subject other-headers continue
|
2011-01-12 23:23:41 -05:00
|
|
|
|
yank-action send-actions
|
|
|
|
|
return-action)
|
1997-04-29 02:07:02 +00:00
|
|
|
|
"Like \\[compose-mail], but edit the outgoing message in another frame."
|
2011-01-12 23:23:41 -05:00
|
|
|
|
(interactive (list nil nil nil current-prefix-arg))
|
1997-04-29 02:07:02 +00:00
|
|
|
|
(compose-mail to subject other-headers continue
|
2011-01-12 23:23:41 -05:00
|
|
|
|
'switch-to-buffer-other-frame yank-action send-actions
|
|
|
|
|
return-action))
|
|
|
|
|
|
2005-01-15 18:08:46 +00:00
|
|
|
|
|
1997-04-30 18:57:35 +00:00
|
|
|
|
(defvar set-variable-value-history nil
|
2007-12-22 17:15:48 +00:00
|
|
|
|
"History of values entered with `set-variable'.
|
|
|
|
|
|
|
|
|
|
Maximum length of the history list is determined by the value
|
|
|
|
|
of `history-length', which see.")
|
1997-04-30 18:57:35 +00:00
|
|
|
|
|
2005-06-23 21:26:31 +00:00
|
|
|
|
(defun set-variable (variable value &optional make-local)
|
1997-04-30 18:57:35 +00:00
|
|
|
|
"Set VARIABLE to VALUE. VALUE is a Lisp object.
|
2005-06-23 21:26:31 +00:00
|
|
|
|
VARIABLE should be a user option variable name, a Lisp variable
|
|
|
|
|
meant to be customized by users. You should enter VALUE in Lisp syntax,
|
|
|
|
|
so if you want VALUE to be a string, you must surround it with doublequotes.
|
1997-04-30 18:57:35 +00:00
|
|
|
|
VALUE is used literally, not evaluated.
|
|
|
|
|
|
|
|
|
|
If VARIABLE has a `variable-interactive' property, that is used as if
|
|
|
|
|
it were the arg to `interactive' (which see) to interactively read VALUE.
|
|
|
|
|
|
|
|
|
|
If VARIABLE has been defined with `defcustom', then the type information
|
2002-08-09 14:14:32 +00:00
|
|
|
|
in the definition is used to check that VALUE is valid.
|
|
|
|
|
|
|
|
|
|
With a prefix argument, set VARIABLE to VALUE buffer-locally."
|
1998-05-20 03:54:58 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(let* ((default-var (variable-at-point))
|
2012-04-09 20:36:01 +08:00
|
|
|
|
(var (if (custom-variable-p default-var)
|
2005-10-21 08:55:12 +00:00
|
|
|
|
(read-variable (format "Set variable (default %s): " default-var)
|
|
|
|
|
default-var)
|
|
|
|
|
(read-variable "Set variable: ")))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(minibuffer-help-form '(describe-variable var))
|
|
|
|
|
(prop (get var 'variable-interactive))
|
2005-06-29 23:50:29 +00:00
|
|
|
|
(obsolete (car (get var 'byte-obsolete-variable)))
|
|
|
|
|
(prompt (format "Set %s %s to value: " var
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(cond ((local-variable-p var)
|
2005-06-29 23:50:29 +00:00
|
|
|
|
"(buffer-local)")
|
2004-04-16 12:51:06 +00:00
|
|
|
|
((or current-prefix-arg
|
|
|
|
|
(local-variable-if-set-p var))
|
2005-06-29 23:50:29 +00:00
|
|
|
|
"buffer-locally")
|
|
|
|
|
(t "globally"))))
|
|
|
|
|
(val (progn
|
|
|
|
|
(when obsolete
|
|
|
|
|
(message (concat "`%S' is obsolete; "
|
|
|
|
|
(if (symbolp obsolete) "use `%S' instead" "%s"))
|
|
|
|
|
var obsolete)
|
|
|
|
|
(sit-for 3))
|
|
|
|
|
(if prop
|
|
|
|
|
;; Use VAR's `variable-interactive' property
|
|
|
|
|
;; as an interactive spec for prompting.
|
|
|
|
|
(call-interactively `(lambda (arg)
|
|
|
|
|
(interactive ,prop)
|
|
|
|
|
arg))
|
2013-06-25 20:50:50 -04:00
|
|
|
|
(read-from-minibuffer prompt nil
|
|
|
|
|
read-expression-map t
|
|
|
|
|
'set-variable-value-history
|
|
|
|
|
(format "%S" (symbol-value var)))))))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(list var val current-prefix-arg)))
|
1997-04-30 18:57:35 +00:00
|
|
|
|
|
2005-06-23 21:26:31 +00:00
|
|
|
|
(and (custom-variable-p variable)
|
|
|
|
|
(not (get variable 'custom-type))
|
|
|
|
|
(custom-load-symbol variable))
|
|
|
|
|
(let ((type (get variable 'custom-type)))
|
1997-04-30 18:57:35 +00:00
|
|
|
|
(when type
|
|
|
|
|
;; Match with custom type.
|
2001-07-16 11:52:56 +00:00
|
|
|
|
(require 'cus-edit)
|
1997-04-30 18:57:35 +00:00
|
|
|
|
(setq type (widget-convert type))
|
2005-06-23 21:26:31 +00:00
|
|
|
|
(unless (widget-apply type :match value)
|
1999-11-15 16:11:14 +00:00
|
|
|
|
(error "Value `%S' does not match type %S of %S"
|
2005-06-23 21:26:31 +00:00
|
|
|
|
value (car type) variable))))
|
2002-08-09 14:14:32 +00:00
|
|
|
|
|
|
|
|
|
(if make-local
|
2005-06-23 21:26:31 +00:00
|
|
|
|
(make-local-variable variable))
|
2003-02-04 12:29:42 +00:00
|
|
|
|
|
2005-06-23 21:26:31 +00:00
|
|
|
|
(set variable value)
|
2001-01-10 15:10:01 +00:00
|
|
|
|
|
|
|
|
|
;; Force a thorough redisplay for the case that the variable
|
|
|
|
|
;; has an effect on the display, like `tab-width' has.
|
|
|
|
|
(force-mode-line-update))
|
2005-01-15 18:08:46 +00:00
|
|
|
|
|
1993-07-13 21:34:05 +00:00
|
|
|
|
;; Define the major mode for lists of completions.
|
|
|
|
|
|
2008-04-13 22:12:02 +00:00
|
|
|
|
(defvar completion-list-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2014-04-22 22:22:06 -04:00
|
|
|
|
(define-key map [mouse-2] 'choose-completion)
|
2008-04-13 22:12:02 +00:00
|
|
|
|
(define-key map [follow-link] 'mouse-face)
|
|
|
|
|
(define-key map [down-mouse-2] nil)
|
|
|
|
|
(define-key map "\C-m" 'choose-completion)
|
|
|
|
|
(define-key map "\e\e\e" 'delete-completion-window)
|
|
|
|
|
(define-key map [left] 'previous-completion)
|
|
|
|
|
(define-key map [right] 'next-completion)
|
2009-04-06 15:45:00 +00:00
|
|
|
|
(define-key map "q" 'quit-window)
|
2011-02-01 16:22:21 -05:00
|
|
|
|
(define-key map "z" 'kill-this-buffer)
|
2008-04-13 22:12:02 +00:00
|
|
|
|
map)
|
1995-04-08 22:42:47 +00:00
|
|
|
|
"Local map for completion list buffers.")
|
1993-07-13 21:34:05 +00:00
|
|
|
|
|
|
|
|
|
;; Completion mode is suitable only for specially formatted data.
|
1993-07-22 05:47:10 +00:00
|
|
|
|
(put 'completion-list-mode 'mode-class 'special)
|
1993-07-13 21:34:05 +00:00
|
|
|
|
|
1995-04-08 22:42:47 +00:00
|
|
|
|
(defvar completion-reference-buffer nil
|
|
|
|
|
"Record the buffer that was current when the completion list was requested.
|
|
|
|
|
This is a local variable in the completion list buffer.
|
1995-04-09 03:33:01 +00:00
|
|
|
|
Initial value is nil to avoid some compiler warnings.")
|
1994-03-02 23:09:40 +00:00
|
|
|
|
|
1997-01-24 03:51:57 +00:00
|
|
|
|
(defvar completion-no-auto-exit nil
|
|
|
|
|
"Non-nil means `choose-completion-string' should never exit the minibuffer.
|
2009-11-14 04:18:10 +00:00
|
|
|
|
This also applies to other functions such as `choose-completion'.")
|
1997-01-24 03:51:57 +00:00
|
|
|
|
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(defvar completion-base-position nil
|
|
|
|
|
"Position of the base of the text corresponding to the shown completions.
|
|
|
|
|
This variable is used in the *Completions* buffers.
|
|
|
|
|
Its value is a list of the form (START END) where START is the place
|
|
|
|
|
where the completion should be inserted and END (if non-nil) is the end
|
|
|
|
|
of the text to replace. If END is nil, point is used instead.")
|
|
|
|
|
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(defvar completion-list-insert-choice-function #'completion--replace
|
|
|
|
|
"Function to use to insert the text chosen in *Completions*.
|
2011-12-09 04:12:38 +01:00
|
|
|
|
Called with three arguments (BEG END TEXT), it should replace the text
|
2011-05-23 23:45:50 -03:00
|
|
|
|
between BEG and END with TEXT. Expected to be set buffer-locally
|
|
|
|
|
in the *Completions* buffer.")
|
|
|
|
|
|
1995-04-08 22:42:47 +00:00
|
|
|
|
(defvar completion-base-size nil
|
2008-08-14 23:44:29 +00:00
|
|
|
|
"Number of chars before point not involved in completion.
|
|
|
|
|
This is a local variable in the completion list buffer.
|
|
|
|
|
It refers to the chars in the minibuffer if completing in the
|
|
|
|
|
minibuffer, or in `completion-reference-buffer' otherwise.
|
|
|
|
|
Only characters in the field at point are included.
|
|
|
|
|
|
|
|
|
|
If nil, Emacs determines which part of the tail end of the
|
|
|
|
|
buffer's text is involved in completion by comparing the text
|
|
|
|
|
directly.")
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(make-obsolete-variable 'completion-base-size 'completion-base-position "23.2")
|
1994-08-07 18:11:58 +00:00
|
|
|
|
|
1994-12-15 02:02:04 +00:00
|
|
|
|
(defun delete-completion-window ()
|
|
|
|
|
"Delete the completion list window.
|
|
|
|
|
Go to the window from which completion was requested."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((buf completion-reference-buffer))
|
1997-01-09 07:59:03 +00:00
|
|
|
|
(if (one-window-p t)
|
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
|
|
|
|
(if (window-dedicated-p) (delete-frame))
|
1997-01-09 07:59:03 +00:00
|
|
|
|
(delete-window (selected-window))
|
|
|
|
|
(if (get-buffer-window buf)
|
|
|
|
|
(select-window (get-buffer-window buf))))))
|
1994-12-15 02:02:04 +00:00
|
|
|
|
|
1994-12-29 18:53:25 +00:00
|
|
|
|
(defun previous-completion (n)
|
|
|
|
|
"Move to the previous item in the completion list."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(next-completion (- n)))
|
|
|
|
|
|
|
|
|
|
(defun next-completion (n)
|
|
|
|
|
"Move to the next item in the completion list.
|
1996-01-04 23:20:13 +00:00
|
|
|
|
With prefix argument N, move N items (negative N means move backward)."
|
1994-12-29 18:53:25 +00:00
|
|
|
|
(interactive "p")
|
2000-11-22 19:47:30 +00:00
|
|
|
|
(let ((beg (point-min)) (end (point-max)))
|
|
|
|
|
(while (and (> n 0) (not (eobp)))
|
1994-12-29 18:53:25 +00:00
|
|
|
|
;; If in a completion, move to the end of it.
|
2000-11-22 19:47:30 +00:00
|
|
|
|
(when (get-text-property (point) 'mouse-face)
|
|
|
|
|
(goto-char (next-single-property-change (point) 'mouse-face nil end)))
|
1994-12-29 18:53:25 +00:00
|
|
|
|
;; Move to start of next one.
|
2000-11-22 19:47:30 +00:00
|
|
|
|
(unless (get-text-property (point) 'mouse-face)
|
|
|
|
|
(goto-char (next-single-property-change (point) 'mouse-face nil end)))
|
|
|
|
|
(setq n (1- n)))
|
|
|
|
|
(while (and (< n 0) (not (bobp)))
|
|
|
|
|
(let ((prop (get-text-property (1- (point)) 'mouse-face)))
|
|
|
|
|
;; If in a completion, move to the start of it.
|
|
|
|
|
(when (and prop (eq prop (get-text-property (point) 'mouse-face)))
|
1995-10-11 03:11:11 +00:00
|
|
|
|
(goto-char (previous-single-property-change
|
2000-11-22 19:47:30 +00:00
|
|
|
|
(point) 'mouse-face nil beg)))
|
|
|
|
|
;; Move to end of the previous completion.
|
|
|
|
|
(unless (or (bobp) (get-text-property (1- (point)) 'mouse-face))
|
|
|
|
|
(goto-char (previous-single-property-change
|
|
|
|
|
(point) 'mouse-face nil beg)))
|
|
|
|
|
;; Move to the start of that one.
|
|
|
|
|
(goto-char (previous-single-property-change
|
|
|
|
|
(point) 'mouse-face nil beg))
|
|
|
|
|
(setq n (1+ n))))))
|
1994-12-29 18:53:25 +00:00
|
|
|
|
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(defun choose-completion (&optional event)
|
2014-02-09 22:58:34 -08:00
|
|
|
|
"Choose the completion at point.
|
2014-02-21 14:22:14 +01:00
|
|
|
|
If EVENT, use EVENT's position to determine the starting position."
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
|
;; In case this is run via the mouse, give temporary modes such as
|
|
|
|
|
;; isearch a chance to turn off.
|
|
|
|
|
(run-hooks 'mouse-leave-buffer-hook)
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(with-current-buffer (window-buffer (posn-window (event-start event)))
|
|
|
|
|
(let ((buffer completion-reference-buffer)
|
|
|
|
|
(base-size completion-base-size)
|
|
|
|
|
(base-position completion-base-position)
|
|
|
|
|
(insert-function completion-list-insert-choice-function)
|
|
|
|
|
(choice
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (posn-point (event-start event)))
|
|
|
|
|
(let (beg end)
|
|
|
|
|
(cond
|
|
|
|
|
((and (not (eobp)) (get-text-property (point) 'mouse-face))
|
|
|
|
|
(setq end (point) beg (1+ (point))))
|
|
|
|
|
((and (not (bobp))
|
|
|
|
|
(get-text-property (1- (point)) 'mouse-face))
|
|
|
|
|
(setq end (1- (point)) beg (point)))
|
|
|
|
|
(t (error "No completion here")))
|
|
|
|
|
(setq beg (previous-single-property-change beg 'mouse-face))
|
|
|
|
|
(setq end (or (next-single-property-change end 'mouse-face)
|
|
|
|
|
(point-max)))
|
2012-06-01 15:44:48 +02:00
|
|
|
|
(buffer-substring-no-properties beg end)))))
|
2011-05-23 23:45:50 -03:00
|
|
|
|
|
|
|
|
|
(unless (buffer-live-p buffer)
|
|
|
|
|
(error "Destination buffer is dead"))
|
2012-05-29 20:21:45 +08:00
|
|
|
|
(quit-window nil (posn-window (event-start event)))
|
2011-05-23 23:45:50 -03:00
|
|
|
|
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(choose-completion-string
|
|
|
|
|
choice buffer
|
|
|
|
|
(or base-position
|
|
|
|
|
(when base-size
|
|
|
|
|
;; Someone's using old completion code that doesn't know
|
|
|
|
|
;; about base-position yet.
|
|
|
|
|
(list (+ base-size (field-beginning))))
|
|
|
|
|
;; If all else fails, just guess.
|
|
|
|
|
(list (choose-completion-guess-base-position choice)))
|
|
|
|
|
insert-function)))))
|
1994-03-27 22:21:04 +00:00
|
|
|
|
|
|
|
|
|
;; Delete the longest partial match for STRING
|
|
|
|
|
;; that can be found before POINT.
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(defun choose-completion-guess-base-position (string)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((opoint (point))
|
|
|
|
|
len)
|
|
|
|
|
;; Try moving back by the length of the string.
|
|
|
|
|
(goto-char (max (- (point) (length string))
|
|
|
|
|
(minibuffer-prompt-end)))
|
|
|
|
|
;; See how far back we were actually able to move. That is the
|
|
|
|
|
;; upper bound on how much we can match and delete.
|
|
|
|
|
(setq len (- opoint (point)))
|
|
|
|
|
(if completion-ignore-case
|
|
|
|
|
(setq string (downcase string)))
|
|
|
|
|
(while (and (> len 0)
|
|
|
|
|
(let ((tail (buffer-substring (point) opoint)))
|
|
|
|
|
(if completion-ignore-case
|
|
|
|
|
(setq tail (downcase tail)))
|
|
|
|
|
(not (string= tail (substring string 0 len)))))
|
|
|
|
|
(setq len (1- len))
|
|
|
|
|
(forward-char 1))
|
|
|
|
|
(point))))
|
|
|
|
|
|
1994-03-27 22:21:04 +00:00
|
|
|
|
(defun choose-completion-delete-max-match (string)
|
Use declare forms, where possible, to mark obsolete functions.
* lisp/allout.el (allout-passphrase-hint-string): Likewise.
(allout-init): Use a declare form to mark obsolete.
* lisp/calendar/calendar.el (calendar-version):
* lisp/calendar/icalendar.el (icalendar-extract-ical-from-buffer)
(icalendar-convert-diary-to-ical):
* lisp/cus-edit.el (custom-mode):
* lisp/ansi-color.el (ansi-color-unfontify-region):
* lisp/international/latin1-disp.el (latin1-char-displayable-p):
* lisp/progmodes/cwarn.el (turn-on-cwarn-mode):
* lisp/progmodes/which-func.el (which-func-update-1): Use
define-obsolete-function-alias.
* lisp/bookmark.el (bookmark-jump-noselect): Use a declare form to mark
this function obsolete.
* lisp/calendar/cal-x.el (calendar-two-frame-setup)
(calendar-only-one-frame-setup, calendar-one-frame-setup):
* lisp/calendar/calendar.el (american-calendar, european-calendar)
(calendar-for-loop):
* lisp/comint.el (comint-dynamic-simple-complete)
(comint-dynamic-complete-as-filename, comint-unquote-filename):
* lisp/desktop.el (desktop-load-default):
* lisp/dired-x.el (dired-omit-here-always)
(dired-hack-local-variables, dired-default-directory):
* lisp/emacs-lisp/derived.el (derived-mode-class):
* lisp/emacs-lisp/timer.el (timer-set-time-with-usecs):
* lisp/emacs-lock.el (toggle-emacs-lock):
* lisp/epa.el (epa-display-verify-result):
* lisp/epg.el (epg-sign-keys, epg-start-sign-keys)
(epg-passphrase-callback-function):
* lisp/eshell/esh-util.el (eshell-for):
* lisp/eshell/eshell.el (eshell-remove-from-window-buffer-names)
(eshell-add-to-window-buffer-names):
* lisp/files.el (locate-file-completion):
* lisp/imenu.el (imenu-example--create-c-index)
(imenu-example--create-lisp-index)
(imenu-example--lisp-extract-index-name)
(imenu-example--name-and-position):
* lisp/international/mule-cmds.el (princ-list):
* lisp/international/mule-diag.el (decode-codepage-char):
* lisp/international/mule-util.el (detect-coding-with-priority):
* lisp/iswitchb.el (iswitchb-read-buffer):
* lisp/mail/mailalias.el (mail-complete):
* lisp/mail/sendmail.el (mail-sent-via):
* lisp/mouse.el (mouse-popup-menubar-stuff, mouse-popup-menubar)
(mouse-major-mode-menu):
* lisp/password-cache.el (password-read-and-add):
* lisp/pcomplete.el (pcomplete-parse-comint-arguments):
* lisp/progmodes/sh-script.el (sh-maybe-here-document):
* lisp/replace.el (query-replace-regexp-eval):
* lisp/savehist.el (savehist-load):
* lisp/simple.el (choose-completion-delete-max-match):
* lisp/term.el (term-dynamic-simple-complete):
* lisp/vc/ediff-init.el (ediff-check-version):
* lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically):
* lisp/vc/vc.el (vc-diff-switches-list):
* lisp/view.el (view-return-to-alist-update): Likewise.
* lisp/iswitchb.el (iswitchb-read-buffer): Move code of
iswitchb-define-mode-map here, and delete that obsolete function.
* lisp/subr.el (eval-next-after-load, makehash, insert-string)
(assoc-ignore-representation, assoc-ignore-case): Use declare to
mark obsolete.
(mode-line-inverse-video): Variable deleted.
* lisp/emacs-lisp/byte-run.el (make-obsolete): Doc fix; emphasize that
this applies to functions.
* lisp/erc/erc.el (erc-send-command): Use define-obsolete-function-alias.
* lisp/international/mule-util.el (string-to-sequence): Remove.
* lisp/net/newst-backend.el (newsticker-cache-filename):
* lisp/net/newst-treeview.el (newsticker-groups-filename): Fix
incorrect obsolescence declaration.
* lisp/net/snmp-mode.el (snmp-font-lock-keywords-3): Don't use obsolete
font-lock-reference-face.
* lisp/url/url-parse.el (url-recreate-url-attributes):
* lisp/url/url-util.el (url-generate-unique-filename): Use declare to mark
obsolete.
* src/xdisp.c (mode_line_inverse_video): Delete obsolete variable.
2012-09-25 12:13:02 +08:00
|
|
|
|
(declare (obsolete choose-completion-guess-base-position "23.2"))
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(delete-region (choose-completion-guess-base-position string) (point)))
|
1994-03-27 22:21:04 +00:00
|
|
|
|
|
2002-06-01 00:00:29 +00:00
|
|
|
|
(defvar choose-completion-string-functions nil
|
2002-06-01 21:56:40 +00:00
|
|
|
|
"Functions that may override the normal insertion of a completion choice.
|
2014-02-08 04:46:09 -08:00
|
|
|
|
These functions are called in order with three arguments:
|
2002-06-01 21:56:40 +00:00
|
|
|
|
CHOICE - the string to insert in the buffer,
|
|
|
|
|
BUFFER - the buffer in which the choice should be inserted,
|
2014-02-08 04:46:09 -08:00
|
|
|
|
BASE-POSITION - where to insert the completion.
|
2002-06-02 00:01:59 +00:00
|
|
|
|
|
2002-06-01 21:56:40 +00:00
|
|
|
|
If a function in the list returns non-nil, that function is supposed
|
|
|
|
|
to have inserted the CHOICE in the BUFFER, and possibly exited
|
2002-06-02 00:01:59 +00:00
|
|
|
|
the minibuffer; no further functions will be called.
|
2002-06-01 00:00:29 +00:00
|
|
|
|
|
2002-06-02 00:01:59 +00:00
|
|
|
|
If all functions in the list return nil, that means to use
|
|
|
|
|
the default method of inserting the completion in BUFFER.")
|
1996-06-22 04:50:32 +00:00
|
|
|
|
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(defun choose-completion-string (choice &optional
|
|
|
|
|
buffer base-position insert-function)
|
2002-06-02 00:01:59 +00:00
|
|
|
|
"Switch to BUFFER and insert the completion choice CHOICE.
|
2013-04-09 11:36:25 +02:00
|
|
|
|
BASE-POSITION says where to insert the completion.
|
|
|
|
|
INSERT-FUNCTION says how to insert the completion and falls
|
|
|
|
|
back on `completion-list-insert-choice-function' when nil."
|
2002-06-02 00:01:59 +00:00
|
|
|
|
|
|
|
|
|
;; If BUFFER is the minibuffer, exit the minibuffer
|
|
|
|
|
;; unless it is reading a file name and CHOICE is a directory,
|
|
|
|
|
;; or completion-no-auto-exit is non-nil.
|
|
|
|
|
|
2009-10-15 01:50:17 +00:00
|
|
|
|
;; Some older code may call us passing `base-size' instead of
|
|
|
|
|
;; `base-position'. It's difficult to make any use of `base-size',
|
|
|
|
|
;; so we just ignore it.
|
|
|
|
|
(unless (consp base-position)
|
|
|
|
|
(message "Obsolete `base-size' passed to choose-completion-string")
|
|
|
|
|
(setq base-position nil))
|
|
|
|
|
|
2003-07-25 12:18:04 +00:00
|
|
|
|
(let* ((buffer (or buffer completion-reference-buffer))
|
|
|
|
|
(mini-p (minibufferp buffer)))
|
1994-05-05 05:27:59 +00:00
|
|
|
|
;; If BUFFER is a minibuffer, barf unless it's the currently
|
|
|
|
|
;; active minibuffer.
|
1999-12-31 04:02:38 +00:00
|
|
|
|
(if (and mini-p
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(not (and (active-minibuffer-window)
|
|
|
|
|
(equal buffer
|
1995-03-31 01:48:40 +00:00
|
|
|
|
(window-buffer (active-minibuffer-window))))))
|
1994-05-05 05:27:59 +00:00
|
|
|
|
(error "Minibuffer is not active for completion")
|
2004-09-12 18:52:03 +00:00
|
|
|
|
;; Set buffer so buffer-local choose-completion-string-functions works.
|
|
|
|
|
(set-buffer buffer)
|
2003-02-04 12:29:42 +00:00
|
|
|
|
(unless (run-hook-with-args-until-success
|
2002-09-09 22:09:14 +00:00
|
|
|
|
'choose-completion-string-functions
|
2009-10-15 01:50:17 +00:00
|
|
|
|
;; The fourth arg used to be `mini-p' but was useless
|
|
|
|
|
;; (since minibufferp can be used on the `buffer' arg)
|
|
|
|
|
;; and indeed unused. The last used to be `base-size', so we
|
|
|
|
|
;; keep it to try and avoid breaking old code.
|
|
|
|
|
choice buffer base-position nil)
|
2011-05-23 23:45:50 -03:00
|
|
|
|
;; This remove-text-properties should be unnecessary since `choice'
|
|
|
|
|
;; comes from buffer-substring-no-properties.
|
2011-12-04 00:02:42 -08:00
|
|
|
|
;;(remove-text-properties 0 (length choice) '(mouse-face nil) choice)
|
2002-09-09 22:09:14 +00:00
|
|
|
|
;; Insert the completion into the buffer where it was requested.
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(funcall (or insert-function completion-list-insert-choice-function)
|
|
|
|
|
(or (car base-position) (point))
|
|
|
|
|
(or (cadr base-position) (point))
|
|
|
|
|
choice)
|
|
|
|
|
;; Update point in the window that BUFFER is showing in.
|
2002-06-01 21:56:40 +00:00
|
|
|
|
(let ((window (get-buffer-window buffer t)))
|
|
|
|
|
(set-window-point window (point)))
|
|
|
|
|
;; If completing for the minibuffer, exit it with this choice.
|
|
|
|
|
(and (not completion-no-auto-exit)
|
2008-04-29 05:36:55 +00:00
|
|
|
|
(minibufferp buffer)
|
2002-06-01 21:56:40 +00:00
|
|
|
|
minibuffer-completion-table
|
|
|
|
|
;; If this is reading a file name, and the file name chosen
|
|
|
|
|
;; is a directory, don't exit the minibuffer.
|
2009-08-19 02:31:59 +00:00
|
|
|
|
(let* ((result (buffer-substring (field-beginning) (point)))
|
|
|
|
|
(bounds
|
|
|
|
|
(completion-boundaries result minibuffer-completion-table
|
|
|
|
|
minibuffer-completion-predicate
|
|
|
|
|
"")))
|
|
|
|
|
(if (eq (car bounds) (length result))
|
|
|
|
|
;; The completion chosen leads to a new set of completions
|
|
|
|
|
;; (e.g. it's a directory): don't exit the minibuffer yet.
|
|
|
|
|
(let ((mini (active-minibuffer-window)))
|
|
|
|
|
(select-window mini)
|
|
|
|
|
(when minibuffer-auto-raise
|
|
|
|
|
(raise-frame (window-frame mini))))
|
|
|
|
|
(exit-minibuffer))))))))
|
1994-03-27 22:21:04 +00:00
|
|
|
|
|
2008-04-13 22:12:02 +00:00
|
|
|
|
(define-derived-mode completion-list-mode nil "Completion List"
|
1993-07-13 21:34:05 +00:00
|
|
|
|
"Major mode for buffers showing lists of possible completions.
|
1994-03-27 22:21:04 +00:00
|
|
|
|
Type \\<completion-list-mode-map>\\[choose-completion] in the completion list\
|
|
|
|
|
to select the completion near point.
|
2014-04-22 22:22:06 -04:00
|
|
|
|
Or click to select one with the mouse.
|
2008-02-11 04:03:25 +00:00
|
|
|
|
|
|
|
|
|
\\{completion-list-mode-map}"
|
2008-04-13 22:12:02 +00:00
|
|
|
|
(set (make-local-variable 'completion-base-size) nil))
|
1993-07-13 21:34:05 +00:00
|
|
|
|
|
2001-04-10 14:48:42 +00:00
|
|
|
|
(defun completion-list-mode-finish ()
|
|
|
|
|
"Finish setup of the completions buffer.
|
|
|
|
|
Called from `temp-buffer-show-hook'."
|
|
|
|
|
(when (eq major-mode 'completion-list-mode)
|
2012-06-28 00:21:41 -07:00
|
|
|
|
(setq buffer-read-only t)))
|
2001-04-10 14:48:42 +00:00
|
|
|
|
|
|
|
|
|
(add-hook 'temp-buffer-show-hook 'completion-list-mode-finish)
|
|
|
|
|
|
2005-10-16 09:31:48 +00:00
|
|
|
|
|
|
|
|
|
;; Variables and faces used in `completion-setup-function'.
|
1997-12-21 01:47:48 +00:00
|
|
|
|
|
2006-09-04 18:26:03 +00:00
|
|
|
|
(defcustom completion-show-help t
|
|
|
|
|
"Non-nil means show help message in *Completions* buffer."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "22.1"
|
|
|
|
|
:group 'completion)
|
|
|
|
|
|
2005-10-16 09:31:48 +00:00
|
|
|
|
;; This function goes in completion-setup-hook, so that it is called
|
|
|
|
|
;; after the text of the completion list buffer is written.
|
1993-07-13 21:34:05 +00:00
|
|
|
|
(defun completion-setup-function ()
|
2005-11-01 07:18:10 +00:00
|
|
|
|
(let* ((mainbuf (current-buffer))
|
2009-05-11 15:35:44 +00:00
|
|
|
|
(base-dir
|
2013-05-04 15:27:41 -04:00
|
|
|
|
;; FIXME: This is a bad hack. We try to set the default-directory
|
|
|
|
|
;; in the *Completions* buffer so that the relative file names
|
|
|
|
|
;; displayed there can be treated as valid file names, independently
|
|
|
|
|
;; from the completion context. But this suffers from many problems:
|
|
|
|
|
;; - It's not clear when the completions are file names. With some
|
|
|
|
|
;; completion tables (e.g. bzr revision specs), the listed
|
|
|
|
|
;; completions can mix file names and other things.
|
|
|
|
|
;; - It doesn't pay attention to possible quoting.
|
|
|
|
|
;; - With fancy completion styles, the code below will not always
|
|
|
|
|
;; find the right base directory.
|
2009-05-11 15:35:44 +00:00
|
|
|
|
(if minibuffer-completing-file-name
|
|
|
|
|
(file-name-as-directory
|
|
|
|
|
(expand-file-name
|
2013-05-04 15:27:41 -04:00
|
|
|
|
(buffer-substring (minibuffer-prompt-end)
|
|
|
|
|
(- (point) (or completion-base-size 0))))))))
|
2004-05-19 19:10:19 +00:00
|
|
|
|
(with-current-buffer standard-output
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(let ((base-size completion-base-size) ;Read before killing localvars.
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(base-position completion-base-position)
|
|
|
|
|
(insert-fun completion-list-insert-choice-function))
|
2008-04-13 22:12:02 +00:00
|
|
|
|
(completion-list-mode)
|
2009-10-15 01:50:17 +00:00
|
|
|
|
(set (make-local-variable 'completion-base-size) base-size)
|
2011-05-23 23:45:50 -03:00
|
|
|
|
(set (make-local-variable 'completion-base-position) base-position)
|
|
|
|
|
(set (make-local-variable 'completion-list-insert-choice-function)
|
|
|
|
|
insert-fun))
|
2005-11-01 07:18:10 +00:00
|
|
|
|
(set (make-local-variable 'completion-reference-buffer) mainbuf)
|
2009-05-11 15:35:44 +00:00
|
|
|
|
(if base-dir (setq default-directory base-dir))
|
2006-09-04 18:26:03 +00:00
|
|
|
|
;; Maybe insert help string.
|
|
|
|
|
(when completion-show-help
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(if (display-mouse-p)
|
|
|
|
|
(insert (substitute-command-keys
|
2014-04-22 22:22:06 -04:00
|
|
|
|
"Click on a completion to select it.\n")))
|
2006-09-04 18:26:03 +00:00
|
|
|
|
(insert (substitute-command-keys
|
|
|
|
|
"In this buffer, type \\[choose-completion] to \
|
|
|
|
|
select the completion near point.\n\n"))))))
|
1992-05-30 21:11:25 +00:00
|
|
|
|
|
1993-07-13 21:34:05 +00:00
|
|
|
|
(add-hook 'completion-setup-hook 'completion-setup-function)
|
1994-12-29 18:53:25 +00:00
|
|
|
|
|
2005-11-01 07:18:10 +00:00
|
|
|
|
(define-key minibuffer-local-completion-map [prior] 'switch-to-completions)
|
|
|
|
|
(define-key minibuffer-local-completion-map "\M-v" 'switch-to-completions)
|
1994-12-29 18:53:25 +00:00
|
|
|
|
|
|
|
|
|
(defun switch-to-completions ()
|
|
|
|
|
"Select the completion list window."
|
|
|
|
|
(interactive)
|
2009-10-22 15:27:17 +00:00
|
|
|
|
(let ((window (or (get-buffer-window "*Completions*" 0)
|
2009-11-19 17:40:14 +00:00
|
|
|
|
;; Make sure we have a completions window.
|
2009-10-22 15:27:17 +00:00
|
|
|
|
(progn (minibuffer-completion-help)
|
|
|
|
|
(get-buffer-window "*Completions*" 0)))))
|
1998-01-18 03:32:20 +00:00
|
|
|
|
(when window
|
|
|
|
|
(select-window window)
|
2009-11-19 17:40:14 +00:00
|
|
|
|
;; In the new buffer, go to the first completion.
|
|
|
|
|
;; FIXME: Perhaps this should be done in `minibuffer-completion-help'.
|
|
|
|
|
(when (bobp)
|
|
|
|
|
(next-completion 1)))))
|
2006-01-23 01:24:26 +00:00
|
|
|
|
|
|
|
|
|
;;; Support keyboard commands to turn on various modifiers.
|
1995-03-28 03:49:39 +00:00
|
|
|
|
|
|
|
|
|
;; These functions -- which are not commands -- each add one modifier
|
|
|
|
|
;; to the following event.
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-alt-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Alt modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-alt-modifier] & to enter Alt-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'alt 22 "A-")))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-super-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Super modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-super-modifier] & to enter Super-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'super 23 "s-")))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-hyper-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Hyper modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-hyper-modifier] & to enter Hyper-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'hyper 24 "H-")))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-shift-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Shift modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-shift-modifier] & to enter Shift-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'shift 25 "S-")))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-control-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Ctrl modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-control-modifier] & to enter Ctrl-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'control 26 "C-")))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun event-apply-meta-modifier (_ignore-prompt)
|
2003-05-13 19:45:01 +00:00
|
|
|
|
"\\<function-key-map>Add the Meta modifier to the following event.
|
1998-06-01 21:10:43 +00:00
|
|
|
|
For example, type \\[event-apply-meta-modifier] & to enter Meta-&."
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(vector (event-apply-modifier (read-event) 'meta 27 "M-")))
|
|
|
|
|
|
|
|
|
|
(defun event-apply-modifier (event symbol lshiftby prefix)
|
|
|
|
|
"Apply a modifier flag to event EVENT.
|
|
|
|
|
SYMBOL is the name of this modifier, as a symbol.
|
|
|
|
|
LSHIFTBY is the numeric value of this modifier, in keyboard events.
|
|
|
|
|
PREFIX is the string that represents this modifier in an event type symbol."
|
|
|
|
|
(if (numberp event)
|
|
|
|
|
(cond ((eq symbol 'control)
|
1995-04-04 22:48:16 +00:00
|
|
|
|
(if (and (<= (downcase event) ?z)
|
|
|
|
|
(>= (downcase event) ?a))
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(- (downcase event) ?a -1)
|
1995-04-04 22:48:16 +00:00
|
|
|
|
(if (and (<= (downcase event) ?Z)
|
|
|
|
|
(>= (downcase event) ?A))
|
1995-03-28 03:49:39 +00:00
|
|
|
|
(- (downcase event) ?A -1)
|
|
|
|
|
(logior (lsh 1 lshiftby) event))))
|
|
|
|
|
((eq symbol 'shift)
|
|
|
|
|
(if (and (<= (downcase event) ?z)
|
|
|
|
|
(>= (downcase event) ?a))
|
|
|
|
|
(upcase event)
|
|
|
|
|
(logior (lsh 1 lshiftby) event)))
|
|
|
|
|
(t
|
|
|
|
|
(logior (lsh 1 lshiftby) event)))
|
|
|
|
|
(if (memq symbol (event-modifiers event))
|
|
|
|
|
event
|
|
|
|
|
(let ((event-type (if (symbolp event) event (car event))))
|
|
|
|
|
(setq event-type (intern (concat prefix (symbol-name event-type))))
|
|
|
|
|
(if (symbolp event)
|
|
|
|
|
event-type
|
|
|
|
|
(cons event-type (cdr event)))))))
|
|
|
|
|
|
1995-04-05 03:34:40 +00:00
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?h] 'event-apply-hyper-modifier)
|
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?s] 'event-apply-super-modifier)
|
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?m] 'event-apply-meta-modifier)
|
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?a] 'event-apply-alt-modifier)
|
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?S] 'event-apply-shift-modifier)
|
|
|
|
|
(define-key function-key-map [?\C-x ?@ ?c] 'event-apply-control-modifier)
|
2006-01-23 01:24:26 +00:00
|
|
|
|
|
1993-07-01 20:34:13 +00:00
|
|
|
|
;;;; Keypad support.
|
|
|
|
|
|
2007-06-29 04:37:34 +00:00
|
|
|
|
;; Make the keypad keys act like ordinary typing keys. If people add
|
|
|
|
|
;; bindings for the function key symbols, then those bindings will
|
|
|
|
|
;; override these, so this shouldn't interfere with any existing
|
|
|
|
|
;; bindings.
|
1993-07-01 20:34:13 +00:00
|
|
|
|
|
1993-12-25 00:45:07 +00:00
|
|
|
|
;; Also tell read-char how to handle these keys.
|
2001-10-31 00:57:04 +00:00
|
|
|
|
(mapc
|
1993-07-01 20:34:13 +00:00
|
|
|
|
(lambda (keypad-normal)
|
|
|
|
|
(let ((keypad (nth 0 keypad-normal))
|
|
|
|
|
(normal (nth 1 keypad-normal)))
|
1993-12-25 00:45:07 +00:00
|
|
|
|
(put keypad 'ascii-character normal)
|
1993-07-01 20:34:13 +00:00
|
|
|
|
(define-key function-key-map (vector keypad) (vector normal))))
|
2013-12-13 03:03:04 +02:00
|
|
|
|
;; See also kp-keys bound in bindings.el.
|
|
|
|
|
'((kp-space ?\s)
|
1993-07-01 20:34:13 +00:00
|
|
|
|
(kp-tab ?\t)
|
|
|
|
|
(kp-enter ?\r)
|
|
|
|
|
(kp-separator ?,)
|
2009-09-14 01:22:42 +00:00
|
|
|
|
(kp-equal ?=)
|
|
|
|
|
;; Do the same for various keys that are represented as symbols under
|
|
|
|
|
;; GUIs but naturally correspond to characters.
|
|
|
|
|
(backspace 127)
|
|
|
|
|
(delete 127)
|
|
|
|
|
(tab ?\t)
|
|
|
|
|
(linefeed ?\n)
|
|
|
|
|
(clear ?\C-l)
|
|
|
|
|
(return ?\C-m)
|
|
|
|
|
(escape ?\e)
|
|
|
|
|
))
|
2002-04-27 23:16:18 +00:00
|
|
|
|
|
1999-11-15 16:11:14 +00:00
|
|
|
|
;;;;
|
1999-10-13 00:48:17 +00:00
|
|
|
|
;;;; forking a twin copy of a buffer.
|
1999-11-15 16:11:14 +00:00
|
|
|
|
;;;;
|
1999-10-13 00:48:17 +00:00
|
|
|
|
|
|
|
|
|
(defvar clone-buffer-hook nil
|
|
|
|
|
"Normal hook to run in the new buffer at the end of `clone-buffer'.")
|
|
|
|
|
|
2008-02-12 02:25:10 +00:00
|
|
|
|
(defvar clone-indirect-buffer-hook nil
|
|
|
|
|
"Normal hook to run in the new buffer at the end of `clone-indirect-buffer'.")
|
|
|
|
|
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(defun clone-process (process &optional newname)
|
|
|
|
|
"Create a twin copy of PROCESS.
|
|
|
|
|
If NEWNAME is nil, it defaults to PROCESS' name;
|
|
|
|
|
NEWNAME is modified by adding or incrementing <N> at the end as necessary.
|
|
|
|
|
If PROCESS is associated with a buffer, the new process will be associated
|
|
|
|
|
with the current buffer instead.
|
|
|
|
|
Returns nil if PROCESS has already terminated."
|
|
|
|
|
(setq newname (or newname (process-name process)))
|
|
|
|
|
(if (string-match "<[0-9]+>\\'" newname)
|
|
|
|
|
(setq newname (substring newname 0 (match-beginning 0))))
|
|
|
|
|
(when (memq (process-status process) '(run stop open))
|
|
|
|
|
(let* ((process-connection-type (process-tty-name process))
|
|
|
|
|
(new-process
|
|
|
|
|
(if (memq (process-status process) '(open))
|
2002-03-17 20:28:53 +00:00
|
|
|
|
(let ((args (process-contact process t)))
|
|
|
|
|
(setq args (plist-put args :name newname))
|
|
|
|
|
(setq args (plist-put args :buffer
|
2003-01-14 10:16:00 +00:00
|
|
|
|
(if (process-buffer process)
|
|
|
|
|
(current-buffer))))
|
2002-03-17 20:28:53 +00:00
|
|
|
|
(apply 'make-network-process args))
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(apply 'start-process newname
|
|
|
|
|
(if (process-buffer process) (current-buffer))
|
|
|
|
|
(process-command process)))))
|
2002-03-17 20:28:53 +00:00
|
|
|
|
(set-process-query-on-exit-flag
|
|
|
|
|
new-process (process-query-on-exit-flag process))
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(set-process-inherit-coding-system-flag
|
|
|
|
|
new-process (process-inherit-coding-system-flag process))
|
|
|
|
|
(set-process-filter new-process (process-filter process))
|
|
|
|
|
(set-process-sentinel new-process (process-sentinel process))
|
2003-01-14 10:16:00 +00:00
|
|
|
|
(set-process-plist new-process (copy-sequence (process-plist process)))
|
1999-10-13 00:48:17 +00:00
|
|
|
|
new-process)))
|
|
|
|
|
|
2002-03-26 06:29:01 +00:00
|
|
|
|
;; things to maybe add (currently partly covered by `funcall mode'):
|
1999-10-13 00:48:17 +00:00
|
|
|
|
;; - syntax-table
|
|
|
|
|
;; - overlays
|
|
|
|
|
(defun clone-buffer (&optional newname display-flag)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"Create and return a twin copy of the current buffer.
|
|
|
|
|
Unlike an indirect buffer, the new buffer can be edited
|
|
|
|
|
independently of the old one (if it is not read-only).
|
|
|
|
|
NEWNAME is the name of the new buffer. It may be modified by
|
|
|
|
|
adding or incrementing <N> at the end as necessary to create a
|
|
|
|
|
unique buffer name. If nil, it defaults to the name of the
|
|
|
|
|
current buffer, with the proper suffix. If DISPLAY-FLAG is
|
|
|
|
|
non-nil, the new buffer is shown with `pop-to-buffer'. Trying to
|
|
|
|
|
clone a file-visiting buffer, or a buffer whose major mode symbol
|
|
|
|
|
has a non-nil `no-clone' property, results in an error.
|
|
|
|
|
|
|
|
|
|
Interactively, DISPLAY-FLAG is t and NEWNAME is the name of the
|
|
|
|
|
current buffer with appropriate suffix. However, if a prefix
|
|
|
|
|
argument is given, then the command prompts for NEWNAME in the
|
|
|
|
|
minibuffer.
|
1999-10-13 00:48:17 +00:00
|
|
|
|
|
|
|
|
|
This runs the normal hook `clone-buffer-hook' in the new buffer
|
|
|
|
|
after it has been set up properly in other respects."
|
2001-11-13 02:09:59 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(progn
|
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(error "Cannot clone a file-visiting buffer"))
|
|
|
|
|
(if (get major-mode 'no-clone)
|
|
|
|
|
(error "Cannot clone a buffer in %s mode" mode-name))
|
2006-01-23 01:24:26 +00:00
|
|
|
|
(list (if current-prefix-arg
|
|
|
|
|
(read-buffer "Name of new cloned buffer: " (current-buffer)))
|
2001-11-13 02:09:59 +00:00
|
|
|
|
t)))
|
1999-10-13 00:48:17 +00:00
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(error "Cannot clone a file-visiting buffer"))
|
|
|
|
|
(if (get major-mode 'no-clone)
|
|
|
|
|
(error "Cannot clone a buffer in %s mode" mode-name))
|
|
|
|
|
(setq newname (or newname (buffer-name)))
|
|
|
|
|
(if (string-match "<[0-9]+>\\'" newname)
|
|
|
|
|
(setq newname (substring newname 0 (match-beginning 0))))
|
|
|
|
|
(let ((buf (current-buffer))
|
|
|
|
|
(ptmin (point-min))
|
|
|
|
|
(ptmax (point-max))
|
|
|
|
|
(pt (point))
|
|
|
|
|
(mk (if mark-active (mark t)))
|
|
|
|
|
(modified (buffer-modified-p))
|
|
|
|
|
(mode major-mode)
|
|
|
|
|
(lvars (buffer-local-variables))
|
|
|
|
|
(process (get-buffer-process (current-buffer)))
|
|
|
|
|
(new (generate-new-buffer (or newname (buffer-name)))))
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(with-current-buffer new
|
|
|
|
|
(insert-buffer-substring buf)))
|
|
|
|
|
(with-current-buffer new
|
|
|
|
|
(narrow-to-region ptmin ptmax)
|
|
|
|
|
(goto-char pt)
|
|
|
|
|
(if mk (set-mark mk))
|
|
|
|
|
(set-buffer-modified-p modified)
|
|
|
|
|
|
|
|
|
|
;; Clone the old buffer's process, if any.
|
|
|
|
|
(when process (clone-process process))
|
|
|
|
|
|
|
|
|
|
;; Now set up the major mode.
|
|
|
|
|
(funcall mode)
|
|
|
|
|
|
|
|
|
|
;; Set up other local variables.
|
2007-09-25 11:13:24 +00:00
|
|
|
|
(mapc (lambda (v)
|
|
|
|
|
(condition-case () ;in case var is read-only
|
|
|
|
|
(if (symbolp v)
|
|
|
|
|
(makunbound v)
|
|
|
|
|
(set (make-local-variable (car v)) (cdr v)))
|
|
|
|
|
(error nil)))
|
|
|
|
|
lvars)
|
1999-10-13 00:48:17 +00:00
|
|
|
|
|
|
|
|
|
;; Run any hooks (typically set up by the major mode
|
|
|
|
|
;; for cloning to work properly).
|
|
|
|
|
(run-hooks 'clone-buffer-hook))
|
2006-01-23 04:05:59 +00:00
|
|
|
|
(if display-flag
|
|
|
|
|
;; Presumably the current buffer is shown in the selected frame, so
|
|
|
|
|
;; we want to display the clone elsewhere.
|
|
|
|
|
(let ((same-window-regexps nil)
|
|
|
|
|
(same-window-buffer-names))
|
|
|
|
|
(pop-to-buffer new)))
|
1999-10-13 00:48:17 +00:00
|
|
|
|
new))
|
|
|
|
|
|
2000-04-17 15:24:58 +00:00
|
|
|
|
|
2000-04-19 20:40:46 +00:00
|
|
|
|
(defun clone-indirect-buffer (newname display-flag &optional norecord)
|
2000-04-17 15:24:58 +00:00
|
|
|
|
"Create an indirect buffer that is a twin copy of the current buffer.
|
|
|
|
|
|
2005-06-20 10:29:02 +00:00
|
|
|
|
Give the indirect buffer name NEWNAME. Interactively, read NEWNAME
|
2000-04-17 15:24:58 +00:00
|
|
|
|
from the minibuffer when invoked with a prefix arg. If NEWNAME is nil
|
|
|
|
|
or if not called with a prefix arg, NEWNAME defaults to the current
|
|
|
|
|
buffer's name. The name is modified by adding a `<N>' suffix to it
|
* simple.el (idle-update-delay, next-error-highlight)
(next-error-highlight-no-select, next-error-recenter, next-error-hook)
(minibuffer-history-case-insensitive-variables, kill-ring-max)
(kill-read-only-ok, backward-delete-char-untabify-method)
(kill-whole-line, mark-ring-max, global-mark-ring-max)
(set-mark-command-repeat-pop, next-line-add-newlines, track-eol)
(goal-column, line-move-ignore-invisible, fill-prefix)
(auto-fill-inhibit-regexp, blink-matching-paren)
(blink-matching-paren-on-screen, blink-matching-paren-distance)
(blink-matching-delay, blink-matching-paren-dont-ignore-comments)
(read-mail-command, mail-user-agent): Remove * in defcustom docstrings.
(minibuffer-history-isearch-wrap, transient-mark-mode)
(next-logical-line, auto-fill-mode, line-number-mode)
(column-number-mode, size-indication-mode, clone-indirect-buffer)
(normal-erase-is-backspace-mode): Doc fixes.
(current-kill, transient-mark-mode, toggle-truncate-lines)
(visible-mode): Reflow docstrings.
(minibuffer-local-shell-command-map, interprogram-paste-function):
Fix typos in docstrings.
2008-10-30 17:03:30 +00:00
|
|
|
|
or by incrementing the N in an existing suffix. Trying to clone a
|
|
|
|
|
buffer whose major mode symbol has a non-nil `no-clone-indirect'
|
|
|
|
|
property results in an error.
|
2000-04-17 15:24:58 +00:00
|
|
|
|
|
|
|
|
|
DISPLAY-FLAG non-nil means show the new buffer with `pop-to-buffer'.
|
2000-04-19 20:40:46 +00:00
|
|
|
|
This is always done when called interactively.
|
|
|
|
|
|
(clone-indirect-buffer): Doc fix.
(fixup-whitespace, just-one-space, backward-delete-char-untabify, lambda):
"?\ " -> "?\s".
(next-error, next-error-highlight, next-error-highlight-no-select,
next-error-last-buffer, next-error-buffer-p, next-error-find-buffer, next-error,
previous-error, next-error-no-select, previous-error-no-select, open-line,
split-line, minibuffer-prompt-width, kill-new, binary-overwrite-mode):
Fix typos in docstrings.
(set-fill-column): Fix typo in message.
2005-07-20 22:29:53 +00:00
|
|
|
|
Optional third arg NORECORD non-nil means do not put this buffer at the
|
2000-04-19 20:40:46 +00:00
|
|
|
|
front of the list of recently selected ones."
|
2001-11-13 02:09:59 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(progn
|
|
|
|
|
(if (get major-mode 'no-clone-indirect)
|
|
|
|
|
(error "Cannot indirectly clone a buffer in %s mode" mode-name))
|
|
|
|
|
(list (if current-prefix-arg
|
2006-01-23 01:24:26 +00:00
|
|
|
|
(read-buffer "Name of indirect buffer: " (current-buffer)))
|
2001-11-13 02:09:59 +00:00
|
|
|
|
t)))
|
|
|
|
|
(if (get major-mode 'no-clone-indirect)
|
|
|
|
|
(error "Cannot indirectly clone a buffer in %s mode" mode-name))
|
2000-04-17 15:24:58 +00:00
|
|
|
|
(setq newname (or newname (buffer-name)))
|
|
|
|
|
(if (string-match "<[0-9]+>\\'" newname)
|
|
|
|
|
(setq newname (substring newname 0 (match-beginning 0))))
|
|
|
|
|
(let* ((name (generate-new-buffer-name newname))
|
|
|
|
|
(buffer (make-indirect-buffer (current-buffer) name t)))
|
2008-02-12 02:25:10 +00:00
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(run-hooks 'clone-indirect-buffer-hook))
|
2000-04-17 15:24:58 +00:00
|
|
|
|
(when display-flag
|
2000-11-22 19:47:30 +00:00
|
|
|
|
(pop-to-buffer buffer norecord))
|
2000-04-17 15:24:58 +00:00
|
|
|
|
buffer))
|
|
|
|
|
|
|
|
|
|
|
2006-01-26 17:56:54 +00:00
|
|
|
|
(defun clone-indirect-buffer-other-window (newname display-flag &optional norecord)
|
|
|
|
|
"Like `clone-indirect-buffer' but display in another window."
|
2006-01-20 01:22:07 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(progn
|
|
|
|
|
(if (get major-mode 'no-clone-indirect)
|
|
|
|
|
(error "Cannot indirectly clone a buffer in %s mode" mode-name))
|
|
|
|
|
(list (if current-prefix-arg
|
2006-01-23 01:24:26 +00:00
|
|
|
|
(read-buffer "Name of indirect buffer: " (current-buffer)))
|
2006-01-20 01:22:07 +00:00
|
|
|
|
t)))
|
2002-05-01 15:08:25 +00:00
|
|
|
|
(let ((pop-up-windows t))
|
2006-01-26 17:56:54 +00:00
|
|
|
|
(clone-indirect-buffer newname display-flag norecord)))
|
2000-04-19 20:40:46 +00:00
|
|
|
|
|
2002-04-27 23:16:18 +00:00
|
|
|
|
|
2000-12-14 13:36:59 +00:00
|
|
|
|
;;; Handling of Backspace and Delete keys.
|
|
|
|
|
|
2005-10-23 22:11:22 +00:00
|
|
|
|
(defcustom normal-erase-is-backspace 'maybe
|
2007-11-15 16:42:43 +00:00
|
|
|
|
"Set the default behavior of the Delete and Backspace keys.
|
2005-10-23 22:11:22 +00:00
|
|
|
|
|
|
|
|
|
If set to t, Delete key deletes forward and Backspace key deletes
|
|
|
|
|
backward.
|
|
|
|
|
|
|
|
|
|
If set to nil, both Delete and Backspace keys delete backward.
|
|
|
|
|
|
|
|
|
|
If set to 'maybe (which is the default), Emacs automatically
|
2007-11-15 16:42:43 +00:00
|
|
|
|
selects a behavior. On window systems, the behavior depends on
|
2005-10-23 22:11:22 +00:00
|
|
|
|
the keyboard used. If the keyboard has both a Backspace key and
|
|
|
|
|
a Delete key, and both are mapped to their usual meanings, the
|
|
|
|
|
option's default value is set to t, so that Backspace can be used
|
|
|
|
|
to delete backward, and Delete can be used to delete forward.
|
|
|
|
|
|
|
|
|
|
If not running under a window system, customizing this option
|
|
|
|
|
accomplishes a similar effect by mapping C-h, which is usually
|
|
|
|
|
generated by the Backspace key, to DEL, and by mapping DEL to C-d
|
|
|
|
|
via `keyboard-translate'. The former functionality of C-h is
|
|
|
|
|
available on the F1 key. You should probably not use this
|
|
|
|
|
setting if you don't have both Backspace, Delete and F1 keys.
|
2000-12-22 12:50:39 +00:00
|
|
|
|
|
|
|
|
|
Setting this variable with setq doesn't take effect. Programmatically,
|
2001-04-04 14:07:13 +00:00
|
|
|
|
call `normal-erase-is-backspace-mode' (which see) instead."
|
2005-10-23 22:11:22 +00:00
|
|
|
|
:type '(choice (const :tag "Off" nil)
|
|
|
|
|
(const :tag "Maybe" maybe)
|
|
|
|
|
(other :tag "On" t))
|
2000-12-14 13:36:59 +00:00
|
|
|
|
:group 'editing-basics
|
|
|
|
|
:version "21.1"
|
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
;; The fboundp is because of a problem with :set when
|
|
|
|
|
;; dumping Emacs. It doesn't really matter.
|
2001-04-04 14:07:13 +00:00
|
|
|
|
(if (fboundp 'normal-erase-is-backspace-mode)
|
|
|
|
|
(normal-erase-is-backspace-mode (or value 0))
|
2000-12-14 13:36:59 +00:00
|
|
|
|
(set-default symbol value))))
|
|
|
|
|
|
2005-10-23 22:11:22 +00:00
|
|
|
|
(defun normal-erase-is-backspace-setup-frame (&optional frame)
|
|
|
|
|
"Set up `normal-erase-is-backspace-mode' on FRAME, if necessary."
|
|
|
|
|
(unless frame (setq frame (selected-frame)))
|
|
|
|
|
(with-selected-frame frame
|
Reimplement terminal parameters in C; clean up term.c, create terminal.c.
* lisp/termdev.el (terminal-parameter-alist, terminal-parameters, terminal-parameter-p)
(terminal-parameter, set-terminal-parameter, terminal-handle-delete-frame): Remove.
* src/term.c (Vring_bell_function, device_list, initial_device)
(next_device_id, ring_bell, update_begin, update_end)
(set_terminal_window, cursor_to, raw_cursor_to)
(clear_to_end, clear_frame, clear_end_of_line)
(write_glyphs, insert_glyphs, delete_glyphs, ins_del_lines)
(get_device, Fdisplay_name, create_device, delete_device)
(Fdelete_display, Fdisplay_live_p, Fdisplay_list)
Move to terminal.c.
(syms_of_term): Move their initialization to terminal.c.
* src/terminal.c: New file.
(device_list, next_device_id, initial_device, Vring_bell_function)
(ring_bell, update_begin, update_end, set_terminal_window)
(cursor_to, raw_cursor_to, clear_to_end, clear_frame)
(clear_end_of_line, write_glyphs, insert_glyphs, delete_glyphs)
(ins_del_lines, get_device, create_device, delete_device)
(Fdelete_display, Fdisplay_live_p, Fdisplay_list, Fdisplay_name): Move here.
(mark_devices, get_terminal_param, store_terminal_param)
(Fterminal_parameters, Fterminal_parameter)
(Fmodify_terminal_parameters, Fset_terminal_parameter)
(init_initial_device, delete_initial_device)
(syms_of_terminal): New functions.
* lisp/simple.el (normal-erase-is-backspace-setup-frame)
(normal-erase-is-backspace-mode): Rephrase things
without terminal-parameter-p.
* lisp/termdev.el (terminal-getenv, terminal-setenv)
(with-terminal-environment): Ditto.
* mac/makefile.MPW (EmacsObjects): Add terminal.c.x.
({Src}terminal.c.x): Add dependencies.
* src/Makefile.in (obj): Add terminal.o.
(terminal.o): Add dependencies.
[HAVE_CARBON]: Make terminal.o depend on macgui.h.
* src/alloc.c (mark_devices): Declare.
(Fgarbage_collect): Call `mark_devices'.
* src/dispextern.h (set_scroll_region, turn_off_insert)
(turn_off_highlight, background_highlight, clear_end_of_line_raw)
(tty_clear_end_of_line, tty_setup_colors, delete_tty): Remove.
(raw_cursor_to, clear_to_end, tty_turn_off_insert)
(tty_turn_off_highlight): Add declaration.
* src/emacs.c (main): Call `syms_of_terminal'.
* src/frame.c (get_future_frame_param): New function.
(Fmake_terminal_frame): Use it.
* src/keyboard.c (pop_kboard): Remove unused variable.
(Fset_output_flow_control): Return nil.
* src/keymap.h (Fset_keymap_parent): Add EXFUN.
* src/lisp.h (syms_of_terminal): Declare it.
* src/sysdep.c (reset_sys_modes): Update for renames.
* src/term.c (set_scroll_region): Rename to `tty_set_scroll_region'.
(turn_on_insert): Rename to `tty_turn_on_insert'.
(turn_off_insert): Rename to `tty_turn_off_insert'.
(turn_off_highlight): Rename to `tty_turn_off_highlight'.
(turn_on_highlight): Rename to `tty_turn_on_highlight'.
(toggle_highligh): Rename to `tty_toggle_highlight'.
(background_highlight): Rename to `tty_background_highlight'.
(highlight_if_desired): Rename to `tty_highlight_if_desired'.
(tty_ring_bell, tty_update_end, tty_set_terminal_window)
(tty_set_scroll_region, tty_background_highlight)
(tty_cursor_to, tty_raw_cursor_to, tty_clear_to_end)
(tty_clear_frame, tty_clear_end_of_line, tty_write_glyphs)
(tty_insert_glyphs, tty_delete_glyphs, tty_ins_del_lines)
(term_get_fkeys, tty_setup_colors, dissociate_if_controlling_tty)
(delete_tty): Add static modifier.
(tty_reset_terminal_modes, tty_set_terminal_window)
(tty_set_scroll_region, tty_background_highlight)
(tty_highlight_if_desired, tty_cursor_to)
(tty_raw_cursor_to, tty_clear_to_end, tty_clear_frame)
(tty_clear_end_of_line, tty_write_glyphs, tty_insert_glyphs)
(tty_delete_glyphs, tty_ins_del_lines, turn_on_face):
Update for renames.
* src/termhooks.h (param_alist): New member to struct device.
* src/xterm.h (x_delete_device): Declare.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-460
2005-12-25 20:06:58 +00:00
|
|
|
|
(unless (terminal-parameter nil 'normal-erase-is-backspace)
|
2007-09-07 19:49:17 +00:00
|
|
|
|
(normal-erase-is-backspace-mode
|
|
|
|
|
(if (if (eq normal-erase-is-backspace 'maybe)
|
|
|
|
|
(and (not noninteractive)
|
|
|
|
|
(or (memq system-type '(ms-dos windows-nt))
|
2012-09-17 03:55:02 -08:00
|
|
|
|
(memq window-system '(w32 ns))
|
2007-09-07 19:49:17 +00:00
|
|
|
|
(and (memq window-system '(x))
|
|
|
|
|
(fboundp 'x-backspace-delete-keys-p)
|
|
|
|
|
(x-backspace-delete-keys-p))
|
|
|
|
|
;; If the terminal Emacs is running on has erase char
|
|
|
|
|
;; set to ^H, use the Backspace key for deleting
|
|
|
|
|
;; backward, and the Delete key for deleting forward.
|
|
|
|
|
(and (null window-system)
|
|
|
|
|
(eq tty-erase-char ?\^H))))
|
|
|
|
|
normal-erase-is-backspace)
|
|
|
|
|
1 0)))))
|
2000-12-14 13:36:59 +00:00
|
|
|
|
|
2010-05-04 23:45:21 -04:00
|
|
|
|
(define-minor-mode normal-erase-is-backspace-mode
|
2001-04-04 14:07:13 +00:00
|
|
|
|
"Toggle the Erase and Delete mode of the Backspace and Delete keys.
|
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
|
|
|
|
With a prefix argument ARG, enable this feature if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
2001-04-04 14:07:13 +00:00
|
|
|
|
|
2005-10-23 22:11:22 +00:00
|
|
|
|
On window systems, when this mode is on, Delete is mapped to C-d
|
|
|
|
|
and Backspace is mapped to DEL; when this mode is off, both
|
|
|
|
|
Delete and Backspace are mapped to DEL. (The remapping goes via
|
|
|
|
|
`local-function-key-map', so binding Delete or Backspace in the
|
|
|
|
|
global or local keymap will override that.)
|
2001-04-04 14:07:13 +00:00
|
|
|
|
|
|
|
|
|
In addition, on window systems, the bindings of C-Delete, M-Delete,
|
|
|
|
|
C-M-Delete, C-Backspace, M-Backspace, and C-M-Backspace are changed in
|
|
|
|
|
the global keymap in accordance with the functionality of Delete and
|
|
|
|
|
Backspace. For example, if Delete is remapped to C-d, which deletes
|
|
|
|
|
forward, C-Delete is bound to `kill-word', but if Delete is remapped
|
|
|
|
|
to DEL, which deletes backward, C-Delete is bound to
|
|
|
|
|
`backward-kill-word'.
|
|
|
|
|
|
|
|
|
|
If not running on a window system, a similar effect is accomplished by
|
|
|
|
|
remapping C-h (normally produced by the Backspace key) and DEL via
|
|
|
|
|
`keyboard-translate': if this mode is on, C-h is mapped to DEL and DEL
|
|
|
|
|
to C-d; if it's off, the keys are not remapped.
|
|
|
|
|
|
|
|
|
|
When not running on a window system, and this mode is turned on, the
|
|
|
|
|
former functionality of C-h is available on the F1 key. You should
|
|
|
|
|
probably not turn on this mode on a text-only terminal if you don't
|
|
|
|
|
have both Backspace, Delete and F1 keys.
|
|
|
|
|
|
|
|
|
|
See also `normal-erase-is-backspace'."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
:variable ((eq (terminal-parameter nil 'normal-erase-is-backspace) 1)
|
|
|
|
|
. (lambda (v)
|
|
|
|
|
(setf (terminal-parameter nil 'normal-erase-is-backspace)
|
|
|
|
|
(if v 1 0))))
|
2010-05-04 23:45:21 -04:00
|
|
|
|
(let ((enabled (eq 1 (terminal-parameter
|
|
|
|
|
nil 'normal-erase-is-backspace))))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
|
2008-07-27 18:24:48 +00:00
|
|
|
|
(cond ((or (memq window-system '(x w32 ns pc))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
(memq system-type '(ms-dos windows-nt)))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(let ((bindings
|
|
|
|
|
`(([M-delete] [M-backspace])
|
|
|
|
|
([C-M-delete] [C-M-backspace])
|
|
|
|
|
([?\e C-delete] [?\e C-backspace]))))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
|
|
|
|
|
(if enabled
|
|
|
|
|
(progn
|
2010-10-19 11:43:27 -04:00
|
|
|
|
(define-key local-function-key-map [delete] [deletechar])
|
2013-12-11 09:22:26 -05:00
|
|
|
|
(define-key local-function-key-map [kp-delete] [deletechar])
|
2009-10-22 19:31:43 +00:00
|
|
|
|
(define-key local-function-key-map [backspace] [?\C-?])
|
|
|
|
|
(dolist (b bindings)
|
|
|
|
|
;; Not sure if input-decode-map is really right, but
|
|
|
|
|
;; keyboard-translate-table (used below) only works
|
|
|
|
|
;; for integer events, and key-translation-table is
|
|
|
|
|
;; global (like the global-map, used earlier).
|
|
|
|
|
(define-key input-decode-map (car b) nil)
|
|
|
|
|
(define-key input-decode-map (cadr b) nil)))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
(define-key local-function-key-map [delete] [?\C-?])
|
|
|
|
|
(define-key local-function-key-map [kp-delete] [?\C-?])
|
2009-10-22 19:31:43 +00:00
|
|
|
|
(define-key local-function-key-map [backspace] [?\C-?])
|
|
|
|
|
(dolist (b bindings)
|
|
|
|
|
(define-key input-decode-map (car b) (cadr b))
|
|
|
|
|
(define-key input-decode-map (cadr b) (car b))))))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
(t
|
|
|
|
|
(if enabled
|
2001-01-16 20:25:23 +00:00
|
|
|
|
(progn
|
2006-01-03 01:22:02 +00:00
|
|
|
|
(keyboard-translate ?\C-h ?\C-?)
|
|
|
|
|
(keyboard-translate ?\C-? ?\C-d))
|
|
|
|
|
(keyboard-translate ?\C-h ?\C-h)
|
|
|
|
|
(keyboard-translate ?\C-? ?\C-?))))
|
|
|
|
|
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(if (called-interactively-p 'interactive)
|
2006-01-03 01:22:02 +00:00
|
|
|
|
(message "Delete key deletes %s"
|
2009-12-01 18:06:06 +00:00
|
|
|
|
(if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
|
2006-01-03 01:22:02 +00:00
|
|
|
|
"forward" "backward")))))
|
2003-05-25 01:45:14 +00:00
|
|
|
|
|
2003-06-17 18:40:06 +00:00
|
|
|
|
(defvar vis-mode-saved-buffer-invisibility-spec nil
|
2003-07-07 21:00:26 +00:00
|
|
|
|
"Saved value of `buffer-invisibility-spec' when Visible mode is on.")
|
2001-04-04 14:07:13 +00:00
|
|
|
|
|
2012-08-29 13:36:49 -04:00
|
|
|
|
(define-minor-mode read-only-mode
|
|
|
|
|
"Change whether the current buffer is read-only.
|
|
|
|
|
With prefix argument ARG, make the buffer read-only if ARG is
|
|
|
|
|
positive, otherwise make it writable. If buffer is read-only
|
|
|
|
|
and `view-read-only' is non-nil, enter view mode.
|
|
|
|
|
|
|
|
|
|
Do not call this from a Lisp program unless you really intend to
|
2012-09-22 23:46:57 +08:00
|
|
|
|
do the same thing as the \\[read-only-mode] command, including
|
2012-08-29 13:36:49 -04:00
|
|
|
|
possibly enabling or disabling View mode. Also, note that this
|
|
|
|
|
command works by setting the variable `buffer-read-only', which
|
|
|
|
|
does not affect read-only regions caused by text properties. To
|
|
|
|
|
ignore read-only status in a Lisp program (whether due to text
|
|
|
|
|
properties or buffer state), bind `inhibit-read-only' temporarily
|
|
|
|
|
to a non-nil value."
|
|
|
|
|
:variable buffer-read-only
|
|
|
|
|
(cond
|
|
|
|
|
((and (not buffer-read-only) view-mode)
|
|
|
|
|
(View-exit-and-edit)
|
|
|
|
|
(make-local-variable 'view-read-only)
|
|
|
|
|
(setq view-read-only t)) ; Must leave view mode.
|
|
|
|
|
((and buffer-read-only view-read-only
|
|
|
|
|
;; If view-mode is already active, `view-mode-enter' is a nop.
|
|
|
|
|
(not view-mode)
|
|
|
|
|
(not (eq (get major-mode 'mode-class) 'special)))
|
|
|
|
|
(view-mode-enter))))
|
|
|
|
|
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(define-minor-mode visible-mode
|
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
|
|
|
|
"Toggle making all invisible text temporarily visible (Visible mode).
|
|
|
|
|
With a prefix argument ARG, enable Visible mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
2000-12-14 13:36:59 +00:00
|
|
|
|
|
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
|
|
|
|
This mode works by saving the value of `buffer-invisibility-spec'
|
|
|
|
|
and setting it to nil."
|
2003-06-17 02:35:46 +00:00
|
|
|
|
:lighter " Vis"
|
2005-04-02 19:24:26 +00:00
|
|
|
|
:group 'editing-basics
|
2003-06-17 18:40:06 +00:00
|
|
|
|
(when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec)
|
|
|
|
|
(setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec)
|
|
|
|
|
(kill-local-variable 'vis-mode-saved-buffer-invisibility-spec))
|
2003-07-07 21:00:26 +00:00
|
|
|
|
(when visible-mode
|
2003-06-17 18:40:06 +00:00
|
|
|
|
(set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec)
|
|
|
|
|
buffer-invisibility-spec)
|
|
|
|
|
(setq buffer-invisibility-spec nil)))
|
2003-06-17 02:35:46 +00:00
|
|
|
|
|
2013-09-17 16:27:10 -04:00
|
|
|
|
(defvar messages-buffer-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map special-mode-map)
|
|
|
|
|
(define-key map "g" nil) ; nothing to revert
|
|
|
|
|
map))
|
|
|
|
|
|
2013-09-17 00:39:54 -07:00
|
|
|
|
(define-derived-mode messages-buffer-mode special-mode "Messages"
|
|
|
|
|
"Major mode used in the \"*Messages*\" buffer.")
|
|
|
|
|
|
|
|
|
|
(defun messages-buffer ()
|
|
|
|
|
"Return the \"*Messages*\" buffer.
|
|
|
|
|
If it does not exist, create and it switch it to `messages-buffer-mode'."
|
|
|
|
|
(or (get-buffer "*Messages*")
|
|
|
|
|
(with-current-buffer (get-buffer-create "*Messages*")
|
|
|
|
|
(messages-buffer-mode)
|
|
|
|
|
(current-buffer))))
|
|
|
|
|
|
|
|
|
|
|
2001-10-31 00:57:04 +00:00
|
|
|
|
;; Minibuffer prompt stuff.
|
2001-09-13 10:02:35 +00:00
|
|
|
|
|
Try and fix w32 build; misc cleanup.
* lisp/subr.el (apply-partially): Move from subr.el; don't use lexical-let.
(eval-after-load): Obey lexical-binding.
* lisp/simple.el (apply-partially): Move to subr.el.
* lisp/makefile.w32-in: Match changes in Makefile.in.
(BIG_STACK_DEPTH, BIG_STACK_OPTS, BYTE_COMPILE_FLAGS): New vars.
(.el.elc, compile-CMD, compile-SH, compile-always-CMD)
(compile-always-SH, compile-calc-CMD, compile-calc-SH): Use them.
(COMPILE_FIRST): Add pcase, macroexp, and cconv.
* lisp/emacs-lisp/macroexp.el (macroexpand-all-1): Silence warning about
calling CL's `compiler-macroexpand'.
* lisp/emacs-lisp/bytecomp.el (byte-compile-preprocess): New function.
(byte-compile-initial-macro-environment)
(byte-compile-toplevel-file-form, byte-compile, byte-compile-sexp): Use it.
(byte-compile-eval, byte-compile-eval-before-compile): Obey lexical-binding.
(byte-compile--for-effect): Rename from `for-effect'.
(display-call-tree): Use case.
* lisp/emacs-lisp/byte-opt.el (for-effect): Don't declare as dynamic.
(byte-optimize-form-code-walker, byte-optimize-form):
Revert to old arg name.
* lisp/Makefile.in (BYTE_COMPILE_FLAGS): New var.
(compile-onefile, .el.elc, compile-calc, recompile): Use it.
2011-03-11 22:32:43 -05:00
|
|
|
|
;;(defun minibuffer-prompt-modification (start end)
|
|
|
|
|
;; (error "You cannot modify the prompt"))
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;;(defun minibuffer-prompt-insertion (start end)
|
|
|
|
|
;; (let ((inhibit-modification-hooks t))
|
|
|
|
|
;; (delete-region start end)
|
|
|
|
|
;; ;; Discard undo information for the text insertion itself
|
|
|
|
|
;; ;; and for the text deletion.above.
|
|
|
|
|
;; (when (consp buffer-undo-list)
|
|
|
|
|
;; (setq buffer-undo-list (cddr buffer-undo-list)))
|
|
|
|
|
;; (message "You cannot modify the prompt")))
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;;(setq minibuffer-prompt-properties
|
|
|
|
|
;; (list 'modification-hooks '(minibuffer-prompt-modification)
|
|
|
|
|
;; 'insert-in-front-hooks '(minibuffer-prompt-insertion)))
|
2001-09-13 10:02:35 +00:00
|
|
|
|
|
2007-08-14 07:41:59 +00:00
|
|
|
|
|
|
|
|
|
;;;; Problematic external packages.
|
|
|
|
|
|
|
|
|
|
;; rms says this should be done by specifying symbols that define
|
|
|
|
|
;; versions together with bad values. This is therefore not as
|
|
|
|
|
;; flexible as it could be. See the thread:
|
|
|
|
|
;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg00300.html
|
|
|
|
|
(defconst bad-packages-alist
|
|
|
|
|
;; Not sure exactly which semantic versions have problems.
|
|
|
|
|
;; Definitely 2.0pre3, probably all 2.0pre's before this.
|
2007-11-03 03:08:29 +00:00
|
|
|
|
'((semantic semantic-version "\\`2\\.0pre[1-3]\\'"
|
2007-08-14 07:41:59 +00:00
|
|
|
|
"The version of `semantic' loaded does not work in Emacs 22.
|
2007-10-07 00:31:20 +00:00
|
|
|
|
It can cause constant high CPU load.
|
|
|
|
|
Upgrade to at least Semantic 2.0pre4 (distributed with CEDET 1.0pre4).")
|
2007-08-14 07:41:59 +00:00
|
|
|
|
;; CUA-mode does not work with GNU Emacs version 22.1 and newer.
|
|
|
|
|
;; Except for version 1.2, all of the 1.x and 2.x version of cua-mode
|
|
|
|
|
;; provided the `CUA-mode' feature. Since this is no longer true,
|
|
|
|
|
;; we can warn the user if the `CUA-mode' feature is ever provided.
|
|
|
|
|
(CUA-mode t nil
|
|
|
|
|
"CUA-mode is now part of the standard GNU Emacs distribution,
|
|
|
|
|
so you can now enable CUA via the Options menu or by customizing `cua-mode'.
|
|
|
|
|
|
|
|
|
|
You have loaded an older version of CUA-mode which does not work
|
|
|
|
|
correctly with this version of Emacs. You should remove the old
|
|
|
|
|
version and use the one distributed with Emacs."))
|
|
|
|
|
"Alist of packages known to cause problems in this version of Emacs.
|
|
|
|
|
Each element has the form (PACKAGE SYMBOL REGEXP STRING).
|
|
|
|
|
PACKAGE is either a regular expression to match file names, or a
|
2013-06-13 18:24:52 -04:00
|
|
|
|
symbol (a feature name), like for `with-eval-after-load'.
|
2007-08-14 07:41:59 +00:00
|
|
|
|
SYMBOL is either the name of a string variable, or `t'. Upon
|
|
|
|
|
loading PACKAGE, if SYMBOL is t or matches REGEXP, display a
|
|
|
|
|
warning using STRING as the message.")
|
|
|
|
|
|
|
|
|
|
(defun bad-package-check (package)
|
|
|
|
|
"Run a check using the element from `bad-packages-alist' matching PACKAGE."
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(let* ((list (assoc package bad-packages-alist))
|
|
|
|
|
(symbol (nth 1 list)))
|
|
|
|
|
(and list
|
|
|
|
|
(boundp symbol)
|
|
|
|
|
(or (eq symbol t)
|
|
|
|
|
(and (stringp (setq symbol (eval symbol)))
|
2008-12-15 12:52:16 +00:00
|
|
|
|
(string-match-p (nth 2 list) symbol)))
|
|
|
|
|
(display-warning package (nth 3 list) :warning)))
|
2007-08-14 07:41:59 +00:00
|
|
|
|
(error nil)))
|
|
|
|
|
|
2013-06-13 18:24:52 -04:00
|
|
|
|
(dolist (elem bad-packages-alist)
|
|
|
|
|
(let ((pkg (car elem)))
|
|
|
|
|
(with-eval-after-load pkg
|
|
|
|
|
(bad-package-check pkg))))
|
2007-08-14 07:41:59 +00:00
|
|
|
|
|
2013-07-06 11:35:37 +02:00
|
|
|
|
|
|
|
|
|
;;; Generic dispatcher commands
|
|
|
|
|
|
2013-07-15 02:49:22 +02:00
|
|
|
|
;; Macro `define-alternatives' is used to create generic commands.
|
2013-07-06 11:35:37 +02:00
|
|
|
|
;; Generic commands are these (like web, mail, news, encrypt, irc, etc.)
|
|
|
|
|
;; that can have different alternative implementations where choosing
|
|
|
|
|
;; among them is exclusively a matter of user preference.
|
|
|
|
|
|
2013-07-15 02:49:22 +02:00
|
|
|
|
;; (define-alternatives COMMAND) creates a new interactive command
|
2013-07-06 11:35:37 +02:00
|
|
|
|
;; M-x COMMAND and a customizable variable COMMAND-alternatives.
|
|
|
|
|
;; Typically, the user will not need to customize this variable; packages
|
|
|
|
|
;; wanting to add alternative implementations should use
|
|
|
|
|
;;
|
|
|
|
|
;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives
|
|
|
|
|
|
2013-07-15 02:49:22 +02:00
|
|
|
|
(defmacro define-alternatives (command &rest customizations)
|
2014-01-13 23:13:44 +01:00
|
|
|
|
"Define the new command `COMMAND'.
|
|
|
|
|
|
|
|
|
|
The argument `COMMAND' should be a symbol.
|
|
|
|
|
|
|
|
|
|
Running `M-x COMMAND RET' for the first time prompts for which
|
2014-01-13 23:24:29 +01:00
|
|
|
|
alternative to use and records the selected command as a custom
|
2014-01-13 23:13:44 +01:00
|
|
|
|
variable.
|
|
|
|
|
|
2014-01-13 23:24:29 +01:00
|
|
|
|
Running `C-u M-x COMMAND RET' prompts again for an alternative
|
|
|
|
|
and overwrites the previous choice.
|
2014-01-13 23:13:44 +01:00
|
|
|
|
|
|
|
|
|
The variable `COMMAND-alternatives' contains an alist with
|
2014-01-17 15:58:34 +01:00
|
|
|
|
alternative implementations of COMMAND. `define-alternatives'
|
|
|
|
|
does not have any effect until this variable is set.
|
2014-01-13 23:13:44 +01:00
|
|
|
|
|
2013-07-06 11:35:37 +02:00
|
|
|
|
CUSTOMIZATIONS, if non-nil, should be composed of alternating
|
|
|
|
|
`defcustom' keywords and values to add to the declaration of
|
2013-07-06 15:31:59 +02:00
|
|
|
|
`COMMAND-alternatives' (typically :group and :version)."
|
2013-07-06 11:35:37 +02:00
|
|
|
|
(let* ((command-name (symbol-name command))
|
|
|
|
|
(varalt-name (concat command-name "-alternatives"))
|
|
|
|
|
(varalt-sym (intern varalt-name))
|
|
|
|
|
(varimp-sym (intern (concat command-name "--implementation"))))
|
|
|
|
|
`(progn
|
|
|
|
|
|
|
|
|
|
(defcustom ,varalt-sym nil
|
|
|
|
|
,(format "Alist of alternative implementations for the `%s' command.
|
|
|
|
|
|
|
|
|
|
Each entry must be a pair (ALTNAME . ALTFUN), where:
|
|
|
|
|
ALTNAME - The name shown at user to describe the alternative implementation.
|
|
|
|
|
ALTFUN - The function called to implement this alternative."
|
|
|
|
|
command-name)
|
|
|
|
|
:type '(alist :key-type string :value-type function)
|
|
|
|
|
,@customizations)
|
|
|
|
|
|
2014-01-14 23:30:42 +01:00
|
|
|
|
(put ',varalt-sym 'definition-name ',command)
|
2013-07-06 11:35:37 +02:00
|
|
|
|
(defvar ,varimp-sym nil "Internal use only.")
|
|
|
|
|
|
|
|
|
|
(defun ,command (&optional arg)
|
|
|
|
|
,(format "Run generic command `%s'.
|
|
|
|
|
If used for the first time, or with interactive ARG, ask the user which
|
|
|
|
|
implementation to use for `%s'. The variable `%s'
|
|
|
|
|
contains the list of implementations currently supported for this command."
|
|
|
|
|
command-name command-name varalt-name)
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(when (or arg (null ,varimp-sym))
|
|
|
|
|
(let ((val (completing-read
|
2014-01-13 23:13:44 +01:00
|
|
|
|
,(format "Select implementation for command `%s': "
|
|
|
|
|
command-name)
|
|
|
|
|
,varalt-sym nil t)))
|
2013-07-06 11:35:37 +02:00
|
|
|
|
(unless (string-equal val "")
|
2014-01-13 23:13:44 +01:00
|
|
|
|
(when (null ,varimp-sym)
|
|
|
|
|
(message
|
|
|
|
|
"Use `C-u M-x %s RET' to select another implementation"
|
|
|
|
|
,command-name)
|
|
|
|
|
(sit-for 3))
|
|
|
|
|
(customize-save-variable ',varimp-sym
|
|
|
|
|
(cdr (assoc-string val ,varalt-sym))))))
|
2013-07-06 11:35:37 +02:00
|
|
|
|
(if ,varimp-sym
|
2014-01-13 23:13:44 +01:00
|
|
|
|
(call-interactively ,varimp-sym)
|
2013-07-06 11:35:37 +02:00
|
|
|
|
(message ,(format "No implementation selected for command `%s'"
|
|
|
|
|
command-name)))))))
|
|
|
|
|
|
2014-02-06 19:22:34 -08:00
|
|
|
|
|
|
|
|
|
;; This is here because files in obsolete/ are not scanned for autoloads.
|
|
|
|
|
|
|
|
|
|
(defvar iswitchb-mode nil "\
|
|
|
|
|
Non-nil if Iswitchb mode is enabled.
|
|
|
|
|
See the command `iswitchb-mode' for a description of this minor mode.
|
|
|
|
|
Setting this variable directly does not take effect;
|
|
|
|
|
either customize it (see the info node `Easy Customization')
|
|
|
|
|
or call the function `iswitchb-mode'.")
|
|
|
|
|
|
|
|
|
|
(custom-autoload 'iswitchb-mode "iswitchb" nil)
|
|
|
|
|
|
|
|
|
|
(autoload 'iswitchb-mode "iswitchb" "\
|
|
|
|
|
Toggle Iswitchb mode.
|
|
|
|
|
With a prefix argument ARG, enable Iswitchb mode if ARG is
|
|
|
|
|
positive, and disable it otherwise. If called from Lisp, enable
|
|
|
|
|
the mode if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
Iswitchb mode is a global minor mode that enables switching
|
|
|
|
|
between buffers using substrings. See `iswitchb' for details.
|
|
|
|
|
|
|
|
|
|
\(fn &optional ARG)" t nil)
|
|
|
|
|
|
|
|
|
|
(make-obsolete 'iswitchb-mode
|
|
|
|
|
"use `icomplete-mode' or `ido-mode' instead." "24.4")
|
|
|
|
|
|
|
|
|
|
|
2002-09-13 13:56:41 +00:00
|
|
|
|
(provide 'simple)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
1992-05-30 21:11:25 +00:00
|
|
|
|
;;; simple.el ends here
|