428
|
1 ;;; simple.el --- basic editing commands for XEmacs
|
|
2
|
|
3 ;; Copyright (C) 1985-7, 1993-5, 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
1261
|
5 ;; Copyright (C) 2000, 2001, 2002, 2003 Ben Wing.
|
428
|
6
|
|
7 ;; Maintainer: XEmacs Development Team
|
|
8 ;; Keywords: lisp, extensions, internal, dumped
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
3000
|
24 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
25 ;; Boston, MA 02110-1301, USA.
|
428
|
26
|
|
27 ;;; Synched up with: FSF 19.34 [But not very closely].
|
3000
|
28 ;;; Occasional synching to FSF 21.2 and FSF 22.0, as marked. Comment stuff
|
|
29 ;;; also synched, and in newcomment.el.
|
428
|
30
|
|
31 ;;; Commentary:
|
|
32
|
|
33 ;; This file is dumped with XEmacs.
|
|
34
|
|
35 ;; A grab-bag of basic XEmacs commands not specifically related to some
|
|
36 ;; major mode or to file-handling.
|
|
37
|
|
38 ;; Changes for zmacs-style active-regions:
|
|
39 ;;
|
|
40 ;; beginning-of-buffer, end-of-buffer, count-lines-region,
|
|
41 ;; count-lines-buffer, what-line, what-cursor-position, set-goal-column,
|
|
42 ;; set-fill-column, prefix-arg-internal, and line-move (which is used by
|
|
43 ;; next-line and previous-line) set zmacs-region-stays to t, so that they
|
|
44 ;; don't affect the current region-hilighting state.
|
|
45 ;;
|
|
46 ;; mark-whole-buffer, mark-word, exchange-point-and-mark, and
|
|
47 ;; set-mark-command (without an argument) call zmacs-activate-region.
|
|
48 ;;
|
|
49 ;; mark takes an optional arg like the new Fmark_marker() does. When
|
|
50 ;; the region is not active, mark returns nil unless the optional arg is true.
|
|
51 ;;
|
|
52 ;; push-mark, pop-mark, exchange-point-and-mark, and set-marker, and
|
|
53 ;; set-mark-command use (mark t) so that they can access the mark whether
|
|
54 ;; the region is active or not.
|
|
55 ;;
|
|
56 ;; shell-command, shell-command-on-region, yank, and yank-pop (which all
|
|
57 ;; push a mark) have been altered to call exchange-point-and-mark with an
|
|
58 ;; argument, meaning "don't activate the region". These commands only use
|
|
59 ;; exchange-point-and-mark to position the newly-pushed mark correctly, so
|
|
60 ;; this isn't a user-visible change. These functions have also been altered
|
|
61 ;; to use (mark t) for the same reason.
|
|
62
|
502
|
63 ;; 97/3/14 Jareth Hein (jhod@po.iijnet.or.jp) added kinsoku processing
|
|
64 ;; (support for filling of Asian text) into the fill code. This was
|
|
65 ;; ripped bleeding from Mule-2.3, and could probably use some feature
|
|
66 ;; additions (like additional wrap styles, etc)
|
428
|
67
|
|
68 ;; 97/06/11 Steve Baur (steve@xemacs.org) Convert use of
|
|
69 ;; (preceding|following)-char to char-(after|before).
|
|
70
|
|
71 ;;; Code:
|
|
72
|
|
73 (defgroup editing-basics nil
|
|
74 "Most basic editing variables."
|
|
75 :group 'editing)
|
|
76
|
|
77 (defgroup killing nil
|
|
78 "Killing and yanking commands."
|
|
79 :group 'editing)
|
|
80
|
|
81 (defgroup fill-comments nil
|
|
82 "Indenting and filling of comments."
|
|
83 :prefix "comment-"
|
|
84 :group 'fill)
|
|
85
|
|
86 (defgroup paren-matching nil
|
|
87 "Highlight (un)matching of parens and expressions."
|
|
88 :prefix "paren-"
|
|
89 :group 'matching)
|
|
90
|
|
91 (defgroup log-message nil
|
|
92 "Messages logging and display customizations."
|
|
93 :group 'minibuffer)
|
|
94
|
|
95 (defgroup warnings nil
|
|
96 "Warnings customizations."
|
|
97 :group 'minibuffer)
|
|
98
|
|
99
|
|
100 (defcustom search-caps-disable-folding t
|
|
101 "*If non-nil, upper case chars disable case fold searching.
|
|
102 This does not apply to \"yanked\" strings."
|
|
103 :type 'boolean
|
|
104 :group 'editing-basics)
|
|
105
|
|
106 ;; This is stolen (and slightly modified) from FSF emacs's
|
|
107 ;; `isearch-no-upper-case-p'.
|
|
108 (defun no-upper-case-p (string &optional regexp-flag)
|
|
109 "Return t if there are no upper case chars in STRING.
|
|
110 If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\')
|
|
111 since they have special meaning in a regexp."
|
|
112 (let ((case-fold-search nil))
|
444
|
113 (not (string-match (if regexp-flag
|
428
|
114 "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]"
|
|
115 "[A-Z]")
|
|
116 string))
|
|
117 ))
|
|
118
|
|
119 (defmacro with-search-caps-disable-folding (string regexp-flag &rest body) "\
|
444
|
120 Eval BODY with `case-fold-search' let to nil if `search-caps-disable-folding'
|
428
|
121 is non-nil, and if STRING (either a string or a regular expression according
|
|
122 to REGEXP-FLAG) contains uppercase letters."
|
|
123 `(let ((case-fold-search
|
|
124 (if (and case-fold-search search-caps-disable-folding)
|
|
125 (no-upper-case-p ,string ,regexp-flag)
|
|
126 case-fold-search)))
|
|
127 ,@body))
|
|
128 (put 'with-search-caps-disable-folding 'lisp-indent-function 2)
|
444
|
129 (put 'with-search-caps-disable-folding 'edebug-form-spec
|
428
|
130 '(sexp sexp &rest form))
|
|
131
|
444
|
132 (defmacro with-interactive-search-caps-disable-folding (string regexp-flag
|
428
|
133 &rest body)
|
|
134 "Same as `with-search-caps-disable-folding', but only in the case of a
|
|
135 function called interactively."
|
|
136 `(let ((case-fold-search
|
444
|
137 (if (and (interactive-p)
|
428
|
138 case-fold-search search-caps-disable-folding)
|
|
139 (no-upper-case-p ,string ,regexp-flag)
|
|
140 case-fold-search)))
|
|
141 ,@body))
|
|
142 (put 'with-interactive-search-caps-disable-folding 'lisp-indent-function 2)
|
444
|
143 (put 'with-interactive-search-caps-disable-folding 'edebug-form-spec
|
428
|
144 '(sexp sexp &rest form))
|
|
145
|
444
|
146 (defun newline (&optional n)
|
428
|
147 "Insert a newline, and move to left margin of the new line if it's blank.
|
|
148 The newline is marked with the text-property `hard'.
|
444
|
149 With optional arg N, insert that many newlines.
|
428
|
150 In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
|
|
151 (interactive "*P")
|
|
152 (barf-if-buffer-read-only nil (point))
|
|
153 ;; Inserting a newline at the end of a line produces better redisplay in
|
|
154 ;; try_window_id than inserting at the beginning of a line, and the textual
|
|
155 ;; result is the same. So, if we're at beginning of line, pretend to be at
|
|
156 ;; the end of the previous line.
|
|
157 ;; #### Does this have any relevance in XEmacs?
|
|
158 (let ((flag (and (not (bobp))
|
|
159 (bolp)
|
|
160 ;; Make sure the newline before point isn't intangible.
|
|
161 (not (get-char-property (1- (point)) 'intangible))
|
|
162 ;; Make sure the newline before point isn't read-only.
|
|
163 (not (get-char-property (1- (point)) 'read-only))
|
|
164 ;; Make sure the newline before point isn't invisible.
|
|
165 (not (get-char-property (1- (point)) 'invisible))
|
|
166 ;; This should probably also test for the previous char
|
|
167 ;; being the *last* character too.
|
|
168 (not (get-char-property (1- (point)) 'end-open))
|
|
169 ;; Make sure the newline before point has the same
|
|
170 ;; properties as the char before it (if any).
|
|
171 (< (or (previous-extent-change (point)) -2)
|
|
172 (- (point) 2))))
|
|
173 (was-page-start (and (bolp)
|
|
174 (looking-at page-delimiter)))
|
|
175 (beforepos (point)))
|
|
176 (if flag (backward-char 1))
|
|
177 ;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
|
|
178 ;; Set last-command-char to tell self-insert what to insert.
|
|
179 (let ((last-command-char ?\n)
|
|
180 ;; Don't auto-fill if we have a numeric argument.
|
|
181 ;; Also not if flag is true (it would fill wrong line);
|
|
182 ;; there is no need to since we're at BOL.
|
444
|
183 (auto-fill-function (if (or n flag) nil auto-fill-function)))
|
428
|
184 (unwind-protect
|
444
|
185 (self-insert-command (prefix-numeric-value n))
|
428
|
186 ;; If we get an error in self-insert-command, put point at right place.
|
|
187 (if flag (forward-char 1))))
|
|
188 ;; If we did *not* get an error, cancel that forward-char.
|
|
189 (if flag (backward-char 1))
|
|
190 ;; Mark the newline(s) `hard'.
|
|
191 (if use-hard-newlines
|
444
|
192 (let* ((from (- (point) (if n (prefix-numeric-value n) 1)))
|
428
|
193 (sticky (get-text-property from 'end-open))) ; XEmacs
|
|
194 (put-text-property from (point) 'hard 't)
|
|
195 ;; If end-open is not "t", add 'hard to end-open list
|
|
196 (if (and (listp sticky) (not (memq 'hard sticky)))
|
|
197 (put-text-property from (point) 'end-open ; XEmacs
|
|
198 (cons 'hard sticky)))))
|
|
199 ;; If the newline leaves the previous line blank,
|
|
200 ;; and we have a left margin, delete that from the blank line.
|
|
201 (or flag
|
|
202 (save-excursion
|
|
203 (goto-char beforepos)
|
|
204 (beginning-of-line)
|
|
205 (and (looking-at "[ \t]$")
|
|
206 (> (current-left-margin) 0)
|
|
207 (delete-region (point) (progn (end-of-line) (point))))))
|
|
208 (if flag (forward-char 1))
|
|
209 ;; Indent the line after the newline, except in one case:
|
|
210 ;; when we added the newline at the beginning of a line
|
|
211 ;; which starts a page.
|
|
212 (or was-page-start
|
|
213 (move-to-left-margin nil t)))
|
|
214 nil)
|
|
215
|
|
216 (defun set-hard-newline-properties (from to)
|
|
217 (let ((sticky (get-text-property from 'rear-nonsticky)))
|
|
218 (put-text-property from to 'hard 't)
|
|
219 ;; If rear-nonsticky is not "t", add 'hard to rear-nonsticky list
|
|
220 (if (and (listp sticky) (not (memq 'hard sticky)))
|
|
221 (put-text-property from (point) 'rear-nonsticky
|
|
222 (cons 'hard sticky)))))
|
|
223
|
444
|
224 (defun open-line (n)
|
428
|
225 "Insert a newline and leave point before it.
|
|
226 If there is a fill prefix and/or a left-margin, insert them on the new line
|
|
227 if the line would have been blank.
|
|
228 With arg N, insert N newlines."
|
|
229 (interactive "*p")
|
|
230 (let* ((do-fill-prefix (and fill-prefix (bolp)))
|
|
231 (do-left-margin (and (bolp) (> (current-left-margin) 0)))
|
|
232 (loc (point)))
|
444
|
233 (newline n)
|
428
|
234 (goto-char loc)
|
444
|
235 (while (> n 0)
|
428
|
236 (cond ((bolp)
|
|
237 (if do-left-margin (indent-to (current-left-margin)))
|
|
238 (if do-fill-prefix (insert fill-prefix))))
|
|
239 (forward-line 1)
|
444
|
240 (setq n (1- n)))
|
428
|
241 (goto-char loc)
|
|
242 (end-of-line)))
|
|
243
|
|
244 (defun split-line ()
|
|
245 "Split current line, moving portion beyond point vertically down."
|
|
246 (interactive "*")
|
|
247 (skip-chars-forward " \t")
|
|
248 (let ((col (current-column))
|
|
249 (pos (point)))
|
|
250 (newline 1)
|
|
251 (indent-to col 0)
|
|
252 (goto-char pos)))
|
|
253
|
|
254 (defun quoted-insert (arg)
|
|
255 "Read next input character and insert it.
|
|
256 This is useful for inserting control characters.
|
|
257 You may also type up to 3 octal digits, to insert a character with that code.
|
|
258
|
|
259 In overwrite mode, this function inserts the character anyway, and
|
|
260 does not handle octal digits specially. This means that if you use
|
|
261 overwrite as your normal editing mode, you can use this function to
|
|
262 insert characters when necessary.
|
|
263
|
|
264 In binary overwrite mode, this function does overwrite, and octal
|
|
265 digits are interpreted as a character code. This is supposed to make
|
|
266 this function useful in editing binary files."
|
|
267 (interactive "*p")
|
|
268 (let ((char (if (or (not overwrite-mode)
|
|
269 (eq overwrite-mode 'overwrite-mode-binary))
|
|
270 (read-quoted-char)
|
|
271 ;; read-char obeys C-g, so we should protect. FSF
|
|
272 ;; doesn't have the protection here, but it's a bug in
|
|
273 ;; FSF.
|
|
274 (let ((inhibit-quit t))
|
|
275 (read-char)))))
|
|
276 (if (> arg 0)
|
|
277 (if (eq overwrite-mode 'overwrite-mode-binary)
|
|
278 (delete-char arg)))
|
|
279 (while (> arg 0)
|
|
280 (insert char)
|
|
281 (setq arg (1- arg)))))
|
|
282
|
|
283 (defun delete-indentation (&optional arg)
|
|
284 "Join this line to previous and fix up whitespace at join.
|
|
285 If there is a fill prefix, delete it from the beginning of this line.
|
|
286 With argument, join this line to following line."
|
|
287 (interactive "*P")
|
|
288 (beginning-of-line)
|
|
289 (if arg (forward-line 1))
|
|
290 (if (eq (char-before (point)) ?\n)
|
|
291 (progn
|
|
292 (delete-region (point) (1- (point)))
|
|
293 ;; If the second line started with the fill prefix,
|
|
294 ;; delete the prefix.
|
|
295 (if (and fill-prefix
|
|
296 (<= (+ (point) (length fill-prefix)) (point-max))
|
|
297 (string= fill-prefix
|
|
298 (buffer-substring (point)
|
|
299 (+ (point) (length fill-prefix)))))
|
|
300 (delete-region (point) (+ (point) (length fill-prefix))))
|
|
301 (fixup-whitespace))))
|
|
302
|
958
|
303 (defalias 'join-line 'delete-indentation)
|
|
304
|
428
|
305 (defun fixup-whitespace ()
|
|
306 "Fixup white space between objects around point.
|
|
307 Leave one space or none, according to the context."
|
|
308 (interactive "*")
|
|
309 (save-excursion
|
|
310 (delete-horizontal-space)
|
|
311 (if (or (looking-at "^\\|\\s)")
|
446
|
312 (save-excursion (backward-char 1)
|
428
|
313 (looking-at "$\\|\\s(\\|\\s'")))
|
|
314 nil
|
|
315 (insert ?\ ))))
|
|
316
|
|
317 (defun delete-horizontal-space ()
|
|
318 "Delete all spaces and tabs around point."
|
|
319 (interactive "*")
|
|
320 (skip-chars-backward " \t")
|
|
321 (delete-region (point) (progn (skip-chars-forward " \t") (point))))
|
|
322
|
|
323 (defun just-one-space ()
|
|
324 "Delete all spaces and tabs around point, leaving one space."
|
|
325 (interactive "*")
|
|
326 (if abbrev-mode ; XEmacs
|
|
327 (expand-abbrev))
|
|
328 (skip-chars-backward " \t")
|
|
329 (if (eq (char-after (point)) ? ) ; XEmacs
|
|
330 (forward-char 1)
|
|
331 (insert ? ))
|
|
332 (delete-region (point) (progn (skip-chars-forward " \t") (point))))
|
|
333
|
|
334 (defun delete-blank-lines ()
|
|
335 "On blank line, delete all surrounding blank lines, leaving just one.
|
|
336 On isolated blank line, delete that one.
|
|
337 On nonblank line, delete any immediately following blank lines."
|
|
338 (interactive "*")
|
|
339 (let (thisblank singleblank)
|
|
340 (save-excursion
|
|
341 (beginning-of-line)
|
|
342 (setq thisblank (looking-at "[ \t]*$"))
|
|
343 ;; Set singleblank if there is just one blank line here.
|
|
344 (setq singleblank
|
|
345 (and thisblank
|
|
346 (not (looking-at "[ \t]*\n[ \t]*$"))
|
|
347 (or (bobp)
|
|
348 (progn (forward-line -1)
|
|
349 (not (looking-at "[ \t]*$")))))))
|
|
350 ;; Delete preceding blank lines, and this one too if it's the only one.
|
|
351 (if thisblank
|
|
352 (progn
|
|
353 (beginning-of-line)
|
|
354 (if singleblank (forward-line 1))
|
|
355 (delete-region (point)
|
|
356 (if (re-search-backward "[^ \t\n]" nil t)
|
|
357 (progn (forward-line 1) (point))
|
|
358 (point-min)))))
|
|
359 ;; Delete following blank lines, unless the current line is blank
|
|
360 ;; and there are no following blank lines.
|
|
361 (if (not (and thisblank singleblank))
|
|
362 (save-excursion
|
|
363 (end-of-line)
|
|
364 (forward-line 1)
|
|
365 (delete-region (point)
|
|
366 (if (re-search-forward "[^ \t\n]" nil t)
|
|
367 (progn (beginning-of-line) (point))
|
|
368 (point-max)))))
|
|
369 ;; Handle the special case where point is followed by newline and eob.
|
|
370 ;; Delete the line, leaving point at eob.
|
|
371 (if (looking-at "^[ \t]*\n\\'")
|
|
372 (delete-region (point) (point-max)))))
|
|
373
|
|
374 (defun back-to-indentation ()
|
|
375 "Move point to the first non-whitespace character on this line."
|
|
376 ;; XEmacs change
|
|
377 (interactive "_")
|
|
378 (beginning-of-line 1)
|
|
379 (skip-chars-forward " \t"))
|
|
380
|
|
381 (defun newline-and-indent ()
|
|
382 "Insert a newline, then indent according to major mode.
|
|
383 Indentation is done using the value of `indent-line-function'.
|
|
384 In programming language modes, this is the same as TAB.
|
|
385 In some text modes, where TAB inserts a tab, this command indents to the
|
|
386 column specified by the function `current-left-margin'."
|
|
387 (interactive "*")
|
|
388 (delete-region (point) (progn (skip-chars-backward " \t") (point)))
|
|
389 (newline)
|
|
390 (indent-according-to-mode))
|
|
391
|
|
392 (defun reindent-then-newline-and-indent ()
|
|
393 "Reindent current line, insert newline, then indent the new line.
|
|
394 Indentation of both lines is done according to the current major mode,
|
|
395 which means calling the current value of `indent-line-function'.
|
|
396 In programming language modes, this is the same as TAB.
|
|
397 In some text modes, where TAB inserts a tab, this indents to the
|
|
398 column specified by the function `current-left-margin'."
|
|
399 (interactive "*")
|
|
400 (save-excursion
|
|
401 (delete-region (point) (progn (skip-chars-backward " \t") (point)))
|
|
402 (indent-according-to-mode))
|
|
403 (newline)
|
|
404 (indent-according-to-mode))
|
|
405
|
|
406 ;; Internal subroutine of delete-char
|
|
407 (defun kill-forward-chars (arg)
|
|
408 (if (listp arg) (setq arg (car arg)))
|
|
409 (if (eq arg '-) (setq arg -1))
|
|
410 (kill-region (point) (+ (point) arg)))
|
|
411
|
|
412 ;; Internal subroutine of backward-delete-char
|
|
413 (defun kill-backward-chars (arg)
|
|
414 (if (listp arg) (setq arg (car arg)))
|
|
415 (if (eq arg '-) (setq arg -1))
|
|
416 (kill-region (point) (- (point) arg)))
|
|
417
|
|
418 (defun backward-delete-char-untabify (arg &optional killp)
|
|
419 "Delete characters backward, changing tabs into spaces.
|
|
420 Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil.
|
|
421 Interactively, ARG is the prefix arg (default 1)
|
|
422 and KILLP is t if a prefix arg was specified."
|
|
423 (interactive "*p\nP")
|
|
424 (let ((count arg))
|
|
425 (save-excursion
|
|
426 (while (and (> count 0) (not (bobp)))
|
|
427 (if (eq (char-before (point)) ?\t) ; XEmacs
|
|
428 (let ((col (current-column)))
|
446
|
429 (backward-char 1)
|
428
|
430 (setq col (- col (current-column)))
|
|
431 (insert-char ?\ col)
|
|
432 (delete-char 1)))
|
446
|
433 (backward-char 1)
|
428
|
434 (setq count (1- count)))))
|
|
435 (delete-backward-char arg killp)
|
|
436 ;; XEmacs: In overwrite mode, back over columns while clearing them out,
|
|
437 ;; unless at end of line.
|
|
438 (and overwrite-mode (not (eolp))
|
|
439 (save-excursion (insert-char ?\ arg))))
|
|
440
|
|
441 (defcustom delete-key-deletes-forward t
|
|
442 "*If non-nil, the DEL key will erase one character forwards.
|
|
443 If nil, the DEL key will erase one character backwards."
|
|
444 :type 'boolean
|
|
445 :group 'editing-basics)
|
|
446
|
446
|
447 (defcustom backward-delete-function 'delete-backward-char
|
428
|
448 "*Function called to delete backwards on a delete keypress.
|
|
449 If `delete-key-deletes-forward' is nil, `backward-or-forward-delete-char'
|
|
450 calls this function to erase one character backwards. Default value
|
446
|
451 is `delete-backward-char', with `backward-delete-char-untabify' being a
|
428
|
452 popular alternate setting."
|
|
453 :type 'function
|
|
454 :group 'editing-basics)
|
|
455
|
|
456 ;; Trash me, baby.
|
|
457 (defsubst delete-forward-p ()
|
|
458 (and delete-key-deletes-forward
|
|
459 (or (not (eq (device-type) 'x))
|
502
|
460 (declare-fboundp
|
|
461 (x-keysym-on-keyboard-sans-modifiers-p 'backspace)))))
|
428
|
462
|
|
463 (defun backward-or-forward-delete-char (arg)
|
|
464 "Delete either one character backwards or one character forwards.
|
|
465 Controlled by the state of `delete-key-deletes-forward' and whether the
|
|
466 BackSpace keysym even exists on your keyboard. If you don't have a
|
|
467 BackSpace keysym, the delete key should always delete one character
|
|
468 backwards."
|
|
469 (interactive "*p")
|
|
470 (if (delete-forward-p)
|
|
471 (delete-char arg)
|
|
472 (funcall backward-delete-function arg)))
|
|
473
|
|
474 (defun backward-or-forward-kill-word (arg)
|
|
475 "Delete either one word backwards or one word forwards.
|
|
476 Controlled by the state of `delete-key-deletes-forward' and whether the
|
|
477 BackSpace keysym even exists on your keyboard. If you don't have a
|
|
478 BackSpace keysym, the delete key should always delete one character
|
|
479 backwards."
|
|
480 (interactive "*p")
|
|
481 (if (delete-forward-p)
|
|
482 (kill-word arg)
|
|
483 (backward-kill-word arg)))
|
|
484
|
|
485 (defun backward-or-forward-kill-sentence (arg)
|
|
486 "Delete either one sentence backwards or one sentence forwards.
|
|
487 Controlled by the state of `delete-key-deletes-forward' and whether the
|
|
488 BackSpace keysym even exists on your keyboard. If you don't have a
|
|
489 BackSpace keysym, the delete key should always delete one character
|
|
490 backwards."
|
|
491 (interactive "*P")
|
|
492 (if (delete-forward-p)
|
|
493 (kill-sentence arg)
|
|
494 (backward-kill-sentence (prefix-numeric-value arg))))
|
|
495
|
|
496 (defun backward-or-forward-kill-sexp (arg)
|
|
497 "Delete either one sexpr backwards or one sexpr forwards.
|
|
498 Controlled by the state of `delete-key-deletes-forward' and whether the
|
|
499 BackSpace keysym even exists on your keyboard. If you don't have a
|
|
500 BackSpace keysym, the delete key should always delete one character
|
|
501 backwards."
|
|
502 (interactive "*p")
|
|
503 (if (delete-forward-p)
|
|
504 (kill-sexp arg)
|
|
505 (backward-kill-sexp arg)))
|
|
506
|
|
507 (defun zap-to-char (arg char)
|
|
508 "Kill up to and including ARG'th occurrence of CHAR.
|
|
509 Goes backward if ARG is negative; error if CHAR not found."
|
|
510 (interactive "*p\ncZap to char: ")
|
|
511 (kill-region (point) (with-interactive-search-caps-disable-folding
|
|
512 (char-to-string char) nil
|
|
513 (search-forward (char-to-string char) nil nil arg)
|
|
514 (point))))
|
|
515
|
|
516 (defun zap-up-to-char (arg char)
|
|
517 "Kill up to ARG'th occurrence of CHAR.
|
|
518 Goes backward if ARG is negative; error if CHAR not found."
|
|
519 (interactive "*p\ncZap up to char: ")
|
|
520 (kill-region (point) (with-interactive-search-caps-disable-folding
|
|
521 (char-to-string char) nil
|
|
522 (search-forward (char-to-string char) nil nil arg)
|
|
523 (goto-char (if (> arg 0) (1- (point)) (1+ (point))))
|
|
524 (point))))
|
|
525
|
|
526 (defun beginning-of-buffer (&optional arg)
|
|
527 "Move point to the beginning of the buffer; leave mark at previous position.
|
|
528 With arg N, put point N/10 of the way from the beginning.
|
|
529
|
|
530 If the buffer is narrowed, this command uses the beginning and size
|
|
531 of the accessible part of the buffer.
|
|
532
|
462
|
533 The characters that are moved over may be added to the current selection
|
|
534 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
535 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
536 the documentation for this variable for more details.
|
|
537
|
428
|
538 Don't use this command in Lisp programs!
|
|
539 \(goto-char (point-min)) is faster and avoids clobbering the mark."
|
|
540 ;; XEmacs change
|
|
541 (interactive "_P")
|
|
542 (push-mark)
|
|
543 (let ((size (- (point-max) (point-min))))
|
|
544 (goto-char (if arg
|
|
545 (+ (point-min)
|
|
546 (if (> size 10000)
|
|
547 ;; Avoid overflow for large buffer sizes!
|
|
548 (* (prefix-numeric-value arg)
|
|
549 (/ size 10))
|
|
550 (/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
|
|
551 (point-min))))
|
|
552 (if arg (forward-line 1)))
|
|
553
|
|
554 (defun end-of-buffer (&optional arg)
|
|
555 "Move point to the end of the buffer; leave mark at previous position.
|
|
556 With arg N, put point N/10 of the way from the end.
|
|
557
|
|
558 If the buffer is narrowed, this command uses the beginning and size
|
|
559 of the accessible part of the buffer.
|
|
560
|
462
|
561 The characters that are moved over may be added to the current selection
|
|
562 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
563 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
564 the documentation for this variable for more details.
|
|
565
|
428
|
566 Don't use this command in Lisp programs!
|
|
567 \(goto-char (point-max)) is faster and avoids clobbering the mark."
|
|
568 ;; XEmacs change
|
|
569 (interactive "_P")
|
|
570 (push-mark)
|
|
571 ;; XEmacs changes here.
|
|
572 (let ((scroll-to-end (not (pos-visible-in-window-p (point-max))))
|
|
573 (size (- (point-max) (point-min))))
|
|
574 (goto-char (if arg
|
|
575 (- (point-max)
|
|
576 (if (> size 10000)
|
|
577 ;; Avoid overflow for large buffer sizes!
|
|
578 (* (prefix-numeric-value arg)
|
|
579 (/ size 10))
|
|
580 (/ (* size (prefix-numeric-value arg)) 10)))
|
|
581 (point-max)))
|
|
582 (cond (arg
|
|
583 ;; If we went to a place in the middle of the buffer,
|
|
584 ;; adjust it to the beginning of a line.
|
|
585 (forward-line 1))
|
|
586 ;; XEmacs change
|
|
587 (scroll-to-end
|
|
588 ;; If the end of the buffer is not already on the screen,
|
|
589 ;; then scroll specially to put it near, but not at, the bottom.
|
|
590 (recenter -3)))))
|
|
591
|
|
592 ;; XEmacs (not in FSF)
|
|
593 (defun mark-beginning-of-buffer (&optional arg)
|
|
594 "Push a mark at the beginning of the buffer; leave point where it is.
|
|
595 With arg N, push mark N/10 of the way from the true beginning."
|
|
596 (interactive "P")
|
|
597 (push-mark (if arg
|
|
598 (if (> (buffer-size) 10000)
|
|
599 ;; Avoid overflow for large buffer sizes!
|
|
600 (* (prefix-numeric-value arg)
|
|
601 (/ (buffer-size) 10))
|
|
602 (/ (+ 10 (* (buffer-size) (prefix-numeric-value arg))) 10))
|
|
603 (point-min))
|
|
604 nil
|
|
605 t))
|
|
606 (define-function 'mark-bob 'mark-beginning-of-buffer)
|
|
607
|
|
608 ;; XEmacs (not in FSF)
|
|
609 (defun mark-end-of-buffer (&optional arg)
|
|
610 "Push a mark at the end of the buffer; leave point where it is.
|
|
611 With arg N, push mark N/10 of the way from the true end."
|
|
612 (interactive "P")
|
|
613 (push-mark (if arg
|
|
614 (- (1+ (buffer-size))
|
|
615 (if (> (buffer-size) 10000)
|
|
616 ;; Avoid overflow for large buffer sizes!
|
|
617 (* (prefix-numeric-value arg)
|
|
618 (/ (buffer-size) 10))
|
|
619 (/ (* (buffer-size) (prefix-numeric-value arg)) 10)))
|
|
620 (point-max))
|
|
621 nil
|
|
622 t))
|
|
623 (define-function 'mark-eob 'mark-end-of-buffer)
|
|
624
|
|
625 (defun mark-whole-buffer ()
|
|
626 "Put point at beginning and mark at end of buffer.
|
|
627 You probably should not use this function in Lisp programs;
|
|
628 it is usually a mistake for a Lisp function to use any subroutine
|
|
629 that uses or sets the mark."
|
|
630 (interactive)
|
|
631 (push-mark (point))
|
|
632 (push-mark (point-max) nil t)
|
|
633 (goto-char (point-min)))
|
|
634
|
|
635 ;; XEmacs
|
|
636 (defun eval-current-buffer (&optional printflag)
|
|
637 "Evaluate the current buffer as Lisp code.
|
|
638 Programs can pass argument PRINTFLAG which controls printing of output:
|
|
639 nil means discard it; anything else is stream for print."
|
|
640 (interactive)
|
|
641 (eval-buffer (current-buffer) printflag))
|
|
642
|
|
643 ;; XEmacs
|
|
644 (defun count-words-buffer (&optional buffer)
|
|
645 "Print the number of words in BUFFER.
|
|
646 If called noninteractively, the value is returned rather than printed.
|
|
647 BUFFER defaults to the current buffer."
|
|
648 (interactive)
|
|
649 (let ((words (count-words-region (point-min) (point-max) buffer)))
|
|
650 (when (interactive-p)
|
|
651 (message "Buffer has %d words" words))
|
|
652 words))
|
|
653
|
|
654 ;; XEmacs
|
|
655 (defun count-words-region (start end &optional buffer)
|
|
656 "Print the number of words in region between START and END in BUFFER.
|
|
657 If called noninteractively, the value is returned rather than printed.
|
|
658 BUFFER defaults to the current buffer."
|
|
659 (interactive "_r")
|
|
660 (save-excursion
|
|
661 (set-buffer (or buffer (current-buffer)))
|
|
662 (let ((words 0))
|
|
663 (goto-char start)
|
|
664 (while (< (point) end)
|
|
665 (when (forward-word 1)
|
|
666 (incf words)))
|
|
667 (when (interactive-p)
|
|
668 (message "Region has %d words" words))
|
|
669 words)))
|
|
670
|
|
671 (defun count-lines-region (start end)
|
|
672 "Print number of lines and characters in the region."
|
|
673 ;; XEmacs change
|
|
674 (interactive "_r")
|
|
675 (message "Region has %d lines, %d characters"
|
|
676 (count-lines start end) (- end start)))
|
|
677
|
|
678 ;; XEmacs
|
|
679 (defun count-lines-buffer (&optional buffer)
|
|
680 "Print number of lines and characters in BUFFER."
|
|
681 (interactive)
|
|
682 (with-current-buffer (or buffer (current-buffer))
|
|
683 (let ((cnt (count-lines (point-min) (point-max))))
|
|
684 (message "Buffer has %d lines, %d characters"
|
|
685 cnt (- (point-max) (point-min)))
|
|
686 cnt)))
|
|
687
|
|
688 ;;; Modified by Bob Weiner, 8/24/95, to print narrowed line number also.
|
|
689 ;;; Expanded by Bob Weiner, BeOpen, on 02/12/1997
|
|
690 (defun what-line ()
|
|
691 "Print the following variants of the line number of point:
|
|
692 Region line - displayed line within the active region
|
|
693 Collapsed line - includes only selectively displayed lines;
|
|
694 Buffer line - physical line in the buffer;
|
|
695 Narrowed line - line number from the start of the buffer narrowing."
|
|
696 ;; XEmacs change
|
|
697 (interactive "_")
|
|
698 (let ((opoint (point)) start)
|
|
699 (save-excursion
|
|
700 (save-restriction
|
|
701 (if (region-active-p)
|
|
702 (goto-char (region-beginning))
|
|
703 (goto-char (point-min)))
|
|
704 (widen)
|
|
705 (beginning-of-line)
|
|
706 (setq start (point))
|
|
707 (goto-char opoint)
|
|
708 (beginning-of-line)
|
|
709 (let* ((buffer-line (1+ (count-lines 1 (point))))
|
|
710 (narrowed-p (or (/= start 1)
|
|
711 (/= (point-max) (1+ (buffer-size)))))
|
|
712 (narrowed-line (if narrowed-p (1+ (count-lines start (point)))))
|
|
713 (selective-line (if selective-display
|
|
714 (1+ (count-lines start (point) t))))
|
|
715 (region-line (if (region-active-p)
|
|
716 (1+ (count-lines start (point) selective-display)))))
|
|
717 (cond (region-line
|
|
718 (message "Region line %d; Buffer line %d"
|
|
719 region-line buffer-line))
|
|
720 ((and narrowed-p selective-line (/= selective-line narrowed-line))
|
|
721 ;; buffer narrowed and some lines selectively displayed
|
|
722 (message "Collapsed line %d; Buffer line %d; Narrowed line %d"
|
|
723 selective-line buffer-line narrowed-line))
|
|
724 (narrowed-p
|
|
725 ;; buffer narrowed
|
|
726 (message "Buffer line %d; Narrowed line %d"
|
|
727 buffer-line narrowed-line))
|
|
728 ((and selective-line (/= selective-line buffer-line))
|
|
729 ;; some lines selectively displayed
|
|
730 (message "Collapsed line %d; Buffer line %d"
|
|
731 selective-line buffer-line))
|
|
732 (t
|
|
733 ;; give a basic line count
|
|
734 (message "Line %d" buffer-line)))))))
|
|
735 (setq zmacs-region-stays t))
|
|
736
|
442
|
737 ;; new in XEmacs 21.2 (not in FSF).
|
|
738 (defun line-number (&optional pos respect-narrowing)
|
|
739 "Return the line number of POS (defaults to point).
|
|
740 If RESPECT-NARROWING is non-nil, then the narrowed line number is returned;
|
|
741 otherwise, the absolute line number is returned. The returned line can always
|
|
742 be given to `goto-line' to get back to the current line."
|
|
743 (if (and pos (/= pos (point)))
|
|
744 (save-excursion
|
|
745 (goto-char pos)
|
|
746 (line-number nil respect-narrowing))
|
|
747 (1+ (count-lines (if respect-narrowing (point-min) 1) (point-at-bol)))))
|
|
748
|
3000
|
749 ;; FSF 22.0.50.1 (CVS) version of above.
|
|
750 (defun line-number-at-pos (&optional pos)
|
|
751 (line-number pos t))
|
|
752
|
428
|
753 (defun count-lines (start end &optional ignore-invisible-lines-flag)
|
|
754 "Return number of lines between START and END.
|
|
755 This is usually the number of newlines between them,
|
|
756 but can be one more if START is not equal to END
|
|
757 and the greater of them is not at the start of a line.
|
|
758
|
|
759 With optional IGNORE-INVISIBLE-LINES-FLAG non-nil, lines collapsed with
|
442
|
760 selective-display are excluded from the line count.
|
|
761
|
|
762 NOTE: The expression to return the current line number is not obvious:
|
|
763
|
|
764 (1+ (count-lines 1 (point-at-bol)))
|
|
765
|
|
766 See also `line-number'."
|
428
|
767 (save-excursion
|
|
768 (save-restriction
|
|
769 (narrow-to-region start end)
|
|
770 (goto-char (point-min))
|
|
771 (if (and (not ignore-invisible-lines-flag) (eq selective-display t))
|
|
772 (save-match-data
|
|
773 (let ((done 0))
|
|
774 (while (re-search-forward "[\n\C-m]" nil t 40)
|
|
775 (setq done (+ 40 done)))
|
|
776 (while (re-search-forward "[\n\C-m]" nil t 1)
|
|
777 (setq done (+ 1 done)))
|
|
778 (goto-char (point-max))
|
|
779 (if (and (/= start end)
|
|
780 (not (bolp)))
|
|
781 (1+ done)
|
|
782 done)))
|
|
783 (- (buffer-size) (forward-line (buffer-size)))))))
|
|
784
|
|
785 (defun what-cursor-position ()
|
|
786 "Print info on cursor position (on screen and within buffer)."
|
|
787 ;; XEmacs change
|
|
788 (interactive "_")
|
|
789 (let* ((char (char-after (point))) ; XEmacs
|
|
790 (beg (point-min))
|
|
791 (end (point-max))
|
|
792 (pos (point))
|
|
793 (total (buffer-size))
|
|
794 (percent (if (> total 50000)
|
|
795 ;; Avoid overflow from multiplying by 100!
|
|
796 (/ (+ (/ total 200) (1- pos)) (max (/ total 100) 1))
|
|
797 (/ (+ (/ total 2) (* 100 (1- pos))) (max total 1))))
|
|
798 (hscroll (if (= (window-hscroll) 0)
|
|
799 ""
|
|
800 (format " Hscroll=%d" (window-hscroll))))
|
|
801 (col (+ (current-column) (if column-number-start-at-one 1 0))))
|
|
802 (if (= pos end)
|
|
803 (if (or (/= beg 1) (/= end (1+ total)))
|
|
804 (message "point=%d of %d(%d%%) <%d - %d> column %d %s"
|
|
805 pos total percent beg end col hscroll)
|
|
806 (message "point=%d of %d(%d%%) column %d %s"
|
|
807 pos total percent col hscroll))
|
|
808 ;; XEmacs: don't use single-key-description
|
|
809 (if (or (/= beg 1) (/= end (1+ total)))
|
|
810 (message "Char: %s (0%o, %d, 0x%x) point=%d of %d(%d%%) <%d - %d> column %d %s"
|
|
811 (text-char-description char) char char char pos total
|
|
812 percent beg end col hscroll)
|
|
813 (message "Char: %s (0%o, %d, 0x%x) point=%d of %d(%d%%) column %d %s"
|
|
814 (text-char-description char) char char char pos total
|
|
815 percent col hscroll)))))
|
|
816
|
|
817 (defun fundamental-mode ()
|
|
818 "Major mode not specialized for anything in particular.
|
|
819 Other major modes are defined by comparison with this one."
|
|
820 (interactive)
|
|
821 (kill-all-local-variables))
|
|
822
|
|
823 ;; XEmacs the following are declared elsewhere
|
|
824 ;(defvar read-expression-map (cons 'keymap minibuffer-local-map)
|
|
825 ; "Minibuffer keymap used for reading Lisp expressions.")
|
|
826 ;(define-key read-expression-map "\M-\t" 'lisp-complete-symbol)
|
|
827
|
|
828 ;(put 'eval-expression 'disabled t)
|
|
829
|
|
830 ;(defvar read-expression-history nil)
|
|
831
|
|
832 ;; We define this, rather than making `eval' interactive,
|
|
833 ;; for the sake of completion of names like eval-region, eval-current-buffer.
|
|
834 (defun eval-expression (expression &optional eval-expression-insert-value)
|
|
835 "Evaluate EXPRESSION and print value in minibuffer.
|
|
836 Value is also consed on to front of the variable `values'.
|
|
837 With prefix argument, insert the result to the current buffer."
|
|
838 ;(interactive "xEval: ")
|
|
839 (interactive
|
|
840 (list (read-from-minibuffer "Eval: "
|
|
841 nil read-expression-map t
|
|
842 'read-expression-history)
|
|
843 current-prefix-arg))
|
|
844 (setq values (cons (eval expression) values))
|
|
845 (prin1 (car values)
|
|
846 (if eval-expression-insert-value (current-buffer) t)))
|
|
847
|
|
848 ;; XEmacs -- extra parameter (variant, but equivalent logic)
|
444
|
849 (defun edit-and-eval-command (prompt form &optional history)
|
|
850 "Prompting with PROMPT, let user edit FORM and eval result.
|
|
851 FORM is a Lisp expression. Let user edit that expression in
|
428
|
852 the minibuffer, then read and evaluate the result."
|
444
|
853 (let ((form (read-expression prompt
|
|
854 ;; first try to format the thing readably;
|
|
855 ;; and if that fails, print it normally.
|
|
856 (condition-case ()
|
|
857 (let ((print-readably t))
|
|
858 (prin1-to-string form))
|
|
859 (error (prin1-to-string form)))
|
|
860 (or history '(command-history . 1)))))
|
428
|
861 (or history (setq history 'command-history))
|
|
862 (if (consp history)
|
|
863 (setq history (car history)))
|
|
864 (if (eq history t)
|
|
865 nil
|
444
|
866 ;; If form was added to the history as a string,
|
428
|
867 ;; get rid of that. We want only evallable expressions there.
|
|
868 (if (stringp (car (symbol-value history)))
|
|
869 (set history (cdr (symbol-value history))))
|
|
870
|
444
|
871 ;; If form to be redone does not match front of history,
|
428
|
872 ;; add it to the history.
|
444
|
873 (or (equal form (car (symbol-value history)))
|
|
874 (set history (cons form (symbol-value history)))))
|
|
875 (eval form)))
|
428
|
876
|
|
877 (defun repeat-complex-command (arg)
|
|
878 "Edit and re-evaluate last complex command, or ARGth from last.
|
|
879 A complex command is one which used the minibuffer.
|
|
880 The command is placed in the minibuffer as a Lisp form for editing.
|
|
881 The result is executed, repeating the command as changed.
|
|
882 If the command has been changed or is not the most recent previous command
|
|
883 it is added to the front of the command history.
|
|
884 You can use the minibuffer history commands \\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element]
|
|
885 to get different commands to edit and resubmit."
|
|
886 (interactive "p")
|
|
887 ;; XEmacs: It looks like our version is better -sb
|
|
888 (let ((print-level nil))
|
|
889 (edit-and-eval-command "Redo: "
|
|
890 (or (nth (1- arg) command-history)
|
|
891 (error ""))
|
|
892 (cons 'command-history arg))))
|
|
893
|
|
894 ;; XEmacs: Functions moved to minibuf.el
|
|
895 ;; previous-matching-history-element
|
|
896 ;; next-matching-history-element
|
|
897 ;; next-history-element
|
|
898 ;; previous-history-element
|
|
899 ;; next-complete-history-element
|
|
900 ;; previous-complete-history-element
|
|
901
|
444
|
902 (defun goto-line (line)
|
|
903 "Goto line LINE, counting from line 1 at beginning of buffer."
|
428
|
904 (interactive "NGoto line: ")
|
444
|
905 (setq line (prefix-numeric-value line))
|
428
|
906 (save-restriction
|
|
907 (widen)
|
|
908 (goto-char 1)
|
|
909 (if (eq selective-display t)
|
444
|
910 (re-search-forward "[\n\C-m]" nil 'end (1- line))
|
|
911 (forward-line (1- line)))))
|
428
|
912
|
771
|
913 ;[Put this on C-x u, so we can force that rather than C-_ into startup msg]
|
|
914 ;No more, stop pandering to TTY users.
|
428
|
915 (define-function 'advertised-undo 'undo)
|
|
916
|
444
|
917 (defun undo (&optional count)
|
428
|
918 "Undo some previous changes.
|
|
919 Repeat this command to undo more changes.
|
|
920 A numeric argument serves as a repeat count."
|
|
921 (interactive "*p")
|
|
922 ;; If we don't get all the way through, make last-command indicate that
|
|
923 ;; for the following command.
|
|
924 (setq this-command t)
|
|
925 (let ((modified (buffer-modified-p))
|
|
926 (recent-save (recent-auto-save-p)))
|
|
927 (or (eq (selected-window) (minibuffer-window))
|
|
928 (display-message 'command "Undo!"))
|
|
929 (or (and (eq last-command 'undo)
|
|
930 (eq (current-buffer) last-undo-buffer)) ; XEmacs
|
|
931 (progn (undo-start)
|
|
932 (undo-more 1)))
|
444
|
933 (undo-more (or count 1))
|
428
|
934 ;; Don't specify a position in the undo record for the undo command.
|
|
935 ;; Instead, undoing this should move point to where the change is.
|
|
936 (let ((tail buffer-undo-list)
|
|
937 done)
|
|
938 (while (and tail (not done) (not (null (car tail))))
|
|
939 (if (integerp (car tail))
|
|
940 (progn
|
|
941 (setq done t)
|
|
942 (setq buffer-undo-list (delq (car tail) buffer-undo-list))))
|
|
943 (setq tail (cdr tail))))
|
|
944 (and modified (not (buffer-modified-p))
|
|
945 (delete-auto-save-file-if-necessary recent-save)))
|
|
946 ;; If we do get all the way through, make this-command indicate that.
|
|
947 (setq this-command 'undo))
|
|
948
|
|
949 (defvar pending-undo-list nil
|
|
950 "Within a run of consecutive undo commands, list remaining to be undone.")
|
|
951
|
|
952 (defvar last-undo-buffer nil) ; XEmacs
|
|
953
|
|
954 (defun undo-start ()
|
|
955 "Set `pending-undo-list' to the front of the undo list.
|
|
956 The next call to `undo-more' will undo the most recently made change."
|
|
957 (if (eq buffer-undo-list t)
|
|
958 (error "No undo information in this buffer"))
|
|
959 (setq pending-undo-list buffer-undo-list))
|
|
960
|
|
961 (defun undo-more (count)
|
|
962 "Undo back N undo-boundaries beyond what was already undone recently.
|
|
963 Call `undo-start' to get ready to undo recent changes,
|
|
964 then call `undo-more' one or more times to undo them."
|
|
965 (or pending-undo-list
|
|
966 (error "No further undo information"))
|
|
967 (setq pending-undo-list (primitive-undo count pending-undo-list)
|
|
968 last-undo-buffer (current-buffer))) ; XEmacs
|
|
969
|
844
|
970 (defun undo-all-changes ()
|
|
971 "Keep undoing till the start of the undo list is reached.
|
|
972 Undoes all changes, even past a file save. Especially useful when you've
|
|
973 saved the file at some point."
|
|
974 (interactive)
|
|
975 (undo-start)
|
|
976 (while pending-undo-list (undo-more 1)))
|
|
977
|
428
|
978 ;; XEmacs
|
|
979 (defun call-with-transparent-undo (fn &rest args)
|
|
980 "Apply FN to ARGS, and then undo all changes made by FN to the current
|
|
981 buffer. The undo records are processed even if FN returns non-locally.
|
|
982 There is no trace of the changes made by FN in the buffer's undo history.
|
|
983
|
|
984 You can use this in a write-file-hooks function with continue-save-buffer
|
|
985 to make the contents of a disk file differ from its in-memory buffer."
|
|
986 (let ((buffer-undo-list nil)
|
|
987 ;; Kludge to prevent undo list truncation:
|
|
988 (undo-high-threshold -1)
|
|
989 (undo-threshold -1)
|
|
990 (obuffer (current-buffer)))
|
|
991 (unwind-protect
|
|
992 (apply fn args)
|
|
993 ;; Go to the buffer we will restore and make it writable:
|
|
994 (set-buffer obuffer)
|
|
995 (save-excursion
|
|
996 (let ((buffer-read-only nil))
|
|
997 (save-restriction
|
|
998 (widen)
|
|
999 ;; Perform all undos, with further undo logging disabled:
|
|
1000 (let ((tail buffer-undo-list))
|
|
1001 (setq buffer-undo-list t)
|
|
1002 (while tail
|
|
1003 (setq tail (primitive-undo (length tail) tail))))))))))
|
|
1004
|
|
1005 ;; XEmacs: The following are in other files
|
|
1006 ;; shell-command-history
|
|
1007 ;; shell-command-switch
|
|
1008 ;; shell-command
|
|
1009 ;; shell-command-sentinel
|
|
1010
|
|
1011
|
|
1012 (defconst universal-argument-map
|
|
1013 (let ((map (make-sparse-keymap)))
|
|
1014 (set-keymap-default-binding map 'universal-argument-other-key)
|
|
1015 ;FSFmacs (define-key map [switch-frame] nil)
|
|
1016 (define-key map [(t)] 'universal-argument-other-key)
|
|
1017 (define-key map [(meta t)] 'universal-argument-other-key)
|
|
1018 (define-key map [(control u)] 'universal-argument-more)
|
|
1019 (define-key map [?-] 'universal-argument-minus)
|
|
1020 (define-key map [?0] 'digit-argument)
|
|
1021 (define-key map [?1] 'digit-argument)
|
|
1022 (define-key map [?2] 'digit-argument)
|
|
1023 (define-key map [?3] 'digit-argument)
|
|
1024 (define-key map [?4] 'digit-argument)
|
|
1025 (define-key map [?5] 'digit-argument)
|
|
1026 (define-key map [?6] 'digit-argument)
|
|
1027 (define-key map [?7] 'digit-argument)
|
|
1028 (define-key map [?8] 'digit-argument)
|
|
1029 (define-key map [?9] 'digit-argument)
|
|
1030 map)
|
|
1031 "Keymap used while processing \\[universal-argument].")
|
|
1032
|
|
1033 (defvar universal-argument-num-events nil
|
|
1034 "Number of argument-specifying events read by `universal-argument'.
|
|
1035 `universal-argument-other-key' uses this to discard those events
|
|
1036 from (this-command-keys), and reread only the final command.")
|
|
1037
|
|
1038 (defun universal-argument ()
|
|
1039 "Begin a numeric argument for the following command.
|
|
1040 Digits or minus sign following \\[universal-argument] make up the numeric argument.
|
|
1041 \\[universal-argument] following the digits or minus sign ends the argument.
|
|
1042 \\[universal-argument] without digits or minus sign provides 4 as argument.
|
|
1043 Repeating \\[universal-argument] without digits or minus sign
|
|
1044 multiplies the argument by 4 each time."
|
|
1045 (interactive)
|
|
1046 (setq prefix-arg (list 4))
|
|
1047 (setq zmacs-region-stays t) ; XEmacs
|
|
1048 (setq universal-argument-num-events (length (this-command-keys)))
|
|
1049 (setq overriding-terminal-local-map universal-argument-map))
|
|
1050
|
|
1051 ;; A subsequent C-u means to multiply the factor by 4 if we've typed
|
|
1052 ;; nothing but C-u's; otherwise it means to terminate the prefix arg.
|
|
1053 (defun universal-argument-more (arg)
|
|
1054 (interactive "_P") ; XEmacs
|
|
1055 (if (consp arg)
|
|
1056 (setq prefix-arg (list (* 4 (car arg))))
|
|
1057 (setq prefix-arg arg)
|
|
1058 (setq overriding-terminal-local-map nil))
|
|
1059 (setq universal-argument-num-events (length (this-command-keys))))
|
|
1060
|
|
1061 (defun negative-argument (arg)
|
|
1062 "Begin a negative numeric argument for the next command.
|
|
1063 \\[universal-argument] following digits or minus sign ends the argument."
|
|
1064 (interactive "_P") ; XEmacs
|
|
1065 (cond ((integerp arg)
|
|
1066 (setq prefix-arg (- arg)))
|
|
1067 ((eq arg '-)
|
|
1068 (setq prefix-arg nil))
|
|
1069 (t
|
|
1070 (setq prefix-arg '-)))
|
|
1071 (setq universal-argument-num-events (length (this-command-keys)))
|
|
1072 (setq overriding-terminal-local-map universal-argument-map))
|
|
1073
|
|
1074 ;; XEmacs: This function not synched with FSF
|
|
1075 (defun digit-argument (arg)
|
|
1076 "Part of the numeric argument for the next command.
|
|
1077 \\[universal-argument] following digits or minus sign ends the argument."
|
|
1078 (interactive "_P") ; XEmacs
|
|
1079 (let* ((event last-command-event)
|
|
1080 (key (and (key-press-event-p event)
|
|
1081 (event-key event)))
|
|
1082 (digit (and key (characterp key) (>= key ?0) (<= key ?9)
|
|
1083 (- key ?0))))
|
|
1084 (if (null digit)
|
|
1085 (universal-argument-other-key arg)
|
|
1086 (cond ((integerp arg)
|
|
1087 (setq prefix-arg (+ (* arg 10)
|
|
1088 (if (< arg 0) (- digit) digit))))
|
|
1089 ((eq arg '-)
|
|
1090 ;; Treat -0 as just -, so that -01 will work.
|
|
1091 (setq prefix-arg (if (zerop digit) '- (- digit))))
|
|
1092 (t
|
|
1093 (setq prefix-arg digit)))
|
|
1094 (setq universal-argument-num-events (length (this-command-keys)))
|
|
1095 (setq overriding-terminal-local-map universal-argument-map))))
|
|
1096
|
|
1097 ;; For backward compatibility, minus with no modifiers is an ordinary
|
|
1098 ;; command if digits have already been entered.
|
|
1099 (defun universal-argument-minus (arg)
|
|
1100 (interactive "_P") ; XEmacs
|
|
1101 (if (integerp arg)
|
|
1102 (universal-argument-other-key arg)
|
|
1103 (negative-argument arg)))
|
|
1104
|
|
1105 ;; Anything else terminates the argument and is left in the queue to be
|
|
1106 ;; executed as a command.
|
|
1107 (defun universal-argument-other-key (arg)
|
|
1108 (interactive "_P") ; XEmacs
|
|
1109 (setq prefix-arg arg)
|
|
1110 (let* ((key (this-command-keys))
|
|
1111 ;; FSF calls silly function `listify-key-sequence' here.
|
|
1112 (keylist (append key nil)))
|
|
1113 (setq unread-command-events
|
|
1114 (append (nthcdr universal-argument-num-events keylist)
|
|
1115 unread-command-events)))
|
|
1116 (reset-this-command-lengths)
|
|
1117 (setq overriding-terminal-local-map nil))
|
|
1118
|
|
1119
|
|
1120 ;; XEmacs -- keep zmacs-region active.
|
444
|
1121 (defun forward-to-indentation (count)
|
|
1122 "Move forward COUNT lines and position at first nonblank character."
|
428
|
1123 (interactive "_p")
|
444
|
1124 (forward-line count)
|
428
|
1125 (skip-chars-forward " \t"))
|
|
1126
|
444
|
1127 (defun backward-to-indentation (count)
|
|
1128 "Move backward COUNT lines and position at first nonblank character."
|
428
|
1129 (interactive "_p")
|
444
|
1130 (forward-line (- count))
|
428
|
1131 (skip-chars-forward " \t"))
|
|
1132
|
|
1133 (defcustom kill-whole-line nil
|
462
|
1134 "*If non-nil, kill the whole line if point is at the beginning.
|
|
1135 Otherwise, `kill-line' kills only up to the end of the line, but not
|
503
|
1136 the terminating newline.
|
462
|
1137
|
|
1138 WARNING: This is a misnamed variable! It should be called something
|
|
1139 like `kill-whole-line-when-at-beginning'. If you simply want
|
|
1140 \\[kill-line] to kill the entire current line, bind it to the function
|
|
1141 `kill-entire-line'. "
|
|
1142 :type 'boolean
|
428
|
1143 :group 'killing)
|
|
1144
|
503
|
1145 (defun kill-line-1 (arg entire-line)
|
462
|
1146 (kill-region (if entire-line
|
442
|
1147 (save-excursion
|
|
1148 (beginning-of-line)
|
|
1149 (point))
|
|
1150 (point))
|
428
|
1151 ;; Don't shift point before doing the delete; that way,
|
|
1152 ;; undo will record the right position of point.
|
|
1153 ;; FSF
|
|
1154 ; ;; It is better to move point to the other end of the kill
|
|
1155 ; ;; before killing. That way, in a read-only buffer, point
|
|
1156 ; ;; moves across the text that is copied to the kill ring.
|
|
1157 ; ;; The choice has no effect on undo now that undo records
|
|
1158 ; ;; the value of point from before the command was run.
|
|
1159 ; (progn
|
|
1160 (save-excursion
|
|
1161 (if arg
|
|
1162 (forward-line (prefix-numeric-value arg))
|
|
1163 (if (eobp)
|
|
1164 (signal 'end-of-buffer nil))
|
442
|
1165 (if (or (looking-at "[ \t]*$")
|
462
|
1166 (or entire-line
|
503
|
1167 (and kill-whole-line (bolp))))
|
428
|
1168 (forward-line 1)
|
|
1169 (end-of-line)))
|
|
1170 (point))))
|
|
1171
|
462
|
1172 (defun kill-entire-line (&optional arg)
|
|
1173 "Kill the entire line.
|
|
1174 With prefix argument, kill that many lines from point. Negative
|
|
1175 arguments kill lines backward.
|
|
1176
|
|
1177 When calling from a program, nil means \"no arg\",
|
|
1178 a number counts as a prefix arg."
|
|
1179 (interactive "*P")
|
503
|
1180 (kill-line-1 arg t))
|
462
|
1181
|
|
1182 (defun kill-line (&optional arg)
|
|
1183 "Kill the rest of the current line, or the entire line.
|
|
1184 If no nonblanks there, kill thru newline. If called interactively,
|
|
1185 may kill the entire line when given no argument at the beginning of a
|
|
1186 line; see `kill-whole-line'. With prefix argument, kill that many
|
|
1187 lines from point. Negative arguments kill lines backward.
|
|
1188
|
|
1189 WARNING: This is a misnamed function! It should be called something
|
|
1190 like `kill-to-end-of-line'. If you simply want to kill the entire
|
|
1191 current line, use `kill-entire-line'.
|
|
1192
|
|
1193 When calling from a program, nil means \"no arg\",
|
|
1194 a number counts as a prefix arg."
|
|
1195 (interactive "*P")
|
503
|
1196 (kill-line-1 arg nil))
|
462
|
1197
|
428
|
1198 ;; XEmacs
|
|
1199 (defun backward-kill-line nil
|
|
1200 "Kill back to the beginning of the line."
|
|
1201 (interactive)
|
|
1202 (let ((point (point)))
|
|
1203 (beginning-of-line nil)
|
|
1204 (kill-region (point) point)))
|
|
1205
|
|
1206
|
|
1207 ;;;; Window system cut and paste hooks.
|
|
1208 ;;;
|
|
1209 ;;; I think that kill-hooks is a better name and more general mechanism
|
|
1210 ;;; than interprogram-cut-function (from FSFmacs). I don't like the behavior
|
|
1211 ;;; of interprogram-paste-function: ^Y should always come from the kill ring,
|
|
1212 ;;; not the X selection. But if that were provided, it should be called (and
|
|
1213 ;;; behave as) yank-hooks instead. -- jwz
|
|
1214
|
|
1215 ;; [... code snipped ...]
|
|
1216
|
|
1217 (defcustom kill-hooks nil
|
|
1218 "*Functions run when something is added to the XEmacs kill ring.
|
|
1219 These functions are called with one argument, the string most recently
|
|
1220 cut or copied. You can use this to, for example, make the most recent
|
|
1221 kill become the X Clipboard selection."
|
|
1222 :type 'hook
|
|
1223 :group 'killing)
|
|
1224
|
|
1225 ;;; `kill-hooks' seems not sufficient because
|
|
1226 ;;; `interprogram-cut-function' requires more variable about to rotate
|
|
1227 ;;; the cut buffers. I'm afraid to change interface of `kill-hooks',
|
|
1228 ;;; so I add it. (1997-11-03 by MORIOKA Tomohiko)
|
|
1229
|
442
|
1230 (defcustom interprogram-cut-function 'own-clipboard
|
428
|
1231 "Function to call to make a killed region available to other programs.
|
|
1232
|
|
1233 Most window systems provide some sort of facility for cutting and
|
|
1234 pasting text between the windows of different programs.
|
|
1235 This variable holds a function that Emacs calls whenever text
|
|
1236 is put in the kill ring, to make the new kill available to other
|
|
1237 programs.
|
|
1238
|
|
1239 The function takes one or two arguments.
|
|
1240 The first argument, TEXT, is a string containing
|
|
1241 the text which should be made available.
|
|
1242 The second, PUSH, if non-nil means this is a \"new\" kill;
|
843
|
1243 nil means appending to an \"old\" kill.
|
|
1244
|
|
1245 One reasonable choice is `own-clipboard' (the default)."
|
442
|
1246 :type '(radio (function-item :tag "Send to Clipboard"
|
|
1247 :format "%t\n"
|
|
1248 own-clipboard)
|
|
1249 (const :tag "None" nil)
|
|
1250 (function :tag "Other"))
|
|
1251 :group 'killing)
|
|
1252
|
843
|
1253 (defcustom interprogram-paste-function 'get-clipboard-foreign
|
428
|
1254 "Function to call to get text cut from other programs.
|
|
1255
|
|
1256 Most window systems provide some sort of facility for cutting and
|
|
1257 pasting text between the windows of different programs.
|
|
1258 This variable holds a function that Emacs calls to obtain
|
|
1259 text that other programs have provided for pasting.
|
|
1260
|
|
1261 The function should be called with no arguments. If the function
|
|
1262 returns nil, then no other program has provided such text, and the top
|
|
1263 of the Emacs kill ring should be used. If the function returns a
|
|
1264 string, that string should be put in the kill ring as the latest kill.
|
|
1265
|
|
1266 Note that the function should return a string only if a program other
|
|
1267 than Emacs has provided a string for pasting; if Emacs provided the
|
|
1268 most recent string, the function should return nil. If it is
|
|
1269 difficult to tell whether Emacs or some other program provided the
|
|
1270 current string, it is probably good enough to return nil if the string
|
843
|
1271 is equal (according to `string=') to the last text Emacs provided.
|
|
1272
|
|
1273 Reasonable choices include `get-clipboard-foreign' (the default), and
|
|
1274 functions calling `get-selection-foreign' (q.v.)."
|
442
|
1275 :type '(radio (function-item :tag "Get from Clipboard"
|
|
1276 :format "%t\n"
|
843
|
1277 get-clipboard-foreign)
|
442
|
1278 (const :tag "None" nil)
|
|
1279 (function :tag "Other"))
|
|
1280 :group 'killing)
|
428
|
1281
|
|
1282
|
|
1283 ;;;; The kill ring data structure.
|
|
1284
|
|
1285 (defvar kill-ring nil
|
|
1286 "List of killed text sequences.
|
|
1287 Since the kill ring is supposed to interact nicely with cut-and-paste
|
|
1288 facilities offered by window systems, use of this variable should
|
|
1289 interact nicely with `interprogram-cut-function' and
|
|
1290 `interprogram-paste-function'. The functions `kill-new',
|
|
1291 `kill-append', and `current-kill' are supposed to implement this
|
|
1292 interaction; you may want to use them instead of manipulating the kill
|
|
1293 ring directly.")
|
|
1294
|
829
|
1295 (defcustom kill-ring-max 60
|
428
|
1296 "*Maximum length of kill ring before oldest elements are thrown away."
|
|
1297 :type 'integer
|
|
1298 :group 'killing)
|
|
1299
|
|
1300 (defvar kill-ring-yank-pointer nil
|
|
1301 "The tail of the kill ring whose car is the last thing yanked.")
|
|
1302
|
|
1303 (defun kill-new (string &optional replace)
|
|
1304 "Make STRING the latest kill in the kill ring.
|
444
|
1305 Set `kill-ring-yank-pointer' to point to it.
|
829
|
1306 If `interprogram-cut-function' is non-nil, apply it to STRING.
|
428
|
1307 Run `kill-hooks'.
|
|
1308 Optional second argument REPLACE non-nil means that STRING will replace
|
|
1309 the front of the kill ring, rather than being added to the list."
|
|
1310 ; (and (fboundp 'menu-bar-update-yank-menu)
|
|
1311 ; (menu-bar-update-yank-menu string (and replace (car kill-ring))))
|
829
|
1312 (if (and replace kill-ring)
|
428
|
1313 (setcar kill-ring string)
|
|
1314 (setq kill-ring (cons string kill-ring))
|
|
1315 (if (> (length kill-ring) kill-ring-max)
|
|
1316 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
|
|
1317 (setq kill-ring-yank-pointer kill-ring)
|
|
1318 (if interprogram-cut-function
|
|
1319 (funcall interprogram-cut-function string (not replace)))
|
|
1320 (run-hook-with-args 'kill-hooks string))
|
|
1321
|
|
1322 (defun kill-append (string before-p)
|
|
1323 "Append STRING to the end of the latest kill in the kill ring.
|
|
1324 If BEFORE-P is non-nil, prepend STRING to the kill.
|
|
1325 Run `kill-hooks'."
|
|
1326 (kill-new (if before-p
|
|
1327 (concat string (car kill-ring))
|
|
1328 (concat (car kill-ring) string)) t))
|
|
1329
|
|
1330 (defun current-kill (n &optional do-not-move)
|
|
1331 "Rotate the yanking point by N places, and then return that kill.
|
|
1332 If N is zero, `interprogram-paste-function' is set, and calling it
|
|
1333 returns a string, then that string is added to the front of the
|
|
1334 kill ring and returned as the latest kill.
|
|
1335 If optional arg DO-NOT-MOVE is non-nil, then don't actually move the
|
|
1336 yanking point\; just return the Nth kill forward."
|
|
1337 (let ((interprogram-paste (and (= n 0)
|
|
1338 interprogram-paste-function
|
|
1339 (funcall interprogram-paste-function))))
|
|
1340 (if interprogram-paste
|
|
1341 (progn
|
|
1342 ;; Disable the interprogram cut function when we add the new
|
|
1343 ;; text to the kill ring, so Emacs doesn't try to own the
|
|
1344 ;; selection, with identical text.
|
|
1345 (let ((interprogram-cut-function nil))
|
|
1346 (kill-new interprogram-paste))
|
|
1347 interprogram-paste)
|
|
1348 (or kill-ring (error "Kill ring is empty"))
|
|
1349 (let* ((tem (nthcdr (mod (- n (length kill-ring-yank-pointer))
|
|
1350 (length kill-ring))
|
|
1351 kill-ring)))
|
|
1352 (or do-not-move
|
|
1353 (setq kill-ring-yank-pointer tem))
|
|
1354 (car tem)))))
|
|
1355
|
|
1356
|
|
1357
|
|
1358 ;;;; Commands for manipulating the kill ring.
|
|
1359
|
|
1360 ;; In FSF killing read-only text just pastes it into kill-ring. Which
|
|
1361 ;; is a very bad idea -- see Jamie's comment below.
|
|
1362
|
|
1363 ;(defvar kill-read-only-ok nil
|
|
1364 ; "*Non-nil means don't signal an error for killing read-only text.")
|
|
1365
|
444
|
1366 (defun kill-region (start end &optional verbose) ; verbose is XEmacs addition
|
428
|
1367 "Kill between point and mark.
|
|
1368 The text is deleted but saved in the kill ring.
|
|
1369 The command \\[yank] can retrieve it from there.
|
|
1370 \(If you want to kill and then yank immediately, use \\[copy-region-as-kill].)
|
|
1371
|
|
1372 This is the primitive for programs to kill text (as opposed to deleting it).
|
|
1373 Supply two arguments, character numbers indicating the stretch of text
|
|
1374 to be killed.
|
|
1375 Any command that calls this function is a \"kill command\".
|
|
1376 If the previous command was also a kill command,
|
|
1377 the text killed this time appends to the text killed last time
|
|
1378 to make one entry in the kill ring."
|
|
1379 (interactive "*r\np")
|
|
1380 ; (interactive
|
|
1381 ; (let ((region-hack (and zmacs-regions (eq last-command 'yank))))
|
|
1382 ; ;; This lets "^Y^W" work. I think this is dumb, but zwei did it.
|
|
1383 ; (if region-hack (zmacs-activate-region))
|
|
1384 ; (prog1
|
|
1385 ; (list (point) (mark) current-prefix-arg)
|
|
1386 ; (if region-hack (zmacs-deactivate-region)))))
|
444
|
1387 ;; start and end can be markers but the rest of this function is
|
428
|
1388 ;; written as if they are only integers
|
444
|
1389 (if (markerp start) (setq start (marker-position start)))
|
428
|
1390 (if (markerp end) (setq end (marker-position end)))
|
444
|
1391 (or (and start end) (if zmacs-regions ;; rewritten for I18N3 snarfing
|
428
|
1392 (error "The region is not active now")
|
|
1393 (error "The mark is not set now")))
|
|
1394 (if verbose (if buffer-read-only
|
|
1395 (lmessage 'command "Copying %d characters"
|
444
|
1396 (- (max start end) (min start end)))
|
428
|
1397 (lmessage 'command "Killing %d characters"
|
444
|
1398 (- (max start end) (min start end)))))
|
428
|
1399 (cond
|
|
1400
|
|
1401 ;; I don't like this large change in behavior -- jwz
|
|
1402 ;; Read-Only text means it shouldn't be deleted, so I'm restoring
|
|
1403 ;; this code, but only for text-properties and not full extents. -sb
|
|
1404 ;; If the buffer is read-only, we should beep, in case the person
|
|
1405 ;; just isn't aware of this. However, there's no harm in putting
|
|
1406 ;; the region's text in the kill ring, anyway.
|
|
1407 ((or (and buffer-read-only (not inhibit-read-only))
|
444
|
1408 (text-property-not-all (min start end) (max start end) 'read-only nil))
|
428
|
1409 ;; This is redundant.
|
|
1410 ;; (if verbose (message "Copying %d characters"
|
444
|
1411 ;; (- (max start end) (min start end))))
|
|
1412 (copy-region-as-kill start end)
|
428
|
1413 ;; ;; This should always barf, and give us the correct error.
|
|
1414 ;; (if kill-read-only-ok
|
|
1415 ;; (message "Read only text copied to kill ring")
|
|
1416 (setq this-command 'kill-region)
|
|
1417 (barf-if-buffer-read-only)
|
|
1418 (signal 'buffer-read-only (list (current-buffer))))
|
|
1419
|
|
1420 ;; In certain cases, we can arrange for the undo list and the kill
|
|
1421 ;; ring to share the same string object. This code does that.
|
|
1422 ((not (or (eq buffer-undo-list t)
|
|
1423 (eq last-command 'kill-region)
|
|
1424 ;; Use = since positions may be numbers or markers.
|
444
|
1425 (= start end)))
|
428
|
1426 ;; Don't let the undo list be truncated before we can even access it.
|
|
1427 ;; FSF calls this `undo-strong-limit'
|
444
|
1428 (let ((undo-high-threshold (+ (- end start) 100))
|
428
|
1429 ;(old-list buffer-undo-list)
|
|
1430 tail)
|
444
|
1431 (delete-region start end)
|
428
|
1432 ;; Search back in buffer-undo-list for this string,
|
|
1433 ;; in case a change hook made property changes.
|
|
1434 (setq tail buffer-undo-list)
|
|
1435 (while (and tail
|
|
1436 (not (stringp (car-safe (car-safe tail))))) ; XEmacs
|
|
1437 (pop tail))
|
|
1438 ;; Take the same string recorded for undo
|
|
1439 ;; and put it in the kill-ring.
|
|
1440 (and tail
|
|
1441 (kill-new (car (car tail))))))
|
|
1442
|
|
1443 (t
|
|
1444 ;; if undo is not kept, grab the string then delete it (which won't
|
|
1445 ;; add another string to the undo list).
|
444
|
1446 (copy-region-as-kill start end)
|
|
1447 (delete-region start end)))
|
428
|
1448 (setq this-command 'kill-region))
|
|
1449
|
|
1450 ;; copy-region-as-kill no longer sets this-command, because it's confusing
|
|
1451 ;; to get two copies of the text when the user accidentally types M-w and
|
|
1452 ;; then corrects it with the intended C-w.
|
444
|
1453 (defun copy-region-as-kill (start end)
|
428
|
1454 "Save the region as if killed, but don't kill it.
|
|
1455 Run `kill-hooks'."
|
|
1456 (interactive "r")
|
|
1457 (if (eq last-command 'kill-region)
|
444
|
1458 (kill-append (buffer-substring start end) (< end start))
|
|
1459 (kill-new (buffer-substring start end)))
|
428
|
1460 nil)
|
|
1461
|
444
|
1462 (defun kill-ring-save (start end)
|
428
|
1463 "Save the region as if killed, but don't kill it.
|
|
1464 This command is similar to `copy-region-as-kill', except that it gives
|
|
1465 visual feedback indicating the extent of the region being copied."
|
|
1466 (interactive "r")
|
444
|
1467 (copy-region-as-kill start end)
|
428
|
1468 ;; copy before delay, for xclipboard's benefit
|
|
1469 (if (interactive-p)
|
444
|
1470 (let ((other-end (if (= (point) start) end start))
|
428
|
1471 (opoint (point))
|
|
1472 ;; Inhibit quitting so we can make a quit here
|
|
1473 ;; look like a C-g typed as a command.
|
|
1474 (inhibit-quit t))
|
|
1475 (if (pos-visible-in-window-p other-end (selected-window))
|
|
1476 (progn
|
|
1477 ;; FSF (I'm not sure what this does -sb)
|
|
1478 ; ;; Swap point and mark.
|
|
1479 ; (set-marker (mark-marker) (point) (current-buffer))
|
|
1480 (goto-char other-end)
|
|
1481 (sit-for 1)
|
|
1482 ; ;; Swap back.
|
|
1483 ; (set-marker (mark-marker) other-end (current-buffer))
|
|
1484 (goto-char opoint)
|
|
1485 ;; If user quit, deactivate the mark
|
|
1486 ;; as C-g would as a command.
|
|
1487 (and quit-flag (mark)
|
|
1488 (zmacs-deactivate-region)))
|
|
1489 ;; too noisy. -- jwz
|
|
1490 ; (let* ((killed-text (current-kill 0))
|
|
1491 ; (message-len (min (length killed-text) 40)))
|
444
|
1492 ; (if (= (point) start)
|
428
|
1493 ; ;; Don't say "killed"; that is misleading.
|
|
1494 ; (message "Saved text until \"%s\""
|
|
1495 ; (substring killed-text (- message-len)))
|
|
1496 ; (message "Saved text from \"%s\""
|
|
1497 ; (substring killed-text 0 message-len))))
|
|
1498 ))))
|
|
1499
|
|
1500 (defun append-next-kill ()
|
|
1501 "Cause following command, if it kills, to append to previous kill."
|
|
1502 ;; XEmacs
|
|
1503 (interactive "_")
|
|
1504 (if (interactive-p)
|
|
1505 (progn
|
|
1506 (setq this-command 'kill-region)
|
|
1507 (display-message 'command
|
|
1508 "If the next command is a kill, it will append"))
|
|
1509 (setq last-command 'kill-region)))
|
|
1510
|
|
1511 (defun yank-pop (arg)
|
|
1512 "Replace just-yanked stretch of killed text with a different stretch.
|
|
1513 This command is allowed only immediately after a `yank' or a `yank-pop'.
|
|
1514 At such a time, the region contains a stretch of reinserted
|
|
1515 previously-killed text. `yank-pop' deletes that text and inserts in its
|
|
1516 place a different stretch of killed text.
|
|
1517
|
|
1518 With no argument, the previous kill is inserted.
|
|
1519 With argument N, insert the Nth previous kill.
|
|
1520 If N is negative, this is a more recent kill.
|
|
1521
|
|
1522 The sequence of kills wraps around, so that after the oldest one
|
|
1523 comes the newest one."
|
|
1524 (interactive "*p")
|
|
1525 (if (not (eq last-command 'yank))
|
|
1526 (error "Previous command was not a yank"))
|
|
1527 (setq this-command 'yank)
|
|
1528 (let ((inhibit-read-only t)
|
|
1529 (before (< (point) (mark t))))
|
|
1530 (delete-region (point) (mark t))
|
|
1531 ;;(set-marker (mark-marker) (point) (current-buffer))
|
|
1532 (set-mark (point))
|
|
1533 (insert (current-kill arg))
|
|
1534 (if before
|
|
1535 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
|
|
1536 ;; It is cleaner to avoid activation, even though the command
|
|
1537 ;; loop would deactivate the mark because we inserted text.
|
|
1538 (goto-char (prog1 (mark t)
|
|
1539 (set-marker (mark-marker t) (point) (current-buffer))))))
|
|
1540 nil)
|
|
1541
|
|
1542
|
|
1543 (defun yank (&optional arg)
|
|
1544 "Reinsert the last stretch of killed text.
|
|
1545 More precisely, reinsert the stretch of killed text most recently
|
|
1546 killed OR yanked. Put point at end, and set mark at beginning.
|
|
1547 With just C-u as argument, same but put point at beginning (and mark at end).
|
|
1548 With argument N, reinsert the Nth most recently killed stretch of killed
|
|
1549 text.
|
|
1550 See also the command \\[yank-pop]."
|
|
1551 (interactive "*P")
|
|
1552 ;; If we don't get all the way through, make last-command indicate that
|
|
1553 ;; for the following command.
|
|
1554 (setq this-command t)
|
|
1555 (push-mark (point))
|
|
1556 (insert (current-kill (cond
|
|
1557 ((listp arg) 0)
|
|
1558 ((eq arg '-) -1)
|
|
1559 (t (1- arg)))))
|
|
1560 (if (consp arg)
|
|
1561 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
|
|
1562 ;; It is cleaner to avoid activation, even though the command
|
|
1563 ;; loop would deactivate the mark because we inserted text.
|
|
1564 ;; (But it's an unnecessary kludge in XEmacs.)
|
|
1565 ;(goto-char (prog1 (mark t)
|
|
1566 ;(set-marker (mark-marker) (point) (current-buffer)))))
|
|
1567 (exchange-point-and-mark t))
|
|
1568 ;; If we do get all the way thru, make this-command indicate that.
|
|
1569 (setq this-command 'yank)
|
|
1570 nil)
|
|
1571
|
|
1572 (defun rotate-yank-pointer (arg)
|
|
1573 "Rotate the yanking point in the kill ring.
|
|
1574 With argument, rotate that many kills forward (or backward, if negative)."
|
|
1575 (interactive "p")
|
|
1576 (current-kill arg))
|
|
1577
|
|
1578
|
|
1579 (defun insert-buffer (buffer)
|
|
1580 "Insert after point the contents of BUFFER.
|
|
1581 Puts mark after the inserted text.
|
|
1582 BUFFER may be a buffer or a buffer name."
|
|
1583 (interactive
|
|
1584 (list
|
|
1585 (progn
|
|
1586 (barf-if-buffer-read-only)
|
|
1587 (read-buffer "Insert buffer: "
|
|
1588 ;; XEmacs: we have different args
|
|
1589 (other-buffer (current-buffer) nil t)
|
|
1590 t))))
|
|
1591 (or (bufferp buffer)
|
|
1592 (setq buffer (get-buffer buffer)))
|
|
1593 (let (start end newmark)
|
|
1594 (save-excursion
|
|
1595 (save-excursion
|
|
1596 (set-buffer buffer)
|
|
1597 (setq start (point-min) end (point-max)))
|
|
1598 (insert-buffer-substring buffer start end)
|
|
1599 (setq newmark (point)))
|
|
1600 (push-mark newmark))
|
|
1601 nil)
|
|
1602
|
|
1603 (defun append-to-buffer (buffer start end)
|
|
1604 "Append to specified buffer the text of the region.
|
|
1605 It is inserted into that buffer before its point.
|
|
1606
|
|
1607 When calling from a program, give three arguments:
|
|
1608 BUFFER (or buffer name), START and END.
|
|
1609 START and END specify the portion of the current buffer to be copied."
|
|
1610 (interactive
|
|
1611 ;; XEmacs: we have different args to other-buffer
|
|
1612 (list (read-buffer "Append to buffer: " (other-buffer (current-buffer)
|
|
1613 nil t))
|
|
1614 (region-beginning) (region-end)))
|
|
1615 (let ((oldbuf (current-buffer)))
|
|
1616 (save-excursion
|
|
1617 (set-buffer (get-buffer-create buffer))
|
|
1618 (insert-buffer-substring oldbuf start end))))
|
|
1619
|
|
1620 (defun prepend-to-buffer (buffer start end)
|
|
1621 "Prepend to specified buffer the text of the region.
|
|
1622 It is inserted into that buffer after its point.
|
|
1623
|
|
1624 When calling from a program, give three arguments:
|
|
1625 BUFFER (or buffer name), START and END.
|
|
1626 START and END specify the portion of the current buffer to be copied."
|
|
1627 (interactive "BPrepend to buffer: \nr")
|
|
1628 (let ((oldbuf (current-buffer)))
|
|
1629 (save-excursion
|
|
1630 (set-buffer (get-buffer-create buffer))
|
|
1631 (save-excursion
|
|
1632 (insert-buffer-substring oldbuf start end)))))
|
|
1633
|
|
1634 (defun copy-to-buffer (buffer start end)
|
|
1635 "Copy to specified buffer the text of the region.
|
|
1636 It is inserted into that buffer, replacing existing text there.
|
|
1637
|
|
1638 When calling from a program, give three arguments:
|
|
1639 BUFFER (or buffer name), START and END.
|
|
1640 START and END specify the portion of the current buffer to be copied."
|
|
1641 (interactive "BCopy to buffer: \nr")
|
|
1642 (let ((oldbuf (current-buffer)))
|
|
1643 (save-excursion
|
|
1644 (set-buffer (get-buffer-create buffer))
|
|
1645 (erase-buffer)
|
|
1646 (save-excursion
|
|
1647 (insert-buffer-substring oldbuf start end)))))
|
|
1648
|
|
1649 ;FSFmacs
|
|
1650 ;(put 'mark-inactive 'error-conditions '(mark-inactive error))
|
|
1651 ;(put 'mark-inactive 'error-message "The mark is not active now")
|
|
1652
|
|
1653 (defun mark (&optional force buffer)
|
|
1654 "Return this buffer's mark value as integer, or nil if no mark.
|
|
1655
|
|
1656 If `zmacs-regions' is true, then this returns nil unless the region is
|
|
1657 currently in the active (highlighted) state. With an argument of t, this
|
|
1658 returns the mark (if there is one) regardless of the active-region state.
|
|
1659 You should *generally* not use the mark unless the region is active, if
|
|
1660 the user has expressed a preference for the active-region model.
|
|
1661
|
|
1662 If you are using this in an editing command, you are most likely making
|
|
1663 a mistake; see the documentation of `set-mark'."
|
|
1664 (setq buffer (decode-buffer buffer))
|
|
1665 ;FSFmacs version:
|
|
1666 ; (if (or force (not transient-mark-mode) mark-active mark-even-if-inactive)
|
|
1667 ; (marker-position (mark-marker))
|
|
1668 ; (signal 'mark-inactive nil)))
|
|
1669 (let ((m (mark-marker force buffer)))
|
|
1670 (and m (marker-position m))))
|
|
1671
|
|
1672 ;;;#### FSFmacs
|
|
1673 ;;; Many places set mark-active directly, and several of them failed to also
|
|
1674 ;;; run deactivate-mark-hook. This shorthand should simplify.
|
|
1675 ;(defsubst deactivate-mark ()
|
|
1676 ; "Deactivate the mark by setting `mark-active' to nil.
|
|
1677 ;\(That makes a difference only in Transient Mark mode.)
|
|
1678 ;Also runs the hook `deactivate-mark-hook'."
|
|
1679 ; (if transient-mark-mode
|
|
1680 ; (progn
|
|
1681 ; (setq mark-active nil)
|
|
1682 ; (run-hooks 'deactivate-mark-hook))))
|
|
1683
|
|
1684 (defun set-mark (pos &optional buffer)
|
|
1685 "Set this buffer's mark to POS. Don't use this function!
|
|
1686 That is to say, don't use this function unless you want
|
|
1687 the user to see that the mark has moved, and you want the previous
|
|
1688 mark position to be lost.
|
|
1689
|
|
1690 Normally, when a new mark is set, the old one should go on the stack.
|
444
|
1691 This is why most applications should use `push-mark', not `set-mark'.
|
428
|
1692
|
|
1693 Novice Emacs Lisp programmers often try to use the mark for the wrong
|
|
1694 purposes. The mark saves a location for the user's convenience.
|
|
1695 Most editing commands should not alter the mark.
|
|
1696 To remember a location for internal use in the Lisp program,
|
|
1697 store it in a Lisp variable. Example:
|
|
1698
|
444
|
1699 (let ((start (point))) (forward-line 1) (delete-region start (point)))."
|
428
|
1700
|
|
1701 (setq buffer (decode-buffer buffer))
|
|
1702 (set-marker (mark-marker t buffer) pos buffer))
|
|
1703 ;; FSF
|
|
1704 ; (if pos
|
|
1705 ; (progn
|
|
1706 ; (setq mark-active t)
|
|
1707 ; (run-hooks 'activate-mark-hook)
|
|
1708 ; (set-marker (mark-marker) pos (current-buffer)))
|
|
1709 ; ;; Normally we never clear mark-active except in Transient Mark mode.
|
|
1710 ; ;; But when we actually clear out the mark value too,
|
|
1711 ; ;; we must clear mark-active in any mode.
|
|
1712 ; (setq mark-active nil)
|
|
1713 ; (run-hooks 'deactivate-mark-hook)
|
|
1714 ; (set-marker (mark-marker) nil)))
|
|
1715
|
|
1716 (defvar mark-ring nil
|
442
|
1717 "The list of former marks of the current buffer, most recent first.
|
|
1718 This variable is automatically buffer-local.")
|
428
|
1719 (make-variable-buffer-local 'mark-ring)
|
|
1720 (put 'mark-ring 'permanent-local t)
|
|
1721
|
442
|
1722 (defvar dont-record-current-mark nil
|
|
1723 "If set to t, the current mark value should not be recorded on the mark ring.
|
|
1724 This is set by commands that manipulate the mark incidentally, to avoid
|
|
1725 cluttering the mark ring unnecessarily. Under most circumstances, you do
|
|
1726 not need to set this directly; it is automatically reset each time
|
|
1727 `push-mark' is called, according to `mark-ring-unrecorded-commands'. This
|
|
1728 variable is automatically buffer-local.")
|
|
1729 (make-variable-buffer-local 'dont-record-current-mark)
|
|
1730 (put 'dont-record-current-mark 'permanent-local t)
|
|
1731
|
|
1732 ;; a conspiracy between push-mark and handle-pre-motion-command
|
|
1733 (defvar in-shifted-motion-command nil)
|
|
1734
|
|
1735 (defcustom mark-ring-unrecorded-commands '(shifted-motion-commands
|
|
1736 yank
|
|
1737 mark-beginning-of-buffer
|
|
1738 mark-bob
|
|
1739 mark-defun
|
|
1740 mark-end-of-buffer
|
|
1741 mark-end-of-line
|
|
1742 mark-end-of-sentence
|
|
1743 mark-eob
|
|
1744 mark-marker
|
|
1745 mark-page
|
|
1746 mark-paragraph
|
|
1747 mark-sexp
|
|
1748 mark-whole-buffer
|
|
1749 mark-word)
|
|
1750 "*List of commands whose marks should not be recorded on the mark stack.
|
|
1751 Many commands set the mark as part of their action. Normally, all such
|
|
1752 marks get recorded onto the mark stack. However, this tends to clutter up
|
|
1753 the mark stack unnecessarily. You can control this by putting a command
|
|
1754 onto this list. Then, any marks set by the function will not be recorded.
|
|
1755
|
|
1756 The special value `shifted-motion-commands' causes marks set as a result
|
|
1757 of selection using any shifted motion commands to not be recorded.
|
|
1758
|
|
1759 The value `yank' affects all yank-like commands, as well as just `yank'."
|
|
1760 :type '(repeat (choice (const :tag "shifted motion commands"
|
462
|
1761 shifted-motion-commands)
|
442
|
1762 (const :tag "functions that select text"
|
|
1763 :inline t
|
462
|
1764 (mark-beginning-of-buffer
|
|
1765 mark-bob
|
|
1766 mark-defun
|
|
1767 mark-end-of-buffer
|
|
1768 mark-end-of-line
|
|
1769 mark-end-of-sentence
|
|
1770 mark-eob
|
|
1771 mark-marker
|
|
1772 mark-page
|
|
1773 mark-paragraph
|
|
1774 mark-sexp
|
|
1775 mark-whole-buffer
|
|
1776 mark-word))
|
442
|
1777 (const :tag "functions that paste text"
|
462
|
1778 yank)
|
442
|
1779 function))
|
|
1780 :group 'killing)
|
|
1781
|
428
|
1782 (defcustom mark-ring-max 16
|
|
1783 "*Maximum size of mark ring. Start discarding off end if gets this big."
|
|
1784 :type 'integer
|
|
1785 :group 'killing)
|
|
1786
|
|
1787 (defvar global-mark-ring nil
|
|
1788 "The list of saved global marks, most recent first.")
|
|
1789
|
|
1790 (defcustom global-mark-ring-max 16
|
|
1791 "*Maximum size of global mark ring. \
|
|
1792 Start discarding off end if gets this big."
|
|
1793 :type 'integer
|
|
1794 :group 'killing)
|
|
1795
|
|
1796 (defun set-mark-command (arg)
|
|
1797 "Set mark at where point is, or jump to mark.
|
|
1798 With no prefix argument, set mark, push old mark position on local mark
|
|
1799 ring, and push mark on global mark ring.
|
|
1800 With argument, jump to mark, and pop a new position for mark off the ring
|
|
1801 \(does not affect global mark ring\).
|
|
1802
|
442
|
1803 The mark ring is a per-buffer stack of marks, most recent first. Its
|
|
1804 maximum length is controlled by `mark-ring-max'. Generally, when new
|
|
1805 marks are set, the current mark is pushed onto the stack. You can pop
|
|
1806 marks off the stack using \\[universal-argument] \\[set-mark-command]. The term \"ring\" is used because when
|
|
1807 you pop a mark off the stack, the current mark value is pushed onto the
|
|
1808 far end of the stack. If this is confusing, just think of the mark ring
|
|
1809 as a stack.
|
|
1810
|
428
|
1811 Novice Emacs Lisp programmers often try to use the mark for the wrong
|
|
1812 purposes. See the documentation of `set-mark' for more information."
|
|
1813 (interactive "P")
|
|
1814 (if (null arg)
|
|
1815 (push-mark nil nil t)
|
|
1816 (if (null (mark t))
|
|
1817 (error "No mark set in this buffer")
|
442
|
1818 (if dont-record-current-mark (pop-mark))
|
428
|
1819 (goto-char (mark t))
|
|
1820 (pop-mark))))
|
|
1821
|
|
1822 ;; XEmacs: Extra parameter
|
|
1823 (defun push-mark (&optional location nomsg activate-region buffer)
|
|
1824 "Set mark at LOCATION (point, by default) and push old mark on mark ring.
|
|
1825 If the last global mark pushed was not in the current buffer,
|
|
1826 also push LOCATION on the global mark ring.
|
|
1827 Display `Mark set' unless the optional second arg NOMSG is non-nil.
|
|
1828 Activate mark if optional third arg ACTIVATE-REGION non-nil.
|
|
1829
|
|
1830 Novice Emacs Lisp programmers often try to use the mark for the wrong
|
|
1831 purposes. See the documentation of `set-mark' for more information."
|
|
1832 (setq buffer (decode-buffer buffer)) ; XEmacs
|
442
|
1833 (if (or dont-record-current-mark (null (mark t buffer))) ; XEmacs
|
428
|
1834 nil
|
|
1835 ;; The save-excursion / set-buffer is necessary because mark-ring
|
|
1836 ;; is a buffer local variable
|
|
1837 (save-excursion
|
|
1838 (set-buffer buffer)
|
|
1839 (setq mark-ring (cons (copy-marker (mark-marker t buffer)) mark-ring))
|
|
1840 (if (> (length mark-ring) mark-ring-max)
|
|
1841 (progn
|
|
1842 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil buffer)
|
|
1843 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil)))))
|
|
1844 (set-mark (or location (point buffer)) buffer)
|
|
1845 ; (set-marker (mark-marker) (or location (point)) (current-buffer)) ; FSF
|
|
1846 ;; Now push the mark on the global mark ring.
|
442
|
1847 (if (and (not dont-record-current-mark)
|
|
1848 (or (null global-mark-ring)
|
|
1849 (not (eq (marker-buffer (car global-mark-ring)) buffer))))
|
428
|
1850 ;; The last global mark pushed wasn't in this same buffer.
|
|
1851 (progn
|
|
1852 (setq global-mark-ring (cons (copy-marker (mark-marker t buffer))
|
|
1853 global-mark-ring))
|
|
1854 (if (> (length global-mark-ring) global-mark-ring-max)
|
|
1855 (progn
|
|
1856 (move-marker (car (nthcdr global-mark-ring-max global-mark-ring))
|
|
1857 nil buffer)
|
|
1858 (setcdr (nthcdr (1- global-mark-ring-max) global-mark-ring) nil)))))
|
442
|
1859 (setq dont-record-current-mark
|
|
1860 (not (not (or (and in-shifted-motion-command
|
|
1861 (memq 'shifted-motion-commands
|
|
1862 mark-ring-unrecorded-commands))
|
|
1863 (memq this-command mark-ring-unrecorded-commands)))))
|
|
1864 (or dont-record-current-mark nomsg executing-kbd-macro
|
|
1865 (> (minibuffer-depth) 0)
|
428
|
1866 (display-message 'command "Mark set"))
|
|
1867 (if activate-region
|
|
1868 (progn
|
|
1869 (setq zmacs-region-stays t)
|
|
1870 (zmacs-activate-region)))
|
|
1871 ; (if (or activate (not transient-mark-mode)) ; FSF
|
|
1872 ; (set-mark (mark t))) ; FSF
|
|
1873 nil)
|
|
1874
|
|
1875 (defun pop-mark ()
|
|
1876 "Pop off mark ring into the buffer's actual mark.
|
|
1877 Does not set point. Does nothing if mark ring is empty."
|
|
1878 (if mark-ring
|
|
1879 (progn
|
|
1880 (setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker t)))))
|
|
1881 (set-mark (car mark-ring))
|
|
1882 (move-marker (car mark-ring) nil)
|
|
1883 (if (null (mark t)) (ding))
|
|
1884 (setq mark-ring (cdr mark-ring)))))
|
|
1885
|
|
1886 (define-function 'exchange-dot-and-mark 'exchange-point-and-mark)
|
|
1887 (defun exchange-point-and-mark (&optional dont-activate-region)
|
|
1888 "Put the mark where point is now, and point where the mark is now.
|
|
1889 The mark is activated unless DONT-ACTIVATE-REGION is non-nil."
|
|
1890 (interactive nil)
|
|
1891 (let ((omark (mark t)))
|
|
1892 (if (null omark)
|
|
1893 (error "No mark set in this buffer"))
|
|
1894 (set-mark (point))
|
|
1895 (goto-char omark)
|
|
1896 (or dont-activate-region (zmacs-activate-region)) ; XEmacs
|
|
1897 nil))
|
|
1898
|
|
1899 ;; XEmacs
|
|
1900 (defun mark-something (mark-fn movement-fn arg)
|
|
1901 "internal function used by mark-sexp, mark-word, etc."
|
|
1902 (let (newmark (pushp t))
|
|
1903 (save-excursion
|
|
1904 (if (and (eq last-command mark-fn) (mark))
|
|
1905 ;; Extend the previous state in the same direction:
|
|
1906 (progn
|
|
1907 (if (< (mark) (point)) (setq arg (- arg)))
|
|
1908 (goto-char (mark))
|
|
1909 (setq pushp nil)))
|
|
1910 (funcall movement-fn arg)
|
|
1911 (setq newmark (point)))
|
|
1912 (if pushp
|
|
1913 (push-mark newmark nil t)
|
|
1914 ;; Do not mess with the mark stack, but merely adjust the previous state:
|
|
1915 (set-mark newmark)
|
|
1916 (activate-region))))
|
|
1917
|
|
1918 ;(defun transient-mark-mode (arg)
|
|
1919 ; "Toggle Transient Mark mode.
|
|
1920 ;With arg, turn Transient Mark mode on if arg is positive, off otherwise.
|
|
1921 ;
|
|
1922 ;In Transient Mark mode, when the mark is active, the region is highlighted.
|
|
1923 ;Changing the buffer \"deactivates\" the mark.
|
|
1924 ;So do certain other operations that set the mark
|
|
1925 ;but whose main purpose is something else--for example,
|
|
1926 ;incremental search, \\[beginning-of-buffer], and \\[end-of-buffer]."
|
|
1927 ; (interactive "P")
|
|
1928 ; (setq transient-mark-mode
|
|
1929 ; (if (null arg)
|
|
1930 ; (not transient-mark-mode)
|
|
1931 ; (> (prefix-numeric-value arg) 0))))
|
|
1932
|
|
1933 (defun pop-global-mark ()
|
|
1934 "Pop off global mark ring and jump to the top location."
|
|
1935 (interactive)
|
|
1936 ;; Pop entries which refer to non-existent buffers.
|
|
1937 (while (and global-mark-ring (not (marker-buffer (car global-mark-ring))))
|
|
1938 (setq global-mark-ring (cdr global-mark-ring)))
|
|
1939 (or global-mark-ring
|
|
1940 (error "No global mark set"))
|
|
1941 (let* ((marker (car global-mark-ring))
|
|
1942 (buffer (marker-buffer marker))
|
|
1943 (position (marker-position marker)))
|
|
1944 (setq global-mark-ring (nconc (cdr global-mark-ring)
|
|
1945 (list (car global-mark-ring))))
|
|
1946 (set-buffer buffer)
|
|
1947 (or (and (>= position (point-min))
|
|
1948 (<= position (point-max)))
|
|
1949 (widen))
|
|
1950 (goto-char position)
|
|
1951 (switch-to-buffer buffer)))
|
|
1952
|
|
1953
|
|
1954 (defcustom signal-error-on-buffer-boundary t
|
462
|
1955 "*If Non-nil, beep or signal an error when moving past buffer boundary.
|
428
|
1956 The commands that honor this variable are
|
|
1957
|
|
1958 forward-char-command
|
|
1959 backward-char-command
|
|
1960 next-line
|
|
1961 previous-line
|
|
1962 scroll-up-command
|
|
1963 scroll-down-command"
|
|
1964 :type 'boolean
|
|
1965 :group 'editing-basics)
|
|
1966
|
|
1967 ;;; After 8 years of waiting ... -sb
|
|
1968 (defcustom next-line-add-newlines nil ; XEmacs
|
|
1969 "*If non-nil, `next-line' inserts newline when the point is at end of buffer.
|
|
1970 This behavior used to be the default, and is still default in FSF Emacs.
|
|
1971 We think it is an unnecessary and unwanted side-effect."
|
|
1972 :type 'boolean
|
|
1973 :group 'editing-basics)
|
|
1974
|
442
|
1975 (defcustom shifted-motion-keys-select-region t
|
|
1976 "*If non-nil, shifted motion keys select text, like in MS Windows.
|
462
|
1977
|
|
1978 More specifically, if a keystroke that matches one of the key
|
|
1979 specifications in `motion-keys-for-shifted-motion' is pressed along
|
|
1980 with the Shift key, and the command invoked moves the cursor and
|
|
1981 preserves the active region (see `zmacs-region-stays'), the
|
|
1982 intervening text will be added to the active region.
|
|
1983
|
|
1984 When the region has been enabled or augmented as a result of a shifted
|
|
1985 motion key, an unshifted motion key will normally deselect the region.
|
2485
|
1986 However, if `unshifted-motion-keys-deselect-region' is nil, the region
|
462
|
1987 will remain active, augmented by the characters moved over by this
|
|
1988 motion key.
|
|
1989
|
|
1990 This functionality is specifically interpreted in terms of keys, and
|
|
1991 *NOT* in terms of particular commands, because that produces the most
|
|
1992 intuitive behavior: `forward-char' will work with shifted motion
|
|
1993 when invoked by `right' but not `C-f', and user-written motion commands
|
|
1994 bound to motion keys will automatically work with shifted motion."
|
442
|
1995 :type 'boolean
|
|
1996 :group 'editing-basics)
|
|
1997
|
|
1998 (defcustom unshifted-motion-keys-deselect-region t
|
|
1999 "*If non-nil, unshifted motion keys deselect a shifted-motion region.
|
462
|
2000 This only occurs after a region has been selected or augmented using
|
|
2001 shifted motion keys (not when using the traditional set-mark-then-move
|
|
2002 method), and has no effect if `shifted-motion-keys-select-region' is
|
|
2003 nil."
|
442
|
2004 :type 'boolean
|
|
2005 :group 'editing-basics)
|
|
2006
|
462
|
2007 (defcustom motion-keys-for-shifted-motion
|
1261
|
2008 ;; meta-shift-home/end are NOT shifted motion commands.
|
|
2009 '(left right up down (home) (control home) (meta control home)
|
|
2010 (end) (control end) (meta control end) prior next
|
|
2011 kp-left kp-right kp-up kp-down (kp-home) (control kp-home)
|
|
2012 (meta control kp-home) (kp-end) (control kp-end) (meta control kp-end)
|
|
2013 kp-prior kp-next)
|
462
|
2014 "*List of keys considered motion keys for the purpose of shifted selection.
|
|
2015 When one of these keys is pressed along with the Shift key, and the
|
|
2016 command invoked moves the cursor and preserves the active region (see
|
|
2017 `zmacs-region-stays'), the intervening text will be added to the active
|
|
2018 region. See `shifted-motion-keys-select-region' for more details.
|
|
2019
|
|
2020 Each entry should be a keysym or a list (MODIFIERS ... KEYSYM),
|
|
2021 i.e. zero or more modifiers followed by a keysym. When a keysym alone
|
|
2022 is given, a keystroke consisting of that keysym, with or without any
|
|
2023 modifiers, is considered a motion key. When the list form is given,
|
|
2024 only a keystroke with exactly those modifiers and no others (with the
|
|
2025 exception of the Shift key) is considered a motion key.
|
|
2026
|
|
2027 NOTE: Currently, the keysym cannot be a non-alphabetic character key
|
|
2028 such as the `=/+' key. In any case, the shifted-motion paradigm does
|
|
2029 not make much sense with those keys. The keysym can, however, be an
|
|
2030 alphabetic key without problem, and you can specify the key using
|
|
2031 either a character or a symbol, uppercase or lowercase."
|
|
2032 :type '(repeat (choice (const :tag "normal cursor-pad (\"gray\") keys"
|
|
2033 :inline t
|
1261
|
2034 (left
|
|
2035 right up down
|
|
2036 (home) (control home) (meta control home)
|
|
2037 (end) (control end) (meta control end)
|
|
2038 prior next))
|
462
|
2039 (const :tag "keypad motion keys"
|
|
2040 :inline t
|
1261
|
2041 (kp-left
|
|
2042 kp-right kp-up kp-down
|
|
2043 (kp-home) (control kp-home)
|
|
2044 (meta control kp-home)
|
|
2045 (kp-end) (control kp-end)
|
|
2046 (meta control kp-end)
|
|
2047 kp-prior kp-next))
|
462
|
2048 (const :tag "alphabetic motion keys"
|
|
2049 :inline t
|
|
2050 ((control b) (control f)
|
|
2051 (control p) (control n)
|
|
2052 (control a) (control e)
|
|
2053 (control v) (meta v)
|
|
2054 (meta b) (meta f)
|
|
2055 (meta a) (meta e)
|
|
2056 (meta m) ; back-to-indentation
|
|
2057 (meta r) ; move-to-window-line
|
|
2058 (meta control b) (meta control f)
|
|
2059 (meta control p) (meta control n)
|
|
2060 (meta control a) (meta control e)
|
|
2061 (meta control d) ;; down-list
|
|
2062 (meta control u) ;; backward-up-list
|
|
2063 ))
|
|
2064 symbol))
|
|
2065 :group 'editing-basics)
|
|
2066
|
442
|
2067 (defun handle-pre-motion-command-current-command-is-motion ()
|
|
2068 (and (key-press-event-p last-input-event)
|
462
|
2069 (let ((key (event-key last-input-event))
|
|
2070 (mods (delq 'shift (event-modifiers last-input-event))))
|
|
2071 ;(princ (format "key: %s mods: %s\n" key mods) 'external-debugging-output)
|
|
2072 (catch 'handle-pre-motion-command-current-command-is-motion
|
|
2073 (flet ((keysyms-equal (a b)
|
|
2074 (if (characterp a)
|
|
2075 (setq a (intern (char-to-string (downcase a)))))
|
|
2076 (if (characterp b)
|
|
2077 (setq b (intern (char-to-string (downcase b)))))
|
|
2078 (eq a b)))
|
|
2079 (mapc #'(lambda (keysym)
|
|
2080 (when (if (listp keysym)
|
|
2081 (and (equal mods (butlast keysym))
|
|
2082 (keysyms-equal key (car (last keysym))))
|
|
2083 (keysyms-equal key keysym))
|
|
2084 (throw
|
|
2085 'handle-pre-motion-command-current-command-is-motion
|
|
2086 t)))
|
|
2087 motion-keys-for-shifted-motion)
|
|
2088 nil)))))
|
444
|
2089
|
442
|
2090 (defun handle-pre-motion-command ()
|
462
|
2091 (if (and
|
442
|
2092 (handle-pre-motion-command-current-command-is-motion)
|
|
2093 zmacs-regions
|
|
2094 shifted-motion-keys-select-region
|
|
2095 (not (region-active-p))
|
462
|
2096 ;; Special-case alphabetic keysyms, because the `shift'
|
|
2097 ;; modifier does not appear on them. (Unfortunately, we have no
|
|
2098 ;; way of determining Shift-key status on non-alphabetic ASCII
|
|
2099 ;; keysyms. However, in this case, using Shift will invoke a
|
|
2100 ;; separate command from the non-shifted version, so the
|
|
2101 ;; "shifted motion" paradigm makes no sense.)
|
|
2102 (or (memq 'shift (event-modifiers last-input-event))
|
|
2103 (let ((key (event-key last-input-event)))
|
|
2104 (and (characterp key)
|
|
2105 (not (eq key (downcase key)))))))
|
442
|
2106 (let ((in-shifted-motion-command t))
|
|
2107 (push-mark nil nil t))))
|
|
2108
|
|
2109 (defun handle-post-motion-command ()
|
|
2110 (if
|
|
2111 (and
|
|
2112 (handle-pre-motion-command-current-command-is-motion)
|
|
2113 zmacs-regions
|
|
2114 (region-active-p))
|
462
|
2115 ;; Special-case alphabetic keysyms, because the `shift'
|
|
2116 ;; modifier does not appear on them. See above.
|
|
2117 (cond ((or (memq 'shift (event-modifiers last-input-event))
|
|
2118 (let ((key (event-key last-input-event)))
|
|
2119 (and (characterp key)
|
|
2120 (not (eq key (downcase key))))))
|
442
|
2121 (if shifted-motion-keys-select-region
|
|
2122 (putf this-command-properties 'shifted-motion-command t))
|
|
2123 (setq zmacs-region-stays t))
|
|
2124 ((and (getf last-command-properties 'shifted-motion-command)
|
|
2125 unshifted-motion-keys-deselect-region)
|
487
|
2126 (setq zmacs-region-stays nil)))))
|
442
|
2127
|
428
|
2128 (defun forward-char-command (&optional arg buffer)
|
|
2129 "Move point right ARG characters (left if ARG negative) in BUFFER.
|
|
2130 On attempt to pass end of buffer, stop and signal `end-of-buffer'.
|
|
2131 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
|
|
2132 Error signaling is suppressed if `signal-error-on-buffer-boundary'
|
462
|
2133 is nil. If BUFFER is nil, the current buffer is assumed.
|
|
2134
|
|
2135 The characters that are moved over may be added to the current selection
|
|
2136 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2137 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2138 the documentation for this variable for more details."
|
428
|
2139 (interactive "_p")
|
|
2140 (if signal-error-on-buffer-boundary
|
|
2141 (forward-char arg buffer)
|
|
2142 (condition-case nil
|
|
2143 (forward-char arg buffer)
|
|
2144 (beginning-of-buffer nil)
|
|
2145 (end-of-buffer nil))))
|
|
2146
|
|
2147 (defun backward-char-command (&optional arg buffer)
|
|
2148 "Move point left ARG characters (right if ARG negative) in BUFFER.
|
|
2149 On attempt to pass end of buffer, stop and signal `end-of-buffer'.
|
|
2150 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
|
|
2151 Error signaling is suppressed if `signal-error-on-buffer-boundary'
|
462
|
2152 is nil. If BUFFER is nil, the current buffer is assumed.
|
|
2153
|
|
2154 The characters that are moved over may be added to the current selection
|
|
2155 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2156 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2157 the documentation for this variable for more details."
|
428
|
2158 (interactive "_p")
|
|
2159 (if signal-error-on-buffer-boundary
|
|
2160 (backward-char arg buffer)
|
|
2161 (condition-case nil
|
|
2162 (backward-char arg buffer)
|
|
2163 (beginning-of-buffer nil)
|
|
2164 (end-of-buffer nil))))
|
|
2165
|
442
|
2166 (defun scroll-up-one ()
|
|
2167 "Scroll text of current window upward one line.
|
|
2168 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
2169 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
2170 signaled.
|
|
2171
|
|
2172 If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
|
|
2173 boundaries do not cause an error to be signaled."
|
|
2174 (interactive "_")
|
|
2175 (scroll-up-command 1))
|
|
2176
|
428
|
2177 (defun scroll-up-command (&optional n)
|
444
|
2178 "Scroll current window upward N lines; or near full screen if N is nil.
|
428
|
2179 A near full screen is `next-screen-context-lines' less than a full screen.
|
444
|
2180 Negative N means scroll downward.
|
428
|
2181 When calling from a program, supply a number as argument or nil.
|
|
2182 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
2183 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
2184 signaled.
|
|
2185
|
462
|
2186 The characters that are moved over may be added to the current selection
|
|
2187 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2188 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2189 the documentation for this variable for more details.
|
|
2190
|
428
|
2191 If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
|
|
2192 boundaries do not cause an error to be signaled."
|
|
2193 (interactive "_P")
|
|
2194 (if signal-error-on-buffer-boundary
|
|
2195 (scroll-up n)
|
|
2196 (condition-case nil
|
|
2197 (scroll-up n)
|
|
2198 (beginning-of-buffer nil)
|
|
2199 (end-of-buffer nil))))
|
|
2200
|
442
|
2201 (defun scroll-down-one ()
|
|
2202 "Scroll text of current window downward one line.
|
|
2203 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
2204 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
2205 signaled.
|
|
2206
|
|
2207 If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
|
|
2208 boundaries do not cause an error to be signaled."
|
|
2209 (interactive "_")
|
|
2210 (scroll-down-command 1))
|
|
2211
|
428
|
2212 (defun scroll-down-command (&optional n)
|
444
|
2213 "Scroll current window downward N lines; or near full screen if N is nil.
|
428
|
2214 A near full screen is `next-screen-context-lines' less than a full screen.
|
444
|
2215 Negative N means scroll upward.
|
428
|
2216 When calling from a program, supply a number as argument or nil.
|
|
2217 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
2218 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
2219 signaled.
|
|
2220
|
|
2221 If `signal-error-on-buffer-boundary' is nil, attempts to scroll past buffer
|
462
|
2222 boundaries do not cause an error to be signaled.
|
|
2223
|
|
2224 The characters that are moved over may be added to the current selection
|
|
2225 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2226 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2227 the documentation for this variable for more details."
|
428
|
2228 (interactive "_P")
|
|
2229 (if signal-error-on-buffer-boundary
|
|
2230 (scroll-down n)
|
|
2231 (condition-case nil
|
|
2232 (scroll-down n)
|
|
2233 (beginning-of-buffer nil)
|
|
2234 (end-of-buffer nil))))
|
|
2235
|
444
|
2236 (defun next-line (count)
|
|
2237 "Move cursor vertically down COUNT lines.
|
428
|
2238 If there is no character in the target line exactly under the current column,
|
|
2239 the cursor is positioned after the character in that line which spans this
|
|
2240 column, or at the end of the line if it is not long enough.
|
|
2241
|
|
2242 If there is no line in the buffer after this one, behavior depends on the
|
|
2243 value of `next-line-add-newlines'. If non-nil, it inserts a newline character
|
|
2244 to create a line, and moves the cursor to that line. Otherwise it moves the
|
2439
|
2245 cursor to the end of the buffer. If `signal-error-on-buffer-boundary' is
|
|
2246 non-nil and you attempt to move past a buffer boundary, XEmacs will ring the
|
|
2247 bell using `ding'.
|
428
|
2248
|
|
2249 The command \\[set-goal-column] can be used to create
|
|
2250 a semipermanent goal column to which this command always moves.
|
|
2251 Then it does not try to move vertically. This goal column is stored
|
|
2252 in `goal-column', which is nil when there is none.
|
|
2253
|
462
|
2254 The characters that are moved over may be added to the current selection
|
|
2255 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2256 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2257 the documentation for this variable for more details.
|
|
2258
|
428
|
2259 If you are thinking of using this in a Lisp program, consider
|
|
2260 using `forward-line' instead. It is usually easier to use
|
|
2261 and more reliable (no dependence on goal column, etc.)."
|
442
|
2262 (interactive "_p")
|
444
|
2263 (if (and next-line-add-newlines (= count 1))
|
428
|
2264 (let ((opoint (point)))
|
|
2265 (end-of-line)
|
|
2266 (if (eobp)
|
|
2267 (newline 1)
|
|
2268 (goto-char opoint)
|
444
|
2269 (line-move count)))
|
428
|
2270 (if (interactive-p)
|
|
2271 ;; XEmacs: Not sure what to do about this. It's inconsistent. -sb
|
|
2272 (condition-case nil
|
444
|
2273 (line-move count)
|
428
|
2274 ((beginning-of-buffer end-of-buffer)
|
|
2275 (when signal-error-on-buffer-boundary
|
|
2276 (ding nil 'buffer-bound))))
|
444
|
2277 (line-move count)))
|
428
|
2278 nil)
|
|
2279
|
444
|
2280 (defun previous-line (count)
|
|
2281 "Move cursor vertically up COUNT lines.
|
428
|
2282 If there is no character in the target line exactly over the current column,
|
|
2283 the cursor is positioned after the character in that line which spans this
|
|
2284 column, or at the end of the line if it is not long enough.
|
|
2285
|
|
2286 The command \\[set-goal-column] can be used to create
|
|
2287 a semipermanent goal column to which this command always moves.
|
|
2288 Then it does not try to move vertically.
|
|
2289
|
462
|
2290 The characters that are moved over may be added to the current selection
|
|
2291 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2292 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2293 the documentation for this variable for more details.
|
|
2294
|
2439
|
2295 If `signal-error-on-buffer-boundary' is non-nil and you attempt to move past
|
|
2296 a buffer boundary, XEmacs will ring the bell using `ding'.
|
|
2297
|
428
|
2298 If you are thinking of using this in a Lisp program, consider using
|
|
2299 `forward-line' with a negative argument instead. It is usually easier
|
|
2300 to use and more reliable (no dependence on goal column, etc.)."
|
442
|
2301 (interactive "_p")
|
428
|
2302 (if (interactive-p)
|
|
2303 (condition-case nil
|
444
|
2304 (line-move (- count))
|
428
|
2305 ((beginning-of-buffer end-of-buffer)
|
|
2306 (when signal-error-on-buffer-boundary ; XEmacs
|
|
2307 (ding nil 'buffer-bound))))
|
444
|
2308 (line-move (- count)))
|
428
|
2309 nil)
|
|
2310
|
442
|
2311 (defcustom block-movement-size 6
|
|
2312 "*Number of lines that \"block movement\" commands (\\[forward-block-of-lines], \\[backward-block-of-lines]) move by."
|
|
2313 :type 'integer
|
|
2314 :group 'editing-basics)
|
|
2315
|
|
2316 (defun backward-block-of-lines ()
|
|
2317 "Move backward by one \"block\" of lines.
|
|
2318 The number of lines that make up a block is controlled by
|
462
|
2319 `block-movement-size', which defaults to 6.
|
|
2320
|
|
2321 The characters that are moved over may be added to the current selection
|
|
2322 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2323 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2324 the documentation for this variable for more details."
|
442
|
2325 (interactive "_")
|
|
2326 (forward-line (- block-movement-size)))
|
|
2327
|
|
2328 (defun forward-block-of-lines ()
|
|
2329 "Move forward by one \"block\" of lines.
|
|
2330 The number of lines that make up a block is controlled by
|
462
|
2331 `block-movement-size', which defaults to 6.
|
|
2332
|
|
2333 The characters that are moved over may be added to the current selection
|
|
2334 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2335 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2336 the documentation for this variable for more details."
|
442
|
2337 (interactive "_")
|
|
2338 (forward-line block-movement-size))
|
|
2339
|
428
|
2340 (defcustom track-eol nil
|
|
2341 "*Non-nil means vertical motion starting at end of line keeps to ends of lines.
|
|
2342 This means moving to the end of each line moved onto.
|
|
2343 The beginning of a blank line does not count as the end of a line."
|
|
2344 :type 'boolean
|
|
2345 :group 'editing-basics)
|
|
2346
|
|
2347 (defcustom goal-column nil
|
|
2348 "*Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil."
|
|
2349 :type '(choice integer (const :tag "None" nil))
|
|
2350 :group 'editing-basics)
|
|
2351 (make-variable-buffer-local 'goal-column)
|
|
2352
|
|
2353 (defvar temporary-goal-column 0
|
|
2354 "Current goal column for vertical motion.
|
|
2355 It is the column where point was
|
|
2356 at the start of current run of vertical motion commands.
|
|
2357 When the `track-eol' feature is doing its job, the value is 9999.")
|
|
2358 (make-variable-buffer-local 'temporary-goal-column)
|
|
2359
|
|
2360 ;XEmacs: not yet ported, so avoid compiler warnings
|
|
2361 (eval-when-compile
|
|
2362 (defvar inhibit-point-motion-hooks))
|
|
2363
|
|
2364 (defcustom line-move-ignore-invisible nil
|
|
2365 "*Non-nil means \\[next-line] and \\[previous-line] ignore invisible lines.
|
|
2366 Use with care, as it slows down movement significantly. Outline mode sets this."
|
|
2367 :type 'boolean
|
|
2368 :group 'editing-basics)
|
|
2369
|
|
2370 ;; This is the guts of next-line and previous-line.
|
444
|
2371 ;; Count says how many lines to move.
|
|
2372 (defun line-move (count)
|
428
|
2373 ;; Don't run any point-motion hooks, and disregard intangibility,
|
|
2374 ;; for intermediate positions.
|
|
2375 (let ((inhibit-point-motion-hooks t)
|
|
2376 (opoint (point))
|
|
2377 new)
|
|
2378 (unwind-protect
|
|
2379 (progn
|
|
2380 (if (not (or (eq last-command 'next-line)
|
|
2381 (eq last-command 'previous-line)))
|
|
2382 (setq temporary-goal-column
|
|
2383 (if (and track-eol (eolp)
|
444
|
2384 ;; Don't count start of empty line as end of line
|
428
|
2385 ;; unless we just did explicit end-of-line.
|
|
2386 (or (not (bolp)) (eq last-command 'end-of-line)))
|
|
2387 9999
|
|
2388 (current-column))))
|
|
2389 (if (and (not (integerp selective-display))
|
|
2390 (not line-move-ignore-invisible))
|
|
2391 ;; Use just newline characters.
|
444
|
2392 (or (if (> count 0)
|
|
2393 (progn (if (> count 1) (forward-line (1- count)))
|
|
2394 ;; This way of moving forward COUNT lines
|
428
|
2395 ;; verifies that we have a newline after the last one.
|
|
2396 ;; It doesn't get confused by intangible text.
|
|
2397 (end-of-line)
|
|
2398 (zerop (forward-line 1)))
|
444
|
2399 (and (zerop (forward-line count))
|
428
|
2400 (bolp)))
|
444
|
2401 (signal (if (< count 0)
|
428
|
2402 'beginning-of-buffer
|
|
2403 'end-of-buffer)
|
|
2404 nil))
|
444
|
2405 ;; Move by count lines, but ignore invisible ones.
|
|
2406 (while (> count 0)
|
428
|
2407 (end-of-line)
|
|
2408 (and (zerop (vertical-motion 1))
|
|
2409 (signal 'end-of-buffer nil))
|
|
2410 ;; If the following character is currently invisible,
|
|
2411 ;; skip all characters with that same `invisible' property value.
|
|
2412 (while (and (not (eobp))
|
|
2413 (let ((prop
|
|
2414 (get-char-property (point) 'invisible)))
|
|
2415 (if (eq buffer-invisibility-spec t)
|
|
2416 prop
|
|
2417 (or (memq prop buffer-invisibility-spec)
|
|
2418 (assq prop buffer-invisibility-spec)))))
|
|
2419 (if (get-text-property (point) 'invisible)
|
|
2420 (goto-char (next-single-property-change (point) 'invisible))
|
|
2421 (goto-char (next-extent-change (point))))) ; XEmacs
|
444
|
2422 (setq count (1- count)))
|
|
2423 (while (< count 0)
|
428
|
2424 (beginning-of-line)
|
|
2425 (and (zerop (vertical-motion -1))
|
|
2426 (signal 'beginning-of-buffer nil))
|
|
2427 (while (and (not (bobp))
|
|
2428 (let ((prop
|
|
2429 (get-char-property (1- (point)) 'invisible)))
|
|
2430 (if (eq buffer-invisibility-spec t)
|
|
2431 prop
|
|
2432 (or (memq prop buffer-invisibility-spec)
|
|
2433 (assq prop buffer-invisibility-spec)))))
|
|
2434 (if (get-text-property (1- (point)) 'invisible)
|
|
2435 (goto-char (previous-single-property-change (point) 'invisible))
|
|
2436 (goto-char (previous-extent-change (point))))) ; XEmacs
|
444
|
2437 (setq count (1+ count))))
|
428
|
2438 (move-to-column (or goal-column temporary-goal-column)))
|
|
2439 ;; Remember where we moved to, go back home,
|
|
2440 ;; then do the motion over again
|
|
2441 ;; in just one step, with intangibility and point-motion hooks
|
|
2442 ;; enabled this time.
|
|
2443 (setq new (point))
|
|
2444 (goto-char opoint)
|
|
2445 (setq inhibit-point-motion-hooks nil)
|
|
2446 (goto-char new)))
|
|
2447 nil)
|
|
2448
|
|
2449 ;;; Many people have said they rarely use this feature, and often type
|
|
2450 ;;; it by accident. Maybe it shouldn't even be on a key.
|
|
2451 ;; It's not on a key, as of 20.2. So no need for this.
|
|
2452 ;(put 'set-goal-column 'disabled t)
|
|
2453
|
444
|
2454 (defun set-goal-column (column)
|
428
|
2455 "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
|
|
2456 Those commands will move to this position in the line moved to
|
|
2457 rather than trying to keep the same horizontal position.
|
|
2458 With a non-nil argument, clears out the goal column
|
|
2459 so that \\[next-line] and \\[previous-line] resume vertical motion.
|
|
2460 The goal column is stored in the variable `goal-column'."
|
|
2461 (interactive "_P") ; XEmacs
|
444
|
2462 (if column
|
428
|
2463 (progn
|
|
2464 (setq goal-column nil)
|
|
2465 (display-message 'command "No goal column"))
|
|
2466 (setq goal-column (current-column))
|
|
2467 (lmessage 'command
|
444
|
2468 "Goal column %d (use %s with a prefix arg to unset it)"
|
428
|
2469 goal-column
|
|
2470 (substitute-command-keys "\\[set-goal-column]")))
|
|
2471 nil)
|
|
2472
|
|
2473 ;; deleted FSFmacs terminal randomness hscroll-point-visible stuff.
|
|
2474 ;; hscroll-step
|
|
2475 ;; hscroll-point-visible
|
|
2476 ;; hscroll-window-column
|
|
2477 ;; right-arrow
|
|
2478 ;; left-arrow
|
|
2479
|
|
2480 (defun scroll-other-window-down (lines)
|
|
2481 "Scroll the \"other window\" down.
|
|
2482 For more details, see the documentation for `scroll-other-window'."
|
|
2483 (interactive "P")
|
|
2484 (scroll-other-window
|
|
2485 ;; Just invert the argument's meaning.
|
|
2486 ;; We can do that without knowing which window it will be.
|
|
2487 (if (eq lines '-) nil
|
|
2488 (if (null lines) '-
|
|
2489 (- (prefix-numeric-value lines))))))
|
|
2490 ;(define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
|
|
2491
|
|
2492 (defun beginning-of-buffer-other-window (arg)
|
|
2493 "Move point to the beginning of the buffer in the other window.
|
|
2494 Leave mark at previous position.
|
|
2495 With arg N, put point N/10 of the way from the true beginning."
|
|
2496 (interactive "P")
|
|
2497 (let ((orig-window (selected-window))
|
|
2498 (window (other-window-for-scrolling)))
|
|
2499 ;; We use unwind-protect rather than save-window-excursion
|
|
2500 ;; because the latter would preserve the things we want to change.
|
|
2501 (unwind-protect
|
|
2502 (progn
|
|
2503 (select-window window)
|
|
2504 ;; Set point and mark in that window's buffer.
|
|
2505 (beginning-of-buffer arg)
|
|
2506 ;; Set point accordingly.
|
|
2507 (recenter '(t)))
|
|
2508 (select-window orig-window))))
|
|
2509
|
|
2510 (defun end-of-buffer-other-window (arg)
|
|
2511 "Move point to the end of the buffer in the other window.
|
|
2512 Leave mark at previous position.
|
|
2513 With arg N, put point N/10 of the way from the true end."
|
|
2514 (interactive "P")
|
|
2515 ;; See beginning-of-buffer-other-window for comments.
|
|
2516 (let ((orig-window (selected-window))
|
|
2517 (window (other-window-for-scrolling)))
|
|
2518 (unwind-protect
|
|
2519 (progn
|
|
2520 (select-window window)
|
|
2521 (end-of-buffer arg)
|
|
2522 (recenter '(t)))
|
|
2523 (select-window orig-window))))
|
|
2524
|
|
2525 (defun transpose-chars (arg)
|
|
2526 "Interchange characters around point, moving forward one character.
|
|
2527 With prefix arg ARG, effect is to take character before point
|
|
2528 and drag it forward past ARG other characters (backward if ARG negative).
|
|
2529 If no argument and at end of line, the previous two chars are exchanged."
|
|
2530 (interactive "*P")
|
446
|
2531 (and (null arg) (eolp) (backward-char 1))
|
428
|
2532 (transpose-subr 'forward-char (prefix-numeric-value arg)))
|
|
2533
|
|
2534 ;;; A very old implementation of transpose-chars from the old days ...
|
|
2535 (defun transpose-preceding-chars (arg)
|
|
2536 "Interchange characters before point.
|
|
2537 With prefix arg ARG, effect is to take character before point
|
|
2538 and drag it forward past ARG other characters (backward if ARG negative).
|
|
2539 If no argument and not at start of line, the previous two chars are exchanged."
|
|
2540 (interactive "*P")
|
446
|
2541 (and (null arg) (not (bolp)) (backward-char 1))
|
428
|
2542 (transpose-subr 'forward-char (prefix-numeric-value arg)))
|
|
2543
|
|
2544
|
|
2545 (defun transpose-words (arg)
|
|
2546 "Interchange words around point, leaving point at end of them.
|
|
2547 With prefix arg ARG, effect is to take word before or around point
|
|
2548 and drag it forward past ARG other words (backward if ARG negative).
|
|
2549 If ARG is zero, the words around or after point and around or after mark
|
|
2550 are interchanged."
|
|
2551 (interactive "*p")
|
|
2552 (transpose-subr 'forward-word arg))
|
|
2553
|
|
2554 (defun transpose-sexps (arg)
|
|
2555 "Like \\[transpose-words] but applies to sexps.
|
|
2556 Does not work on a sexp that point is in the middle of
|
|
2557 if it is a list or string."
|
|
2558 (interactive "*p")
|
|
2559 (transpose-subr 'forward-sexp arg))
|
|
2560
|
613
|
2561 (defun Simple-forward-line-creating-newline ()
|
|
2562 ;; Move forward over a line,
|
|
2563 ;; but create a newline if none exists yet.
|
|
2564 (end-of-line)
|
|
2565 (if (eobp)
|
|
2566 (newline)
|
|
2567 (forward-char 1)))
|
|
2568
|
|
2569 (defun Simple-transpose-lines-mover (arg)
|
|
2570 (if (= arg 1)
|
|
2571 (Simple-forward-line-creating-newline)
|
|
2572 (forward-line arg)))
|
|
2573
|
428
|
2574 (defun transpose-lines (arg)
|
|
2575 "Exchange current line and previous line, leaving point after both.
|
|
2576 With argument ARG, takes previous line and moves it past ARG lines.
|
|
2577 With argument 0, interchanges line point is in with line mark is in."
|
|
2578 (interactive "*p")
|
613
|
2579 (transpose-subr 'Simple-transpose-lines-mover arg))
|
428
|
2580
|
442
|
2581 (defun transpose-line-up (arg)
|
|
2582 "Move current line one line up, leaving point at beginning of that line.
|
613
|
2583 With argument ARG, move it ARG lines up. This can be run repeatedly
|
|
2584 to move the current line up a number of lines.
|
|
2585
|
|
2586 If the region is active, move the region up one line (or ARG lines,
|
|
2587 if specified). The region will not be selected afterwards, but this
|
|
2588 command can still be run repeatedly to move the region up a number
|
|
2589 of lines."
|
442
|
2590 (interactive "*p")
|
613
|
2591 (transpose-line-down (- arg)))
|
442
|
2592
|
|
2593 (defun transpose-line-down (arg)
|
|
2594 "Move current line one line down, leaving point at beginning of that line.
|
613
|
2595 With argument ARG, move it ARG lines down. This can be run repeatedly
|
|
2596 to move the current line down a number of lines.
|
|
2597
|
|
2598 If the region is active, move the region down one line (or ARG lines,
|
|
2599 if specified). The region will not be selected afterwards, but this
|
|
2600 command can still be run repeatedly to move the region down a number
|
|
2601 of lines."
|
442
|
2602 (interactive "*p")
|
613
|
2603 (if (or (region-active-p)
|
|
2604 (getf last-command-properties 'transpose-region-by-line-command))
|
|
2605 (progn
|
|
2606 (transpose-subr 'Simple-transpose-lines-mover arg t)
|
|
2607 (putf this-command-properties 'transpose-region-by-line-command t))
|
|
2608 (Simple-forward-line-creating-newline)
|
|
2609 (transpose-subr 'Simple-transpose-lines-mover arg)
|
|
2610 (forward-line -1)))
|
|
2611
|
|
2612 (defun transpose-subr (mover arg &optional move-region)
|
428
|
2613 (let (start1 end1 start2 end2)
|
442
|
2614 ;; XEmacs -- use flet instead of defining a separate function and
|
613
|
2615 ;; relying on dynamic scope; use (mark t) etc; add code to support
|
|
2616 ;; the new MOVE-REGION arg.
|
442
|
2617 (flet ((transpose-subr-1 ()
|
|
2618 (if (> (min end1 end2) (max start1 start2))
|
|
2619 (error "Don't have two things to transpose"))
|
|
2620 (let ((word1 (buffer-substring start1 end1))
|
|
2621 (word2 (buffer-substring start2 end2)))
|
|
2622 (delete-region start2 end2)
|
|
2623 (goto-char start2)
|
|
2624 (insert word1)
|
|
2625 (goto-char (if (< start1 start2) start1
|
|
2626 (+ start1 (- (length word1) (length word2)))))
|
|
2627 (delete-char (length word1))
|
|
2628 (insert word2))))
|
|
2629 (if (= arg 0)
|
|
2630 (progn
|
|
2631 (save-excursion
|
|
2632 (funcall mover 1)
|
|
2633 (setq end2 (point))
|
|
2634 (funcall mover -1)
|
|
2635 (setq start2 (point))
|
613
|
2636 (goto-char (mark t))
|
442
|
2637 (funcall mover 1)
|
|
2638 (setq end1 (point))
|
|
2639 (funcall mover -1)
|
|
2640 (setq start1 (point))
|
|
2641 (transpose-subr-1))
|
613
|
2642 (exchange-point-and-mark t)))
|
|
2643 (if move-region
|
|
2644 (let ((rbeg (region-beginning))
|
|
2645 (rend (region-end)))
|
|
2646 (while (> arg 0)
|
|
2647 (goto-char rend)
|
|
2648 (funcall mover 1)
|
|
2649 (setq end2 (point))
|
|
2650 (funcall mover -1)
|
|
2651 (setq start2 (point))
|
|
2652 (setq start1 rbeg end1 rend)
|
|
2653 (transpose-subr-1)
|
|
2654 (incf rbeg (- end2 start2))
|
|
2655 (incf rend (- end2 start2))
|
|
2656 (setq arg (1- arg)))
|
|
2657 (while (< arg 0)
|
|
2658 (goto-char rbeg)
|
|
2659 (funcall mover -1)
|
|
2660 (setq start1 (point))
|
|
2661 (funcall mover 1)
|
|
2662 (setq end1 (point))
|
|
2663 (setq start2 rbeg end2 rend)
|
|
2664 (transpose-subr-1)
|
|
2665 (decf rbeg (- end1 start1))
|
|
2666 (decf rend (- end1 start1))
|
|
2667 (setq arg (1+ arg)))
|
|
2668 (set-mark rbeg)
|
|
2669 (goto-char rend))
|
|
2670 (while (> arg 0)
|
|
2671 (funcall mover -1)
|
|
2672 (setq start1 (point))
|
|
2673 (funcall mover 1)
|
|
2674 (setq end1 (point))
|
|
2675 (funcall mover 1)
|
|
2676 (setq end2 (point))
|
|
2677 (funcall mover -1)
|
|
2678 (setq start2 (point))
|
|
2679 (transpose-subr-1)
|
|
2680 (goto-char end2)
|
|
2681 (setq arg (1- arg)))
|
|
2682 (while (< arg 0)
|
|
2683 (funcall mover -1)
|
|
2684 (setq start2 (point))
|
|
2685 (funcall mover -1)
|
|
2686 (setq start1 (point))
|
|
2687 (funcall mover 1)
|
|
2688 (setq end1 (point))
|
|
2689 (funcall mover 1)
|
|
2690 (setq end2 (point))
|
|
2691 (transpose-subr-1)
|
|
2692 (setq arg (1+ arg)))))))
|
442
|
2693
|
428
|
2694
|
|
2695 ;; XEmacs
|
|
2696 (defun prefix-region (prefix)
|
|
2697 "Add a prefix string to each line between mark and point."
|
|
2698 (interactive "sPrefix string: ")
|
|
2699 (if prefix
|
|
2700 (let ((count (count-lines (mark) (point))))
|
|
2701 (goto-char (min (mark) (point)))
|
|
2702 (while (> count 0)
|
|
2703 (setq count (1- count))
|
|
2704 (beginning-of-line 1)
|
|
2705 (insert prefix)
|
|
2706 (end-of-line 1)
|
|
2707 (forward-char 1)))))
|
|
2708
|
|
2709
|
446
|
2710 (defun backward-word (&optional count buffer)
|
|
2711 "Move point backward COUNT words (forward if COUNT is negative).
|
|
2712 Normally t is returned, but if an edge of the buffer is reached,
|
|
2713 point is left there and nil is returned.
|
|
2714
|
462
|
2715 COUNT defaults to 1, and BUFFER defaults to the current buffer.
|
|
2716
|
|
2717 The characters that are moved over may be added to the current selection
|
|
2718 \(i.e. active region) if the Shift key is held down, a motion key is used
|
|
2719 to invoke this command, and `shifted-motion-keys-select-region' is t; see
|
|
2720 the documentation for this variable for more details."
|
446
|
2721 (interactive "_p")
|
|
2722 (forward-word (- (or count 1)) buffer))
|
|
2723
|
|
2724 (defun mark-word (&optional count)
|
|
2725 "Mark the text from point until encountering the end of a word.
|
|
2726 With optional argument COUNT, mark COUNT words."
|
428
|
2727 (interactive "p")
|
446
|
2728 (mark-something 'mark-word 'forward-word count))
|
|
2729
|
844
|
2730 (defcustom kill-word-into-kill-ring t
|
|
2731 "*Non-nil means `kill-word' saves word killed into kill ring.
|
|
2732 \(Normally, this also affects the clipboard.)
|
|
2733 Nil means word is just deleted, without being remembered.
|
|
2734 This also applies to `backward-kill-word' and `backward-or-forward-kill-word'."
|
|
2735 :type 'boolean
|
|
2736 :group 'editing-basics)
|
|
2737
|
446
|
2738 (defun kill-word (&optional count)
|
428
|
2739 "Kill characters forward until encountering the end of a word.
|
446
|
2740 With optional argument COUNT, do this that many times."
|
|
2741 (interactive "*p")
|
844
|
2742 (if kill-word-into-kill-ring
|
|
2743 (kill-region (point) (save-excursion (forward-word count) (point)))
|
|
2744 (delete-region (point) (save-excursion (forward-word count) (point)))))
|
446
|
2745
|
|
2746 (defun backward-kill-word (&optional count)
|
|
2747 "Kill characters backward until encountering the end of a word.
|
428
|
2748 With argument, do this that many times."
|
|
2749 (interactive "*p")
|
446
|
2750 (kill-word (- (or count 1))))
|
428
|
2751
|
|
2752 (defun current-word (&optional strict)
|
|
2753 "Return the word point is on (or a nearby word) as a string.
|
|
2754 If optional arg STRICT is non-nil, return nil unless point is within
|
|
2755 or adjacent to a word.
|
|
2756 If point is not between two word-constituent characters, but immediately
|
|
2757 follows one, move back first.
|
|
2758 Otherwise, if point precedes a word constituent, move forward first.
|
|
2759 Otherwise, move backwards until a word constituent is found and get that word;
|
|
2760 if you a newlines is reached first, move forward instead."
|
|
2761 (save-excursion
|
|
2762 (let ((oldpoint (point)) (start (point)) (end (point)))
|
|
2763 (skip-syntax-backward "w_") (setq start (point))
|
|
2764 (goto-char oldpoint)
|
|
2765 (skip-syntax-forward "w_") (setq end (point))
|
|
2766 (if (and (eq start oldpoint) (eq end oldpoint))
|
|
2767 ;; Point is neither within nor adjacent to a word.
|
|
2768 (and (not strict)
|
|
2769 (progn
|
|
2770 ;; Look for preceding word in same line.
|
|
2771 (skip-syntax-backward "^w_"
|
|
2772 (save-excursion
|
|
2773 (beginning-of-line) (point)))
|
|
2774 (if (bolp)
|
|
2775 ;; No preceding word in same line.
|
|
2776 ;; Look for following word in same line.
|
|
2777 (progn
|
|
2778 (skip-syntax-forward "^w_"
|
|
2779 (save-excursion
|
|
2780 (end-of-line) (point)))
|
|
2781 (setq start (point))
|
|
2782 (skip-syntax-forward "w_")
|
|
2783 (setq end (point)))
|
|
2784 (setq end (point))
|
|
2785 (skip-syntax-backward "w_")
|
|
2786 (setq start (point)))
|
|
2787 (buffer-substring start end)))
|
|
2788 (buffer-substring start end)))))
|
|
2789
|
|
2790 (defcustom fill-prefix nil
|
|
2791 "*String for filling to insert at front of new line, or nil for none.
|
|
2792 Setting this variable automatically makes it local to the current buffer."
|
|
2793 :type '(choice (const :tag "None" nil)
|
|
2794 string)
|
|
2795 :group 'fill)
|
|
2796 (make-variable-buffer-local 'fill-prefix)
|
|
2797
|
|
2798 (defcustom auto-fill-inhibit-regexp nil
|
|
2799 "*Regexp to match lines which should not be auto-filled."
|
|
2800 :type '(choice (const :tag "None" nil)
|
|
2801 regexp)
|
|
2802 :group 'fill)
|
|
2803
|
|
2804 (defvar comment-line-break-function 'indent-new-comment-line
|
|
2805 "*Mode-specific function which line breaks and continues a comment.
|
|
2806
|
|
2807 This function is only called during auto-filling of a comment section.
|
|
2808 The function should take a single optional argument which is a flag
|
|
2809 indicating whether soft newlines should be inserted.")
|
|
2810
|
|
2811 ;; This function is the auto-fill-function of a buffer
|
|
2812 ;; when Auto-Fill mode is enabled.
|
|
2813 ;; It returns t if it really did any work.
|
|
2814 ;; XEmacs: This function is totally different.
|
|
2815 (defun do-auto-fill ()
|
|
2816 (let (give-up)
|
|
2817 (or (and auto-fill-inhibit-regexp
|
|
2818 (save-excursion (beginning-of-line)
|
|
2819 (looking-at auto-fill-inhibit-regexp)))
|
|
2820 (while (and (not give-up) (> (current-column) fill-column))
|
|
2821 ;; Determine where to split the line.
|
|
2822 (let ((fill-prefix fill-prefix)
|
|
2823 (fill-point
|
|
2824 (let ((opoint (point))
|
|
2825 bounce
|
502
|
2826 (re-break-point ;; Kinsoku processing
|
|
2827 (if (featurep 'mule)
|
771
|
2828 (with-boundp 'word-across-newline
|
|
2829 (concat "[ \t\n]\\|" word-across-newline
|
|
2830 ".\\|." word-across-newline))
|
502
|
2831 "[ \t\n]"))
|
428
|
2832 (first t))
|
|
2833 (save-excursion
|
|
2834 (move-to-column (1+ fill-column))
|
|
2835 ;; Move back to a word boundary.
|
|
2836 (while (or first
|
|
2837 ;; If this is after period and a single space,
|
|
2838 ;; move back once more--we don't want to break
|
|
2839 ;; the line there and make it look like a
|
|
2840 ;; sentence end.
|
|
2841 (and (not (bobp))
|
|
2842 (not bounce)
|
|
2843 sentence-end-double-space
|
446
|
2844 (save-excursion (backward-char 1)
|
428
|
2845 (and (looking-at "\\. ")
|
|
2846 (not (looking-at "\\. "))))))
|
|
2847 (setq first nil)
|
502
|
2848 ;; XEmacs: change for Kinsoku processing
|
428
|
2849 (fill-move-backward-to-break-point re-break-point)
|
|
2850 ;; If we find nowhere on the line to break it,
|
|
2851 ;; break after one word. Set bounce to t
|
|
2852 ;; so we will not keep going in this while loop.
|
|
2853 (if (bolp)
|
|
2854 (progn
|
502
|
2855 ;; XEmacs: change for Kinsoku processing
|
428
|
2856 (fill-move-forward-to-break-point re-break-point
|
|
2857 opoint)
|
|
2858 (setq bounce t)))
|
|
2859 (skip-chars-backward " \t"))
|
|
2860 (if (and (featurep 'mule)
|
502
|
2861 (or bounce (bolp)))
|
|
2862 (declare-fboundp (kinsoku-process)))
|
428
|
2863 ;; Let fill-point be set to the place where we end up.
|
|
2864 (point)))))
|
|
2865
|
|
2866 ;; I'm not sure why Stig made this change but it breaks
|
|
2867 ;; auto filling in at least C mode so I'm taking it back
|
|
2868 ;; out. --cet
|
|
2869 ;; XEmacs - adaptive fill.
|
|
2870 ;;(maybe-adapt-fill-prefix
|
|
2871 ;; (or from (setq from (save-excursion (beginning-of-line)
|
|
2872 ;; (point))))
|
|
2873 ;; (or to (setq to (save-excursion (beginning-of-line 2)
|
|
2874 ;; (point))))
|
|
2875 ;; t)
|
|
2876
|
|
2877 ;; If that place is not the beginning of the line,
|
|
2878 ;; break the line there.
|
|
2879 (if (save-excursion
|
|
2880 (goto-char fill-point)
|
502
|
2881 ;; during kinsoku processing it is possible to move beyond
|
|
2882 (not (or (bolp) (eolp))))
|
428
|
2883 (let ((prev-column (current-column)))
|
|
2884 ;; If point is at the fill-point, do not `save-excursion'.
|
|
2885 ;; Otherwise, if a comment prefix or fill-prefix is inserted,
|
|
2886 ;; point will end up before it rather than after it.
|
|
2887 (if (save-excursion
|
|
2888 (skip-chars-backward " \t")
|
|
2889 (= (point) fill-point))
|
|
2890 ;; 1999-09-17 hniksic: turn off Kinsoku until
|
|
2891 ;; it's debugged.
|
444
|
2892 (funcall comment-line-break-function)
|
502
|
2893 ;; XEmacs: Kinsoku processing
|
428
|
2894 ; ;(indent-new-comment-line)
|
|
2895 ; (let ((spacep (memq (char-before (point)) '(?\ ?\t))))
|
|
2896 ; (funcall comment-line-break-function)
|
|
2897 ; ;; if user type space explicitly, leave SPC
|
|
2898 ; ;; even if there is no WAN.
|
|
2899 ; (if spacep
|
|
2900 ; (save-excursion
|
|
2901 ; (goto-char fill-point)
|
|
2902 ; ;; put SPC except that there is SPC
|
|
2903 ; ;; already or there is sentence end.
|
|
2904 ; (or (memq (char-after (point)) '(?\ ?\t))
|
|
2905 ; (fill-end-of-sentence-p)
|
|
2906 ; (insert ?\ )))))
|
|
2907 (save-excursion
|
|
2908 (goto-char fill-point)
|
|
2909 (funcall comment-line-break-function)))
|
|
2910 ;; If making the new line didn't reduce the hpos of
|
|
2911 ;; the end of the line, then give up now;
|
|
2912 ;; trying again will not help.
|
|
2913 (if (>= (current-column) prev-column)
|
|
2914 (setq give-up t)))
|
|
2915 ;; No place to break => stop trying.
|
|
2916 (setq give-up t)))))))
|
|
2917
|
|
2918 ;; Put FSF one in until I can one or the other working properly, then the
|
|
2919 ;; other one is history.
|
|
2920 ;(defun fsf:do-auto-fill ()
|
|
2921 ; (let (fc justify
|
|
2922 ; ;; bol
|
|
2923 ; give-up
|
|
2924 ; (fill-prefix fill-prefix))
|
|
2925 ; (if (or (not (setq justify (current-justification)))
|
|
2926 ; (null (setq fc (current-fill-column)))
|
|
2927 ; (and (eq justify 'left)
|
|
2928 ; (<= (current-column) fc))
|
|
2929 ; (save-excursion (beginning-of-line)
|
|
2930 ; ;; (setq bol (point))
|
|
2931 ; (and auto-fill-inhibit-regexp
|
|
2932 ; (looking-at auto-fill-inhibit-regexp))))
|
|
2933 ; nil ;; Auto-filling not required
|
|
2934 ; (if (memq justify '(full center right))
|
|
2935 ; (save-excursion (unjustify-current-line)))
|
|
2936
|
|
2937 ; ;; Choose a fill-prefix automatically.
|
|
2938 ; (if (and adaptive-fill-mode
|
|
2939 ; (or (null fill-prefix) (string= fill-prefix "")))
|
|
2940 ; (let ((prefix
|
|
2941 ; (fill-context-prefix
|
|
2942 ; (save-excursion (backward-paragraph 1) (point))
|
|
2943 ; (save-excursion (forward-paragraph 1) (point))
|
|
2944 ; ;; Don't accept a non-whitespace fill prefix
|
|
2945 ; ;; from the first line of a paragraph.
|
|
2946 ; "^[ \t]*$")))
|
|
2947 ; (and prefix (not (equal prefix ""))
|
|
2948 ; (setq fill-prefix prefix))))
|
|
2949
|
|
2950 ; (while (and (not give-up) (> (current-column) fc))
|
|
2951 ; ;; Determine where to split the line.
|
|
2952 ; (let ((fill-point
|
|
2953 ; (let ((opoint (point))
|
|
2954 ; bounce
|
|
2955 ; (first t))
|
|
2956 ; (save-excursion
|
|
2957 ; (move-to-column (1+ fc))
|
|
2958 ; ;; Move back to a word boundary.
|
|
2959 ; (while (or first
|
|
2960 ; ;; If this is after period and a single space,
|
|
2961 ; ;; move back once more--we don't want to break
|
|
2962 ; ;; the line there and make it look like a
|
|
2963 ; ;; sentence end.
|
|
2964 ; (and (not (bobp))
|
|
2965 ; (not bounce)
|
|
2966 ; sentence-end-double-space
|
446
|
2967 ; (save-excursion (backward-char 1)
|
428
|
2968 ; (and (looking-at "\\. ")
|
|
2969 ; (not (looking-at "\\. "))))))
|
|
2970 ; (setq first nil)
|
|
2971 ; (skip-chars-backward "^ \t\n")
|
|
2972 ; ;; If we find nowhere on the line to break it,
|
|
2973 ; ;; break after one word. Set bounce to t
|
|
2974 ; ;; so we will not keep going in this while loop.
|
|
2975 ; (if (bolp)
|
|
2976 ; (progn
|
|
2977 ; (re-search-forward "[ \t]" opoint t)
|
|
2978 ; (setq bounce t)))
|
|
2979 ; (skip-chars-backward " \t"))
|
|
2980 ; ;; Let fill-point be set to the place where we end up.
|
|
2981 ; (point)))))
|
|
2982 ; ;; If that place is not the beginning of the line,
|
|
2983 ; ;; break the line there.
|
|
2984 ; (if (save-excursion
|
|
2985 ; (goto-char fill-point)
|
|
2986 ; (not (bolp)))
|
|
2987 ; (let ((prev-column (current-column)))
|
|
2988 ; ;; If point is at the fill-point, do not `save-excursion'.
|
|
2989 ; ;; Otherwise, if a comment prefix or fill-prefix is inserted,
|
|
2990 ; ;; point will end up before it rather than after it.
|
|
2991 ; (if (save-excursion
|
|
2992 ; (skip-chars-backward " \t")
|
|
2993 ; (= (point) fill-point))
|
|
2994 ; (funcall comment-line-break-function t)
|
|
2995 ; (save-excursion
|
|
2996 ; (goto-char fill-point)
|
|
2997 ; (funcall comment-line-break-function t)))
|
|
2998 ; ;; Now do justification, if required
|
|
2999 ; (if (not (eq justify 'left))
|
|
3000 ; (save-excursion
|
|
3001 ; (end-of-line 0)
|
|
3002 ; (justify-current-line justify nil t)))
|
|
3003 ; ;; If making the new line didn't reduce the hpos of
|
|
3004 ; ;; the end of the line, then give up now;
|
|
3005 ; ;; trying again will not help.
|
|
3006 ; (if (>= (current-column) prev-column)
|
|
3007 ; (setq give-up t)))
|
|
3008 ; ;; No place to break => stop trying.
|
|
3009 ; (setq give-up t))))
|
|
3010 ; ;; Justify last line.
|
|
3011 ; (justify-current-line justify t t)
|
|
3012 ; t)))
|
|
3013
|
|
3014 (defvar normal-auto-fill-function 'do-auto-fill
|
|
3015 "The function to use for `auto-fill-function' if Auto Fill mode is turned on.
|
|
3016 Some major modes set this.")
|
|
3017
|
|
3018 (defun auto-fill-mode (&optional arg)
|
|
3019 "Toggle auto-fill mode.
|
|
3020 With arg, turn auto-fill mode on if and only if arg is positive.
|
|
3021 In Auto-Fill mode, inserting a space at a column beyond `current-fill-column'
|
|
3022 automatically breaks the line at a previous space.
|
|
3023
|
|
3024 The value of `normal-auto-fill-function' specifies the function to use
|
|
3025 for `auto-fill-function' when turning Auto Fill mode on."
|
|
3026 (interactive "P")
|
|
3027 (prog1 (setq auto-fill-function
|
|
3028 (if (if (null arg)
|
|
3029 (not auto-fill-function)
|
|
3030 (> (prefix-numeric-value arg) 0))
|
|
3031 normal-auto-fill-function
|
|
3032 nil))
|
|
3033 (redraw-modeline)))
|
|
3034
|
|
3035 ;; This holds a document string used to document auto-fill-mode.
|
|
3036 (defun auto-fill-function ()
|
|
3037 "Automatically break line at a previous space, in insertion of text."
|
|
3038 nil)
|
|
3039
|
|
3040 (defun turn-on-auto-fill ()
|
|
3041 "Unconditionally turn on Auto Fill mode."
|
444
|
3042 (interactive)
|
428
|
3043 (auto-fill-mode 1))
|
|
3044
|
|
3045 (defun set-fill-column (arg)
|
|
3046 "Set `fill-column' to specified argument.
|
|
3047 Just \\[universal-argument] as argument means to use the current column
|
|
3048 The variable `fill-column' has a separate value for each buffer."
|
|
3049 (interactive "_P") ; XEmacs
|
|
3050 (cond ((integerp arg)
|
|
3051 (setq fill-column arg))
|
|
3052 ((consp arg)
|
|
3053 (setq fill-column (current-column)))
|
|
3054 ;; Disallow missing argument; it's probably a typo for C-x C-f.
|
|
3055 (t
|
|
3056 (error "set-fill-column requires an explicit argument")))
|
|
3057 (lmessage 'command "fill-column set to %d" fill-column))
|
|
3058
|
1333
|
3059
|
|
3060 ;; BEGIN SYNCHED WITH FSF 21.2.
|
|
3061
|
428
|
3062 (defun set-selective-display (arg)
|
|
3063 "Set `selective-display' to ARG; clear it if no arg.
|
|
3064 When the value of `selective-display' is a number > 0,
|
|
3065 lines whose indentation is >= that value are not displayed.
|
|
3066 The variable `selective-display' has a separate value for each buffer."
|
|
3067 (interactive "P")
|
|
3068 (if (eq selective-display t)
|
|
3069 (error "selective-display already in use for marked lines"))
|
|
3070 (let ((current-vpos
|
|
3071 (save-restriction
|
|
3072 (narrow-to-region (point-min) (point))
|
|
3073 (goto-char (window-start))
|
|
3074 (vertical-motion (window-height)))))
|
|
3075 (setq selective-display
|
|
3076 (and arg (prefix-numeric-value arg)))
|
|
3077 (recenter current-vpos))
|
|
3078 (set-window-start (selected-window) (window-start (selected-window)))
|
|
3079 ;; #### doesn't localize properly:
|
|
3080 (princ "selective-display set to " t)
|
|
3081 (prin1 selective-display t)
|
|
3082 (princ "." t))
|
|
3083
|
|
3084 ;; XEmacs
|
|
3085 (defun nuke-selective-display ()
|
|
3086 "Ensure that the buffer is not in selective-display mode.
|
|
3087 If `selective-display' is t, then restore the buffer text to its original
|
|
3088 state before disabling selective display."
|
|
3089 ;; by Stig@hackvan.com
|
|
3090 (interactive)
|
|
3091 (and (eq t selective-display)
|
|
3092 (save-excursion
|
|
3093 (save-restriction
|
|
3094 (widen)
|
|
3095 (goto-char (point-min))
|
|
3096 (let ((mod-p (buffer-modified-p))
|
|
3097 (buffer-read-only nil))
|
|
3098 (while (search-forward "\r" nil t)
|
|
3099 (delete-char -1)
|
|
3100 (insert "\n"))
|
|
3101 (set-buffer-modified-p mod-p)
|
|
3102 ))))
|
|
3103 (setq selective-display nil))
|
|
3104
|
|
3105 (add-hook 'change-major-mode-hook 'nuke-selective-display)
|
|
3106
|
1333
|
3107 (defvar overwrite-mode-textual " Ovwrt"
|
428
|
3108 "The string displayed in the mode line when in overwrite mode.")
|
1333
|
3109 (defvar overwrite-mode-binary " Bin Ovwrt"
|
428
|
3110 "The string displayed in the mode line when in binary overwrite mode.")
|
|
3111
|
|
3112 (defun overwrite-mode (arg)
|
|
3113 "Toggle overwrite mode.
|
1333
|
3114 With arg, turn overwrite mode on iff arg is positive.
|
428
|
3115 In overwrite mode, printing characters typed in replace existing text
|
|
3116 on a one-for-one basis, rather than pushing it to the right. At the
|
|
3117 end of a line, such characters extend the line. Before a tab,
|
|
3118 such characters insert until the tab is filled in.
|
|
3119 \\[quoted-insert] still inserts characters in overwrite mode; this
|
|
3120 is supposed to make it easier to insert characters when necessary."
|
|
3121 (interactive "P")
|
|
3122 (setq overwrite-mode
|
|
3123 (if (if (null arg) (not overwrite-mode)
|
|
3124 (> (prefix-numeric-value arg) 0))
|
|
3125 'overwrite-mode-textual))
|
|
3126 (redraw-modeline))
|
|
3127
|
|
3128 (defun binary-overwrite-mode (arg)
|
|
3129 "Toggle binary overwrite mode.
|
1333
|
3130 With arg, turn binary overwrite mode on iff arg is positive.
|
428
|
3131 In binary overwrite mode, printing characters typed in replace
|
|
3132 existing text. Newlines are not treated specially, so typing at the
|
|
3133 end of a line joins the line to the next, with the typed character
|
|
3134 between them. Typing before a tab character simply replaces the tab
|
|
3135 with the character typed.
|
|
3136 \\[quoted-insert] replaces the text at the cursor, just as ordinary
|
|
3137 typing characters do.
|
|
3138
|
|
3139 Note that binary overwrite mode is not its own minor mode; it is a
|
|
3140 specialization of overwrite-mode, entered by setting the
|
|
3141 `overwrite-mode' variable to `overwrite-mode-binary'."
|
|
3142 (interactive "P")
|
|
3143 (setq overwrite-mode
|
|
3144 (if (if (null arg)
|
|
3145 (not (eq overwrite-mode 'overwrite-mode-binary))
|
|
3146 (> (prefix-numeric-value arg) 0))
|
|
3147 'overwrite-mode-binary))
|
|
3148 (redraw-modeline))
|
1333
|
3149
|
|
3150 ;; END SYNCHED WITH FSF 21.2.
|
|
3151
|
428
|
3152
|
771
|
3153 (defcustom line-number-mode t
|
428
|
3154 "*Non-nil means display line number in modeline."
|
|
3155 :type 'boolean
|
|
3156 :group 'editing-basics)
|
|
3157
|
|
3158 (defun line-number-mode (arg)
|
|
3159 "Toggle Line Number mode.
|
444
|
3160 With arg, enable Line Number mode if arg is positive, else disable.
|
428
|
3161 When Line Number mode is enabled, the line number appears
|
|
3162 in the mode line."
|
|
3163 (interactive "P")
|
|
3164 (setq line-number-mode
|
|
3165 (if (null arg) (not line-number-mode)
|
|
3166 (> (prefix-numeric-value arg) 0)))
|
|
3167 (redraw-modeline))
|
|
3168
|
771
|
3169 (defcustom column-number-mode t
|
428
|
3170 "*Non-nil means display column number in mode line."
|
|
3171 :type 'boolean
|
|
3172 :group 'editing-basics)
|
|
3173
|
|
3174 (defun column-number-mode (arg)
|
|
3175 "Toggle Column Number mode.
|
444
|
3176 With arg, enable Column Number mode if arg is positive, else disable.
|
428
|
3177 When Column Number mode is enabled, the column number appears
|
|
3178 in the mode line."
|
|
3179 (interactive "P")
|
|
3180 (setq column-number-mode
|
|
3181 (if (null arg) (not column-number-mode)
|
|
3182 (> (prefix-numeric-value arg) 0)))
|
|
3183 (redraw-modeline))
|
|
3184
|
|
3185
|
|
3186 (defcustom blink-matching-paren t
|
|
3187 "*Non-nil means show matching open-paren when close-paren is inserted."
|
|
3188 :type 'boolean
|
|
3189 :group 'paren-blinking)
|
|
3190
|
|
3191 (defcustom blink-matching-paren-on-screen t
|
|
3192 "*Non-nil means show matching open-paren when it is on screen.
|
|
3193 nil means don't show it (but the open-paren can still be shown
|
|
3194 when it is off screen."
|
|
3195 :type 'boolean
|
|
3196 :group 'paren-blinking)
|
|
3197
|
|
3198 (defcustom blink-matching-paren-distance 12000
|
|
3199 "*If non-nil, is maximum distance to search for matching open-paren."
|
|
3200 :type '(choice integer (const nil))
|
|
3201 :group 'paren-blinking)
|
|
3202
|
|
3203 (defcustom blink-matching-delay 1
|
|
3204 "*The number of seconds that `blink-matching-open' will delay at a match."
|
|
3205 :type 'number
|
|
3206 :group 'paren-blinking)
|
|
3207
|
|
3208 (defcustom blink-matching-paren-dont-ignore-comments nil
|
|
3209 "*Non-nil means `blink-matching-paren' should not ignore comments."
|
|
3210 :type 'boolean
|
|
3211 :group 'paren-blinking)
|
|
3212
|
|
3213 (defun blink-matching-open ()
|
|
3214 "Move cursor momentarily to the beginning of the sexp before point."
|
|
3215 (interactive "_") ; XEmacs
|
|
3216 (and (> (point) (1+ (point-min)))
|
|
3217 blink-matching-paren
|
|
3218 ;; Verify an even number of quoting characters precede the close.
|
|
3219 (= 1 (logand 1 (- (point)
|
|
3220 (save-excursion
|
446
|
3221 (backward-char 1)
|
428
|
3222 (skip-syntax-backward "/\\")
|
|
3223 (point)))))
|
|
3224 (let* ((oldpos (point))
|
|
3225 (blinkpos)
|
|
3226 (mismatch))
|
|
3227 (save-excursion
|
|
3228 (save-restriction
|
|
3229 (if blink-matching-paren-distance
|
|
3230 (narrow-to-region (max (point-min)
|
|
3231 (- (point) blink-matching-paren-distance))
|
|
3232 oldpos))
|
|
3233 (condition-case ()
|
|
3234 (let ((parse-sexp-ignore-comments
|
|
3235 (and parse-sexp-ignore-comments
|
|
3236 (not blink-matching-paren-dont-ignore-comments))))
|
|
3237 (setq blinkpos (scan-sexps oldpos -1)))
|
|
3238 (error nil)))
|
|
3239 (and blinkpos
|
|
3240 (/= (char-syntax (char-after blinkpos))
|
|
3241 ?\$)
|
|
3242 (setq mismatch
|
|
3243 (or (null (matching-paren (char-after blinkpos)))
|
|
3244 (/= (char-after (1- oldpos))
|
|
3245 (matching-paren (char-after blinkpos))))))
|
|
3246 (if mismatch (setq blinkpos nil))
|
|
3247 (if blinkpos
|
|
3248 (progn
|
|
3249 (goto-char blinkpos)
|
|
3250 (if (pos-visible-in-window-p)
|
|
3251 (and blink-matching-paren-on-screen
|
|
3252 (progn
|
|
3253 (auto-show-make-point-visible)
|
|
3254 (sit-for blink-matching-delay)))
|
|
3255 (goto-char blinkpos)
|
|
3256 (lmessage 'command "Matches %s"
|
|
3257 ;; Show what precedes the open in its line, if anything.
|
|
3258 (if (save-excursion
|
|
3259 (skip-chars-backward " \t")
|
|
3260 (not (bolp)))
|
|
3261 (buffer-substring (progn (beginning-of-line) (point))
|
|
3262 (1+ blinkpos))
|
|
3263 ;; Show what follows the open in its line, if anything.
|
|
3264 (if (save-excursion
|
|
3265 (forward-char 1)
|
|
3266 (skip-chars-forward " \t")
|
|
3267 (not (eolp)))
|
|
3268 (buffer-substring blinkpos
|
|
3269 (progn (end-of-line) (point)))
|
|
3270 ;; Otherwise show the previous nonblank line,
|
|
3271 ;; if there is one.
|
|
3272 (if (save-excursion
|
|
3273 (skip-chars-backward "\n \t")
|
|
3274 (not (bobp)))
|
|
3275 (concat
|
|
3276 (buffer-substring (progn
|
|
3277 (skip-chars-backward "\n \t")
|
|
3278 (beginning-of-line)
|
|
3279 (point))
|
|
3280 (progn (end-of-line)
|
|
3281 (skip-chars-backward " \t")
|
|
3282 (point)))
|
|
3283 ;; Replace the newline and other whitespace with `...'.
|
|
3284 "..."
|
|
3285 (buffer-substring blinkpos (1+ blinkpos)))
|
|
3286 ;; There is nothing to show except the char itself.
|
|
3287 (buffer-substring blinkpos (1+ blinkpos))))))))
|
|
3288 (cond (mismatch
|
|
3289 (display-message 'no-log "Mismatched parentheses"))
|
|
3290 ((not blink-matching-paren-distance)
|
|
3291 (display-message 'no-log "Unmatched parenthesis"))))))))
|
|
3292
|
|
3293 ;Turned off because it makes dbx bomb out.
|
|
3294 (setq blink-paren-function 'blink-matching-open)
|
|
3295
|
|
3296
|
|
3297 ;; XEmacs: Some functions moved to cmdloop.el:
|
|
3298 ;; keyboard-quit
|
|
3299 ;; buffer-quit-function
|
|
3300 ;; keyboard-escape-quit
|
|
3301
|
|
3302 (defun assoc-ignore-case (key alist)
|
|
3303 "Like `assoc', but assumes KEY is a string and ignores case when comparing."
|
801
|
3304 (assoc* key alist :test #'equalp))
|
428
|
3305
|
|
3306
|
442
|
3307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3308 ;; mail composition code ;;
|
|
3309 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3310
|
1333
|
3311 ;; BEGIN SYNCHED WITH FSF 21.2.
|
|
3312
|
2768
|
3313 (defcustom mail-user-agent 'xemacs-default-mail-user-agent
|
428
|
3314 "*Your preference for a mail composition package.
|
1333
|
3315 Various Emacs Lisp packages (e.g. Reporter) require you to compose an
|
428
|
3316 outgoing email message. This variable lets you specify which
|
|
3317 mail-sending package you prefer.
|
|
3318
|
2768
|
3319 Valid values may include:
|
|
3320
|
|
3321 `vm-user-agent' -- use Kyle Jones' VM, as documented in the `(vm)'
|
|
3322 Info node. Compatible with `sendmail-user-agent'
|
|
3323 and can handle attachments and non-ASCII content,
|
|
3324 which the former can't.
|
|
3325 `sendmail-user-agent' -- use the default, bare-bones, Emacs Mail
|
|
3326 package. See Info node `(xemacs)Sending Mail'.
|
1333
|
3327 `mh-e-user-agent' -- use the Emacs interface to the MH mail system.
|
|
3328 See Info node `(mh-e)'.
|
|
3329 `message-user-agent' -- use the Gnus Message package.
|
|
3330 See Info node `(message)'.
|
|
3331 `gnus-user-agent' -- like `message-user-agent', but with Gnus
|
|
3332 paraphernalia, particularly the Gcc: header for
|
|
3333 archiving.
|
428
|
3334
|
2768
|
3335 If you examine the value of this variable before setting it or composing a
|
|
3336 mail, it will have another value, `xemacs-default-mail-user-agent'--this is to
|
|
3337 allow XEmacs to suggest that you use another email client instead of
|
|
3338 `sendmail-user-agent'. The latter, while part of the base XEmacs Lisp code,
|
|
3339 and very lightweight, doesn't support MIME, a considerable disadvantage
|
|
3340 today.
|
|
3341
|
428
|
3342 Additional valid symbols may be available; check with the author of
|
1333
|
3343 your package for details. The function should return non-nil if it
|
|
3344 succeeds.
|
|
3345
|
|
3346 See also `read-mail-command' concerning reading mail."
|
2768
|
3347 :type '(radio (function-item :tag "VM mail package"
|
|
3348 :format "%t\n"
|
|
3349 vm-user-agent)
|
|
3350 (function-item :tag "Bare-bones Emacs mail"
|
428
|
3351 :format "%t\n"
|
|
3352 sendmail-user-agent)
|
1333
|
3353 (function-item :tag "Emacs interface to MH"
|
|
3354 :format "%t\n"
|
|
3355 mh-e-user-agent)
|
|
3356 (function-item :tag "Gnus Message package"
|
428
|
3357 :format "%t\n"
|
|
3358 message-user-agent)
|
1333
|
3359 (function-item :tag "Gnus Message with full Gnus features"
|
|
3360 :format "%t\n"
|
|
3361 gnus-user-agent)
|
428
|
3362 (function :tag "Other"))
|
|
3363 :group 'mail)
|
|
3364
|
|
3365 (defun define-mail-user-agent (symbol composefunc sendfunc
|
|
3366 &optional abortfunc hookvar)
|
|
3367 "Define a symbol to identify a mail-sending package for `mail-user-agent'.
|
|
3368
|
|
3369 SYMBOL can be any Lisp symbol. Its function definition and/or
|
|
3370 value as a variable do not matter for this usage; we use only certain
|
|
3371 properties on its property list, to encode the rest of the arguments.
|
|
3372
|
|
3373 COMPOSEFUNC is program callable function that composes an outgoing
|
|
3374 mail message buffer. This function should set up the basics of the
|
|
3375 buffer without requiring user interaction. It should populate the
|
|
3376 standard mail headers, leaving the `to:' and `subject:' headers blank
|
|
3377 by default.
|
|
3378
|
|
3379 COMPOSEFUNC should accept several optional arguments--the same
|
|
3380 arguments that `compose-mail' takes. See that function's documentation.
|
|
3381
|
|
3382 SENDFUNC is the command a user would run to send the message.
|
|
3383
|
|
3384 Optional ABORTFUNC is the command a user would run to abort the
|
|
3385 message. For mail packages that don't have a separate abort function,
|
|
3386 this can be `kill-buffer' (the equivalent of omitting this argument).
|
|
3387
|
|
3388 Optional HOOKVAR is a hook variable that gets run before the message
|
|
3389 is actually sent. Callers that use the `mail-user-agent' may
|
|
3390 install a hook function temporarily on this hook variable.
|
|
3391 If HOOKVAR is nil, `mail-send-hook' is used.
|
|
3392
|
|
3393 The properties used on SYMBOL are `composefunc', `sendfunc',
|
|
3394 `abortfunc', and `hookvar'."
|
|
3395 (put symbol 'composefunc composefunc)
|
|
3396 (put symbol 'sendfunc sendfunc)
|
|
3397 (put symbol 'abortfunc (or abortfunc 'kill-buffer))
|
|
3398 (put symbol 'hookvar (or hookvar 'mail-send-hook)))
|
|
3399
|
2768
|
3400 (define-mail-user-agent 'vm-user-agent
|
|
3401 'vm-compose-mail
|
|
3402 'vm-mail-send-and-exit)
|
|
3403
|
428
|
3404 (define-mail-user-agent 'sendmail-user-agent
|
|
3405 'sendmail-user-agent-compose 'mail-send-and-exit)
|
|
3406
|
2768
|
3407 ;; Recent GNU sendmail.el does have MIME support, but it's buggy (as of
|
|
3408 ;; 2005-05-01.) For example, if you FCC to a file more than once with
|
|
3409 ;; different coding systems, your non-ASCII data will get
|
|
3410 ;; trashed. quoted-printable encoding isn't done by default, attachments
|
|
3411 ;; just add a line:
|
|
3412 ;;
|
|
3413 ;; ===File /path/to/file/here=================
|
|
3414 ;;
|
|
3415 ;; the file's contents,
|
|
3416 ;;
|
|
3417 ;; ===========================================
|
|
3418 ;;
|
|
3419 ;; and hope for the best. Not code we want to use, IMO.
|
|
3420
|
|
3421 (defun xemacs-default-composefunc (&rest args)
|
|
3422 "Warn that the default mail-reading package is heinously underfeatured;
|
|
3423 compose a mail using it, all the same. "
|
2977
|
3424 (unless (noninteractive)
|
|
3425 (warn "
|
2768
|
3426
|
|
3427 Defaulting to the GNU Emacs-derived `sendmail.el' mail client. This facility,
|
|
3428 while part of base XEmacs, is heinously underfeatured, and not going to get
|
|
3429 better in the medium term. We include it so that bug reports work without
|
|
3430 packages; we suggest that you choose and/or install one of the other mail
|
|
3431 clients from packages if you're doing something other than M-x
|
|
3432 report-xemacs-bug , or even if you are reporting bugs regularly.
|
|
3433
|
|
3434 To choose a package from those installed, click on \"Options\" ->
|
|
3435 \"Internet\" -> \"Compose Mail With ...\" and decide on one from the
|
|
3436 list. Gnus and VM are full-featured and have active user communities.
|
|
3437
|
|
3438 To disable this warning and stick with the old behavior, you can explicitly
|
2977
|
3439 initialize `mail-user-agent' to 'sendmail-user-agent . "))
|
2768
|
3440 (setq mail-user-agent 'sendmail-user-agent)
|
|
3441 (apply (get 'sendmail-user-agent 'composefunc) args))
|
|
3442
|
|
3443 (defun xemacs-default-sendfunc (&rest args)
|
|
3444 "Set `mail-user-agent' to `sendmail-user-agent'; call the send function
|
|
3445 associated with that package, passing it the supplied arguments. "
|
|
3446 (setq mail-user-agent 'sendmail-user-agent)
|
|
3447 (apply (get 'sendmail-user-agent 'sendfunc) args))
|
|
3448
|
|
3449 (define-mail-user-agent 'xemacs-default-mail-user-agent
|
|
3450 'xemacs-default-composefunc 'xemacs-default-sendfunc)
|
|
3451
|
428
|
3452 (define-mail-user-agent 'message-user-agent
|
|
3453 'message-mail 'message-send-and-exit
|
|
3454 'message-kill-buffer 'message-send-hook)
|
|
3455
|
1333
|
3456 (defun rfc822-goto-eoh ()
|
|
3457 ;; Go to header delimiter line in a mail message, following RFC822 rules
|
|
3458 (goto-char (point-min))
|
|
3459 (while (looking-at "^[^: \n]+:\\|^[ \t]")
|
|
3460 (forward-line 1))
|
|
3461 (point))
|
|
3462
|
428
|
3463 (defun sendmail-user-agent-compose (&optional to subject other-headers continue
|
|
3464 switch-function yank-action
|
|
3465 send-actions)
|
|
3466 (if switch-function
|
|
3467 (let ((special-display-buffer-names nil)
|
|
3468 (special-display-regexps nil)
|
|
3469 (same-window-buffer-names nil)
|
|
3470 (same-window-regexps nil))
|
|
3471 (funcall switch-function "*mail*")))
|
|
3472 (let ((cc (cdr (assoc-ignore-case "cc" other-headers)))
|
1333
|
3473 (in-reply-to (cdr (assoc-ignore-case "in-reply-to" other-headers)))
|
|
3474 (body (cdr (assoc-ignore-case "body" other-headers))))
|
776
|
3475 (or (declare-fboundp
|
|
3476 (mail continue to subject in-reply-to cc yank-action send-actions))
|
428
|
3477 continue
|
|
3478 (error "Message aborted"))
|
|
3479 (save-excursion
|
1333
|
3480 (rfc822-goto-eoh)
|
428
|
3481 (while other-headers
|
1333
|
3482 (unless (member* (car (car other-headers))
|
|
3483 '("in-reply-to" "cc" "body")
|
|
3484 :test 'equalp)
|
428
|
3485 (insert (car (car other-headers)) ": "
|
|
3486 (cdr (car other-headers)) "\n"))
|
|
3487 (setq other-headers (cdr other-headers)))
|
1333
|
3488 (when body
|
|
3489 (forward-line 1)
|
|
3490 (insert body))
|
428
|
3491 t)))
|
|
3492
|
|
3493 (define-mail-user-agent 'mh-e-user-agent
|
1333
|
3494 'mh-smail-batch 'mh-send-letter 'mh-fully-kill-draft
|
428
|
3495 'mh-before-send-letter-hook)
|
|
3496
|
|
3497 (defun compose-mail (&optional to subject other-headers continue
|
|
3498 switch-function yank-action send-actions)
|
|
3499 "Start composing a mail message to send.
|
|
3500 This uses the user's chosen mail composition package
|
|
3501 as selected with the variable `mail-user-agent'.
|
|
3502 The optional arguments TO and SUBJECT specify recipients
|
|
3503 and the initial Subject field, respectively.
|
|
3504
|
|
3505 OTHER-HEADERS is an alist specifying additional
|
|
3506 header fields. Elements look like (HEADER . VALUE) where both
|
|
3507 HEADER and VALUE are strings.
|
|
3508
|
|
3509 CONTINUE, if non-nil, says to continue editing a message already
|
|
3510 being composed.
|
|
3511
|
|
3512 SWITCH-FUNCTION, if non-nil, is a function to use to
|
|
3513 switch to and display the buffer used for mail composition.
|
|
3514
|
|
3515 YANK-ACTION, if non-nil, is an action to perform, if and when necessary,
|
|
3516 to insert the raw text of the message being replied to.
|
|
3517 It has the form (FUNCTION . ARGS). The user agent will apply
|
|
3518 FUNCTION to ARGS, to insert the raw text of the original message.
|
|
3519 \(The user agent will also run `mail-citation-hook', *after* the
|
|
3520 original text has been inserted in this way.)
|
|
3521
|
|
3522 SEND-ACTIONS is a list of actions to call when the message is sent.
|
|
3523 Each action has the form (FUNCTION . ARGS)."
|
|
3524 (interactive
|
|
3525 (list nil nil nil current-prefix-arg))
|
|
3526 (let ((function (get mail-user-agent 'composefunc)))
|
|
3527 (funcall function to subject other-headers continue
|
|
3528 switch-function yank-action send-actions)))
|
|
3529
|
|
3530 (defun compose-mail-other-window (&optional to subject other-headers continue
|
|
3531 yank-action send-actions)
|
|
3532 "Like \\[compose-mail], but edit the outgoing message in another window."
|
|
3533 (interactive
|
|
3534 (list nil nil nil current-prefix-arg))
|
|
3535 (compose-mail to subject other-headers continue
|
|
3536 'switch-to-buffer-other-window yank-action send-actions))
|
|
3537
|
|
3538
|
|
3539 (defun compose-mail-other-frame (&optional to subject other-headers continue
|
|
3540 yank-action send-actions)
|
|
3541 "Like \\[compose-mail], but edit the outgoing message in another frame."
|
|
3542 (interactive
|
|
3543 (list nil nil nil current-prefix-arg))
|
|
3544 (compose-mail to subject other-headers continue
|
|
3545 'switch-to-buffer-other-frame yank-action send-actions))
|
|
3546
|
|
3547
|
442
|
3548 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3549 ;; set variable ;;
|
|
3550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3551
|
1333
|
3552 (defvar set-variable-value-history nil
|
|
3553 "History of values entered with `set-variable'.")
|
|
3554
|
428
|
3555 (defun set-variable (var val)
|
|
3556 "Set VARIABLE to VALUE. VALUE is a Lisp object.
|
1333
|
3557 When using this interactively, enter a Lisp object for VALUE.
|
428
|
3558 If you want VALUE to be a string, you must surround it with doublequotes.
|
1333
|
3559 VALUE is used literally, not evaluated.
|
|
3560
|
428
|
3561 If VARIABLE is a specifier, VALUE is added to it as an instantiator in
|
|
3562 the 'global locale with nil tag set (see `set-specifier').
|
|
3563
|
|
3564 If VARIABLE has a `variable-interactive' property, that is used as if
|
1333
|
3565 it were the arg to `interactive' (which see) to interactively read VALUE.
|
|
3566
|
|
3567 If VARIABLE has been defined with `defcustom', then the type information
|
|
3568 in the definition is used to check that VALUE is valid."
|
428
|
3569 (interactive
|
1333
|
3570 (let* ((default-var (variable-at-point))
|
|
3571 (var (if (symbolp default-var)
|
|
3572 (read-variable (format "Set variable (default %s): " default-var)
|
|
3573 default-var)
|
|
3574 (read-variable "Set variable: ")))
|
|
3575 (minibuffer-help-form '(describe-variable var))
|
|
3576 (prop (get var 'variable-interactive))
|
|
3577 (prompt (format "Set %s to value: " var))
|
|
3578 (val (if prop
|
|
3579 ;; Use VAR's `variable-interactive' property
|
|
3580 ;; as an interactive spec for prompting.
|
|
3581 (call-interactively `(lambda (arg)
|
|
3582 (interactive ,prop)
|
|
3583 arg))
|
|
3584 (read
|
|
3585 (read-string prompt nil
|
|
3586 'set-variable-value-history)))))
|
|
3587 (list var val)))
|
|
3588
|
|
3589 (let ((type (get var 'custom-type)))
|
|
3590 (when type
|
|
3591 ;; Match with custom type.
|
|
3592 (require 'cus-edit)
|
|
3593 (setq type (widget-convert type))
|
|
3594 (unless (widget-apply type :match val)
|
|
3595 (error "Value `%S' does not match type %S of %S"
|
|
3596 val (car type) var))))
|
428
|
3597 (if (and (boundp var) (specifierp (symbol-value var)))
|
|
3598 (set-specifier (symbol-value var) val)
|
1333
|
3599 (set var val))
|
|
3600
|
|
3601 ;; Force a thorough redisplay for the case that the variable
|
|
3602 ;; has an effect on the display, like `tab-width' has.
|
|
3603 (force-mode-line-update))
|
|
3604
|
|
3605
|
|
3606
|
|
3607 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3608 ;; forking a twin copy of a buffer ;;
|
|
3609 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3610
|
|
3611 (defvar clone-buffer-hook nil
|
|
3612 "Normal hook to run in the new buffer at the end of `clone-buffer'.")
|
|
3613
|
|
3614 (defun clone-process (process &optional newname)
|
|
3615 "Create a twin copy of PROCESS.
|
|
3616 If NEWNAME is nil, it defaults to PROCESS' name;
|
|
3617 NEWNAME is modified by adding or incrementing <N> at the end as necessary.
|
|
3618 If PROCESS is associated with a buffer, the new process will be associated
|
|
3619 with the current buffer instead.
|
|
3620 Returns nil if PROCESS has already terminated."
|
|
3621 (setq newname (or newname (process-name process)))
|
|
3622 (if (string-match "<[0-9]+>\\'" newname)
|
|
3623 (setq newname (substring newname 0 (match-beginning 0))))
|
|
3624 (when (memq (process-status process) '(run stop open))
|
|
3625 (let* ((process-connection-type (process-tty-name process))
|
|
3626 (old-kwoq (process-kill-without-query process nil))
|
|
3627 (new-process
|
|
3628 (if (memq (process-status process) '(open))
|
|
3629 (apply 'open-network-stream newname
|
|
3630 (if (process-buffer process) (current-buffer))
|
|
3631 ;; FSF: (process-contact process)
|
|
3632 (process-command process))
|
|
3633 (apply 'start-process newname
|
|
3634 (if (process-buffer process) (current-buffer))
|
|
3635 (process-command process)))))
|
|
3636 (process-kill-without-query new-process old-kwoq)
|
|
3637 (process-kill-without-query process old-kwoq)
|
|
3638 ;; FSF 21.2:
|
|
3639 ; (set-process-inherit-coding-system-flag
|
|
3640 ; new-process (process-inherit-coding-system-flag process))
|
|
3641 (set-process-filter new-process (process-filter process))
|
|
3642 (set-process-sentinel new-process (process-sentinel process))
|
|
3643 new-process)))
|
|
3644
|
|
3645 ;; things to maybe add (currently partly covered by `funcall mode':
|
|
3646 ;; - syntax-table
|
|
3647 ;; - overlays
|
|
3648 (defun clone-buffer (&optional newname display-flag)
|
|
3649 "Create a twin copy of the current buffer.
|
|
3650 If NEWNAME is nil, it defaults to the current buffer's name;
|
|
3651 NEWNAME is modified by adding or incrementing <N> at the end as necessary.
|
|
3652
|
|
3653 If DISPLAY-FLAG is non-nil, the new buffer is shown with `pop-to-buffer'.
|
|
3654 This runs the normal hook `clone-buffer-hook' in the new buffer
|
|
3655 after it has been set up properly in other respects."
|
|
3656 (interactive (list (if current-prefix-arg (read-string "Name: "))
|
|
3657 t))
|
|
3658 (if buffer-file-name
|
|
3659 (error "Cannot clone a file-visiting buffer"))
|
|
3660 (if (get major-mode 'no-clone)
|
|
3661 (error "Cannot clone a buffer in %s mode" mode-name))
|
|
3662 (setq newname (or newname (buffer-name)))
|
|
3663 (if (string-match "<[0-9]+>\\'" newname)
|
|
3664 (setq newname (substring newname 0 (match-beginning 0))))
|
|
3665 (let ((buf (current-buffer))
|
|
3666 (ptmin (point-min))
|
|
3667 (ptmax (point-max))
|
|
3668 (pt (point))
|
|
3669 (mk (mark t)) ;(if mark-active (mark t)))
|
|
3670 (modified (buffer-modified-p))
|
|
3671 (mode major-mode)
|
|
3672 (lvars (buffer-local-variables))
|
|
3673 (process (get-buffer-process (current-buffer)))
|
|
3674 (new (generate-new-buffer (or newname (buffer-name)))))
|
|
3675 (save-restriction
|
|
3676 (widen)
|
|
3677 (with-current-buffer new
|
|
3678 (insert-buffer-substring buf)))
|
|
3679 (with-current-buffer new
|
|
3680 (narrow-to-region ptmin ptmax)
|
|
3681 (goto-char pt)
|
|
3682 (if mk (set-mark mk))
|
|
3683 (set-buffer-modified-p modified)
|
|
3684
|
|
3685 ;; Clone the old buffer's process, if any.
|
|
3686 (when process (clone-process process))
|
|
3687
|
|
3688 ;; Now set up the major mode.
|
|
3689 (funcall mode)
|
|
3690
|
|
3691 ;; Set up other local variables.
|
|
3692 (mapcar (lambda (v)
|
|
3693 (condition-case () ;in case var is read-only
|
|
3694 (if (symbolp v)
|
|
3695 (makunbound v)
|
|
3696 (set (make-local-variable (car v)) (cdr v)))
|
|
3697 (error nil)))
|
|
3698 lvars)
|
|
3699
|
|
3700 ;; Run any hooks (typically set up by the major mode
|
|
3701 ;; for cloning to work properly).
|
|
3702 (run-hooks 'clone-buffer-hook))
|
|
3703 (if display-flag (pop-to-buffer new))
|
|
3704 new))
|
|
3705
|
|
3706
|
|
3707 (defun clone-indirect-buffer (newname display-flag &optional norecord)
|
|
3708 "Create an indirect buffer that is a twin copy of the current buffer.
|
|
3709
|
|
3710 Give the indirect buffer name NEWNAME. Interactively, read NEW-NAME
|
|
3711 from the minibuffer when invoked with a prefix arg. If NEWNAME is nil
|
|
3712 or if not called with a prefix arg, NEWNAME defaults to the current
|
|
3713 buffer's name. The name is modified by adding a `<N>' suffix to it
|
|
3714 or by incrementing the N in an existing suffix.
|
|
3715
|
|
3716 DISPLAY-FLAG non-nil means show the new buffer with `pop-to-buffer'.
|
|
3717 This is always done when called interactively.
|
|
3718
|
|
3719 Optional last arg NORECORD non-nil means do not put this buffer at the
|
|
3720 front of the list of recently selected ones."
|
|
3721 (interactive (list (if current-prefix-arg
|
|
3722 (read-string "BName of indirect buffer: "))
|
|
3723 t))
|
|
3724 (setq newname (or newname (buffer-name)))
|
|
3725 (if (string-match "<[0-9]+>\\'" newname)
|
|
3726 (setq newname (substring newname 0 (match-beginning 0))))
|
|
3727 (let* ((name (generate-new-buffer-name newname))
|
|
3728 (buffer (make-indirect-buffer (current-buffer) name t)))
|
|
3729 (when display-flag
|
|
3730 (pop-to-buffer buffer norecord))
|
|
3731 buffer))
|
|
3732
|
|
3733
|
|
3734 (defun clone-indirect-buffer-other-window (buffer &optional norecord)
|
|
3735 "Create an indirect buffer that is a twin copy of BUFFER.
|
|
3736 Select the new buffer in another window.
|
|
3737 Optional second arg NORECORD non-nil means do not put this buffer at
|
|
3738 the front of the list of recently selected ones."
|
|
3739 (interactive "bClone buffer in other window: ")
|
|
3740 (let ((pop-up-windows t))
|
|
3741 (set-buffer buffer)
|
|
3742 (clone-indirect-buffer nil t norecord)))
|
|
3743
|
|
3744 ;; END SYNCHED WITH FSF 21.2.
|
442
|
3745
|
428
|
3746
|
442
|
3747 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3748 ;; case changing code ;;
|
|
3749 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
428
|
3750
|
|
3751 ;; A bunch of stuff was moved elsewhere:
|
|
3752 ;; completion-list-mode-map
|
|
3753 ;; completion-reference-buffer
|
|
3754 ;; completion-base-size
|
|
3755 ;; delete-completion-window
|
|
3756 ;; previous-completion
|
|
3757 ;; next-completion
|
|
3758 ;; choose-completion
|
|
3759 ;; choose-completion-delete-max-match
|
|
3760 ;; choose-completion-string
|
|
3761 ;; completion-list-mode
|
|
3762 ;; completion-fixup-function
|
|
3763 ;; completion-setup-function
|
|
3764 ;; switch-to-completions
|
|
3765 ;; event stuffs
|
|
3766 ;; keypad stuffs
|
|
3767
|
|
3768 ;; The rest of this file is not in Lisp in FSF
|
|
3769 (defun capitalize-region-or-word (arg)
|
|
3770 "Capitalize the selected region or the following word (or ARG words)."
|
|
3771 (interactive "p")
|
|
3772 (if (region-active-p)
|
|
3773 (capitalize-region (region-beginning) (region-end))
|
|
3774 (capitalize-word arg)))
|
|
3775
|
|
3776 (defun upcase-region-or-word (arg)
|
|
3777 "Upcase the selected region or the following word (or ARG words)."
|
|
3778 (interactive "p")
|
|
3779 (if (region-active-p)
|
|
3780 (upcase-region (region-beginning) (region-end))
|
|
3781 (upcase-word arg)))
|
|
3782
|
|
3783 (defun downcase-region-or-word (arg)
|
|
3784 "Downcase the selected region or the following word (or ARG words)."
|
|
3785 (interactive "p")
|
|
3786 (if (region-active-p)
|
|
3787 (downcase-region (region-beginning) (region-end))
|
|
3788 (downcase-word arg)))
|
|
3789
|
442
|
3790 ;; #### not localized
|
|
3791 (defvar uncapitalized-title-words
|
|
3792 '("the" "a" "an" "in" "of" "for" "to" "and" "but" "at" "on" "as" "by"))
|
|
3793
|
|
3794 (defvar uncapitalized-title-word-regexp
|
|
3795 (concat "[ \t]*\\(" (mapconcat #'identity uncapitalized-title-words "\\|")
|
|
3796 "\\)\\>"))
|
|
3797
|
|
3798 (defun capitalize-string-as-title (string)
|
|
3799 "Capitalize the words in the string, except for small words (as in titles).
|
|
3800 The words not capitalized are specified in `uncapitalized-title-words'."
|
|
3801 (let ((buffer (get-buffer-create " *capitalize-string-as-title*")))
|
|
3802 (unwind-protect
|
|
3803 (progn
|
|
3804 (insert-string string buffer)
|
|
3805 (capitalize-region-as-title 1 (point-max buffer) buffer)
|
|
3806 (buffer-string buffer))
|
|
3807 (kill-buffer buffer))))
|
|
3808
|
|
3809 (defun capitalize-region-as-title (b e &optional buffer)
|
|
3810 "Capitalize the words in the region, except for small words (as in titles).
|
|
3811 The words not capitalized are specified in `uncapitalized-title-words'."
|
|
3812 (interactive "r")
|
|
3813 (save-excursion
|
|
3814 (and buffer
|
|
3815 (set-buffer buffer))
|
|
3816 (save-restriction
|
|
3817 (narrow-to-region b e)
|
|
3818 (goto-char (point-min))
|
|
3819 (let ((first t))
|
|
3820 (while (< (point) (point-max))
|
|
3821 (if (or first
|
|
3822 (not (looking-at uncapitalized-title-word-regexp)))
|
|
3823 (capitalize-word 1)
|
|
3824 (forward-word 1))
|
|
3825 (setq first nil))))))
|
|
3826
|
|
3827
|
|
3828 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3829 ;; zmacs active region code ;;
|
|
3830 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3831
|
428
|
3832 ;; Most of the zmacs code is now in elisp. The only thing left in C
|
|
3833 ;; are the variables zmacs-regions, zmacs-region-active-p and
|
|
3834 ;; zmacs-region-stays plus the function zmacs_update_region which
|
|
3835 ;; simply calls the lisp level zmacs-update-region. It must remain
|
|
3836 ;; for convenience, since it is called by core C code.
|
|
3837
|
442
|
3838 ;; XEmacs
|
|
3839 (defun activate-region ()
|
|
3840 "Activate the region, if `zmacs-regions' is true.
|
|
3841 Setting `zmacs-regions' to true causes LISPM-style active regions to be used.
|
|
3842 This function has no effect if `zmacs-regions' is false."
|
|
3843 (interactive)
|
|
3844 (and zmacs-regions (zmacs-activate-region)))
|
|
3845
|
|
3846 ;; XEmacs
|
|
3847 (defsubst region-exists-p ()
|
|
3848 "Return t if the region exists.
|
|
3849 If active regions are in use (i.e. `zmacs-regions' is true), this means that
|
|
3850 the region is active. Otherwise, this means that the user has pushed
|
|
3851 a mark in this buffer at some point in the past.
|
|
3852 The functions `region-beginning' and `region-end' can be used to find the
|
502
|
3853 limits of the region.
|
|
3854
|
|
3855 You should use this, *NOT* `region-active-p', in a menu item
|
|
3856 specification that you want grayed out when the region is not active:
|
|
3857
|
|
3858 [ ... ... :active (region-exists-p)]
|
|
3859
|
|
3860 This correctly caters to the user's setting of `zmacs-regions'."
|
442
|
3861 (not (null (mark))))
|
|
3862
|
|
3863 ;; XEmacs
|
|
3864 (defun region-active-p ()
|
2611
|
3865 "Return non-nil if the region is active in the current buffer.
|
442
|
3866 If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
|
502
|
3867 Otherwise, this function always returns false.
|
|
3868
|
|
3869 You should generally *NOT* use this in a menu item specification that you
|
|
3870 want grayed out when the region is not active. Instead, use this:
|
|
3871
|
|
3872 [ ... ... :active (region-exists-p)]
|
|
3873
|
|
3874 Which correctly caters to the user's setting of `zmacs-regions'."
|
2611
|
3875 (and zmacs-regions zmacs-region-extent
|
|
3876 (eq (current-buffer) (zmacs-region-buffer))))
|
442
|
3877
|
428
|
3878 (defvar zmacs-activate-region-hook nil
|
|
3879 "Function or functions called when the region becomes active;
|
|
3880 see the variable `zmacs-regions'.")
|
|
3881
|
|
3882 (defvar zmacs-deactivate-region-hook nil
|
|
3883 "Function or functions called when the region becomes inactive;
|
|
3884 see the variable `zmacs-regions'.")
|
|
3885
|
|
3886 (defvar zmacs-update-region-hook nil
|
|
3887 "Function or functions called when the active region changes.
|
|
3888 This is called after each command that sets `zmacs-region-stays' to t.
|
|
3889 See the variable `zmacs-regions'.")
|
|
3890
|
487
|
3891 (add-hook 'zmacs-deactivate-region-hook 'disown-selection)
|
|
3892 (add-hook 'zmacs-activate-region-hook 'activate-region-as-selection)
|
|
3893 (add-hook 'zmacs-update-region-hook 'activate-region-as-selection)
|
|
3894
|
428
|
3895 (defvar zmacs-region-extent nil
|
|
3896 "The extent of the zmacs region; don't use this.")
|
|
3897
|
|
3898 (defvar zmacs-region-rectangular-p nil
|
|
3899 "Whether the zmacs region is a rectangle; don't use this.")
|
|
3900
|
|
3901 (defun zmacs-make-extent-for-region (region)
|
|
3902 ;; Given a region, this makes an extent in the buffer which holds that
|
|
3903 ;; region, for highlighting purposes. If the region isn't associated
|
|
3904 ;; with a buffer, this does nothing.
|
|
3905 (let ((buffer nil)
|
|
3906 (valid (and (extentp zmacs-region-extent)
|
|
3907 (extent-object zmacs-region-extent)
|
|
3908 (buffer-live-p (extent-object zmacs-region-extent))))
|
|
3909 start end)
|
|
3910 (cond ((consp region)
|
|
3911 (setq start (min (car region) (cdr region))
|
|
3912 end (max (car region) (cdr region))
|
|
3913 valid (and valid
|
|
3914 (eq (marker-buffer (car region))
|
|
3915 (extent-object zmacs-region-extent)))
|
|
3916 buffer (marker-buffer (car region))))
|
|
3917 (t
|
|
3918 (signal 'error (list "Invalid region" region))))
|
|
3919
|
|
3920 (if valid
|
|
3921 nil
|
|
3922 ;; The condition case is in case any of the extents are dead or
|
|
3923 ;; otherwise incapacitated.
|
|
3924 (condition-case ()
|
|
3925 (if (listp zmacs-region-extent)
|
|
3926 (mapc 'delete-extent zmacs-region-extent)
|
|
3927 (delete-extent zmacs-region-extent))
|
|
3928 (error nil)))
|
|
3929
|
|
3930 (if valid
|
|
3931 (set-extent-endpoints zmacs-region-extent start end)
|
|
3932 (setq zmacs-region-extent (make-extent start end buffer))
|
|
3933
|
|
3934 ;; Make the extent be closed on the right, which means that if
|
|
3935 ;; characters are inserted exactly at the end of the extent, the
|
|
3936 ;; extent will grow to cover them. This is important for shell
|
|
3937 ;; buffers - suppose one makes a region, and one end is at point-max.
|
|
3938 ;; If the shell produces output, that marker will remain at point-max
|
|
3939 ;; (its position will increase). So it's important that the extent
|
|
3940 ;; exhibit the same behavior, lest the region covered by the extent
|
|
3941 ;; (the visual indication), and the region between point and mark
|
|
3942 ;; (the actual region value) become different!
|
|
3943 (set-extent-property zmacs-region-extent 'end-open nil)
|
|
3944
|
|
3945 ;; use same priority as mouse-highlighting so that conflicts between
|
|
3946 ;; the region extent and a mouse-highlighted extent are resolved by
|
|
3947 ;; the usual size-and-endpoint-comparison method.
|
|
3948 (set-extent-priority zmacs-region-extent mouse-highlight-priority)
|
|
3949 (set-extent-face zmacs-region-extent 'zmacs-region)
|
|
3950
|
|
3951 ;; #### It might be better to actually break
|
|
3952 ;; default-mouse-track-next-move-rect out of mouse.el so that we
|
|
3953 ;; can use its logic here.
|
|
3954 (cond
|
|
3955 (zmacs-region-rectangular-p
|
|
3956 (setq zmacs-region-extent (list zmacs-region-extent))
|
|
3957 (default-mouse-track-next-move-rect start end zmacs-region-extent)
|
|
3958 ))
|
|
3959
|
|
3960 zmacs-region-extent)))
|
|
3961
|
|
3962 (defun zmacs-region-buffer ()
|
|
3963 "Return the buffer containing the zmacs region, or nil."
|
|
3964 ;; #### this is horrible and kludgy! This stuff needs to be rethought.
|
|
3965 (and zmacs-regions zmacs-region-active-p
|
|
3966 (or (marker-buffer (mark-marker t))
|
|
3967 (and (extent-live-p zmacs-region-extent)
|
|
3968 (buffer-live-p (extent-object zmacs-region-extent))
|
|
3969 (extent-object zmacs-region-extent)))))
|
|
3970
|
|
3971 (defun zmacs-activate-region ()
|
|
3972 "Make the region between `point' and `mark' be active (highlighted),
|
|
3973 if `zmacs-regions' is true. Only a very small number of commands
|
|
3974 should ever do this. Calling this function will call the hook
|
|
3975 `zmacs-activate-region-hook', if the region was previously inactive.
|
|
3976 Calling this function ensures that the region stays active after the
|
|
3977 current command terminates, even if `zmacs-region-stays' is not set.
|
|
3978 Returns t if the region was activated (i.e. if `zmacs-regions' if t)."
|
|
3979 (if (not zmacs-regions)
|
|
3980 nil
|
|
3981 (setq zmacs-region-active-p t
|
|
3982 zmacs-region-stays t
|
|
3983 zmacs-region-rectangular-p (and (boundp 'mouse-track-rectangle-p)
|
|
3984 mouse-track-rectangle-p))
|
|
3985 (if (marker-buffer (mark-marker t))
|
|
3986 (zmacs-make-extent-for-region (cons (point-marker t) (mark-marker t))))
|
|
3987 (run-hooks 'zmacs-activate-region-hook)
|
|
3988 t))
|
|
3989
|
|
3990 (defun zmacs-deactivate-region ()
|
|
3991 "Make the region between `point' and `mark' no longer be active,
|
|
3992 if `zmacs-regions' is true. You shouldn't need to call this; the
|
|
3993 command loop calls it when appropriate. Calling this function will
|
|
3994 call the hook `zmacs-deactivate-region-hook', if the region was
|
|
3995 previously active. Returns t if the region had been active, nil
|
|
3996 otherwise."
|
|
3997 (if (not zmacs-region-active-p)
|
|
3998 nil
|
|
3999 (setq zmacs-region-active-p nil
|
|
4000 zmacs-region-stays nil
|
|
4001 zmacs-region-rectangular-p nil)
|
|
4002 (if zmacs-region-extent
|
|
4003 (let ((inhibit-quit t))
|
|
4004 (if (listp zmacs-region-extent)
|
|
4005 (mapc 'delete-extent zmacs-region-extent)
|
|
4006 (delete-extent zmacs-region-extent))
|
|
4007 (setq zmacs-region-extent nil)))
|
|
4008 (run-hooks 'zmacs-deactivate-region-hook)
|
|
4009 t))
|
|
4010
|
|
4011 (defun zmacs-update-region ()
|
|
4012 "Update the highlighted region between `point' and `mark'.
|
|
4013 You shouldn't need to call this; the command loop calls it
|
|
4014 when appropriate. Calling this function will call the hook
|
|
4015 `zmacs-update-region-hook', if the region is active."
|
|
4016 (when zmacs-region-active-p
|
|
4017 (when (marker-buffer (mark-marker t))
|
|
4018 (zmacs-make-extent-for-region (cons (point-marker t)
|
|
4019 (mark-marker t))))
|
|
4020 (run-hooks 'zmacs-update-region-hook)))
|
|
4021
|
442
|
4022
|
|
4023 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4024 ;; message logging code ;;
|
|
4025 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
428
|
4026
|
|
4027 ;;; #### Should this be moved to a separate file, for clarity?
|
|
4028 ;;; -hniksic
|
|
4029
|
|
4030 ;;; The `message-stack' is an alist of labels with messages; the first
|
|
4031 ;;; message in this list is always in the echo area. A call to
|
|
4032 ;;; `display-message' inserts a label/message pair at the head of the
|
|
4033 ;;; list, and removes any other pairs with that label. Calling
|
|
4034 ;;; `clear-message' causes any pair with matching label to be removed,
|
|
4035 ;;; and this may cause the displayed message to change or vanish. If
|
|
4036 ;;; the label arg is nil, the entire message stack is cleared.
|
|
4037 ;;;
|
|
4038 ;;; Message/error filtering will be a little tricker to implement than
|
|
4039 ;;; logging, since messages can be built up incrementally
|
|
4040 ;;; using clear-message followed by repeated calls to append-message
|
|
4041 ;;; (this happens with error messages). For messages which aren't
|
|
4042 ;;; created this way, filtering could be implemented at display-message
|
|
4043 ;;; very easily.
|
|
4044 ;;;
|
|
4045 ;;; Bits of the logging code are borrowed from log-messages.el by
|
|
4046 ;;; Robert Potter (rpotter@grip.cis.upenn.edu).
|
|
4047
|
|
4048 ;; need this to terminate the currently-displayed message
|
|
4049 ;; ("Loading simple ...")
|
|
4050 (when (and
|
|
4051 (not (fboundp 'display-message))
|
|
4052 (not (featurep 'debug)))
|
1346
|
4053 (set-device-clear-left-side nil nil)
|
428
|
4054 (send-string-to-terminal "\n"))
|
|
4055
|
|
4056 (defvar message-stack nil
|
|
4057 "An alist of label/string pairs representing active echo-area messages.
|
|
4058 The first element in the list is currently displayed in the echo area.
|
|
4059 Do not modify this directly--use the `message' or
|
|
4060 `display-message'/`clear-message' functions.")
|
|
4061
|
|
4062 (defvar remove-message-hook 'log-message
|
|
4063 "A function or list of functions to be called when a message is removed
|
|
4064 from the echo area at the bottom of the frame. The label of the removed
|
|
4065 message is passed as the first argument, and the text of the message
|
|
4066 as the second argument.")
|
|
4067
|
|
4068 (defcustom log-message-max-size 50000
|
|
4069 "Maximum size of the \" *Message-Log*\" buffer. See `log-message'."
|
|
4070 :type 'integer
|
|
4071 :group 'log-message)
|
|
4072 (make-compatible-variable 'message-log-max 'log-message-max-size)
|
|
4073
|
|
4074 ;; We used to reject quite a lot of stuff here, but it was a bad idea,
|
|
4075 ;; for two reasons:
|
|
4076 ;;
|
|
4077 ;; a) In most circumstances, you *want* to see the message in the log.
|
|
4078 ;; The explicitly non-loggable messages should be marked as such by
|
|
4079 ;; the issuer. Gratuitous non-displaying of random regexps made
|
|
4080 ;; debugging harder, too (because various reasonable debugging
|
|
4081 ;; messages would get eaten).
|
|
4082 ;;
|
|
4083 ;; b) It slowed things down. Yes, visibly.
|
|
4084 ;;
|
|
4085 ;; So, I left only a few of the really useless ones on this kill-list.
|
|
4086 ;;
|
|
4087 ;; --hniksic
|
|
4088 (defcustom log-message-ignore-regexps
|
|
4089 '(;; Note: adding entries to this list slows down messaging
|
440
|
4090 ;; significantly. Wherever possible, use message labels.
|
428
|
4091
|
|
4092 ;; Often-seen messages
|
|
4093 "\\`\\'" ; empty message
|
|
4094 "\\`\\(Beginning\\|End\\) of buffer\\'"
|
|
4095 ;;"^Quit$"
|
|
4096 ;; completions
|
|
4097 ;; Many packages print this -- impossible to categorize
|
|
4098 ;;"^Making completion list"
|
|
4099 ;; Gnus
|
|
4100 ;; "^No news is no news$"
|
|
4101 ;; "^No more\\( unread\\)? newsgroups$"
|
|
4102 ;; "^Opening [^ ]+ server\\.\\.\\."
|
|
4103 ;; "^[^:]+: Reading incoming mail"
|
|
4104 ;; "^Getting mail from "
|
|
4105 ;; "^\\(Generating Summary\\|Sorting threads\\|Making sparse threads\\|Scoring\\|Checking new news\\|Expiring articles\\|Sending\\)\\.\\.\\."
|
|
4106 ;; "^\\(Fetching headers for\\|Retrieving newsgroup\\|Reading active file\\)"
|
|
4107 ;; "^No more\\( unread\\)? articles"
|
|
4108 ;; "^Deleting article "
|
|
4109 ;; W3
|
|
4110 ;; "^Parsed [0-9]+ of [0-9]+ ([0-9]+%)"
|
|
4111 )
|
|
4112 "List of regular expressions matching messages which shouldn't be logged.
|
|
4113 See `log-message'.
|
|
4114
|
|
4115 Ideally, packages which generate messages which might need to be ignored
|
|
4116 should label them with 'progress, 'prompt, or 'no-log, so they can be
|
|
4117 filtered by the log-message-ignore-labels."
|
|
4118 :type '(repeat regexp)
|
|
4119 :group 'log-message)
|
|
4120
|
|
4121 (defcustom log-message-ignore-labels
|
|
4122 '(help-echo command progress prompt no-log garbage-collecting auto-saving)
|
|
4123 "List of symbols indicating labels of messages which shouldn't be logged.
|
|
4124 See `display-message' for some common labels. See also `log-message'."
|
|
4125 :type '(repeat (symbol :tag "Label"))
|
|
4126 :group 'log-message)
|
|
4127
|
1703
|
4128 (defcustom redisplay-echo-area-function 'redisplay-echo-area
|
|
4129 "The function to call to display echo area buffer."
|
|
4130 :type 'function
|
|
4131 :group 'log-message)
|
|
4132
|
|
4133 (defcustom undisplay-echo-area-function nil
|
|
4134 "The function to call to undisplay echo area buffer."
|
|
4135 :type 'function
|
|
4136 :group 'log-message)
|
|
4137
|
428
|
4138 ;;Subsumed by view-lossage
|
|
4139 ;; Not really, I'm adding it back by popular demand. -slb
|
|
4140 (defun show-message-log ()
|
|
4141 "Show the \" *Message-Log*\" buffer, which contains old messages and errors."
|
|
4142 (interactive)
|
793
|
4143 (view-lossage t))
|
428
|
4144
|
|
4145 (defvar log-message-filter-function 'log-message-filter
|
|
4146 "Value must be a function of two arguments: a symbol (label) and
|
|
4147 a string (message). It should return non-nil to indicate a message
|
|
4148 should be logged. Possible values include 'log-message-filter and
|
|
4149 'log-message-filter-errors-only.")
|
|
4150
|
|
4151 (defun log-message-filter (label message)
|
|
4152 "Default value of `log-message-filter-function'.
|
|
4153 Messages whose text matches one of the `log-message-ignore-regexps'
|
|
4154 or whose label appears in `log-message-ignore-labels' are not saved."
|
|
4155 (let ((r log-message-ignore-regexps)
|
|
4156 (ok (not (memq label log-message-ignore-labels))))
|
|
4157 (save-match-data
|
|
4158 (while (and r ok)
|
|
4159 (when (string-match (car r) message)
|
|
4160 (setq ok nil))
|
|
4161 (setq r (cdr r))))
|
|
4162 ok))
|
|
4163
|
|
4164 (defun log-message-filter-errors-only (label message)
|
|
4165 "For use as the `log-message-filter-function'. Only logs error messages."
|
|
4166 (eq label 'error))
|
|
4167
|
|
4168 (defun log-message (label message)
|
|
4169 "Stuff a copy of the message into the \" *Message-Log*\" buffer,
|
|
4170 if it satisfies the `log-message-filter-function'.
|
|
4171
|
|
4172 For use on `remove-message-hook'."
|
|
4173 (when (and (not noninteractive)
|
|
4174 (funcall log-message-filter-function label message))
|
|
4175 ;; Use save-excursion rather than save-current-buffer because we
|
|
4176 ;; change the value of point.
|
|
4177 (save-excursion
|
|
4178 (set-buffer (get-buffer-create " *Message-Log*"))
|
|
4179 (goto-char (point-max))
|
|
4180 ;(insert (concat (upcase (symbol-name label)) ": " message "\n"))
|
|
4181 (let (extent)
|
|
4182 ;; Mark multiline message with an extent, which `view-lossage'
|
|
4183 ;; will recognize.
|
793
|
4184 (save-match-data
|
|
4185 (when (string-match "\n" message)
|
|
4186 (setq extent (make-extent (point) (point)))
|
|
4187 (set-extent-properties extent '(end-open nil message-multiline t)))
|
|
4188 )
|
428
|
4189 (insert message "\n")
|
|
4190 (when extent
|
|
4191 (set-extent-property extent 'end-open t)))
|
|
4192 (when (> (point-max) (max log-message-max-size (point-min)))
|
|
4193 ;; Trim log to ~90% of max size.
|
|
4194 (goto-char (max (- (point-max)
|
|
4195 (truncate (* 0.9 log-message-max-size)))
|
|
4196 (point-min)))
|
|
4197 (forward-line 1)
|
|
4198 (delete-region (point-min) (point))))))
|
|
4199
|
|
4200 (defun message-displayed-p (&optional return-string frame)
|
|
4201 "Return a non-nil value if a message is presently displayed in the\n\
|
|
4202 minibuffer's echo area. If optional argument RETURN-STRING is non-nil,\n\
|
|
4203 return a string containing the message, otherwise just return t."
|
|
4204 ;; by definition, a message is displayed if the echo area buffer is
|
|
4205 ;; non-empty (see also echo_area_active()). It had better also
|
|
4206 ;; be the case that message-stack is nil exactly when the echo area
|
|
4207 ;; is non-empty.
|
|
4208 (let ((buffer (get-buffer " *Echo Area*")))
|
|
4209 (and (< (point-min buffer) (point-max buffer))
|
|
4210 (if return-string
|
|
4211 (buffer-substring nil nil buffer)
|
|
4212 t))))
|
|
4213
|
|
4214 ;;; Returns the string which remains in the echo area, or nil if none.
|
|
4215 ;;; If label is nil, the whole message stack is cleared.
|
|
4216 (defun clear-message (&optional label frame stdout-p no-restore)
|
|
4217 "Remove any message with the given LABEL from the message-stack,
|
|
4218 erasing it from the echo area if it's currently displayed there.
|
|
4219 If a message remains at the head of the message-stack and NO-RESTORE
|
|
4220 is nil, it will be displayed. The string which remains in the echo
|
|
4221 area will be returned, or nil if the message-stack is now empty.
|
|
4222 If LABEL is nil, the entire message-stack is cleared.
|
|
4223
|
|
4224 Unless you need the return value or you need to specify a label,
|
|
4225 you should just use (message nil)."
|
|
4226 (or frame (setq frame (selected-frame)))
|
|
4227 (let ((clear-stream (and message-stack (eq 'stream (frame-type frame)))))
|
|
4228 (remove-message label frame)
|
502
|
4229 (let ((inhibit-read-only t))
|
428
|
4230 (erase-buffer " *Echo Area*"))
|
1703
|
4231 (if undisplay-echo-area-function
|
|
4232 (funcall undisplay-echo-area-function))
|
1346
|
4233 ;; If outputting to the terminal, make sure we clear the left side.
|
|
4234 (when (or clear-stream
|
|
4235 (and (eq 'stream (frame-type frame))
|
|
4236 (not (device-left-side-clear-p (frame-device frame)))))
|
|
4237 (set-device-clear-left-side (frame-device frame) nil)
|
|
4238 (send-string-to-terminal ?\n stdout-p))
|
428
|
4239 (if no-restore
|
|
4240 nil ; just preparing to put another msg up
|
|
4241 (if message-stack
|
|
4242 (let ((oldmsg (cdr (car message-stack))))
|
|
4243 (raw-append-message oldmsg frame stdout-p)
|
|
4244 oldmsg)
|
|
4245 ;; #### Should we (redisplay-echo-area) here? Messes some
|
|
4246 ;; things up.
|
|
4247 nil))))
|
|
4248
|
|
4249 (defun remove-message (&optional label frame)
|
|
4250 ;; If label is nil, we want to remove all matching messages.
|
|
4251 ;; Must reverse the stack first to log them in the right order.
|
|
4252 (let ((log nil))
|
|
4253 (while (and message-stack
|
|
4254 (or (null label) ; null label means clear whole stack
|
|
4255 (eq label (car (car message-stack)))))
|
|
4256 (push (car message-stack) log)
|
|
4257 (setq message-stack (cdr message-stack)))
|
|
4258 (let ((s message-stack))
|
|
4259 (while (cdr s)
|
|
4260 (let ((msg (car (cdr s))))
|
|
4261 (if (eq label (car msg))
|
|
4262 (progn
|
|
4263 (push msg log)
|
|
4264 (setcdr s (cdr (cdr s))))
|
|
4265 (setq s (cdr s))))))
|
|
4266 ;; (possibly) log each removed message
|
|
4267 (while log
|
793
|
4268 (with-trapping-errors
|
|
4269 :operation 'remove-message-hook
|
|
4270 :class 'message-log
|
|
4271 :error-form (progn
|
|
4272 (setq remove-message-hook nil)
|
|
4273 (let ((inhibit-read-only t))
|
|
4274 (erase-buffer " *Echo Area*")))
|
|
4275 :resignal t
|
|
4276 (run-hook-with-args 'remove-message-hook
|
|
4277 (car (car log)) (cdr (car log))))
|
428
|
4278 (setq log (cdr log)))))
|
|
4279
|
|
4280 (defun append-message (label message &optional frame stdout-p)
|
|
4281 (or frame (setq frame (selected-frame)))
|
1346
|
4282 ;; If outputting to the terminal, make sure output from anyone else clears
|
|
4283 ;; the left side first, but don't do it ourselves, otherwise we won't be
|
|
4284 ;; able to append to an existing message.
|
|
4285 (if (eq 'stream (frame-type frame))
|
|
4286 (set-device-clear-left-side (frame-device frame) nil))
|
428
|
4287 ;; Add a new entry to the message-stack, or modify an existing one
|
|
4288 (let ((top (car message-stack)))
|
|
4289 (if (eq label (car top))
|
|
4290 (setcdr top (concat (cdr top) message))
|
|
4291 (push (cons label message) message-stack)))
|
1346
|
4292 (raw-append-message message frame stdout-p)
|
|
4293 (if (eq 'stream (frame-type frame))
|
|
4294 (set-device-clear-left-side (frame-device frame) t)))
|
428
|
4295
|
|
4296 ;; Really append the message to the echo area. no fiddling with
|
|
4297 ;; message-stack.
|
|
4298 (defun raw-append-message (message &optional frame stdout-p)
|
|
4299 (unless (equal message "")
|
502
|
4300 (let ((inhibit-read-only t))
|
428
|
4301 (insert-string message " *Echo Area*")
|
|
4302 ;; Conditionalizing on the device type in this way is not that clean,
|
|
4303 ;; but neither is having a device method, as I originally implemented
|
|
4304 ;; it: all non-stream devices behave in the same way. Perhaps
|
|
4305 ;; the cleanest way is to make the concept of a "redisplayable"
|
|
4306 ;; device, which stream devices are not. Look into this more if
|
|
4307 ;; we ever create another non-redisplayable device type (e.g.
|
|
4308 ;; processes? printers?).
|
|
4309
|
|
4310 ;; Don't redisplay the echo area if we are executing a macro.
|
|
4311 (if (not executing-kbd-macro)
|
|
4312 (if (eq 'stream (frame-type frame))
|
|
4313 (send-string-to-terminal message stdout-p (frame-device frame))
|
1703
|
4314 (funcall redisplay-echo-area-function))))))
|
428
|
4315
|
|
4316 (defun display-message (label message &optional frame stdout-p)
|
|
4317 "Print a one-line message at the bottom of the frame. First argument
|
|
4318 LABEL is an identifier for this message. MESSAGE is the string to display.
|
|
4319 Use `clear-message' to remove a labelled message.
|
|
4320
|
|
4321 Here are some standard labels (those marked with `*' are not logged
|
|
4322 by default--see the `log-message-ignore-labels' variable):
|
|
4323 message default label used by the `message' function
|
|
4324 error default label used for reporting errors
|
|
4325 * progress progress indicators like \"Converting... 45%\"
|
|
4326 * prompt prompt-like messages like \"I-search: foo\"
|
|
4327 * command helper command messages like \"Mark set\"
|
|
4328 * no-log messages that should never be logged"
|
|
4329 (clear-message label frame stdout-p t)
|
|
4330 (append-message label message frame stdout-p))
|
|
4331
|
|
4332 (defun current-message (&optional frame)
|
|
4333 "Return the current message in the echo area, or nil.
|
|
4334 The FRAME argument is currently unused."
|
|
4335 (cdr (car message-stack)))
|
|
4336
|
|
4337 ;;; may eventually be frame-dependent
|
|
4338 (defun current-message-label (&optional frame)
|
|
4339 (car (car message-stack)))
|
|
4340
|
|
4341 (defun message (fmt &rest args)
|
|
4342 "Print a one-line message at the bottom of the frame.
|
|
4343 The arguments are the same as to `format'.
|
|
4344
|
|
4345 If the only argument is nil, clear any existing message; let the
|
|
4346 minibuffer contents show."
|
|
4347 ;; questionable junk in the C code
|
|
4348 ;; (if (framep default-minibuffer-frame)
|
|
4349 ;; (make-frame-visible default-minibuffer-frame))
|
|
4350 (if (and (null fmt) (null args))
|
|
4351 (prog1 nil
|
|
4352 (clear-message nil))
|
|
4353 (let ((str (apply 'format fmt args)))
|
|
4354 (display-message 'message str)
|
|
4355 str)))
|
|
4356
|
|
4357 (defun lmessage (label fmt &rest args)
|
|
4358 "Print a one-line message at the bottom of the frame.
|
|
4359 First argument LABEL is an identifier for this message. The rest of the
|
|
4360 arguments are the same as to `format'.
|
|
4361
|
|
4362 See `display-message' for a list of standard labels."
|
|
4363 (if (and (null fmt) (null args))
|
|
4364 (prog1 nil
|
|
4365 (clear-message label nil))
|
|
4366 (let ((str (apply 'format fmt args)))
|
|
4367 (display-message label str)
|
|
4368 str)))
|
|
4369
|
442
|
4370
|
|
4371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4372 ;; warning code ;;
|
|
4373 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
428
|
4374
|
|
4375 (defcustom log-warning-minimum-level 'info
|
|
4376 "Minimum level of warnings that should be logged.
|
|
4377 The warnings in levels below this are completely ignored, as if they never
|
|
4378 happened.
|
|
4379
|
|
4380 The recognized warning levels, in decreasing order of priority, are
|
793
|
4381 'emergency, 'critical, 'error, 'warning, 'alert, 'notice, 'info, and
|
428
|
4382 'debug.
|
|
4383
|
|
4384 See also `display-warning-minimum-level'.
|
|
4385
|
|
4386 You can also control which warnings are displayed on a class-by-class
|
|
4387 basis. See `display-warning-suppressed-classes' and
|
793
|
4388 `log-warning-suppressed-classes'.
|
|
4389
|
3064
|
4390 For a description of the meaning of the levels, see `display-warning'."
|
793
|
4391 :type '(choice (const emergency) (const critical)
|
|
4392 (const error) (const warning) (const alert) (const notice)
|
428
|
4393 (const info) (const debug))
|
|
4394 :group 'warnings)
|
|
4395
|
793
|
4396 (defcustom display-warning-minimum-level 'warning
|
|
4397 "Minimum level of warnings that cause the warnings buffer to be displayed.
|
|
4398 Warnings at this level or higher will force the *Warnings* buffer, in which
|
|
4399 the warnings are logged, to be displayed. The warnings in levels below
|
|
4400 this, but at least as high as `log-warning-suppressed-classes', will be
|
|
4401 shown in the minibuffer.
|
428
|
4402
|
|
4403 The recognized warning levels, in decreasing order of priority, are
|
793
|
4404 'emergency, 'critical, 'error, 'warning, 'alert, 'notice, 'info, and
|
428
|
4405 'debug.
|
|
4406
|
|
4407 See also `log-warning-minimum-level'.
|
|
4408
|
|
4409 You can also control which warnings are displayed on a class-by-class
|
|
4410 basis. See `display-warning-suppressed-classes' and
|
793
|
4411 `log-warning-suppressed-classes'.
|
|
4412
|
3064
|
4413 For a description of the meaning of the levels, see `display-warning'."
|
793
|
4414 :type '(choice (const emergency) (const critical)
|
|
4415 (const error) (const warning) (const alert) (const notice)
|
428
|
4416 (const info) (const debug))
|
|
4417 :group 'warnings)
|
|
4418
|
|
4419 (defvar log-warning-suppressed-classes nil
|
|
4420 "List of classes of warnings that shouldn't be logged or displayed.
|
|
4421 If any of the CLASS symbols associated with a warning is the same as
|
|
4422 any of the symbols listed here, the warning will be completely ignored,
|
|
4423 as it they never happened.
|
|
4424
|
|
4425 NOTE: In most circumstances, you should *not* set this variable.
|
|
4426 Set `display-warning-suppressed-classes' instead. That way the suppressed
|
|
4427 warnings are not displayed but are still unobtrusively logged.
|
|
4428
|
|
4429 See also `log-warning-minimum-level' and `display-warning-minimum-level'.")
|
|
4430
|
|
4431 (defcustom display-warning-suppressed-classes nil
|
|
4432 "List of classes of warnings that shouldn't be displayed.
|
|
4433 If any of the CLASS symbols associated with a warning is the same as
|
|
4434 any of the symbols listed here, the warning will not be displayed.
|
|
4435 The warning will still logged in the *Warnings* buffer (unless also
|
|
4436 contained in `log-warning-suppressed-classes'), but the buffer will
|
|
4437 not be automatically popped up.
|
|
4438
|
|
4439 See also `log-warning-minimum-level' and `display-warning-minimum-level'."
|
|
4440 :type '(repeat symbol)
|
|
4441 :group 'warnings)
|
|
4442
|
|
4443 (defvar warning-count 0
|
|
4444 "Count of the number of warning messages displayed so far.")
|
|
4445
|
|
4446 (defconst warning-level-alist '((emergency . 8)
|
793
|
4447 (critical . 7)
|
|
4448 (error . 6)
|
|
4449 (warning . 5)
|
|
4450 (alert . 4)
|
428
|
4451 (notice . 3)
|
|
4452 (info . 2)
|
|
4453 (debug . 1)))
|
|
4454
|
|
4455 (defun warning-level-p (level)
|
|
4456 "Non-nil if LEVEL specifies a warning level."
|
|
4457 (and (symbolp level) (assq level warning-level-alist)))
|
|
4458
|
793
|
4459 (defun warning-level-< (level1 level2)
|
|
4460 "Non-nil if warning level LEVEL1 is lower than LEVEL2."
|
|
4461 (check-argument-type 'warning-level-p level1)
|
|
4462 (check-argument-type 'warning-level-p level2)
|
|
4463 (< (cdr (assq level1 warning-level-alist))
|
|
4464 (cdr (assq level2 warning-level-alist))))
|
|
4465
|
428
|
4466 ;; If you're interested in rewriting this function, be aware that it
|
|
4467 ;; could be called at arbitrary points in a Lisp program (when a
|
|
4468 ;; built-in function wants to issue a warning, it will call out to
|
|
4469 ;; this function the next time some Lisp code is evaluated). Therefore,
|
|
4470 ;; this function *must* not permanently modify any global variables
|
|
4471 ;; (e.g. the current buffer) except those that specifically apply
|
|
4472 ;; to the warning system.
|
|
4473
|
|
4474 (defvar before-init-deferred-warnings nil)
|
|
4475
|
|
4476 (defun after-init-display-warnings ()
|
|
4477 "Display warnings deferred till after the init file is run.
|
|
4478 Warnings that occur before then are deferred so that warning
|
|
4479 suppression in the .emacs file will be honored."
|
|
4480 (while before-init-deferred-warnings
|
|
4481 (apply 'display-warning (car before-init-deferred-warnings))
|
|
4482 (setq before-init-deferred-warnings
|
|
4483 (cdr before-init-deferred-warnings))))
|
|
4484
|
|
4485 (add-hook 'after-init-hook 'after-init-display-warnings)
|
|
4486
|
|
4487 (defun display-warning (class message &optional level)
|
|
4488 "Display a warning message.
|
793
|
4489
|
|
4490 \[This is the most basic entry point for displaying a warning. In practice,
|
|
4491 `lwarn' or `warn' are probably more convenient for most usages.]
|
|
4492
|
|
4493 CLASS should be a symbol describing what sort of warning this is, such as
|
|
4494 `resource' or `key-mapping' -- this refers, more or less, to the module in
|
|
4495 which the warning is generated and serves to group warnings together with
|
|
4496 similar semantics. A list of such symbols is also accepted.
|
|
4497
|
|
4498 Optional argument LEVEL can be used to specify a priority for the warning,
|
|
4499 other than default priority `warning'. The currently defined levels are,
|
|
4500 from highest to lowest:
|
|
4501
|
|
4502 Level Meaning
|
|
4503 -----------------------------------------------------------------------------
|
|
4504 emergency A fatal or near-fatal error. XEmacs is likely to crash.
|
|
4505
|
|
4506 critical A serious, nonrecoverable problem has occurred -- e.g., the
|
|
4507 loss of a major subsystem, such as the crash of the X server
|
|
4508 when XEmacs is connected to the server.
|
|
4509
|
|
4510 error A warning about a problematic condition that should be fixed,
|
|
4511 and XEmacs cannot work around it -- it causes a failure of an
|
|
4512 operation. (In most circumstances, consider just signalling
|
|
4513 an error). However, there is no permanent damage and the
|
|
4514 situation is ultimately recoverable.
|
|
4515
|
|
4516 warning A warning about a problematic condition that should be fixed,
|
|
4517 but XEmacs can work around it.
|
|
4518
|
|
4519 \[By default, warnings above here, as well as being logged, cause the
|
|
4520 *Warnings* buffer to be forcibly displayed, so that the warning (and
|
|
4521 previous warnings, since often a whole series of warnings are issued at
|
|
4522 once) can be examined in detail. Also, the annoying presence of the
|
|
4523 *Warnings* buffer will encourage people to go out and fix the
|
|
4524 problem. Warnings below here are displayed in the minibuffer as well as
|
|
4525 logged in the *Warnings* buffer. but the *Warnings* buffer will not be
|
|
4526 forcibly shown, as these represent conditions the user is not expected to
|
|
4527 fix.]
|
|
4528
|
|
4529 alert A warning about a problematic condition that can't easily be
|
|
4530 fixed (often having to do with the external environment), and
|
|
4531 causes a failure. We don't force the *Warnings* buffer to be
|
|
4532 displayed because the purpose of doing that is to force the
|
|
4533 user to fix the problem so that the buffer no longer appears.
|
|
4534 When the problem is outside the user's control, forcing the
|
|
4535 buffer is pointless and annoying.
|
|
4536
|
|
4537 notice A warning about a problematic condition that can't easily be
|
|
4538 fixed (often having to do with the external environment),
|
|
4539 but XEmacs can work around it.
|
|
4540
|
|
4541 info Random info about something new or unexpected that was noticed;
|
|
4542 does not generally indicate a problem.
|
|
4543
|
|
4544 \[By default, warnings below here are ignored entirely. All warnings above
|
|
4545 here are logged in the *Warnings* buffer.]
|
|
4546
|
|
4547 debug A debugging notice; normally, not seen at all.
|
|
4548
|
|
4549 NOTE: `specifier-instance' outputs warnings at level `debug' when errors occur
|
|
4550 in the process of trying to instantiate a particular instantiator. If you
|
|
4551 want to see these, change `log-warning-minimum-level'.
|
|
4552
|
|
4553 There are two sets of variables. One controls the lower level (see the
|
|
4554 above diagram) -- i.e. ignored entirely. One controls the upper level --
|
|
4555 whether the *Warnings* buffer is forcibly displayed. In particular:
|
|
4556
|
|
4557 `display-warning-minimum-level' sets the upper level (see above), and
|
|
4558 `log-warning-minimum-level' the lower level.
|
|
4559
|
|
4560 Individual classes can be suppressed. `log-warning-suppressed-classes'
|
|
4561 specifies a list of classes where warnings on those classes will be treated
|
|
4562 as if their level is below `log-warning-minimum-level' (i.e. they will be
|
|
4563 ignored completely), regardless of their actual level. Similarly,
|
|
4564 `display-warning-suppressed-classes' specifies a list of classes where
|
|
4565 warnings on those classes will be treated as if their level is below
|
|
4566 `display-warning-minimum-level', but above `log-warning-minimum-level' so
|
|
4567 long as they're not listed in that variable as well."
|
428
|
4568 (or level (setq level 'warning))
|
|
4569 (or (listp class) (setq class (list class)))
|
|
4570 (check-argument-type 'warning-level-p level)
|
|
4571 (if (and (not (featurep 'infodock))
|
|
4572 (not init-file-loaded))
|
|
4573 (push (list class message level) before-init-deferred-warnings)
|
|
4574 (catch 'ignored
|
|
4575 (let ((display-p t)
|
|
4576 (level-num (cdr (assq level warning-level-alist))))
|
|
4577 (if (< level-num (cdr (assq log-warning-minimum-level
|
|
4578 warning-level-alist)))
|
|
4579 (throw 'ignored nil))
|
|
4580 (if (intersection class log-warning-suppressed-classes)
|
|
4581 (throw 'ignored nil))
|
|
4582
|
|
4583 (if (< level-num (cdr (assq display-warning-minimum-level
|
|
4584 warning-level-alist)))
|
|
4585 (setq display-p nil))
|
|
4586 (if (and display-p
|
|
4587 (intersection class display-warning-suppressed-classes))
|
|
4588 (setq display-p nil))
|
|
4589 (let ((buffer (get-buffer-create "*Warnings*")))
|
|
4590 (when display-p
|
|
4591 ;; The C code looks at display-warning-tick to determine
|
|
4592 ;; when it should call `display-warning-buffer'. Change it
|
|
4593 ;; to get the C code's attention.
|
|
4594 (incf display-warning-tick))
|
|
4595 (with-current-buffer buffer
|
|
4596 (goto-char (point-max))
|
|
4597 (incf warning-count)
|
793
|
4598 (let ((start (point)))
|
|
4599 (princ (format "(%d) (%s/%s) "
|
|
4600 warning-count
|
|
4601 (mapconcat 'symbol-name class ",")
|
|
4602 level)
|
|
4603 buffer)
|
|
4604 (princ message buffer)
|
|
4605 (terpri buffer)
|
|
4606 (terpri buffer)
|
|
4607 (let ((ex (make-extent start (point))))
|
|
4608 (set-extent-properties ex
|
|
4609 `(warning t warning-count ,warning-count
|
|
4610 warning-class ,class
|
|
4611 warning-level ,level)))))
|
|
4612 (message "%s: %s" (capitalize (symbol-name level)) message))))))
|
428
|
4613
|
|
4614 (defun warn (&rest args)
|
793
|
4615 "Display a formatted warning message at default class and level.
|
428
|
4616 The message is constructed by passing all args to `format'. The message
|
|
4617 is placed in the *Warnings* buffer, which will be popped up at the next
|
793
|
4618 redisplay. The class of the warning is `general'; the level is `warning'.
|
|
4619
|
|
4620 See `display-warning' for more info."
|
|
4621 (display-warning 'default (apply 'format args)))
|
428
|
4622
|
|
4623 (defun lwarn (class level &rest args)
|
793
|
4624 "Display a formatted warning message at specified class and level.
|
|
4625 The message is constructed by passing all args to `format'. The message
|
|
4626 is placed in the *Warnings* buffer, which will be popped up at the next
|
|
4627 redisplay.
|
|
4628
|
|
4629 See `display-warning' for more info."
|
428
|
4630 (display-warning class (apply 'format args)
|
|
4631 (or level 'warning)))
|
|
4632
|
|
4633 (defvar warning-marker nil)
|
|
4634
|
|
4635 ;; When this function is called by the C code, all non-local exits are
|
|
4636 ;; trapped and C-g is inhibited; therefore, it would be a very, very
|
|
4637 ;; bad idea for this function to get into an infinite loop.
|
|
4638
|
|
4639 (defun display-warning-buffer ()
|
|
4640 "Make the buffer that contains the warnings be visible.
|
|
4641 The C code calls this periodically, right before redisplay."
|
|
4642 (let ((buffer (get-buffer-create "*Warnings*")))
|
|
4643 (when (or (not warning-marker)
|
|
4644 (not (eq (marker-buffer warning-marker) buffer)))
|
|
4645 (setq warning-marker (make-marker))
|
|
4646 (set-marker warning-marker 1 buffer))
|
|
4647 (if temp-buffer-show-function
|
442
|
4648 (progn
|
|
4649 (funcall temp-buffer-show-function buffer)
|
|
4650 (mapc #'(lambda (win) (set-window-start win warning-marker))
|
|
4651 (windows-of-buffer buffer nil t)))
|
428
|
4652 (set-window-start (display-buffer buffer) warning-marker))
|
|
4653 (set-marker warning-marker (point-max buffer) buffer)))
|
|
4654
|
442
|
4655
|
|
4656 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4657 ;; misc junk ;;
|
|
4658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4659
|
428
|
4660 (defun emacs-name ()
|
|
4661 "Return the printable name of this instance of Emacs."
|
|
4662 (cond ((featurep 'infodock) "InfoDock")
|
|
4663 ((featurep 'xemacs) "XEmacs")
|
|
4664 (t "Emacs")))
|
|
4665
|
793
|
4666 (defun debug-print-1 (&rest args)
|
|
4667 "Send a debugging-type string to standard output.
|
|
4668 If the first argument is a string, it is considered to be a format
|
|
4669 specifier if there are sufficient numbers of other args, and the string is
|
|
4670 formatted using (apply #'format args). Otherwise, each argument is printed
|
|
4671 individually in a numbered list."
|
|
4672 (let ((standard-output 'external-debugging-output)
|
|
4673 (fmt (condition-case nil
|
|
4674 (and (stringp (first args))
|
|
4675 (apply #'format args))
|
|
4676 (error nil))))
|
|
4677 (if fmt
|
|
4678 (progn
|
3064
|
4679 (princ (apply #'format args))
|
793
|
4680 (terpri))
|
|
4681 (princ "--> ")
|
|
4682 (let ((i 1))
|
|
4683 (dolist (sgra args)
|
|
4684 (if (> i 1) (princ " "))
|
|
4685 (princ (format "%d. " i))
|
|
4686 (prin1 sgra)
|
|
4687 (incf i))
|
|
4688 (terpri)))))
|
|
4689
|
|
4690 (defun debug-print (&rest args)
|
442
|
4691 "Send a string to the debugging output.
|
793
|
4692 If the first argument is a string, it is considered to be a format
|
|
4693 specifier if there are sufficient numbers of other args, and the string is
|
|
4694 formatted using (apply #'format args). Otherwise, each argument is printed
|
|
4695 individually in a numbered list."
|
|
4696 (let ((standard-output 'external-debugging-output))
|
|
4697 (apply #'debug-print-1 args)))
|
|
4698
|
|
4699 (defun debug-backtrace ()
|
|
4700 "Send a backtrace to the debugging output."
|
|
4701 (let ((standard-output 'external-debugging-output))
|
|
4702 (backtrace nil t)
|
|
4703 (terpri)))
|
444
|
4704
|
428
|
4705 ;;; simple.el ends here
|