2001-07-15 16:15:35 +00:00
|
|
|
|
;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model
|
1992-05-30 22:12:04 +00:00
|
|
|
|
|
2011-01-25 04:08:28 +00:00
|
|
|
|
;; Copyright (C) 1985, 1994, 2001-2011 Free Software Foundation, Inc.
|
1992-07-22 04:22:42 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;; Author: K. Shane Hartman
|
|
|
|
|
;; Maintainer: FSF
|
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
|
2008-05-06 04:34:22 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1993-03-22 05:42:35 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2000-11-22 20:59:39 +00: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
|
|
|
|
|
;; support for rectangle operations and `etch-a-sketch' character
|
|
|
|
|
;; 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
|
2001-07-18 09:06:38 +00:00
|
|
|
|
"Picture mode --- editing using quarter-plane screen model."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:prefix "picture-"
|
2010-03-12 17:47:22 +00:00
|
|
|
|
:group 'wp)
|
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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for top left corners."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for top right corners."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for bottom right corners."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for bottom left corners."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for vertical lines."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"Character `picture-draw-rectangle' uses for horizontal lines."
|
1998-02-22 17:34:42 +00:00
|
|
|
|
:type 'character
|
|
|
|
|
:group 'picture)
|
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
;; Picture Movement Commands
|
|
|
|
|
|
1998-11-24 03:52:08 +00:00
|
|
|
|
;; When a cursor is on a wide-column character (e.g. Chinese,
|
|
|
|
|
;; Japanese, Korean), this variable tells the desired current column
|
|
|
|
|
;; which may be different from (current-column).
|
|
|
|
|
(defvar picture-desired-column 0)
|
|
|
|
|
|
|
|
|
|
;; If the value of picture-desired-column is far from the current
|
|
|
|
|
;; column, or if the arg ADJUST-TO-CURRENT is non-nil, set it to the
|
|
|
|
|
;; current column. Return the current column.
|
|
|
|
|
(defun picture-update-desired-column (adjust-to-current)
|
|
|
|
|
(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."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(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."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(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.
|
|
|
|
|
With argument, move that many columns."
|
2002-03-08 09:58:51 +00: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.
|
|
|
|
|
With argument, move that many columns."
|
2002-03-08 09:58:51 +00:00
|
|
|
|
(interactive "p\nd")
|
|
|
|
|
(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.
|
|
|
|
|
With argument, move that many lines."
|
|
|
|
|
(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.
|
|
|
|
|
With argument, move that many lines."
|
|
|
|
|
(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.
|
|
|
|
|
With prefix argument, move up and two-column left."
|
|
|
|
|
(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.
|
|
|
|
|
With prefix argument, move up and two-column right."
|
|
|
|
|
(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.
|
|
|
|
|
With prefix argument, move down and two-column left."
|
|
|
|
|
(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.
|
|
|
|
|
With prefix argument, move down and two-column right."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(picture-set-motion 1 (if arg 2 1)))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-set-motion (vert horiz)
|
|
|
|
|
"Set VERTICAL and HORIZONTAL increments for movement in Picture mode.
|
|
|
|
|
The mode line is updated to reflect the current direction."
|
|
|
|
|
(setq picture-vertical-step vert
|
|
|
|
|
picture-horizontal-step horiz)
|
|
|
|
|
(setq mode-name
|
|
|
|
|
(format "Picture:%s"
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(nth (+ 2 (% horiz 3) (* 5 (1+ (% vert 2))))
|
|
|
|
|
'(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.
|
|
|
|
|
Do \\[command-apropos] picture-movement to see commands which control motion."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(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.
|
2002-10-26 22:40:40 +00:00
|
|
|
|
Do \\[command-apropos] picture-movement to see commands which control motion."
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(picture-motion (- arg)))
|
|
|
|
|
|
2002-10-26 22:40:40 +00:00
|
|
|
|
(defun picture-mouse-set-point (event)
|
2010-11-13 21:01:10 +00: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 21:01:10 +00: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)
|
|
|
|
|
(frame-parameter frame 'line-spacing))))
|
|
|
|
|
rows cols)
|
|
|
|
|
(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)
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(delete-region pos (point)))))
|
|
|
|
|
(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.
|
|
|
|
|
Do \\[command-apropos] `picture-movement' to see those commands."
|
|
|
|
|
(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.
|
|
|
|
|
Cleared-out line text goes into the kill ring, as do newlines that are
|
|
|
|
|
advanced over. With argument, clear out (and save in kill ring) that
|
|
|
|
|
many lines."
|
|
|
|
|
(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.
|
|
|
|
|
With argument, moves that many lines (up, if negative argument);
|
|
|
|
|
always moves to the beginning of a line."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(if (< arg 0)
|
|
|
|
|
(forward-line arg)
|
|
|
|
|
(while (> arg 0)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (eobp) (newline) (forward-char 1))
|
1999-07-29 21:56:02 +00:00
|
|
|
|
(setq arg (1- arg)))))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
(defun picture-open-line (arg)
|
|
|
|
|
"Insert an empty line after the current line.
|
|
|
|
|
With positive argument insert that many lines."
|
|
|
|
|
(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-23 06:42:45 +00:00
|
|
|
|
"A character set which controls behavior of commands.
|
1991-04-10 17:07:22 +00:00
|
|
|
|
\\[picture-set-tab-stops] and \\[picture-tab-search]. It is NOT a
|
|
|
|
|
regular expression, any regexp special characters will be quoted.
|
|
|
|
|
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."
|
|
|
|
|
:type 'string
|
|
|
|
|
:group 'picture)
|
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
|
|
|
|
|
(setq tabs (default-value 'tab-stop-list))
|
|
|
|
|
(let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")))
|
|
|
|
|
(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)
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "No characters in set %s on this line"
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(regexp-quote picture-tab-chars))))))
|
|
|
|
|
(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."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(let ((target (current-column)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (and (not arg)
|
|
|
|
|
(progn
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(skip-chars-backward
|
|
|
|
|
(concat "^" (regexp-quote picture-tab-chars))
|
|
|
|
|
(point-min))
|
|
|
|
|
(not (bobp))))
|
|
|
|
|
(move-to-column target))
|
|
|
|
|
(if (re-search-forward
|
|
|
|
|
(concat "[ \t]+[" (regexp-quote 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 20:23:42 +00: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.
|
|
|
|
|
With prefix arg, overwrite the traversed text with spaces. The tab stop
|
|
|
|
|
list can be changed by \\[picture-set-tab-stops] and \\[edit-tab-stops].
|
|
|
|
|
See also documentation for variable `picture-tab-chars'."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(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
|
|
|
|
|
prefix argument, the rectangle is actually killed, shifting remaining text."
|
|
|
|
|
(interactive "r\ncRectangle to register: \nP")
|
|
|
|
|
(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)
|
|
|
|
|
"Overlay rectangle saved by \\[picture-clear-rectangle]
|
|
|
|
|
The rectangle is positioned with upper left corner at point, overwriting
|
|
|
|
|
existing text. With prefix argument, the rectangle is inserted instead,
|
|
|
|
|
shifting existing text. Leaves mark at one corner of rectangle and
|
|
|
|
|
point at the other (diagonally opposed) corner."
|
|
|
|
|
(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.
|
|
|
|
|
The rectangle is positioned with upper left corner at point, overwriting
|
|
|
|
|
existing text. With prefix argument, the rectangle is
|
|
|
|
|
inserted instead, shifting existing text. Leaves mark at one corner
|
|
|
|
|
of rectangle and point at the other (diagonally opposed) corner."
|
|
|
|
|
(interactive "cRectangle from register: \nP")
|
|
|
|
|
(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.
|
|
|
|
|
Leaves the region surrounding the rectangle."
|
|
|
|
|
(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)
|
|
|
|
|
"Draw a rectangle around region."
|
|
|
|
|
(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.
|
|
|
|
|
|
2001-12-02 07:06:43 +00:00
|
|
|
|
(defvar picture-mode-map nil)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(defun picture-substitute (oldfun newfun)
|
2003-01-12 20:51:36 +00:00
|
|
|
|
(define-key picture-mode-map (vector 'remap oldfun) newfun))
|
1993-04-27 21:59:55 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(if (not picture-mode-map)
|
1994-11-18 20:37:28 +00:00
|
|
|
|
(progn
|
1998-11-24 03:52:08 +00:00
|
|
|
|
(setq picture-mode-map (make-keymap))
|
1994-11-18 20:37:28 +00:00
|
|
|
|
(picture-substitute 'self-insert-command 'picture-self-insert)
|
1996-02-14 20:11:04 +00:00
|
|
|
|
(picture-substitute 'completion-separator-self-insert-command
|
|
|
|
|
'picture-self-insert)
|
|
|
|
|
(picture-substitute 'completion-separator-self-insert-autofilling
|
|
|
|
|
'picture-self-insert)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(picture-substitute 'forward-char 'picture-forward-column)
|
|
|
|
|
(picture-substitute 'backward-char 'picture-backward-column)
|
|
|
|
|
(picture-substitute 'delete-char 'picture-clear-column)
|
1994-02-21 02:49:58 +00:00
|
|
|
|
;; There are two possibilities for what is normally on DEL.
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(picture-substitute 'backward-delete-char-untabify 'picture-backward-clear-column)
|
1994-02-21 02:49:58 +00:00
|
|
|
|
(picture-substitute 'delete-backward-char 'picture-backward-clear-column)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(picture-substitute 'kill-line 'picture-clear-line)
|
|
|
|
|
(picture-substitute 'open-line 'picture-open-line)
|
|
|
|
|
(picture-substitute 'newline 'picture-newline)
|
1994-11-18 20:37:28 +00:00
|
|
|
|
(picture-substitute 'newline-and-indent 'picture-duplicate-line)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(picture-substitute 'next-line 'picture-move-down)
|
|
|
|
|
(picture-substitute 'previous-line 'picture-move-up)
|
|
|
|
|
(picture-substitute 'beginning-of-line 'picture-beginning-of-line)
|
|
|
|
|
(picture-substitute 'end-of-line 'picture-end-of-line)
|
2002-10-26 22:40:40 +00:00
|
|
|
|
(picture-substitute 'mouse-set-point 'picture-mouse-set-point)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(define-key picture-mode-map "\C-c\C-d" 'delete-char)
|
|
|
|
|
(define-key picture-mode-map "\e\t" 'picture-toggle-tab-state)
|
|
|
|
|
(define-key picture-mode-map "\t" 'picture-tab)
|
|
|
|
|
(define-key picture-mode-map "\e\t" 'picture-tab-search)
|
|
|
|
|
(define-key picture-mode-map "\C-c\t" 'picture-set-tab-stops)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-k" 'picture-clear-rectangle)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-w" 'picture-clear-rectangle-to-register)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-y" 'picture-yank-rectangle)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-x" 'picture-yank-rectangle-from-register)
|
1997-06-23 04:16:44 +00:00
|
|
|
|
(define-key picture-mode-map "\C-c\C-r" 'picture-draw-rectangle)
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(define-key picture-mode-map "\C-c\C-c" 'picture-mode-exit)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-f" 'picture-motion)
|
|
|
|
|
(define-key picture-mode-map "\C-c\C-b" 'picture-motion-reverse)
|
|
|
|
|
(define-key picture-mode-map "\C-c<" 'picture-movement-left)
|
|
|
|
|
(define-key picture-mode-map "\C-c>" 'picture-movement-right)
|
|
|
|
|
(define-key picture-mode-map "\C-c^" 'picture-movement-up)
|
|
|
|
|
(define-key picture-mode-map "\C-c." 'picture-movement-down)
|
|
|
|
|
(define-key picture-mode-map "\C-c`" 'picture-movement-nw)
|
|
|
|
|
(define-key picture-mode-map "\C-c'" 'picture-movement-ne)
|
|
|
|
|
(define-key picture-mode-map "\C-c/" 'picture-movement-sw)
|
2004-04-27 06:46:51 +00:00
|
|
|
|
(define-key picture-mode-map "\C-c\\" 'picture-movement-se)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) left] 'picture-movement-left)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) right] 'picture-movement-right)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) up] 'picture-movement-up)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) down] 'picture-movement-down)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) home] 'picture-movement-nw)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) prior] 'picture-movement-ne)
|
|
|
|
|
(define-key picture-mode-map [(control ?c) end] 'picture-movement-sw)
|
|
|
|
|
(define-key picture-mode-map [(control ?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]."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'picture)
|
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]
|
|
|
|
|
|
|
|
|
|
Move westnorthwest (wnw) after insertion: C-u \\[picture-movement-nw]
|
|
|
|
|
Move eastnortheast (ene) after insertion: C-u \\[picture-movement-ne]
|
|
|
|
|
Move westsouthwest (wsw) after insertion: C-u \\[picture-movement-sw]
|
|
|
|
|
Move eastsoutheast (ese) after insertion: C-u \\[picture-movement-se]
|
|
|
|
|
|
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]
|
|
|
|
|
Delete char at point: \\[delete-char]
|
|
|
|
|
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
|
|
|
|
|
they are not defaultly assigned to keys."
|
|
|
|
|
(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")
|
2001-10-13 19:11:32 +00:00
|
|
|
|
(set (make-local-variable 'picture-mode-old-local-map) (current-local-map))
|
1991-04-10 17:07:22 +00:00
|
|
|
|
(use-local-map picture-mode-map)
|
2001-10-13 19:11:32 +00:00
|
|
|
|
(set (make-local-variable 'picture-mode-old-mode-name) mode-name)
|
|
|
|
|
(set (make-local-variable 'picture-mode-old-major-mode) major-mode)
|
1993-04-27 21:59:55 +00:00
|
|
|
|
(setq major-mode 'picture-mode)
|
2001-10-13 19:11:32 +00:00
|
|
|
|
(set (make-local-variable 'picture-killed-rectangle) nil)
|
|
|
|
|
(set (make-local-variable 'tab-stop-list) (default-value 'tab-stop-list))
|
|
|
|
|
(set (make-local-variable '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)
|
2001-10-13 19:11:32 +00:00
|
|
|
|
(set (make-local-variable '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.
|
2006-04-10 03:06:55 +00:00
|
|
|
|
With no argument, strip whitespace from end of every line in Picture buffer;
|
|
|
|
|
otherwise, just return to previous mode.
|
|
|
|
|
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
|