comparison lisp/simple.el @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 1ccc32a20af4
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
106 (defun no-upper-case-p (string &optional regexp-flag) 106 (defun no-upper-case-p (string &optional regexp-flag)
107 "Return t if there are no upper case chars in STRING. 107 "Return t if there are no upper case chars in STRING.
108 If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\') 108 If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\')
109 since they have special meaning in a regexp." 109 since they have special meaning in a regexp."
110 (let ((case-fold-search nil)) 110 (let ((case-fold-search nil))
111 (not (string-match (if regexp-flag 111 (not (string-match (if regexp-flag
112 "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]" 112 "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]"
113 "[A-Z]") 113 "[A-Z]")
114 string)) 114 string))
115 )) 115 ))
116 116
117 (defmacro with-search-caps-disable-folding (string regexp-flag &rest body) "\ 117 (defmacro with-search-caps-disable-folding (string regexp-flag &rest body) "\
118 Eval BODY with `case-fold-search' let to nil if `search-caps-disable-folding' 118 Eval BODY with `case-fold-search' let to nil if `search-caps-disable-folding'
119 is non-nil, and if STRING (either a string or a regular expression according 119 is non-nil, and if STRING (either a string or a regular expression according
120 to REGEXP-FLAG) contains uppercase letters." 120 to REGEXP-FLAG) contains uppercase letters."
121 `(let ((case-fold-search 121 `(let ((case-fold-search
122 (if (and case-fold-search search-caps-disable-folding) 122 (if (and case-fold-search search-caps-disable-folding)
123 (no-upper-case-p ,string ,regexp-flag) 123 (no-upper-case-p ,string ,regexp-flag)
124 case-fold-search))) 124 case-fold-search)))
125 ,@body)) 125 ,@body))
126 (put 'with-search-caps-disable-folding 'lisp-indent-function 2) 126 (put 'with-search-caps-disable-folding 'lisp-indent-function 2)
127 (put 'with-search-caps-disable-folding 'edebug-form-spec 127 (put 'with-search-caps-disable-folding 'edebug-form-spec
128 '(sexp sexp &rest form)) 128 '(sexp sexp &rest form))
129 129
130 (defmacro with-interactive-search-caps-disable-folding (string regexp-flag 130 (defmacro with-interactive-search-caps-disable-folding (string regexp-flag
131 &rest body) 131 &rest body)
132 "Same as `with-search-caps-disable-folding', but only in the case of a 132 "Same as `with-search-caps-disable-folding', but only in the case of a
133 function called interactively." 133 function called interactively."
134 `(let ((case-fold-search 134 `(let ((case-fold-search
135 (if (and (interactive-p) 135 (if (and (interactive-p)
136 case-fold-search search-caps-disable-folding) 136 case-fold-search search-caps-disable-folding)
137 (no-upper-case-p ,string ,regexp-flag) 137 (no-upper-case-p ,string ,regexp-flag)
138 case-fold-search))) 138 case-fold-search)))
139 ,@body)) 139 ,@body))
140 (put 'with-interactive-search-caps-disable-folding 'lisp-indent-function 2) 140 (put 'with-interactive-search-caps-disable-folding 'lisp-indent-function 2)
141 (put 'with-interactive-search-caps-disable-folding 'edebug-form-spec 141 (put 'with-interactive-search-caps-disable-folding 'edebug-form-spec
142 '(sexp sexp &rest form)) 142 '(sexp sexp &rest form))
143 143
144 (defun newline (&optional arg) 144 (defun newline (&optional n)
145 "Insert a newline, and move to left margin of the new line if it's blank. 145 "Insert a newline, and move to left margin of the new line if it's blank.
146 The newline is marked with the text-property `hard'. 146 The newline is marked with the text-property `hard'.
147 With arg, insert that many newlines. 147 With optional arg N, insert that many newlines.
148 In Auto Fill mode, if no numeric arg, break the preceding line if it's long." 148 In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
149 (interactive "*P") 149 (interactive "*P")
150 (barf-if-buffer-read-only nil (point)) 150 (barf-if-buffer-read-only nil (point))
151 ;; Inserting a newline at the end of a line produces better redisplay in 151 ;; Inserting a newline at the end of a line produces better redisplay in
152 ;; try_window_id than inserting at the beginning of a line, and the textual 152 ;; try_window_id than inserting at the beginning of a line, and the textual
176 ;; Set last-command-char to tell self-insert what to insert. 176 ;; Set last-command-char to tell self-insert what to insert.
177 (let ((last-command-char ?\n) 177 (let ((last-command-char ?\n)
178 ;; Don't auto-fill if we have a numeric argument. 178 ;; Don't auto-fill if we have a numeric argument.
179 ;; Also not if flag is true (it would fill wrong line); 179 ;; Also not if flag is true (it would fill wrong line);
180 ;; there is no need to since we're at BOL. 180 ;; there is no need to since we're at BOL.
181 (auto-fill-function (if (or arg flag) nil auto-fill-function))) 181 (auto-fill-function (if (or n flag) nil auto-fill-function)))
182 (unwind-protect 182 (unwind-protect
183 (self-insert-command (prefix-numeric-value arg)) 183 (self-insert-command (prefix-numeric-value n))
184 ;; If we get an error in self-insert-command, put point at right place. 184 ;; If we get an error in self-insert-command, put point at right place.
185 (if flag (forward-char 1)))) 185 (if flag (forward-char 1))))
186 ;; If we did *not* get an error, cancel that forward-char. 186 ;; If we did *not* get an error, cancel that forward-char.
187 (if flag (backward-char 1)) 187 (if flag (backward-char 1))
188 ;; Mark the newline(s) `hard'. 188 ;; Mark the newline(s) `hard'.
189 (if use-hard-newlines 189 (if use-hard-newlines
190 (let* ((from (- (point) (if arg (prefix-numeric-value arg) 1))) 190 (let* ((from (- (point) (if n (prefix-numeric-value n) 1)))
191 (sticky (get-text-property from 'end-open))) ; XEmacs 191 (sticky (get-text-property from 'end-open))) ; XEmacs
192 (put-text-property from (point) 'hard 't) 192 (put-text-property from (point) 'hard 't)
193 ;; If end-open is not "t", add 'hard to end-open list 193 ;; If end-open is not "t", add 'hard to end-open list
194 (if (and (listp sticky) (not (memq 'hard sticky))) 194 (if (and (listp sticky) (not (memq 'hard sticky)))
195 (put-text-property from (point) 'end-open ; XEmacs 195 (put-text-property from (point) 'end-open ; XEmacs
217 ;; If rear-nonsticky is not "t", add 'hard to rear-nonsticky list 217 ;; If rear-nonsticky is not "t", add 'hard to rear-nonsticky list
218 (if (and (listp sticky) (not (memq 'hard sticky))) 218 (if (and (listp sticky) (not (memq 'hard sticky)))
219 (put-text-property from (point) 'rear-nonsticky 219 (put-text-property from (point) 'rear-nonsticky
220 (cons 'hard sticky))))) 220 (cons 'hard sticky)))))
221 221
222 (defun open-line (arg) 222 (defun open-line (n)
223 "Insert a newline and leave point before it. 223 "Insert a newline and leave point before it.
224 If there is a fill prefix and/or a left-margin, insert them on the new line 224 If there is a fill prefix and/or a left-margin, insert them on the new line
225 if the line would have been blank. 225 if the line would have been blank.
226 With arg N, insert N newlines." 226 With arg N, insert N newlines."
227 (interactive "*p") 227 (interactive "*p")
228 (let* ((do-fill-prefix (and fill-prefix (bolp))) 228 (let* ((do-fill-prefix (and fill-prefix (bolp)))
229 (do-left-margin (and (bolp) (> (current-left-margin) 0))) 229 (do-left-margin (and (bolp) (> (current-left-margin) 0)))
230 (loc (point))) 230 (loc (point)))
231 (newline arg) 231 (newline n)
232 (goto-char loc) 232 (goto-char loc)
233 (while (> arg 0) 233 (while (> n 0)
234 (cond ((bolp) 234 (cond ((bolp)
235 (if do-left-margin (indent-to (current-left-margin))) 235 (if do-left-margin (indent-to (current-left-margin)))
236 (if do-fill-prefix (insert fill-prefix)))) 236 (if do-fill-prefix (insert fill-prefix))))
237 (forward-line 1) 237 (forward-line 1)
238 (setq arg (1- arg))) 238 (setq n (1- n)))
239 (goto-char loc) 239 (goto-char loc)
240 (end-of-line))) 240 (end-of-line)))
241 241
242 (defun split-line () 242 (defun split-line ()
243 "Split current line, moving portion beyond point vertically down." 243 "Split current line, moving portion beyond point vertically down."
825 (setq values (cons (eval expression) values)) 825 (setq values (cons (eval expression) values))
826 (prin1 (car values) 826 (prin1 (car values)
827 (if eval-expression-insert-value (current-buffer) t))) 827 (if eval-expression-insert-value (current-buffer) t)))
828 828
829 ;; XEmacs -- extra parameter (variant, but equivalent logic) 829 ;; XEmacs -- extra parameter (variant, but equivalent logic)
830 (defun edit-and-eval-command (prompt command &optional history) 830 (defun edit-and-eval-command (prompt form &optional history)
831 "Prompting with PROMPT, let user edit COMMAND and eval result. 831 "Prompting with PROMPT, let user edit FORM and eval result.
832 COMMAND is a Lisp expression. Let user edit that expression in 832 FORM is a Lisp expression. Let user edit that expression in
833 the minibuffer, then read and evaluate the result." 833 the minibuffer, then read and evaluate the result."
834 (let ((command (read-expression prompt 834 (let ((form (read-expression prompt
835 ;; first try to format the thing readably; 835 ;; first try to format the thing readably;
836 ;; and if that fails, print it normally. 836 ;; and if that fails, print it normally.
837 (condition-case () 837 (condition-case ()
838 (let ((print-readably t)) 838 (let ((print-readably t))
839 (prin1-to-string command)) 839 (prin1-to-string form))
840 (error (prin1-to-string command))) 840 (error (prin1-to-string form)))
841 (or history '(command-history . 1))))) 841 (or history '(command-history . 1)))))
842 (or history (setq history 'command-history)) 842 (or history (setq history 'command-history))
843 (if (consp history) 843 (if (consp history)
844 (setq history (car history))) 844 (setq history (car history)))
845 (if (eq history t) 845 (if (eq history t)
846 nil 846 nil
847 ;; If command was added to the history as a string, 847 ;; If form was added to the history as a string,
848 ;; get rid of that. We want only evallable expressions there. 848 ;; get rid of that. We want only evallable expressions there.
849 (if (stringp (car (symbol-value history))) 849 (if (stringp (car (symbol-value history)))
850 (set history (cdr (symbol-value history)))) 850 (set history (cdr (symbol-value history))))
851 851
852 ;; If command to be redone does not match front of history, 852 ;; If form to be redone does not match front of history,
853 ;; add it to the history. 853 ;; add it to the history.
854 (or (equal command (car (symbol-value history))) 854 (or (equal form (car (symbol-value history)))
855 (set history (cons command (symbol-value history))))) 855 (set history (cons form (symbol-value history)))))
856 (eval command))) 856 (eval form)))
857 857
858 (defun repeat-complex-command (arg) 858 (defun repeat-complex-command (arg)
859 "Edit and re-evaluate last complex command, or ARGth from last. 859 "Edit and re-evaluate last complex command, or ARGth from last.
860 A complex command is one which used the minibuffer. 860 A complex command is one which used the minibuffer.
861 The command is placed in the minibuffer as a Lisp form for editing. 861 The command is placed in the minibuffer as a Lisp form for editing.
878 ;; next-history-element 878 ;; next-history-element
879 ;; previous-history-element 879 ;; previous-history-element
880 ;; next-complete-history-element 880 ;; next-complete-history-element
881 ;; previous-complete-history-element 881 ;; previous-complete-history-element
882 882
883 (defun goto-line (arg) 883 (defun goto-line (line)
884 "Goto line ARG, counting from line 1 at beginning of buffer." 884 "Goto line LINE, counting from line 1 at beginning of buffer."
885 (interactive "NGoto line: ") 885 (interactive "NGoto line: ")
886 (setq arg (prefix-numeric-value arg)) 886 (setq line (prefix-numeric-value line))
887 (save-restriction 887 (save-restriction
888 (widen) 888 (widen)
889 (goto-char 1) 889 (goto-char 1)
890 (if (eq selective-display t) 890 (if (eq selective-display t)
891 (re-search-forward "[\n\C-m]" nil 'end (1- arg)) 891 (re-search-forward "[\n\C-m]" nil 'end (1- line))
892 (forward-line (1- arg))))) 892 (forward-line (1- line)))))
893 893
894 ;Put this on C-x u, so we can force that rather than C-_ into startup msg 894 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
895 (define-function 'advertised-undo 'undo) 895 (define-function 'advertised-undo 'undo)
896 896
897 (defun undo (&optional arg) 897 (defun undo (&optional count)
898 "Undo some previous changes. 898 "Undo some previous changes.
899 Repeat this command to undo more changes. 899 Repeat this command to undo more changes.
900 A numeric argument serves as a repeat count." 900 A numeric argument serves as a repeat count."
901 (interactive "*p") 901 (interactive "*p")
902 ;; If we don't get all the way through, make last-command indicate that 902 ;; If we don't get all the way through, make last-command indicate that
908 (display-message 'command "Undo!")) 908 (display-message 'command "Undo!"))
909 (or (and (eq last-command 'undo) 909 (or (and (eq last-command 'undo)
910 (eq (current-buffer) last-undo-buffer)) ; XEmacs 910 (eq (current-buffer) last-undo-buffer)) ; XEmacs
911 (progn (undo-start) 911 (progn (undo-start)
912 (undo-more 1))) 912 (undo-more 1)))
913 (undo-more (or arg 1)) 913 (undo-more (or count 1))
914 ;; Don't specify a position in the undo record for the undo command. 914 ;; Don't specify a position in the undo record for the undo command.
915 ;; Instead, undoing this should move point to where the change is. 915 ;; Instead, undoing this should move point to where the change is.
916 (let ((tail buffer-undo-list) 916 (let ((tail buffer-undo-list)
917 done) 917 done)
918 (while (and tail (not done) (not (null (car tail)))) 918 (while (and tail (not done) (not (null (car tail))))
1088 (reset-this-command-lengths) 1088 (reset-this-command-lengths)
1089 (setq overriding-terminal-local-map nil)) 1089 (setq overriding-terminal-local-map nil))
1090 1090
1091 1091
1092 ;; XEmacs -- keep zmacs-region active. 1092 ;; XEmacs -- keep zmacs-region active.
1093 (defun forward-to-indentation (arg) 1093 (defun forward-to-indentation (count)
1094 "Move forward ARG lines and position at first nonblank character." 1094 "Move forward COUNT lines and position at first nonblank character."
1095 (interactive "_p") 1095 (interactive "_p")
1096 (forward-line arg) 1096 (forward-line count)
1097 (skip-chars-forward " \t")) 1097 (skip-chars-forward " \t"))
1098 1098
1099 (defun backward-to-indentation (arg) 1099 (defun backward-to-indentation (count)
1100 "Move backward ARG lines and position at first nonblank character." 1100 "Move backward COUNT lines and position at first nonblank character."
1101 (interactive "_p") 1101 (interactive "_p")
1102 (forward-line (- arg)) 1102 (forward-line (- count))
1103 (skip-chars-forward " \t")) 1103 (skip-chars-forward " \t"))
1104 1104
1105 (defcustom kill-whole-line nil 1105 (defcustom kill-whole-line nil
1106 "*Control when and whether `kill-line' removes entire lines. 1106 "*Control when and whether `kill-line' removes entire lines.
1107 Note: This only applies when `kill-line' is called interactively; 1107 Note: This only applies when `kill-line' is called interactively;
1269 (defvar kill-ring-yank-pointer nil 1269 (defvar kill-ring-yank-pointer nil
1270 "The tail of the kill ring whose car is the last thing yanked.") 1270 "The tail of the kill ring whose car is the last thing yanked.")
1271 1271
1272 (defun kill-new (string &optional replace) 1272 (defun kill-new (string &optional replace)
1273 "Make STRING the latest kill in the kill ring. 1273 "Make STRING the latest kill in the kill ring.
1274 Set the kill-ring-yank pointer to point to it. 1274 Set `kill-ring-yank-pointer' to point to it.
1275 Run `kill-hooks'. 1275 Run `kill-hooks'.
1276 Optional second argument REPLACE non-nil means that STRING will replace 1276 Optional second argument REPLACE non-nil means that STRING will replace
1277 the front of the kill ring, rather than being added to the list." 1277 the front of the kill ring, rather than being added to the list."
1278 ; (and (fboundp 'menu-bar-update-yank-menu) 1278 ; (and (fboundp 'menu-bar-update-yank-menu)
1279 ; (menu-bar-update-yank-menu string (and replace (car kill-ring)))) 1279 ; (menu-bar-update-yank-menu string (and replace (car kill-ring))))
1329 ;; is a very bad idea -- see Jamie's comment below. 1329 ;; is a very bad idea -- see Jamie's comment below.
1330 1330
1331 ;(defvar kill-read-only-ok nil 1331 ;(defvar kill-read-only-ok nil
1332 ; "*Non-nil means don't signal an error for killing read-only text.") 1332 ; "*Non-nil means don't signal an error for killing read-only text.")
1333 1333
1334 (defun kill-region (beg end &optional verbose) ; verbose is XEmacs addition 1334 (defun kill-region (start end &optional verbose) ; verbose is XEmacs addition
1335 "Kill between point and mark. 1335 "Kill between point and mark.
1336 The text is deleted but saved in the kill ring. 1336 The text is deleted but saved in the kill ring.
1337 The command \\[yank] can retrieve it from there. 1337 The command \\[yank] can retrieve it from there.
1338 \(If you want to kill and then yank immediately, use \\[copy-region-as-kill].) 1338 \(If you want to kill and then yank immediately, use \\[copy-region-as-kill].)
1339 1339
1350 ; ;; This lets "^Y^W" work. I think this is dumb, but zwei did it. 1350 ; ;; This lets "^Y^W" work. I think this is dumb, but zwei did it.
1351 ; (if region-hack (zmacs-activate-region)) 1351 ; (if region-hack (zmacs-activate-region))
1352 ; (prog1 1352 ; (prog1
1353 ; (list (point) (mark) current-prefix-arg) 1353 ; (list (point) (mark) current-prefix-arg)
1354 ; (if region-hack (zmacs-deactivate-region))))) 1354 ; (if region-hack (zmacs-deactivate-region)))))
1355 ;; beg and end can be markers but the rest of this function is 1355 ;; start and end can be markers but the rest of this function is
1356 ;; written as if they are only integers 1356 ;; written as if they are only integers
1357 (if (markerp beg) (setq beg (marker-position beg))) 1357 (if (markerp start) (setq start (marker-position start)))
1358 (if (markerp end) (setq end (marker-position end))) 1358 (if (markerp end) (setq end (marker-position end)))
1359 (or (and beg end) (if zmacs-regions ;; rewritten for I18N3 snarfing 1359 (or (and start end) (if zmacs-regions ;; rewritten for I18N3 snarfing
1360 (error "The region is not active now") 1360 (error "The region is not active now")
1361 (error "The mark is not set now"))) 1361 (error "The mark is not set now")))
1362 (if verbose (if buffer-read-only 1362 (if verbose (if buffer-read-only
1363 (lmessage 'command "Copying %d characters" 1363 (lmessage 'command "Copying %d characters"
1364 (- (max beg end) (min beg end))) 1364 (- (max start end) (min start end)))
1365 (lmessage 'command "Killing %d characters" 1365 (lmessage 'command "Killing %d characters"
1366 (- (max beg end) (min beg end))))) 1366 (- (max start end) (min start end)))))
1367 (cond 1367 (cond
1368 1368
1369 ;; I don't like this large change in behavior -- jwz 1369 ;; I don't like this large change in behavior -- jwz
1370 ;; Read-Only text means it shouldn't be deleted, so I'm restoring 1370 ;; Read-Only text means it shouldn't be deleted, so I'm restoring
1371 ;; this code, but only for text-properties and not full extents. -sb 1371 ;; this code, but only for text-properties and not full extents. -sb
1372 ;; If the buffer is read-only, we should beep, in case the person 1372 ;; If the buffer is read-only, we should beep, in case the person
1373 ;; just isn't aware of this. However, there's no harm in putting 1373 ;; just isn't aware of this. However, there's no harm in putting
1374 ;; the region's text in the kill ring, anyway. 1374 ;; the region's text in the kill ring, anyway.
1375 ((or (and buffer-read-only (not inhibit-read-only)) 1375 ((or (and buffer-read-only (not inhibit-read-only))
1376 (text-property-not-all (min beg end) (max beg end) 'read-only nil)) 1376 (text-property-not-all (min start end) (max start end) 'read-only nil))
1377 ;; This is redundant. 1377 ;; This is redundant.
1378 ;; (if verbose (message "Copying %d characters" 1378 ;; (if verbose (message "Copying %d characters"
1379 ;; (- (max beg end) (min beg end)))) 1379 ;; (- (max start end) (min start end))))
1380 (copy-region-as-kill beg end) 1380 (copy-region-as-kill start end)
1381 ;; ;; This should always barf, and give us the correct error. 1381 ;; ;; This should always barf, and give us the correct error.
1382 ;; (if kill-read-only-ok 1382 ;; (if kill-read-only-ok
1383 ;; (message "Read only text copied to kill ring") 1383 ;; (message "Read only text copied to kill ring")
1384 (setq this-command 'kill-region) 1384 (setq this-command 'kill-region)
1385 (barf-if-buffer-read-only) 1385 (barf-if-buffer-read-only)
1388 ;; In certain cases, we can arrange for the undo list and the kill 1388 ;; In certain cases, we can arrange for the undo list and the kill
1389 ;; ring to share the same string object. This code does that. 1389 ;; ring to share the same string object. This code does that.
1390 ((not (or (eq buffer-undo-list t) 1390 ((not (or (eq buffer-undo-list t)
1391 (eq last-command 'kill-region) 1391 (eq last-command 'kill-region)
1392 ;; Use = since positions may be numbers or markers. 1392 ;; Use = since positions may be numbers or markers.
1393 (= beg end))) 1393 (= start end)))
1394 ;; Don't let the undo list be truncated before we can even access it. 1394 ;; Don't let the undo list be truncated before we can even access it.
1395 ;; FSF calls this `undo-strong-limit' 1395 ;; FSF calls this `undo-strong-limit'
1396 (let ((undo-high-threshold (+ (- end beg) 100)) 1396 (let ((undo-high-threshold (+ (- end start) 100))
1397 ;(old-list buffer-undo-list) 1397 ;(old-list buffer-undo-list)
1398 tail) 1398 tail)
1399 (delete-region beg end) 1399 (delete-region start end)
1400 ;; Search back in buffer-undo-list for this string, 1400 ;; Search back in buffer-undo-list for this string,
1401 ;; in case a change hook made property changes. 1401 ;; in case a change hook made property changes.
1402 (setq tail buffer-undo-list) 1402 (setq tail buffer-undo-list)
1403 (while (and tail 1403 (while (and tail
1404 (not (stringp (car-safe (car-safe tail))))) ; XEmacs 1404 (not (stringp (car-safe (car-safe tail))))) ; XEmacs
1409 (kill-new (car (car tail)))))) 1409 (kill-new (car (car tail))))))
1410 1410
1411 (t 1411 (t
1412 ;; if undo is not kept, grab the string then delete it (which won't 1412 ;; if undo is not kept, grab the string then delete it (which won't
1413 ;; add another string to the undo list). 1413 ;; add another string to the undo list).
1414 (copy-region-as-kill beg end) 1414 (copy-region-as-kill start end)
1415 (delete-region beg end))) 1415 (delete-region start end)))
1416 (setq this-command 'kill-region)) 1416 (setq this-command 'kill-region))
1417 1417
1418 ;; copy-region-as-kill no longer sets this-command, because it's confusing 1418 ;; copy-region-as-kill no longer sets this-command, because it's confusing
1419 ;; to get two copies of the text when the user accidentally types M-w and 1419 ;; to get two copies of the text when the user accidentally types M-w and
1420 ;; then corrects it with the intended C-w. 1420 ;; then corrects it with the intended C-w.
1421 (defun copy-region-as-kill (beg end) 1421 (defun copy-region-as-kill (start end)
1422 "Save the region as if killed, but don't kill it. 1422 "Save the region as if killed, but don't kill it.
1423 Run `kill-hooks'." 1423 Run `kill-hooks'."
1424 (interactive "r") 1424 (interactive "r")
1425 (if (eq last-command 'kill-region) 1425 (if (eq last-command 'kill-region)
1426 (kill-append (buffer-substring beg end) (< end beg)) 1426 (kill-append (buffer-substring start end) (< end start))
1427 (kill-new (buffer-substring beg end))) 1427 (kill-new (buffer-substring start end)))
1428 nil) 1428 nil)
1429 1429
1430 (defun kill-ring-save (beg end) 1430 (defun kill-ring-save (start end)
1431 "Save the region as if killed, but don't kill it. 1431 "Save the region as if killed, but don't kill it.
1432 This command is similar to `copy-region-as-kill', except that it gives 1432 This command is similar to `copy-region-as-kill', except that it gives
1433 visual feedback indicating the extent of the region being copied." 1433 visual feedback indicating the extent of the region being copied."
1434 (interactive "r") 1434 (interactive "r")
1435 (copy-region-as-kill beg end) 1435 (copy-region-as-kill start end)
1436 ;; copy before delay, for xclipboard's benefit 1436 ;; copy before delay, for xclipboard's benefit
1437 (if (interactive-p) 1437 (if (interactive-p)
1438 (let ((other-end (if (= (point) beg) end beg)) 1438 (let ((other-end (if (= (point) start) end start))
1439 (opoint (point)) 1439 (opoint (point))
1440 ;; Inhibit quitting so we can make a quit here 1440 ;; Inhibit quitting so we can make a quit here
1441 ;; look like a C-g typed as a command. 1441 ;; look like a C-g typed as a command.
1442 (inhibit-quit t)) 1442 (inhibit-quit t))
1443 (if (pos-visible-in-window-p other-end (selected-window)) 1443 (if (pos-visible-in-window-p other-end (selected-window))
1455 (and quit-flag (mark) 1455 (and quit-flag (mark)
1456 (zmacs-deactivate-region))) 1456 (zmacs-deactivate-region)))
1457 ;; too noisy. -- jwz 1457 ;; too noisy. -- jwz
1458 ; (let* ((killed-text (current-kill 0)) 1458 ; (let* ((killed-text (current-kill 0))
1459 ; (message-len (min (length killed-text) 40))) 1459 ; (message-len (min (length killed-text) 40)))
1460 ; (if (= (point) beg) 1460 ; (if (= (point) start)
1461 ; ;; Don't say "killed"; that is misleading. 1461 ; ;; Don't say "killed"; that is misleading.
1462 ; (message "Saved text until \"%s\"" 1462 ; (message "Saved text until \"%s\""
1463 ; (substring killed-text (- message-len))) 1463 ; (substring killed-text (- message-len)))
1464 ; (message "Saved text from \"%s\"" 1464 ; (message "Saved text from \"%s\""
1465 ; (substring killed-text 0 message-len)))) 1465 ; (substring killed-text 0 message-len))))
1654 That is to say, don't use this function unless you want 1654 That is to say, don't use this function unless you want
1655 the user to see that the mark has moved, and you want the previous 1655 the user to see that the mark has moved, and you want the previous
1656 mark position to be lost. 1656 mark position to be lost.
1657 1657
1658 Normally, when a new mark is set, the old one should go on the stack. 1658 Normally, when a new mark is set, the old one should go on the stack.
1659 This is why most applications should use push-mark, not set-mark. 1659 This is why most applications should use `push-mark', not `set-mark'.
1660 1660
1661 Novice Emacs Lisp programmers often try to use the mark for the wrong 1661 Novice Emacs Lisp programmers often try to use the mark for the wrong
1662 purposes. The mark saves a location for the user's convenience. 1662 purposes. The mark saves a location for the user's convenience.
1663 Most editing commands should not alter the mark. 1663 Most editing commands should not alter the mark.
1664 To remember a location for internal use in the Lisp program, 1664 To remember a location for internal use in the Lisp program,
1665 store it in a Lisp variable. Example: 1665 store it in a Lisp variable. Example:
1666 1666
1667 (let ((beg (point))) (forward-line 1) (delete-region beg (point)))." 1667 (let ((start (point))) (forward-line 1) (delete-region start (point)))."
1668 1668
1669 (setq buffer (decode-buffer buffer)) 1669 (setq buffer (decode-buffer buffer))
1670 (set-marker (mark-marker t buffer) pos buffer)) 1670 (set-marker (mark-marker t buffer) pos buffer))
1671 ;; FSF 1671 ;; FSF
1672 ; (if pos 1672 ; (if pos
1958 (and (key-press-event-p last-input-event) 1958 (and (key-press-event-p last-input-event)
1959 (memq (event-key last-input-event) 1959 (memq (event-key last-input-event)
1960 '(left right up down home end prior next 1960 '(left right up down home end prior next
1961 kp-left kp-right kp-up kp-down 1961 kp-left kp-right kp-up kp-down
1962 kp-home kp-end kp-prior kp-next)))) 1962 kp-home kp-end kp-prior kp-next))))
1963 1963
1964 (defun handle-pre-motion-command () 1964 (defun handle-pre-motion-command ()
1965 (if 1965 (if
1966 (and 1966 (and
1967 (handle-pre-motion-command-current-command-is-motion) 1967 (handle-pre-motion-command-current-command-is-motion)
1968 zmacs-regions 1968 zmacs-regions
2026 boundaries do not cause an error to be signaled." 2026 boundaries do not cause an error to be signaled."
2027 (interactive "_") 2027 (interactive "_")
2028 (scroll-up-command 1)) 2028 (scroll-up-command 1))
2029 2029
2030 (defun scroll-up-command (&optional n) 2030 (defun scroll-up-command (&optional n)
2031 "Scroll text of current window upward ARG lines; or near full screen if no ARG. 2031 "Scroll current window upward N lines; or near full screen if N is nil.
2032 A near full screen is `next-screen-context-lines' less than a full screen. 2032 A near full screen is `next-screen-context-lines' less than a full screen.
2033 Negative ARG means scroll downward. 2033 Negative N means scroll downward.
2034 When calling from a program, supply a number as argument or nil. 2034 When calling from a program, supply a number as argument or nil.
2035 On attempt to scroll past end of buffer, `end-of-buffer' is signaled. 2035 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
2036 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is 2036 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
2037 signaled. 2037 signaled.
2038 2038
2056 boundaries do not cause an error to be signaled." 2056 boundaries do not cause an error to be signaled."
2057 (interactive "_") 2057 (interactive "_")
2058 (scroll-down-command 1)) 2058 (scroll-down-command 1))
2059 2059
2060 (defun scroll-down-command (&optional n) 2060 (defun scroll-down-command (&optional n)
2061 "Scroll text of current window downward ARG lines; or near full screen if no ARG. 2061 "Scroll current window downward N lines; or near full screen if N is nil.
2062 A near full screen is `next-screen-context-lines' less than a full screen. 2062 A near full screen is `next-screen-context-lines' less than a full screen.
2063 Negative ARG means scroll upward. 2063 Negative N means scroll upward.
2064 When calling from a program, supply a number as argument or nil. 2064 When calling from a program, supply a number as argument or nil.
2065 On attempt to scroll past end of buffer, `end-of-buffer' is signaled. 2065 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
2066 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is 2066 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
2067 signaled. 2067 signaled.
2068 2068
2074 (condition-case nil 2074 (condition-case nil
2075 (scroll-down n) 2075 (scroll-down n)
2076 (beginning-of-buffer nil) 2076 (beginning-of-buffer nil)
2077 (end-of-buffer nil)))) 2077 (end-of-buffer nil))))
2078 2078
2079 (defun next-line (arg) 2079 (defun next-line (count)
2080 "Move cursor vertically down ARG lines. 2080 "Move cursor vertically down COUNT lines.
2081 If there is no character in the target line exactly under the current column, 2081 If there is no character in the target line exactly under the current column,
2082 the cursor is positioned after the character in that line which spans this 2082 the cursor is positioned after the character in that line which spans this
2083 column, or at the end of the line if it is not long enough. 2083 column, or at the end of the line if it is not long enough.
2084 2084
2085 If there is no line in the buffer after this one, behavior depends on the 2085 If there is no line in the buffer after this one, behavior depends on the
2094 2094
2095 If you are thinking of using this in a Lisp program, consider 2095 If you are thinking of using this in a Lisp program, consider
2096 using `forward-line' instead. It is usually easier to use 2096 using `forward-line' instead. It is usually easier to use
2097 and more reliable (no dependence on goal column, etc.)." 2097 and more reliable (no dependence on goal column, etc.)."
2098 (interactive "_p") 2098 (interactive "_p")
2099 (if (and next-line-add-newlines (= arg 1)) 2099 (if (and next-line-add-newlines (= count 1))
2100 (let ((opoint (point))) 2100 (let ((opoint (point)))
2101 (end-of-line) 2101 (end-of-line)
2102 (if (eobp) 2102 (if (eobp)
2103 (newline 1) 2103 (newline 1)
2104 (goto-char opoint) 2104 (goto-char opoint)
2105 (line-move arg))) 2105 (line-move count)))
2106 (if (interactive-p) 2106 (if (interactive-p)
2107 ;; XEmacs: Not sure what to do about this. It's inconsistent. -sb 2107 ;; XEmacs: Not sure what to do about this. It's inconsistent. -sb
2108 (condition-case nil 2108 (condition-case nil
2109 (line-move arg) 2109 (line-move count)
2110 ((beginning-of-buffer end-of-buffer) 2110 ((beginning-of-buffer end-of-buffer)
2111 (when signal-error-on-buffer-boundary 2111 (when signal-error-on-buffer-boundary
2112 (ding nil 'buffer-bound)))) 2112 (ding nil 'buffer-bound))))
2113 (line-move arg))) 2113 (line-move count)))
2114 nil) 2114 nil)
2115 2115
2116 (defun previous-line (arg) 2116 (defun previous-line (count)
2117 "Move cursor vertically up ARG lines. 2117 "Move cursor vertically up COUNT lines.
2118 If there is no character in the target line exactly over the current column, 2118 If there is no character in the target line exactly over the current column,
2119 the cursor is positioned after the character in that line which spans this 2119 the cursor is positioned after the character in that line which spans this
2120 column, or at the end of the line if it is not long enough. 2120 column, or at the end of the line if it is not long enough.
2121 2121
2122 The command \\[set-goal-column] can be used to create 2122 The command \\[set-goal-column] can be used to create
2127 `forward-line' with a negative argument instead. It is usually easier 2127 `forward-line' with a negative argument instead. It is usually easier
2128 to use and more reliable (no dependence on goal column, etc.)." 2128 to use and more reliable (no dependence on goal column, etc.)."
2129 (interactive "_p") 2129 (interactive "_p")
2130 (if (interactive-p) 2130 (if (interactive-p)
2131 (condition-case nil 2131 (condition-case nil
2132 (line-move (- arg)) 2132 (line-move (- count))
2133 ((beginning-of-buffer end-of-buffer) 2133 ((beginning-of-buffer end-of-buffer)
2134 (when signal-error-on-buffer-boundary ; XEmacs 2134 (when signal-error-on-buffer-boundary ; XEmacs
2135 (ding nil 'buffer-bound)))) 2135 (ding nil 'buffer-bound))))
2136 (line-move (- arg))) 2136 (line-move (- count)))
2137 nil) 2137 nil)
2138 2138
2139 (defcustom block-movement-size 6 2139 (defcustom block-movement-size 6
2140 "*Number of lines that \"block movement\" commands (\\[forward-block-of-lines], \\[backward-block-of-lines]) move by." 2140 "*Number of lines that \"block movement\" commands (\\[forward-block-of-lines], \\[backward-block-of-lines]) move by."
2141 :type 'integer 2141 :type 'integer
2184 Use with care, as it slows down movement significantly. Outline mode sets this." 2184 Use with care, as it slows down movement significantly. Outline mode sets this."
2185 :type 'boolean 2185 :type 'boolean
2186 :group 'editing-basics) 2186 :group 'editing-basics)
2187 2187
2188 ;; This is the guts of next-line and previous-line. 2188 ;; This is the guts of next-line and previous-line.
2189 ;; Arg says how many lines to move. 2189 ;; Count says how many lines to move.
2190 (defun line-move (arg) 2190 (defun line-move (count)
2191 ;; Don't run any point-motion hooks, and disregard intangibility, 2191 ;; Don't run any point-motion hooks, and disregard intangibility,
2192 ;; for intermediate positions. 2192 ;; for intermediate positions.
2193 (let ((inhibit-point-motion-hooks t) 2193 (let ((inhibit-point-motion-hooks t)
2194 (opoint (point)) 2194 (opoint (point))
2195 new) 2195 new)
2197 (progn 2197 (progn
2198 (if (not (or (eq last-command 'next-line) 2198 (if (not (or (eq last-command 'next-line)
2199 (eq last-command 'previous-line))) 2199 (eq last-command 'previous-line)))
2200 (setq temporary-goal-column 2200 (setq temporary-goal-column
2201 (if (and track-eol (eolp) 2201 (if (and track-eol (eolp)
2202 ;; Don't count beg of empty line as end of line 2202 ;; Don't count start of empty line as end of line
2203 ;; unless we just did explicit end-of-line. 2203 ;; unless we just did explicit end-of-line.
2204 (or (not (bolp)) (eq last-command 'end-of-line))) 2204 (or (not (bolp)) (eq last-command 'end-of-line)))
2205 9999 2205 9999
2206 (current-column)))) 2206 (current-column))))
2207 (if (and (not (integerp selective-display)) 2207 (if (and (not (integerp selective-display))
2208 (not line-move-ignore-invisible)) 2208 (not line-move-ignore-invisible))
2209 ;; Use just newline characters. 2209 ;; Use just newline characters.
2210 (or (if (> arg 0) 2210 (or (if (> count 0)
2211 (progn (if (> arg 1) (forward-line (1- arg))) 2211 (progn (if (> count 1) (forward-line (1- count)))
2212 ;; This way of moving forward ARG lines 2212 ;; This way of moving forward COUNT lines
2213 ;; verifies that we have a newline after the last one. 2213 ;; verifies that we have a newline after the last one.
2214 ;; It doesn't get confused by intangible text. 2214 ;; It doesn't get confused by intangible text.
2215 (end-of-line) 2215 (end-of-line)
2216 (zerop (forward-line 1))) 2216 (zerop (forward-line 1)))
2217 (and (zerop (forward-line arg)) 2217 (and (zerop (forward-line count))
2218 (bolp))) 2218 (bolp)))
2219 (signal (if (< arg 0) 2219 (signal (if (< count 0)
2220 'beginning-of-buffer 2220 'beginning-of-buffer
2221 'end-of-buffer) 2221 'end-of-buffer)
2222 nil)) 2222 nil))
2223 ;; Move by arg lines, but ignore invisible ones. 2223 ;; Move by count lines, but ignore invisible ones.
2224 (while (> arg 0) 2224 (while (> count 0)
2225 (end-of-line) 2225 (end-of-line)
2226 (and (zerop (vertical-motion 1)) 2226 (and (zerop (vertical-motion 1))
2227 (signal 'end-of-buffer nil)) 2227 (signal 'end-of-buffer nil))
2228 ;; If the following character is currently invisible, 2228 ;; If the following character is currently invisible,
2229 ;; skip all characters with that same `invisible' property value. 2229 ;; skip all characters with that same `invisible' property value.
2235 (or (memq prop buffer-invisibility-spec) 2235 (or (memq prop buffer-invisibility-spec)
2236 (assq prop buffer-invisibility-spec))))) 2236 (assq prop buffer-invisibility-spec)))))
2237 (if (get-text-property (point) 'invisible) 2237 (if (get-text-property (point) 'invisible)
2238 (goto-char (next-single-property-change (point) 'invisible)) 2238 (goto-char (next-single-property-change (point) 'invisible))
2239 (goto-char (next-extent-change (point))))) ; XEmacs 2239 (goto-char (next-extent-change (point))))) ; XEmacs
2240 (setq arg (1- arg))) 2240 (setq count (1- count)))
2241 (while (< arg 0) 2241 (while (< count 0)
2242 (beginning-of-line) 2242 (beginning-of-line)
2243 (and (zerop (vertical-motion -1)) 2243 (and (zerop (vertical-motion -1))
2244 (signal 'beginning-of-buffer nil)) 2244 (signal 'beginning-of-buffer nil))
2245 (while (and (not (bobp)) 2245 (while (and (not (bobp))
2246 (let ((prop 2246 (let ((prop
2250 (or (memq prop buffer-invisibility-spec) 2250 (or (memq prop buffer-invisibility-spec)
2251 (assq prop buffer-invisibility-spec))))) 2251 (assq prop buffer-invisibility-spec)))))
2252 (if (get-text-property (1- (point)) 'invisible) 2252 (if (get-text-property (1- (point)) 'invisible)
2253 (goto-char (previous-single-property-change (point) 'invisible)) 2253 (goto-char (previous-single-property-change (point) 'invisible))
2254 (goto-char (previous-extent-change (point))))) ; XEmacs 2254 (goto-char (previous-extent-change (point))))) ; XEmacs
2255 (setq arg (1+ arg)))) 2255 (setq count (1+ count))))
2256 (move-to-column (or goal-column temporary-goal-column))) 2256 (move-to-column (or goal-column temporary-goal-column)))
2257 ;; Remember where we moved to, go back home, 2257 ;; Remember where we moved to, go back home,
2258 ;; then do the motion over again 2258 ;; then do the motion over again
2259 ;; in just one step, with intangibility and point-motion hooks 2259 ;; in just one step, with intangibility and point-motion hooks
2260 ;; enabled this time. 2260 ;; enabled this time.
2267 ;;; Many people have said they rarely use this feature, and often type 2267 ;;; Many people have said they rarely use this feature, and often type
2268 ;;; it by accident. Maybe it shouldn't even be on a key. 2268 ;;; it by accident. Maybe it shouldn't even be on a key.
2269 ;; It's not on a key, as of 20.2. So no need for this. 2269 ;; It's not on a key, as of 20.2. So no need for this.
2270 ;(put 'set-goal-column 'disabled t) 2270 ;(put 'set-goal-column 'disabled t)
2271 2271
2272 (defun set-goal-column (arg) 2272 (defun set-goal-column (column)
2273 "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line]. 2273 "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
2274 Those commands will move to this position in the line moved to 2274 Those commands will move to this position in the line moved to
2275 rather than trying to keep the same horizontal position. 2275 rather than trying to keep the same horizontal position.
2276 With a non-nil argument, clears out the goal column 2276 With a non-nil argument, clears out the goal column
2277 so that \\[next-line] and \\[previous-line] resume vertical motion. 2277 so that \\[next-line] and \\[previous-line] resume vertical motion.
2278 The goal column is stored in the variable `goal-column'." 2278 The goal column is stored in the variable `goal-column'."
2279 (interactive "_P") ; XEmacs 2279 (interactive "_P") ; XEmacs
2280 (if arg 2280 (if column
2281 (progn 2281 (progn
2282 (setq goal-column nil) 2282 (setq goal-column nil)
2283 (display-message 'command "No goal column")) 2283 (display-message 'command "No goal column"))
2284 (setq goal-column (current-column)) 2284 (setq goal-column (current-column))
2285 (lmessage 'command 2285 (lmessage 'command
2286 "Goal column %d (use %s with an arg to unset it)" 2286 "Goal column %d (use %s with a prefix arg to unset it)"
2287 goal-column 2287 goal-column
2288 (substitute-command-keys "\\[set-goal-column]"))) 2288 (substitute-command-keys "\\[set-goal-column]")))
2289 nil) 2289 nil)
2290 2290
2291 ;; deleted FSFmacs terminal randomness hscroll-point-visible stuff. 2291 ;; deleted FSFmacs terminal randomness hscroll-point-visible stuff.
2393 (forward-line arg))) 2393 (forward-line arg)))
2394 arg)) 2394 arg))
2395 2395
2396 (defun transpose-line-up (arg) 2396 (defun transpose-line-up (arg)
2397 "Move current line one line up, leaving point at beginning of that line. 2397 "Move current line one line up, leaving point at beginning of that line.
2398 This can be run repeatedly to move to current line up a number of lines." 2398 This can be run repeatedly to move the current line up a number of lines."
2399 (interactive "*p") 2399 (interactive "*p")
2400 ;; Move forward over a line, 2400 ;; Move forward over a line,
2401 ;; but create a newline if none exists yet. 2401 ;; but create a newline if none exists yet.
2402 (end-of-line) 2402 (end-of-line)
2403 (if (eobp) 2403 (if (eobp)
2406 (transpose-lines (- arg)) 2406 (transpose-lines (- arg))
2407 (forward-line -1)) 2407 (forward-line -1))
2408 2408
2409 (defun transpose-line-down (arg) 2409 (defun transpose-line-down (arg)
2410 "Move current line one line down, leaving point at beginning of that line. 2410 "Move current line one line down, leaving point at beginning of that line.
2411 This can be run repeatedly to move to current line down a number of lines." 2411 This can be run repeatedly to move the current line down a number of lines."
2412 (interactive "*p") 2412 (interactive "*p")
2413 ;; Move forward over a line, 2413 ;; Move forward over a line,
2414 ;; but create a newline if none exists yet. 2414 ;; but create a newline if none exists yet.
2415 (end-of-line) 2415 (end-of-line)
2416 (if (eobp) 2416 (if (eobp)
2640 ;; to catch comments a line beginnings 2640 ;; to catch comments a line beginnings
2641 (indent-according-to-mode)))) 2641 (indent-according-to-mode))))
2642 (if arg (forward-line 1)) 2642 (if arg (forward-line 1))
2643 (setq count (1- count))))) 2643 (setq count (1- count)))))
2644 2644
2645 (defun comment-region (beg end &optional arg) 2645 (defun comment-region (start end &optional arg)
2646 "Comment or uncomment each line in the region. 2646 "Comment or uncomment each line in the region.
2647 With just C-u prefix arg, uncomment each line in region. 2647 With just C-u prefix arg, uncomment each line in region.
2648 Numeric prefix arg ARG means use ARG comment characters. 2648 Numeric prefix arg ARG means use ARG comment characters.
2649 If ARG is negative, delete that many comment characters instead. 2649 If ARG is negative, delete that many comment characters instead.
2650 Comments are terminated on each line, even for syntax in which newline does 2650 Comments are terminated on each line, even for syntax in which newline does
2653 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x 2653 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x
2654 ;; is easy enough. No option is made here for other than commenting 2654 ;; is easy enough. No option is made here for other than commenting
2655 ;; every line. 2655 ;; every line.
2656 (interactive "r\nP") 2656 (interactive "r\nP")
2657 (or comment-start (error "No comment syntax is defined")) 2657 (or comment-start (error "No comment syntax is defined"))
2658 (if (> beg end) (let (mid) (setq mid beg beg end end mid))) 2658 (if (> start end) (let (mid) (setq mid start start end end mid)))
2659 (save-excursion 2659 (save-excursion
2660 (save-restriction 2660 (save-restriction
2661 (let ((cs comment-start) (ce comment-end) 2661 (let ((cs comment-start) (ce comment-end)
2662 numarg) 2662 numarg)
2663 (if (consp arg) (setq numarg t) 2663 (if (consp arg) (setq numarg t)
2666 ;; then insert the replicated strings just once. 2666 ;; then insert the replicated strings just once.
2667 (while (> numarg 1) 2667 (while (> numarg 1)
2668 (setq cs (concat cs comment-start) 2668 (setq cs (concat cs comment-start)
2669 ce (concat ce comment-end)) 2669 ce (concat ce comment-end))
2670 (setq numarg (1- numarg)))) 2670 (setq numarg (1- numarg))))
2671 ;; Loop over all lines from BEG to END. 2671 ;; Loop over all lines from START to END.
2672 (narrow-to-region beg end) 2672 (narrow-to-region start end)
2673 (goto-char beg) 2673 (goto-char start)
2674 (while (not (eobp)) 2674 (while (not (eobp))
2675 (if (or (eq numarg t) (< numarg 0)) 2675 (if (or (eq numarg t) (< numarg 0))
2676 (progn 2676 (progn
2677 ;; Delete comment start from beginning of line. 2677 ;; Delete comment start from beginning of line.
2678 (if (eq numarg t) 2678 (if (eq numarg t)
2900 (if (save-excursion 2900 (if (save-excursion
2901 (skip-chars-backward " \t") 2901 (skip-chars-backward " \t")
2902 (= (point) fill-point)) 2902 (= (point) fill-point))
2903 ;; 1999-09-17 hniksic: turn off Kinsoku until 2903 ;; 1999-09-17 hniksic: turn off Kinsoku until
2904 ;; it's debugged. 2904 ;; it's debugged.
2905 (indent-new-comment-line) 2905 (funcall comment-line-break-function)
2906 ;; 97/3/14 jhod: Kinsoku processing 2906 ;; 97/3/14 jhod: Kinsoku processing
2907 ; ;(indent-new-comment-line) 2907 ; ;(indent-new-comment-line)
2908 ; (let ((spacep (memq (char-before (point)) '(?\ ?\t)))) 2908 ; (let ((spacep (memq (char-before (point)) '(?\ ?\t))))
2909 ; (funcall comment-line-break-function) 2909 ; (funcall comment-line-break-function)
2910 ; ;; if user type space explicitly, leave SPC 2910 ; ;; if user type space explicitly, leave SPC
3050 "Automatically break line at a previous space, in insertion of text." 3050 "Automatically break line at a previous space, in insertion of text."
3051 nil) 3051 nil)
3052 3052
3053 (defun turn-on-auto-fill () 3053 (defun turn-on-auto-fill ()
3054 "Unconditionally turn on Auto Fill mode." 3054 "Unconditionally turn on Auto Fill mode."
3055 (interactive)
3055 (auto-fill-mode 1)) 3056 (auto-fill-mode 1))
3056 3057
3057 (defun set-fill-column (arg) 3058 (defun set-fill-column (arg)
3058 "Set `fill-column' to specified argument. 3059 "Set `fill-column' to specified argument.
3059 Just \\[universal-argument] as argument means to use the current column 3060 Just \\[universal-argument] as argument means to use the current column
3204 )))) 3205 ))))
3205 (setq selective-display nil)) 3206 (setq selective-display nil))
3206 3207
3207 (add-hook 'change-major-mode-hook 'nuke-selective-display) 3208 (add-hook 'change-major-mode-hook 'nuke-selective-display)
3208 3209
3209 (defconst overwrite-mode-textual (purecopy " Ovwrt") 3210 (defconst overwrite-mode-textual " Ovwrt"
3210 "The string displayed in the mode line when in overwrite mode.") 3211 "The string displayed in the mode line when in overwrite mode.")
3211 (defconst overwrite-mode-binary (purecopy " Bin Ovwrt") 3212 (defconst overwrite-mode-binary " Bin Ovwrt"
3212 "The string displayed in the mode line when in binary overwrite mode.") 3213 "The string displayed in the mode line when in binary overwrite mode.")
3213 3214
3214 (defun overwrite-mode (arg) 3215 (defun overwrite-mode (arg)
3215 "Toggle overwrite mode. 3216 "Toggle overwrite mode.
3216 With arg, turn overwrite mode on iff arg is positive. 3217 With arg, enable overwrite mode if arg is positive, else disable.
3217 In overwrite mode, printing characters typed in replace existing text 3218 In overwrite mode, printing characters typed in replace existing text
3218 on a one-for-one basis, rather than pushing it to the right. At the 3219 on a one-for-one basis, rather than pushing it to the right. At the
3219 end of a line, such characters extend the line. Before a tab, 3220 end of a line, such characters extend the line. Before a tab,
3220 such characters insert until the tab is filled in. 3221 such characters insert until the tab is filled in.
3221 \\[quoted-insert] still inserts characters in overwrite mode; this 3222 \\[quoted-insert] still inserts characters in overwrite mode; this
3227 'overwrite-mode-textual)) 3228 'overwrite-mode-textual))
3228 (redraw-modeline)) 3229 (redraw-modeline))
3229 3230
3230 (defun binary-overwrite-mode (arg) 3231 (defun binary-overwrite-mode (arg)
3231 "Toggle binary overwrite mode. 3232 "Toggle binary overwrite mode.
3232 With arg, turn binary overwrite mode on iff arg is positive. 3233 With arg, enable binary overwrite mode if arg is positive, else disable.
3233 In binary overwrite mode, printing characters typed in replace 3234 In binary overwrite mode, printing characters typed in replace
3234 existing text. Newlines are not treated specially, so typing at the 3235 existing text. Newlines are not treated specially, so typing at the
3235 end of a line joins the line to the next, with the typed character 3236 end of a line joins the line to the next, with the typed character
3236 between them. Typing before a tab character simply replaces the tab 3237 between them. Typing before a tab character simply replaces the tab
3237 with the character typed. 3238 with the character typed.
3254 :type 'boolean 3255 :type 'boolean
3255 :group 'editing-basics) 3256 :group 'editing-basics)
3256 3257
3257 (defun line-number-mode (arg) 3258 (defun line-number-mode (arg)
3258 "Toggle Line Number mode. 3259 "Toggle Line Number mode.
3259 With arg, turn Line Number mode on iff arg is positive. 3260 With arg, enable Line Number mode if arg is positive, else disable.
3260 When Line Number mode is enabled, the line number appears 3261 When Line Number mode is enabled, the line number appears
3261 in the mode line." 3262 in the mode line."
3262 (interactive "P") 3263 (interactive "P")
3263 (setq line-number-mode 3264 (setq line-number-mode
3264 (if (null arg) (not line-number-mode) 3265 (if (null arg) (not line-number-mode)
3270 :type 'boolean 3271 :type 'boolean
3271 :group 'editing-basics) 3272 :group 'editing-basics)
3272 3273
3273 (defun column-number-mode (arg) 3274 (defun column-number-mode (arg)
3274 "Toggle Column Number mode. 3275 "Toggle Column Number mode.
3275 With arg, turn Column Number mode on iff arg is positive. 3276 With arg, enable Column Number mode if arg is positive, else disable.
3276 When Column Number mode is enabled, the column number appears 3277 When Column Number mode is enabled, the column number appears
3277 in the mode line." 3278 in the mode line."
3278 (interactive "P") 3279 (interactive "P")
3279 (setq column-number-mode 3280 (setq column-number-mode
3280 (if (null arg) (not column-number-mode) 3281 (if (null arg) (not column-number-mode)
4397 4398
4398 (defun debug-print (format &rest args) 4399 (defun debug-print (format &rest args)
4399 "Send a string to the debugging output. 4400 "Send a string to the debugging output.
4400 The string is formatted using (apply #'format FORMAT ARGS)." 4401 The string is formatted using (apply #'format FORMAT ARGS)."
4401 (princ (apply #'format format args) 'external-debugging-output)) 4402 (princ (apply #'format format args) 'external-debugging-output))
4402 4403
4403 ;;; simple.el ends here 4404 ;;; simple.el ends here