2020-10-20 17:27:31 +02:00
|
|
|
|
;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model -*- lexical-binding: t -*-
|
1992-05-30 22:12:04 +00:00
|
|
|
|
|
2023-01-01 05:31:12 -05:00
|
|
|
|
;; Copyright (C) 1985-2023 Free Software Foundation, Inc.
|
1992-07-22 04:22:42 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;; Author: K. Shane Hartman
|
2019-05-25 13:43:06 -07:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2000-11-27 19:27:33 +00:00
|
|
|
|
;; Keywords: convenience wp
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 04:34:22 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1991-04-10 17:07:22 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 04:34:22 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1993-03-22 05:42:35 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2022-09-16 12:44:08 +02:00
|
|
|
|
;; This code provides the `picture-mode' commands documented in the Emacs
|
1993-03-22 05:42:35 +00:00
|
|
|
|
;; manual. The screen is treated as a semi-infinite quarter-plane with
|
2022-09-16 12:44:08 +02:00
|
|
|
|
;; support for rectangle operations and "etch-a-sketch" character
|
1993-03-22 05:42:35 +00:00
|
|
|
|
;; insertion in any of eight directions.
|
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defgroup picture nil
|
2012-04-22 21:58:00 +08:00
|
|
|
|
"Editing text-based pictures (\"ASCII art\")."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:prefix "picture-"
|
2016-10-08 16:37:42 +03:00
|
|
|
|
:group 'text)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
|
|
|
|
|
(defcustom picture-rectangle-ctl ?+
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for top left corners."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-rectangle-ctr ?+
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for top right corners."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-rectangle-cbr ?+
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for bottom right corners."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-rectangle-cbl ?+
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for bottom left corners."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-rectangle-v ?|
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for vertical lines."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-rectangle-h ?-
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"Character `picture-draw-rectangle' uses for horizontal lines."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'character)
|
1998-02-22 17:34:42 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; Picture Movement Commands
|
|
|
|
|
|
2012-04-16 14:53:06 -04:00
|
|
|
|
(defvar picture-desired-column 0
|
|
|
|
|
"Desired current column for Picture mode.
|
|
|
|
|
When a cursor is on a wide-column character (e.g. Chinese,
|
2017-10-09 22:53:19 -07:00
|
|
|
|
Japanese, Korean), this may be different from `current-column'.")
|
2012-04-16 14:53:06 -04:00
|
|
|
|
|
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(defun picture-update-desired-column (adjust-to-current)
|
2012-04-16 14:53:06 -04:00
|
|
|
|
"Maybe update `picture-desired-column'.
|
|
|
|
|
If the value of `picture-desired-column' is more than one column
|
|
|
|
|
from `current-column', or if the argument ADJUST-TO-CURRENT is
|
|
|
|
|
non-nil, set it to the current column. Return `current-column'."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(let ((current-column (current-column)))
|
|
|
|
|
(if (or adjust-to-current
|
|
|
|
|
(< picture-desired-column (1- current-column))
|
|
|
|
|
(> picture-desired-column (1+ current-column)))
|
|
|
|
|
(setq picture-desired-column current-column))
|
|
|
|
|
current-column))
|
|
|
|
|
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(defun picture-beginning-of-line (&optional arg)
|
|
|
|
|
"Position point at the beginning of the line.
|
|
|
|
|
With ARG not nil, move forward ARG - 1 lines first.
|
|
|
|
|
If scan reaches end of buffer, stop there without error."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^P")
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(if arg (forward-line (1- (prefix-numeric-value arg))))
|
|
|
|
|
(beginning-of-line)
|
1999-07-29 21:56:02 +00:00
|
|
|
|
(setq picture-desired-column 0))
|
1993-04-27 21:59:55 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(defun picture-end-of-line (&optional arg)
|
|
|
|
|
"Position point after last non-blank character on current line.
|
|
|
|
|
With ARG not nil, move forward ARG - 1 lines first.
|
|
|
|
|
If scan reaches end of buffer, stop there without error."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^P")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(if arg (forward-line (1- (prefix-numeric-value arg))))
|
|
|
|
|
(beginning-of-line)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(skip-chars-backward " \t" (prog1 (point) (end-of-line)))
|
1999-07-29 21:56:02 +00:00
|
|
|
|
(setq picture-desired-column (current-column)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
2002-03-08 09:58:51 +00:00
|
|
|
|
(defun picture-forward-column (arg &optional interactive)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Move cursor right, making whitespace if necessary.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move that many columns."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p\nd")
|
2002-07-01 07:47:22 +00:00
|
|
|
|
(let (deactivate-mark)
|
|
|
|
|
(picture-update-desired-column interactive)
|
|
|
|
|
(setq picture-desired-column (max 0 (+ picture-desired-column arg)))
|
|
|
|
|
(let ((current-column (move-to-column picture-desired-column t)))
|
|
|
|
|
(if (and (> current-column picture-desired-column)
|
|
|
|
|
(< arg 0))
|
|
|
|
|
;; It seems that we have just tried to move to the right
|
|
|
|
|
;; column of a multi-column character.
|
|
|
|
|
(forward-char -1)))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
2002-03-08 09:58:51 +00:00
|
|
|
|
(defun picture-backward-column (arg &optional interactive)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Move cursor left, making whitespace if necessary.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move that many columns."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p\nd")
|
2002-03-08 09:58:51 +00:00
|
|
|
|
(picture-update-desired-column interactive)
|
1994-03-01 06:19:22 +00:00
|
|
|
|
(picture-forward-column (- arg)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-move-down (arg)
|
|
|
|
|
"Move vertically down, making whitespace if necessary.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move that many lines."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p")
|
2002-07-01 07:47:22 +00:00
|
|
|
|
(let (deactivate-mark)
|
|
|
|
|
(picture-update-desired-column nil)
|
|
|
|
|
(picture-newline arg)
|
|
|
|
|
(let ((current-column (move-to-column picture-desired-column t)))
|
|
|
|
|
(if (> current-column picture-desired-column)
|
|
|
|
|
(forward-char -1)))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
2001-11-19 23:45:15 +00:00
|
|
|
|
(defvar picture-vertical-step 0
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Amount to move vertically after text character in Picture mode.")
|
|
|
|
|
|
2001-11-19 23:45:15 +00:00
|
|
|
|
(defvar picture-horizontal-step 1
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Amount to move horizontally after text character in Picture mode.")
|
|
|
|
|
|
|
|
|
|
(defun picture-move-up (arg)
|
|
|
|
|
"Move vertically up, making whitespace if necessary.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move that many lines."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p")
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(picture-update-desired-column nil)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-move-down (- arg)))
|
|
|
|
|
|
|
|
|
|
(defun picture-movement-right ()
|
|
|
|
|
"Move right after self-inserting character in Picture mode."
|
|
|
|
|
(interactive)
|
|
|
|
|
(picture-set-motion 0 1))
|
|
|
|
|
|
|
|
|
|
(defun picture-movement-left ()
|
|
|
|
|
"Move left after self-inserting character in Picture mode."
|
|
|
|
|
(interactive)
|
|
|
|
|
(picture-set-motion 0 -1))
|
|
|
|
|
|
|
|
|
|
(defun picture-movement-up ()
|
|
|
|
|
"Move up after self-inserting character in Picture mode."
|
|
|
|
|
(interactive)
|
|
|
|
|
(picture-set-motion -1 0))
|
|
|
|
|
|
|
|
|
|
(defun picture-movement-down ()
|
|
|
|
|
"Move down after self-inserting character in Picture mode."
|
|
|
|
|
(interactive)
|
|
|
|
|
(picture-set-motion 1 0))
|
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(defun picture-movement-nw (&optional arg)
|
|
|
|
|
"Move up and left after self-inserting character in Picture mode.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move up and two-column left."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(picture-set-motion -1 (if arg -2 -1)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(defun picture-movement-ne (&optional arg)
|
|
|
|
|
"Move up and right after self-inserting character in Picture mode.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move up and two-column right."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(picture-set-motion -1 (if arg 2 1)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(defun picture-movement-sw (&optional arg)
|
|
|
|
|
"Move down and left after self-inserting character in Picture mode.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move down and two-column left."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(picture-set-motion 1 (if arg -2 -1)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(defun picture-movement-se (&optional arg)
|
|
|
|
|
"Move down and right after self-inserting character in Picture mode.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move down and two-column right."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(picture-set-motion 1 (if arg 2 1)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
2022-09-16 12:44:08 +02:00
|
|
|
|
(defun picture-set-motion (vertical horizontal)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Set VERTICAL and HORIZONTAL increments for movement in Picture mode.
|
|
|
|
|
The mode line is updated to reflect the current direction."
|
2022-09-16 12:44:08 +02:00
|
|
|
|
(setq picture-vertical-step vertical
|
|
|
|
|
picture-horizontal-step horizontal)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(setq mode-name
|
|
|
|
|
(format "Picture:%s"
|
2022-09-16 12:44:08 +02:00
|
|
|
|
(nth (+ 2 (% horizontal 3) (* 5 (1+ (% vertical 2))))
|
1998-11-24 03:52:08 +00:00
|
|
|
|
'(wnw nw up ne ene Left left none right Right
|
|
|
|
|
wsw sw down se ese))))
|
1995-04-25 22:26:54 +00:00
|
|
|
|
(force-mode-line-update)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(message ""))
|
|
|
|
|
|
|
|
|
|
(defun picture-move ()
|
|
|
|
|
"Move in direction of `picture-vertical-step' and `picture-horizontal-step'."
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(if (/= picture-vertical-step 0)
|
|
|
|
|
(picture-move-down picture-vertical-step))
|
|
|
|
|
(if (/= picture-horizontal-step 0)
|
|
|
|
|
(picture-forward-column picture-horizontal-step)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-motion (arg)
|
|
|
|
|
"Move point in direction of current picture motion in Picture mode.
|
|
|
|
|
With ARG do it that many times. Useful for delineating rectangles in
|
|
|
|
|
conjunction with diagonal picture motion.
|
2012-02-21 00:28:18 -08:00
|
|
|
|
Use \"\\[command-apropos] picture-movement\" to see commands which control motion."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-move-down (* arg picture-vertical-step))
|
|
|
|
|
(picture-forward-column (* arg picture-horizontal-step)))
|
|
|
|
|
|
|
|
|
|
(defun picture-motion-reverse (arg)
|
|
|
|
|
"Move point in direction opposite of current picture motion in Picture mode.
|
|
|
|
|
With ARG do it that many times. Useful for delineating rectangles in
|
|
|
|
|
conjunction with diagonal picture motion.
|
2012-02-21 00:28:18 -08:00
|
|
|
|
Use \"\\[command-apropos] picture-movement\" to see commands which control motion."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-motion (- arg)))
|
|
|
|
|
|
2002-10-26 22:40:40 +00:00
|
|
|
|
(defun picture-mouse-set-point (event)
|
2010-11-13 16:01:10 -05:00
|
|
|
|
"Move point to the position of EVENT, making whitespace if necessary."
|
2002-10-26 22:40:40 +00:00
|
|
|
|
(interactive "e")
|
2010-11-13 16:01:10 -05:00
|
|
|
|
(let ((position (event-start event)))
|
|
|
|
|
(unless (posn-area position) ; Ignore EVENT unless in text area
|
|
|
|
|
(let* ((window (posn-window position))
|
|
|
|
|
(frame (if (framep window) window (window-frame window)))
|
|
|
|
|
(pair (posn-x-y position))
|
|
|
|
|
(start-pos (window-start window))
|
|
|
|
|
(start-pair (posn-x-y (posn-at-point start-pos)))
|
|
|
|
|
(dx (- (car pair) (car start-pair)))
|
|
|
|
|
(dy (- (cdr pair) (cdr start-pair)))
|
|
|
|
|
(char-ht (frame-char-height frame))
|
|
|
|
|
(spacing (when (display-graphic-p frame)
|
|
|
|
|
(or (with-current-buffer (window-buffer window)
|
|
|
|
|
line-spacing)
|
lisp/*: Add declarations, remove unused bindings, mark unused args.
* lisp/avoid.el (mouse-avoidance-mode): Mark unused arg.
(mouse-avoidance-nudge-mouse): Remove unused binding.
* lisp/imenu.el (imenu-default-goto-function): Mark unused args.
(imenu-progress-message): Remove obsolete macro; all callers changed.
* lisp/mouse.el (mouse-menu-major-mode-map):
* lisp/emacs-lisp/authors.el (authors-scan-change-log)
(authors-add-to-author-list):
* lisp/emacs-lisp/avl-tree.el (avl-tree--enter-balance):
* lisp/emacs-lisp/smie.el (smie-auto-fill):
* lisp/mail/sendmail.el (mail-bury):
* lisp/mail/unrmail.el (unrmail):
* lisp/net/tls.el (open-tls-stream):
* lisp/textmodes/picture.el (picture-mouse-set-point):
Remove unused bindings.
* lisp/subr.el (keymap-canonicalize): Remove unused binding.
(read-passwd): Mark unused arg.
* lisp/tutorial.el (tutorial--display-changes): Remove unused binding.
(tutorial--save-tutorial-to): Remove unused variable.
* lisp/emacs-lisp/package.el (define-package, package-menu-mark-delete)
(package-menu-mark-install, package-menu-mark-unmark): Mark unused args.
(package-generate-autoloads, package-menu--generate)
(package-menu--find-upgrades): Remove unused bindings.
* lisp/emulation/cua-rect.el (cua-restrict-regexp-rectangle)
(cua-restrict-prefix-rectangle): Doc fixes. Remove unused bindings.
(cua--mouse-ignore, cua--delete-rectangle, cua--extract-rectangle)
(cua--indent-rectangle, cua-open-rectangle, cua-close-rectangle)
(cua-blank-rectangle, cua-string-rectangle, cua-replace-in-rectangle)
(cua-incr-rectangle, cua-sequence-rectangle, cua--convert-rectangle-as)
(cua--rectangle-aux-replace, cua--left-fill-rectangle)
(cua-scroll-rectangle-up, cua-scroll-rectangle-down)
(cua-delete-char-rectangle): Mark unused args.
(cua-align-rectangle): Remove unused binding.
* lisp/mail/rmail.el (compilation--message->loc)
(epa--find-coding-system-for-mime-charset): Declare.
* lisp/net/dbus.el (dbus-register-service): Declare.
(dbus-name-owner-changed-handler): Remove unused binding.
* lisp/nxml/nxml-mode.el (nxml-electric-slash, nxml-in-mixed-content-p)
(nxml-compute-indent-from-matching-start-tag): Remove unused variables.
(nxml-scan-backward-within): Mark unused arg.
(nxml-dynamic-markup-word): Remove unused binding.
2012-04-19 19:20:26 +02:00
|
|
|
|
(frame-parameter frame 'line-spacing)))))
|
2010-11-13 16:01:10 -05:00
|
|
|
|
(cond ((floatp spacing)
|
|
|
|
|
(setq spacing (truncate (* spacing char-ht))))
|
|
|
|
|
((null spacing)
|
|
|
|
|
(setq spacing 0)))
|
|
|
|
|
(goto-char start-pos)
|
|
|
|
|
(picture-move-down (/ dy (+ char-ht spacing)))
|
|
|
|
|
(picture-forward-column (/ dx (frame-char-width frame)))))))
|
2002-10-26 22:40:40 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; Picture insertion and deletion.
|
|
|
|
|
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(defun picture-insert (ch arg)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(let* ((width (char-width ch))
|
|
|
|
|
;; We must be sure that the succeeding insertion won't delete
|
|
|
|
|
;; the just inserted character.
|
|
|
|
|
(picture-horizontal-step
|
|
|
|
|
(if (and (= picture-vertical-step 0)
|
|
|
|
|
(> width 1)
|
|
|
|
|
(< (abs picture-horizontal-step) 2))
|
|
|
|
|
(* picture-horizontal-step 2)
|
|
|
|
|
picture-horizontal-step)))
|
|
|
|
|
(while (> arg 0)
|
|
|
|
|
(setq arg (1- arg))
|
|
|
|
|
(if (/= picture-desired-column (current-column))
|
2002-03-14 08:57:36 +00:00
|
|
|
|
(move-to-column picture-desired-column t))
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(let ((col (+ picture-desired-column width)))
|
|
|
|
|
(or (eolp)
|
|
|
|
|
(let ((pos (point)))
|
2002-03-14 08:57:36 +00:00
|
|
|
|
(move-to-column col t)
|
2016-01-15 10:26:10 +02:00
|
|
|
|
(let ((old-width (string-width (buffer-substring pos (point)))))
|
|
|
|
|
(delete-region pos (point))
|
|
|
|
|
(when (> old-width width)
|
|
|
|
|
(insert-char ? (- old-width width))
|
|
|
|
|
(goto-char pos))))))
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(insert ch)
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(picture-move))))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(defun picture-self-insert (arg)
|
|
|
|
|
"Insert this character in place of character previously at the cursor.
|
|
|
|
|
The cursor then moves in the direction you previously specified
|
|
|
|
|
with the commands `picture-movement-right', `picture-movement-up', etc.
|
2012-02-21 00:28:18 -08:00
|
|
|
|
Use \"\\[command-apropos] picture-movement\" to see those commands."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "p")
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(picture-update-desired-column (not (eq this-command last-command)))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(picture-insert last-command-event arg)) ; Always a character in this case.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-clear-column (arg)
|
|
|
|
|
"Clear out ARG columns after point without moving."
|
|
|
|
|
(interactive "p")
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(let* ((original-col (current-column))
|
|
|
|
|
(target-col (max 0 (+ original-col arg)))
|
|
|
|
|
pos)
|
2002-03-14 08:57:36 +00:00
|
|
|
|
(move-to-column target-col t)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(setq pos (point))
|
|
|
|
|
(move-to-column original-col)
|
|
|
|
|
(delete-region pos (point))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(save-excursion
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(indent-to (max target-col original-col))))
|
|
|
|
|
(setq picture-desired-column (current-column)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-backward-clear-column (arg)
|
|
|
|
|
"Clear out ARG columns before point, moving back over them."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(picture-clear-column (- arg)))
|
|
|
|
|
|
|
|
|
|
(defun picture-clear-line (arg)
|
|
|
|
|
"Clear out rest of line; if at end of line, advance to next line.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
Cleared-out line text goes into the kill ring, as do newlines
|
|
|
|
|
that are advanced over. With prefix argument ARG, clear out (and
|
|
|
|
|
save in kill ring) that many lines."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
(progn
|
|
|
|
|
(setq arg (prefix-numeric-value arg))
|
|
|
|
|
(kill-line arg)
|
|
|
|
|
(newline (if (> arg 0) arg (- arg))))
|
|
|
|
|
(if (looking-at "[ \t]*$")
|
|
|
|
|
(kill-ring-save (point) (progn (forward-line 1) (point)))
|
|
|
|
|
(kill-region (point) (progn (end-of-line) (point))))))
|
|
|
|
|
|
|
|
|
|
(defun picture-newline (arg)
|
|
|
|
|
"Move to the beginning of the following line.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, move that many lines (up, if negative
|
|
|
|
|
argument);
|
1991-04-10 17:07:22 +00:00
|
|
|
|
always moves to the beginning of a line."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^p")
|
|
|
|
|
(let ((start (point))
|
|
|
|
|
(lines-left (forward-line arg)))
|
|
|
|
|
(if (and (eobp)
|
|
|
|
|
(> (point) start))
|
|
|
|
|
(newline))
|
|
|
|
|
(if (> lines-left 0)
|
|
|
|
|
(newline lines-left))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-open-line (arg)
|
2018-01-02 21:24:34 +02:00
|
|
|
|
"Insert ARG empty lines after the current line.
|
|
|
|
|
ARG must be positive.
|
|
|
|
|
Interactively, ARG is the numeric argument, and defaults to 1."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(end-of-line)
|
1999-07-29 21:56:02 +00:00
|
|
|
|
(open-line arg)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-duplicate-line ()
|
|
|
|
|
"Insert a duplicate of the current line, below it."
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((contents
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(progn (beginning-of-line) (point))
|
|
|
|
|
(progn (picture-newline 1) (point)))))
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(insert contents))))
|
|
|
|
|
|
1993-06-14 18:53:40 +00:00
|
|
|
|
;; Like replace-match, but overwrites.
|
|
|
|
|
(defun picture-replace-match (newtext fixedcase literal)
|
|
|
|
|
(let (ocolumn change pos)
|
|
|
|
|
(goto-char (setq pos (match-end 0)))
|
|
|
|
|
(setq ocolumn (current-column))
|
|
|
|
|
;; Make the replacement and undo it, to see how it changes the length.
|
|
|
|
|
(let ((buffer-undo-list nil)
|
|
|
|
|
list1)
|
|
|
|
|
(replace-match newtext fixedcase literal)
|
|
|
|
|
(setq change (- (current-column) ocolumn))
|
|
|
|
|
(setq list1 buffer-undo-list)
|
|
|
|
|
(while list1
|
|
|
|
|
(setq list1 (primitive-undo 1 list1))))
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(if (> change 0)
|
|
|
|
|
(delete-region (point)
|
|
|
|
|
(progn
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(move-to-column (+ change (current-column)) t)
|
1993-06-14 18:53:40 +00:00
|
|
|
|
(point))))
|
|
|
|
|
(replace-match newtext fixedcase literal)
|
|
|
|
|
(if (< change 0)
|
2005-06-29 13:54:22 +00:00
|
|
|
|
(insert-char ?\s (- change)))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; Picture Tabs
|
|
|
|
|
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-tab-chars "!-~"
|
Remove leading `*' from docs of some defcustoms etc.
* emulation/crisp.el, emulation/cua-base.el, emulation/edt.el:
* emulation/pc-select.el, emulation/vip.el, international/iso-ascii.el:
* international/kkc.el, international/ogonek.el, mail/feedmail.el:
* net/browse-url.el, net/eudc-vars.el, net/net-utils.el:
* net/rcompile.el, net/rlogin.el, textmodes/enriched.el:
* textmodes/makeinfo.el, textmodes/page-ext.el, textmodes/picture.el:
* textmodes/refer.el, textmodes/spell.el, textmodes/table.el:
* textmodes/tex-mode.el, textmodes/two-column.el:
Remove leading `*' from docs of defcustoms etc.
2010-09-22 23:42:45 -07:00
|
|
|
|
"A character set which controls behavior of commands.
|
2012-02-21 00:28:18 -08:00
|
|
|
|
\\[picture-set-tab-stops] and \\[picture-tab-search].
|
|
|
|
|
The syntax for this variable is like the syntax used inside of `[...]'
|
|
|
|
|
in a regular expression--but without the `[' and the `]'.
|
2019-03-26 19:06:36 -07:00
|
|
|
|
It is NOT a regular expression, and should follow the usual
|
|
|
|
|
rules for the contents of a character alternative.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
It defines a set of \"interesting characters\" to look for when setting
|
|
|
|
|
\(or searching for) tab stops, initially \"!-~\" (all printing characters).
|
|
|
|
|
For example, suppose that you are editing a table which is formatted thus:
|
|
|
|
|
| foo | bar + baz | 23 *
|
|
|
|
|
| bubbles | and + etc | 97 *
|
|
|
|
|
and that `picture-tab-chars' is \"|+*\". Then invoking
|
|
|
|
|
\\[picture-set-tab-stops] on either of the previous lines would result
|
|
|
|
|
in the following tab stops
|
|
|
|
|
: : : :
|
|
|
|
|
Another example - \"A-Za-z0-9\" would produce the tab stops
|
|
|
|
|
: : : :
|
|
|
|
|
|
|
|
|
|
Note that if you want the character `-' to be in the set, it must be
|
|
|
|
|
included in a range or else appear in a context where it cannot be
|
|
|
|
|
taken for indicating a range (e.g. \"-A-Z\" declares the set to be the
|
|
|
|
|
letters `A' through `Z' and the character `-'). If you want the
|
|
|
|
|
character `\\' in the set it must be preceded by itself: \"\\\\\".
|
|
|
|
|
|
|
|
|
|
The command \\[picture-tab-search] is defined to move beneath (or to) a
|
1998-02-22 17:34:42 +00:00
|
|
|
|
character belonging to this set independent of the tab stops list."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'string)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-set-tab-stops (&optional arg)
|
|
|
|
|
"Set value of `tab-stop-list' according to context of this line.
|
|
|
|
|
This controls the behavior of \\[picture-tab]. A tab stop is set at
|
|
|
|
|
every column occupied by an \"interesting character\" that is preceded
|
|
|
|
|
by whitespace. Interesting characters are defined by the variable
|
|
|
|
|
`picture-tab-chars', see its documentation for an example of usage.
|
|
|
|
|
With ARG, just (re)set `tab-stop-list' to its default value. The tab
|
|
|
|
|
stops computed are displayed in the minibuffer with `:' at each stop."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let (tabs)
|
|
|
|
|
(if arg
|
2014-06-26 07:53:37 +08:00
|
|
|
|
(setq tabs (or (default-value 'tab-stop-list)
|
|
|
|
|
(indent-accumulate-tab-stops (window-width))))
|
2019-03-26 19:06:36 -07:00
|
|
|
|
(let ((regexp (concat "[ \t]+[" picture-tab-chars "]")))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((bol (point)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(while (re-search-backward regexp bol t)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(setq tabs (cons (current-column) tabs)))
|
|
|
|
|
(if (null tabs)
|
2019-03-26 19:06:36 -07:00
|
|
|
|
(error "No characters in set [%s] on this line"
|
|
|
|
|
picture-tab-chars)))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(setq tab-stop-list tabs)
|
|
|
|
|
(let ((blurb (make-string (1+ (nth (1- (length tabs)) tabs)) ?\ )))
|
|
|
|
|
(while tabs
|
|
|
|
|
(aset blurb (car tabs) ?:)
|
|
|
|
|
(setq tabs (cdr tabs)))
|
|
|
|
|
(message blurb)))))
|
|
|
|
|
|
|
|
|
|
(defun picture-tab-search (&optional arg)
|
|
|
|
|
"Move to column beneath next interesting char in previous line.
|
|
|
|
|
With ARG move to column occupied by next interesting character in this
|
|
|
|
|
line. The character must be preceded by whitespace.
|
|
|
|
|
\"interesting characters\" are defined by variable `picture-tab-chars'.
|
|
|
|
|
If no such character is found, move to beginning of line."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^P")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(let ((target (current-column)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (and (not arg)
|
|
|
|
|
(progn
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(skip-chars-backward
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
|
|
|
|
(concat "^" (string-replace
|
|
|
|
|
"\\" "\\\\" picture-tab-chars))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(point-min))
|
|
|
|
|
(not (bobp))))
|
|
|
|
|
(move-to-column target))
|
|
|
|
|
(if (re-search-forward
|
2019-03-26 19:06:36 -07:00
|
|
|
|
(concat "[ \t]+[" picture-tab-chars "]")
|
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-end-position)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
'move)
|
|
|
|
|
(setq target (1- (current-column)))
|
|
|
|
|
(setq target nil)))
|
|
|
|
|
(if target
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(move-to-column target t)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(beginning-of-line))))
|
|
|
|
|
|
|
|
|
|
(defun picture-tab (&optional arg)
|
|
|
|
|
"Tab transparently (just move point) to next tab stop.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
With prefix argument ARG, overwrite the traversed text with
|
|
|
|
|
spaces. The tab stop list can be changed by \
|
|
|
|
|
\\<picture-mode-map>\\[picture-set-tab-stops] and
|
|
|
|
|
\\[edit-tab-stops].
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
See also documentation for variable `picture-tab-chars'."
|
2011-09-23 10:47:01 -04:00
|
|
|
|
(interactive "^P")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(let* ((opoint (point)))
|
|
|
|
|
(move-to-tab-stop)
|
|
|
|
|
(if arg
|
|
|
|
|
(let (indent-tabs-mode
|
|
|
|
|
(column (current-column)))
|
|
|
|
|
(delete-region opoint (point))
|
|
|
|
|
(indent-to column)))))
|
|
|
|
|
|
|
|
|
|
;; Picture Rectangles
|
|
|
|
|
|
1999-10-18 21:20:22 +00:00
|
|
|
|
(defvar picture-killed-rectangle nil
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Rectangle killed or copied by \\[picture-clear-rectangle] in Picture mode.
|
|
|
|
|
The contents can be retrieved by \\[picture-yank-rectangle]")
|
|
|
|
|
|
|
|
|
|
(defun picture-clear-rectangle (start end &optional killp)
|
|
|
|
|
"Clear and save rectangle delineated by point and mark.
|
|
|
|
|
The rectangle is saved for yanking by \\[picture-yank-rectangle] and replaced
|
|
|
|
|
with whitespace. The previously saved rectangle, if any, is lost. With
|
|
|
|
|
prefix argument, the rectangle is actually killed, shifting remaining text."
|
|
|
|
|
(interactive "r\nP")
|
|
|
|
|
(setq picture-killed-rectangle (picture-snarf-rectangle start end killp)))
|
|
|
|
|
|
|
|
|
|
(defun picture-clear-rectangle-to-register (start end register &optional killp)
|
|
|
|
|
"Clear rectangle delineated by point and mark into REGISTER.
|
|
|
|
|
The rectangle is saved in REGISTER and replaced with whitespace. With
|
2014-02-02 16:40:49 -08:00
|
|
|
|
prefix argument, the rectangle is actually killed, shifting remaining text.
|
|
|
|
|
|
|
|
|
|
Interactively, reads the register using `register-read-with-preview'."
|
|
|
|
|
(interactive (list (region-beginning) (region-end)
|
|
|
|
|
(register-read-with-preview "Rectangle to register: ")
|
|
|
|
|
current-prefix-arg))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(set-register register (picture-snarf-rectangle start end killp)))
|
|
|
|
|
|
|
|
|
|
(defun picture-snarf-rectangle (start end &optional killp)
|
|
|
|
|
(let ((column (current-column))
|
|
|
|
|
(indent-tabs-mode nil))
|
|
|
|
|
(prog1 (save-excursion
|
|
|
|
|
(if killp
|
|
|
|
|
(delete-extract-rectangle start end)
|
|
|
|
|
(prog1 (extract-rectangle start end)
|
|
|
|
|
(clear-rectangle start end))))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(move-to-column column t))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-yank-rectangle (&optional insertp)
|
2021-09-13 06:04:32 +02:00
|
|
|
|
"Overlay rectangle saved by \\[picture-clear-rectangle].
|
2022-09-16 12:44:08 +02:00
|
|
|
|
The rectangle is positioned with upper left corner at point,
|
|
|
|
|
overwriting existing text. With prefix argument INSERTP, the
|
|
|
|
|
rectangle is inserted instead, shifting existing text. Leave
|
|
|
|
|
mark at one corner of rectangle and point at the
|
|
|
|
|
other (diagonally opposed) corner."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(if (not (consp picture-killed-rectangle))
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "No rectangle saved")
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-insert-rectangle picture-killed-rectangle insertp)))
|
|
|
|
|
|
1994-09-19 05:51:16 +00:00
|
|
|
|
(defun picture-yank-at-click (click arg)
|
|
|
|
|
"Insert the last killed rectangle at the position clicked on.
|
|
|
|
|
Also move point to one end of the text thus inserted (normally the end).
|
|
|
|
|
Prefix arguments are interpreted as with \\[yank].
|
|
|
|
|
If `mouse-yank-at-point' is non-nil, insert at point
|
|
|
|
|
regardless of where you click."
|
|
|
|
|
(interactive "e\nP")
|
|
|
|
|
(or mouse-yank-at-point (mouse-set-point click))
|
|
|
|
|
(picture-yank-rectangle arg))
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(defun picture-yank-rectangle-from-register (register &optional insertp)
|
|
|
|
|
"Overlay rectangle saved in REGISTER.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
The rectangle is positioned with upper left corner at point,
|
|
|
|
|
overwriting existing text. With prefix argument INSERTP, the
|
|
|
|
|
rectangle is inserted instead, shifting existing text. Leave
|
|
|
|
|
mark at one corner of rectangle and point at the
|
|
|
|
|
other (diagonally opposed) corner.
|
2014-02-02 16:40:49 -08:00
|
|
|
|
|
|
|
|
|
Interactively, reads the register using `register-read-with-preview'."
|
|
|
|
|
(interactive (list (register-read-with-preview "Rectangle from register: ")
|
|
|
|
|
current-prefix-arg))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(let ((rectangle (get-register register)))
|
|
|
|
|
(if (not (consp rectangle))
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "Register %c does not contain a rectangle" register)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-insert-rectangle rectangle insertp))))
|
|
|
|
|
|
|
|
|
|
(defun picture-insert-rectangle (rectangle &optional insertp)
|
|
|
|
|
"Overlay RECTANGLE with upper left corner at point.
|
|
|
|
|
Optional argument INSERTP, if non-nil causes RECTANGLE to be inserted.
|
2022-09-16 12:44:08 +02:00
|
|
|
|
Leave the region surrounding the rectangle."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(let ((indent-tabs-mode nil))
|
|
|
|
|
(if (not insertp)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(delete-rectangle (point)
|
|
|
|
|
(progn
|
|
|
|
|
(picture-forward-column (length (car rectangle)))
|
|
|
|
|
(picture-move-down (1- (length rectangle)))
|
|
|
|
|
(point)))))
|
|
|
|
|
(push-mark)
|
|
|
|
|
(insert-rectangle rectangle)))
|
|
|
|
|
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(defun picture-current-line ()
|
|
|
|
|
"Return the vertical position of point. Top line is 1."
|
|
|
|
|
(+ (count-lines (point-min) (point))
|
|
|
|
|
(if (= (current-column) 0) 1 0)))
|
|
|
|
|
|
|
|
|
|
(defun picture-draw-rectangle (start end)
|
2022-09-16 12:44:08 +02:00
|
|
|
|
"Draw a rectangle around region from START to END."
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(interactive "*r") ; start will be less than end
|
|
|
|
|
(let* ((sl (picture-current-line))
|
|
|
|
|
(sc (current-column))
|
|
|
|
|
(pvs picture-vertical-step)
|
|
|
|
|
(phs picture-horizontal-step)
|
|
|
|
|
(c1 (progn (goto-char start) (current-column)))
|
|
|
|
|
(r1 (picture-current-line))
|
|
|
|
|
(c2 (progn (goto-char end) (current-column)))
|
|
|
|
|
(r2 (picture-current-line))
|
|
|
|
|
(right (max c1 c2))
|
|
|
|
|
(left (min c1 c2))
|
|
|
|
|
(top (min r1 r2))
|
|
|
|
|
(bottom (max r1 r2)))
|
2009-08-22 19:29:18 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line (1- top))
|
2002-03-14 08:57:36 +00:00
|
|
|
|
(move-to-column left t)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(picture-update-desired-column t)
|
1997-06-23 04:16:44 +00:00
|
|
|
|
|
|
|
|
|
(picture-movement-right)
|
|
|
|
|
(picture-insert picture-rectangle-ctl 1)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(picture-insert picture-rectangle-h (- right picture-desired-column))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
|
|
|
|
|
(picture-movement-down)
|
|
|
|
|
(picture-insert picture-rectangle-ctr 1)
|
|
|
|
|
(picture-insert picture-rectangle-v (- bottom (picture-current-line)))
|
|
|
|
|
|
|
|
|
|
(picture-movement-left)
|
|
|
|
|
(picture-insert picture-rectangle-cbr 1)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(picture-insert picture-rectangle-h (- picture-desired-column left))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
|
|
|
|
|
(picture-movement-up)
|
|
|
|
|
(picture-insert picture-rectangle-cbl 1)
|
|
|
|
|
(picture-insert picture-rectangle-v (- (picture-current-line) top))
|
|
|
|
|
|
|
|
|
|
(picture-set-motion pvs phs)
|
2009-08-22 19:29:18 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line (1- sl))
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(move-to-column sc t)))
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; Picture Keymap, entry and exit points.
|
|
|
|
|
|
2012-02-21 09:09:19 -08:00
|
|
|
|
(defalias 'picture-delete-char 'delete-char)
|
|
|
|
|
|
2022-09-16 12:51:28 +02:00
|
|
|
|
(defvar-keymap picture-mode-map
|
|
|
|
|
:doc "Keymap used in `picture-mode'."
|
|
|
|
|
:full t
|
|
|
|
|
"<remap> <self-insert-command>" #'picture-self-insert
|
|
|
|
|
"<remap> <completion-separator-self-insert-command>" #'picture-self-insert
|
|
|
|
|
"<remap> <completion-separator-self-insert-autofilling>" #'picture-self-insert
|
|
|
|
|
"<remap> <forward-char>" #'picture-forward-column
|
|
|
|
|
"<remap> <right-char>" #'picture-forward-column
|
|
|
|
|
"<remap> <backward-char>" #'picture-backward-column
|
|
|
|
|
"<remap> <left-char>" #'picture-backward-column
|
|
|
|
|
"<remap> <delete-char>" #'picture-clear-column
|
|
|
|
|
;; There are two possibilities for what is normally on DEL.
|
|
|
|
|
"<remap> <backward-delete-char-untabify>" #'picture-backward-clear-column
|
|
|
|
|
"<remap> <delete-backward-char>" #'picture-backward-clear-column
|
|
|
|
|
"<remap> <kill-line>" #'picture-clear-line
|
|
|
|
|
"<remap> <open-line>" #'picture-open-line
|
|
|
|
|
"<remap> <newline>" #'picture-newline
|
|
|
|
|
"<remap> <newline-and-indent>" #'picture-duplicate-line
|
|
|
|
|
"<remap> <next-line>" #'picture-move-down
|
|
|
|
|
"<remap> <previous-line>" #'picture-move-up
|
|
|
|
|
"<remap> <move-beginning-of-line>" #'picture-beginning-of-line
|
|
|
|
|
"<remap> <move-end-of-line>" #'picture-end-of-line
|
|
|
|
|
"<remap> <mouse-set-point>" #'picture-mouse-set-point
|
|
|
|
|
"C-c C-d" #'picture-delete-char
|
|
|
|
|
"TAB" #'picture-tab
|
|
|
|
|
"M-TAB" #'picture-tab-search
|
|
|
|
|
"C-c TAB" #'picture-set-tab-stops
|
|
|
|
|
"C-c C-k" #'picture-clear-rectangle
|
|
|
|
|
"C-c C-w" #'picture-clear-rectangle-to-register
|
|
|
|
|
"C-c C-y" #'picture-yank-rectangle
|
|
|
|
|
"C-c C-x" #'picture-yank-rectangle-from-register
|
|
|
|
|
"C-c C-r" #'picture-draw-rectangle
|
|
|
|
|
"C-c C-c" #'picture-mode-exit
|
|
|
|
|
"C-c C-f" #'picture-motion
|
|
|
|
|
"C-c C-b" #'picture-motion-reverse
|
|
|
|
|
"C-c <" #'picture-movement-left
|
|
|
|
|
"C-c >" #'picture-movement-right
|
|
|
|
|
"C-c ^" #'picture-movement-up
|
|
|
|
|
"C-c ." #'picture-movement-down
|
|
|
|
|
"C-c `" #'picture-movement-nw
|
|
|
|
|
"C-c '" #'picture-movement-ne
|
|
|
|
|
"C-c /" #'picture-movement-sw
|
|
|
|
|
"C-c \\" #'picture-movement-se
|
|
|
|
|
"C-c <left>" #'picture-movement-left
|
|
|
|
|
"C-c <right>" #'picture-movement-right
|
|
|
|
|
"C-c <up>" #'picture-movement-up
|
|
|
|
|
"C-c <down>" #'picture-movement-down
|
|
|
|
|
"C-c <home>" #'picture-movement-nw
|
|
|
|
|
"C-c <prior>" #'picture-movement-ne
|
|
|
|
|
"C-c <end>" #'picture-movement-sw
|
|
|
|
|
"C-c <next>" #'picture-movement-se)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1998-02-22 17:34:42 +00:00
|
|
|
|
(defcustom picture-mode-hook nil
|
1993-04-27 21:59:55 +00:00
|
|
|
|
"If non-nil, its value is called on entry to Picture mode.
|
1998-02-22 17:34:42 +00:00
|
|
|
|
Picture mode is invoked by the command \\[picture-mode]."
|
2021-02-14 12:54:36 +01:00
|
|
|
|
:type 'hook)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1992-07-26 22:20:40 +00:00
|
|
|
|
(defvar picture-mode-old-local-map)
|
|
|
|
|
(defvar picture-mode-old-mode-name)
|
|
|
|
|
(defvar picture-mode-old-major-mode)
|
1993-12-23 05:01:36 +00:00
|
|
|
|
(defvar picture-mode-old-truncate-lines)
|
1992-07-26 22:20:40 +00:00
|
|
|
|
|
1991-05-09 21:50:34 +00:00
|
|
|
|
;;;###autoload
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(defun picture-mode ()
|
1991-04-10 17:07:22 +00:00
|
|
|
|
"Switch to Picture mode, in which a quarter-plane screen model is used.
|
2005-12-18 01:17:27 +00:00
|
|
|
|
\\<picture-mode-map>
|
1991-04-10 17:07:22 +00:00
|
|
|
|
Printing characters replace instead of inserting themselves with motion
|
|
|
|
|
afterwards settable by these commands:
|
2005-12-18 01:17:27 +00:00
|
|
|
|
|
|
|
|
|
Move left after insertion: \\[picture-movement-left]
|
|
|
|
|
Move right after insertion: \\[picture-movement-right]
|
|
|
|
|
Move up after insertion: \\[picture-movement-up]
|
|
|
|
|
Move down after insertion: \\[picture-movement-down]
|
|
|
|
|
|
|
|
|
|
Move northwest (nw) after insertion: \\[picture-movement-nw]
|
|
|
|
|
Move northeast (ne) after insertion: \\[picture-movement-ne]
|
|
|
|
|
Move southwest (sw) after insertion: \\[picture-movement-sw]
|
|
|
|
|
Move southeast (se) after insertion: \\[picture-movement-se]
|
|
|
|
|
|
2021-09-14 08:43:18 +02:00
|
|
|
|
Move westnorthwest (wnw) after insertion: \\[universal-argument] \\[picture-movement-nw]
|
|
|
|
|
Move eastnortheast (ene) after insertion: \\[universal-argument] \\[picture-movement-ne]
|
|
|
|
|
Move westsouthwest (wsw) after insertion: \\[universal-argument] \\[picture-movement-sw]
|
|
|
|
|
Move eastsoutheast (ese) after insertion: \\[universal-argument] \\[picture-movement-se]
|
2005-12-18 01:17:27 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
The current direction is displayed in the mode line. The initial
|
|
|
|
|
direction is right. Whitespace is inserted and tabs are changed to
|
|
|
|
|
spaces when required by movement. You can move around in the buffer
|
|
|
|
|
with these commands:
|
2005-12-18 01:17:27 +00:00
|
|
|
|
|
|
|
|
|
Move vertically to SAME column in previous line: \\[picture-move-down]
|
|
|
|
|
Move vertically to SAME column in next line: \\[picture-move-up]
|
|
|
|
|
Move to column following last
|
|
|
|
|
non-whitespace character: \\[picture-end-of-line]
|
|
|
|
|
Move right, inserting spaces if required: \\[picture-forward-column]
|
|
|
|
|
Move left changing tabs to spaces if required: \\[picture-backward-column]
|
|
|
|
|
Move in direction of current picture motion: \\[picture-motion]
|
|
|
|
|
Move opposite to current picture motion: \\[picture-motion-reverse]
|
|
|
|
|
Move to beginning of next line: \\[next-line]
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
You can edit tabular text with these commands:
|
2005-12-18 01:17:27 +00:00
|
|
|
|
|
|
|
|
|
Move to column beneath (or at) next interesting
|
|
|
|
|
character (see variable `picture-tab-chars'): \\[picture-tab-search]
|
|
|
|
|
Move to next stop in tab stop list: \\[picture-tab]
|
|
|
|
|
Set tab stops according to context of this line: \\[picture-set-tab-stops]
|
|
|
|
|
(With ARG, resets tab stops to default value.)
|
|
|
|
|
Change the tab stop list: \\[edit-tab-stops]
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
You can manipulate text with these commands:
|
2005-12-18 01:17:27 +00:00
|
|
|
|
Clear ARG columns after point without moving: \\[picture-clear-column]
|
2012-02-21 09:09:19 -08:00
|
|
|
|
Delete char at point: \\[picture-delete-char]
|
2005-12-18 01:17:27 +00:00
|
|
|
|
Clear ARG columns backward: \\[picture-backward-clear-column]
|
|
|
|
|
Clear ARG lines, advancing over them: \\[picture-clear-line]
|
|
|
|
|
(the cleared text is saved in the kill ring)
|
|
|
|
|
Open blank line(s) beneath current line: \\[picture-open-line]
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
You can manipulate rectangles with these commands:
|
2005-12-18 01:17:27 +00:00
|
|
|
|
Clear a rectangle and save it: \\[picture-clear-rectangle]
|
|
|
|
|
Clear a rectangle, saving in a named register: \\[picture-clear-rectangle-to-register]
|
|
|
|
|
Insert currently saved rectangle at point: \\[picture-yank-rectangle]
|
|
|
|
|
Insert rectangle from named register: \\[picture-yank-rectangle-from-register]
|
|
|
|
|
Draw a rectangular box around mark and point: \\[picture-draw-rectangle]
|
|
|
|
|
Copies a rectangle to a register: \\[copy-rectangle-to-register]
|
2009-09-11 00:58:59 +00:00
|
|
|
|
Undo effects of rectangle overlay commands: \\[undo]
|
2005-12-18 01:17:27 +00:00
|
|
|
|
|
|
|
|
|
You can return to the previous mode with \\[picture-mode-exit], which
|
|
|
|
|
also strips trailing whitespace from every line. Stripping is suppressed
|
|
|
|
|
by supplying an argument.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
2001-10-13 19:11:32 +00:00
|
|
|
|
Entry to this mode calls the value of `picture-mode-hook' if non-nil.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
Note that Picture mode commands will work outside of Picture mode, but
|
2011-12-05 00:55:25 -08:00
|
|
|
|
they are not by default assigned to keys."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(if (eq major-mode 'picture-mode)
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "You are already editing a picture")
|
2020-12-04 16:00:12 +01:00
|
|
|
|
(setq-local picture-mode-old-local-map (current-local-map))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(use-local-map picture-mode-map)
|
2020-12-04 16:00:12 +01:00
|
|
|
|
(setq-local picture-mode-old-mode-name mode-name)
|
|
|
|
|
(setq-local picture-mode-old-major-mode major-mode)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(setq major-mode 'picture-mode)
|
2020-12-04 16:00:12 +01:00
|
|
|
|
(setq-local picture-killed-rectangle nil)
|
|
|
|
|
(setq-local tab-stop-list (default-value 'tab-stop-list))
|
|
|
|
|
(setq-local picture-tab-chars (default-value 'picture-tab-chars))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(make-local-variable 'picture-vertical-step)
|
|
|
|
|
(make-local-variable 'picture-horizontal-step)
|
2020-12-04 16:00:12 +01:00
|
|
|
|
(setq-local picture-mode-old-truncate-lines truncate-lines)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(setq truncate-lines t)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(picture-set-motion 0 1)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
|
1992-10-12 04:53:11 +00:00
|
|
|
|
;; edit-picture-hook is what we used to run, picture-mode-hook is in doc.
|
|
|
|
|
(run-hooks 'edit-picture-hook 'picture-mode-hook)
|
1996-01-25 00:56:19 +00:00
|
|
|
|
(message "Type %s in this buffer to return it to %s mode."
|
|
|
|
|
(substitute-command-keys "\\[picture-mode-exit]")
|
|
|
|
|
picture-mode-old-mode-name)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1991-05-13 22:05:14 +00:00
|
|
|
|
;;;###autoload
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(defalias 'edit-picture 'picture-mode)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-mode-exit (&optional nostrip)
|
2001-12-02 07:06:43 +00:00
|
|
|
|
"Undo `picture-mode' and return to previous major mode.
|
2018-01-02 21:34:58 +02:00
|
|
|
|
With NOSTRIP omitted or nil, strip whitespace from end of every line
|
|
|
|
|
in Picture buffer; otherwise, just return to previous mode.
|
|
|
|
|
Interactively, NOSTRIP is the prefix argument, and defaults to nil.
|
2006-04-10 03:06:55 +00:00
|
|
|
|
Runs `picture-mode-exit-hook' at the end."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "P")
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(if (not (eq major-mode 'picture-mode))
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "You aren't editing a Picture")
|
2000-11-22 20:59:39 +00:00
|
|
|
|
(if (not nostrip) (delete-trailing-whitespace))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(setq mode-name picture-mode-old-mode-name)
|
|
|
|
|
(use-local-map picture-mode-old-local-map)
|
|
|
|
|
(setq major-mode picture-mode-old-major-mode)
|
|
|
|
|
(kill-local-variable 'tab-stop-list)
|
1993-12-23 05:01:36 +00:00
|
|
|
|
(setq truncate-lines picture-mode-old-truncate-lines)
|
2006-04-10 03:06:55 +00:00
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(run-hooks 'picture-mode-exit-hook)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1992-03-16 20:39:07 +00:00
|
|
|
|
(provide 'picture)
|
|
|
|
|
|
1992-05-30 22:12:04 +00:00
|
|
|
|
;;; picture.el ends here
|