aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-08-27 17:23:29 +0000
committerChong Yidong2008-08-27 17:23:29 +0000
commit921d84aa36da88b7b8d1d185bb96e2c7f79ba94c (patch)
treef5abe889fdc6c1bb3023988b4385c28d3895be87
parent46b3318051b02e18a3e401b815e9e30c81055fa6 (diff)
downloademacs-921d84aa36da88b7b8d1d185bb96e2c7f79ba94c.tar.gz
emacs-921d84aa36da88b7b8d1d185bb96e2c7f79ba94c.zip
(artist-mode-init): Added comment on the setting up of the
`artist-replacement-table' array. (artist-get-replacement-char): New defsubst. (artist-get-char-at-xy-conv, artist-replace-char) (artist-replace-chars, artist-replace-string): Use it instead of accessing `artist-replacement-table' directly. Reported by Rubén Berenguel <ruben@maia.ub.es>. (artist-mt): Fixed structures for cut and copy operations.
-rw-r--r--lisp/textmodes/artist.el35
1 files changed, 25 insertions, 10 deletions
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index b8654af2d25..216b306d1f3 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -723,14 +723,14 @@ This variable is initialized by the artist-make-prev-next-op-alist function.")
723 2 723 2
724 artist-draw-rect 724 artist-draw-rect
725 (artist-undraw-rect 725 (artist-undraw-rect
726 artist-t artist-cut-rect) 726 artist-t artist-cut-rect))
727 ("cut square" cut-s "cut-s" 727 ("cut square" cut-s "cut-s"
728 artist-no-arrows nil 728 artist-no-arrows nil
729 nil nil nil 729 nil nil nil
730 2 730 2
731 artist-draw-square 731 artist-draw-square
732 (artist-undraw-square 732 (artist-undraw-square
733 artist-t artist-cut-square)))))) 733 artist-t artist-cut-square)))))
734 734
735 (graphics-operation 735 (graphics-operation
736 ("Copy" (("copy rectangle" copy-r "copy-r" 736 ("Copy" (("copy rectangle" copy-r "copy-r"
@@ -739,14 +739,14 @@ This variable is initialized by the artist-make-prev-next-op-alist function.")
739 2 739 2
740 artist-draw-rect 740 artist-draw-rect
741 (artist-undraw-rect 741 (artist-undraw-rect
742 artist-t artist-copy-rect) 742 artist-t artist-copy-rect))
743 ("copy square" copy-s "copy-s" 743 ("copy square" copy-s "copy-s"
744 artist-no-arrows nil 744 artist-no-arrows nil
745 nil nil nil 745 nil nil nil
746 2 746 2
747 artist-draw-square 747 artist-draw-square
748 (artist-undraw-square 748 (artist-undraw-square
749 artist-t artist-copy-square)))))) 749 artist-t artist-copy-square)))))
750 750
751 (graphics-operation 751 (graphics-operation
752 ("Paste" (("paste" paste "paste" 752 ("Paste" (("paste" paste "paste"
@@ -1375,6 +1375,9 @@ Keymap summary
1375;; Init and exit 1375;; Init and exit
1376(defun artist-mode-init () 1376(defun artist-mode-init ()
1377 "Init Artist mode. This will call the hook `artist-mode-init-hook'." 1377 "Init Artist mode. This will call the hook `artist-mode-init-hook'."
1378 ;; Set up a conversion table for mapping tabs and new-lines to spaces.
1379 ;; the last case, 0, is for the last position in buffer/region, where
1380 ;; the `following-char' function returns 0.
1378 (let ((i 0)) 1381 (let ((i 0))
1379 (while (< i 256) 1382 (while (< i 256)
1380 (aset artist-replacement-table i i) 1383 (aset artist-replacement-table i i)
@@ -1382,6 +1385,7 @@ Keymap summary
1382 (aset artist-replacement-table ?\n ?\s) 1385 (aset artist-replacement-table ?\n ?\s)
1383 (aset artist-replacement-table ?\t ?\s) 1386 (aset artist-replacement-table ?\t ?\s)
1384 (aset artist-replacement-table 0 ?\s) 1387 (aset artist-replacement-table 0 ?\s)
1388 ;; More setup
1385 (make-local-variable 'artist-key-is-drawing) 1389 (make-local-variable 'artist-key-is-drawing)
1386 (make-local-variable 'artist-key-endpoint1) 1390 (make-local-variable 'artist-key-endpoint1)
1387 (make-local-variable 'artist-key-poly-point-list) 1391 (make-local-variable 'artist-key-poly-point-list)
@@ -1944,10 +1948,21 @@ Also updates the variables `artist-draw-min-y' and `artist-draw-max-y'."
1944 (following-char)) 1948 (following-char))
1945 1949
1946 1950
1951(defsubst artist-get-replacement-char (c)
1952 "Retrieve a replacement for character C from `artist-replacement-table'.
1953The replacement is used to convert tabs and new-lines to spaces."
1954 ;; Characters may be outside the range of the `artist-replacement-table',
1955 ;; for example if they are unicode code points >= 256.
1956 ;; Check so we don't attempt to access the array out of its bounds,
1957 ;; assuming no such character needs to be replaced.
1958 (if (< c (length artist-replacement-table))
1959 (aref artist-replacement-table c)
1960 c))
1961
1947(defun artist-get-char-at-xy-conv (x y) 1962(defun artist-get-char-at-xy-conv (x y)
1948 "Retrieve the character at X, Y, converting tabs and new-lines to spaces." 1963 "Retrieve the character at X, Y, converting tabs and new-lines to spaces."
1949 (save-excursion 1964 (save-excursion
1950 (aref artist-replacement-table (artist-get-char-at-xy x y)))) 1965 (artist-get-replacement-char (artist-get-char-at-xy x y))))
1951 1966
1952 1967
1953(defun artist-replace-char (new-char) 1968(defun artist-replace-char (new-char)
@@ -1963,12 +1978,12 @@ Also updates the variables `artist-draw-min-y' and `artist-draw-max-y'."
1963 (artist-move-to-xy (1+ (artist-current-column)) 1978 (artist-move-to-xy (1+ (artist-current-column))
1964 (artist-current-line)) 1979 (artist-current-line))
1965 (delete-char -1) 1980 (delete-char -1)
1966 (insert (aref artist-replacement-table new-char))) 1981 (insert (artist-get-replacement-char new-char)))
1967 ;; In emacs-19, the self-insert-command works better and faster 1982 ;; In emacs-19, the self-insert-command works better and faster
1968 (let ((overwrite-mode 'overwrite-mode-textual) 1983 (let ((overwrite-mode 'overwrite-mode-textual)
1969 (fill-column 32765) ; Large :-) 1984 (fill-column 32765) ; Large :-)
1970 (blink-matching-paren nil)) 1985 (blink-matching-paren nil))
1971 (setq last-command-event (aref artist-replacement-table new-char)) 1986 (setq last-command-event (artist-get-replacement-char new-char))
1972 (self-insert-command 1)))) 1987 (self-insert-command 1))))
1973 1988
1974(defun artist-replace-chars (new-char count) 1989(defun artist-replace-chars (new-char count)
@@ -1980,7 +1995,7 @@ Also updates the variables `artist-draw-min-y' and `artist-draw-max-y'."
1980 ;; The self-insert-command doesn't care about the overwrite-mode, 1995 ;; The self-insert-command doesn't care about the overwrite-mode,
1981 ;; so the insertion is done in the same way as in picture mode. 1996 ;; so the insertion is done in the same way as in picture mode.
1982 ;; This seems to be a little bit slower. 1997 ;; This seems to be a little bit slower.
1983 (let* ((replaced-c (aref artist-replacement-table new-char)) 1998 (let* ((replaced-c (artist-get-replacement-char new-char))
1984 (replaced-s (make-string count replaced-c))) 1999 (replaced-s (make-string count replaced-c)))
1985 (artist-move-to-xy (+ (artist-current-column) count) 2000 (artist-move-to-xy (+ (artist-current-column) count)
1986 (artist-current-line)) 2001 (artist-current-line))
@@ -1990,7 +2005,7 @@ Also updates the variables `artist-draw-min-y' and `artist-draw-max-y'."
1990 (let ((overwrite-mode 'overwrite-mode-textual) 2005 (let ((overwrite-mode 'overwrite-mode-textual)
1991 (fill-column 32765) ; Large :-) 2006 (fill-column 32765) ; Large :-)
1992 (blink-matching-paren nil)) 2007 (blink-matching-paren nil))
1993 (setq last-command-event (aref artist-replacement-table new-char)) 2008 (setq last-command-event (artist-get-replacement-char new-char))
1994 (self-insert-command count)))) 2009 (self-insert-command count))))
1995 2010
1996(defsubst artist-replace-string (string &optional see-thru) 2011(defsubst artist-replace-string (string &optional see-thru)
@@ -2003,7 +2018,7 @@ With optional argument SEE-THRU, set to non-nil, text in the buffer
2003 (blink-matching-paren nil)) 2018 (blink-matching-paren nil))
2004 (while char-list 2019 (while char-list
2005 (let ((c (car char-list))) 2020 (let ((c (car char-list)))
2006 (if (and see-thru (= (aref artist-replacement-table c) ?\s)) 2021 (if (and see-thru (= (artist-get-replacement-char c) ?\s))
2007 (artist-move-to-xy (1+ (artist-current-column)) 2022 (artist-move-to-xy (1+ (artist-current-column))
2008 (artist-current-line)) 2023 (artist-current-line))
2009 (artist-replace-char c))) 2024 (artist-replace-char c)))