comparison lisp/emacs-lisp/lisp.el @ 89943:4c90ffeb71c5

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 28 Jun 2004 07:56:49 +0000
parents 68c22ea6027c eb9d99ced391
children 3219f94257bc
comparison
equal deleted inserted replaced
89942:9cb747ae49af 89943:4c90ffeb71c5
173 open-parenthesis, and point ends up at the beginning of the line. 173 open-parenthesis, and point ends up at the beginning of the line.
174 174
175 If variable `beginning-of-defun-function' is non-nil, its value 175 If variable `beginning-of-defun-function' is non-nil, its value
176 is called as a function to find the defun's beginning." 176 is called as a function to find the defun's beginning."
177 (interactive "p") 177 (interactive "p")
178 (and (eq this-command 'beginning-of-defun)
179 (or (eq last-command 'beginning-of-defun) (push-mark)))
178 (and (beginning-of-defun-raw arg) 180 (and (beginning-of-defun-raw arg)
179 (progn (beginning-of-line) t))) 181 (progn (beginning-of-line) t)))
180 182
181 (defun beginning-of-defun-raw (&optional arg) 183 (defun beginning-of-defun-raw (&optional arg)
182 "Move point to the character that starts a defun. 184 "Move point to the character that starts a defun.
221 `beginning-of-defun'. 223 `beginning-of-defun'.
222 224
223 If variable `end-of-defun-function' is non-nil, its value 225 If variable `end-of-defun-function' is non-nil, its value
224 is called as a function to find the defun's end." 226 is called as a function to find the defun's end."
225 (interactive "p") 227 (interactive "p")
228 (and (eq this-command 'end-of-defun)
229 (or (eq last-command 'end-of-defun) (push-mark)))
226 (if (or (null arg) (= arg 0)) (setq arg 1)) 230 (if (or (null arg) (= arg 0)) (setq arg 1))
227 (if end-of-defun-function 231 (if end-of-defun-function
228 (if (> arg 0) 232 (if (> arg 0)
229 (dotimes (i arg) 233 (dotimes (i arg)
230 (funcall end-of-defun-function)) 234 (funcall end-of-defun-function))
275 (save-excursion 279 (save-excursion
276 (goto-char (mark)) 280 (goto-char (mark))
277 (end-of-defun) 281 (end-of-defun)
278 (point)))) 282 (point))))
279 (t 283 (t
280 ;; Do it in this order for the sake of languages with nested 284 (let ((opoint (point))
281 ;; functions where several can end at the same place as with 285 beg end)
282 ;; the offside rule, e.g. Python. 286 (push-mark opoint)
283 (push-mark (point)) 287 ;; Try first in this order for the sake of languages with nested
284 (beginning-of-defun) 288 ;; functions where several can end at the same place as with
285 (push-mark (point) nil t) 289 ;; the offside rule, e.g. Python.
286 (end-of-defun) 290 (beginning-of-defun)
287 (exchange-point-and-mark) 291 (setq beg (point))
288 (re-search-backward "^\n" (- (point) 1) t)))) 292 (end-of-defun)
293 (setq end (point))
294 (while (looking-at "^\n")
295 (forward-line 1))
296 (if (> (point) opoint)
297 (progn
298 ;; We got the right defun.
299 (push-mark beg nil t)
300 (goto-char end)
301 (exchange-point-and-mark))
302 ;; beginning-of-defun moved back one defun
303 ;; so we got the wrong one.
304 (goto-char opoint)
305 (end-of-defun)
306 (push-mark (point) nil t)
307 (beginning-of-defun))
308 (re-search-backward "^\n" (- (point) 1) t)))))
289 309
290 (defun narrow-to-defun (&optional arg) 310 (defun narrow-to-defun (&optional arg)
291 "Make text outside current defun invisible. 311 "Make text outside current defun invisible.
292 The defun visible is the one that contains point or follows point. 312 The defun visible is the one that contains point or follows point.
293 Optional ARG is ignored." 313 Optional ARG is ignored."
294 (interactive) 314 (interactive)
295 (save-excursion 315 (save-excursion
296 (widen) 316 (widen)
297 ;; Do it in this order for the sake of languages with nested 317 (let ((opoint (point))
298 ;; functions where several can end at the same place as with the 318 beg end)
299 ;; offside rule, e.g. Python. 319 ;; Try first in this order for the sake of languages with nested
300 (beginning-of-defun) 320 ;; functions where several can end at the same place as with
301 (let ((beg (point))) 321 ;; the offside rule, e.g. Python.
322 (beginning-of-defun)
323 (setq beg (point))
302 (end-of-defun) 324 (end-of-defun)
303 (narrow-to-region beg (point))))) 325 (setq end (point))
304 326 (while (looking-at "^\n")
305 (defun insert-parentheses (arg) 327 (forward-line 1))
328 (unless (> (point) opoint)
329 ;; beginning-of-defun moved back one defun
330 ;; so we got the wrong one.
331 (goto-char opoint)
332 (end-of-defun)
333 (setq end (point))
334 (beginning-of-defun)
335 (setq beg (point)))
336 (goto-char end)
337 (re-search-backward "^\n" (- (point) 1) t)
338 (narrow-to-region beg end))))
339
340 (defvar insert-pair-alist
341 '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
342 "Alist of paired characters inserted by `insert-pair'.
343 Each element looks like (OPEN-CHAR CLOSE-CHAR) or (COMMAND-CHAR
344 OPEN-CHAR CLOSE-CHAR). The characters OPEN-CHAR and CLOSE-CHAR
345 of the pair whose key is equal to the last input character with
346 or without modifiers, are inserted by `insert-pair'.")
347
348 (defun insert-pair (&optional arg open close)
349 "Enclose following ARG sexps in a pair of OPEN and CLOSE characters.
350 Leave point after the first character.
351 A negative ARG encloses the preceding ARG sexps instead.
352 No argument is equivalent to zero: just insert characters
353 and leave point between.
354 If `parens-require-spaces' is non-nil, this command also inserts a space
355 before and after, depending on the surrounding characters.
356 If region is active, insert enclosing characters at region boundaries.
357
358 If arguments OPEN and CLOSE are nil, the character pair is found
359 from the variable `insert-pair-alist' according to the last input
360 character with or without modifiers. If no character pair is
361 found in the variable `insert-pair-alist', then the last input
362 character is inserted ARG times."
363 (interactive "P")
364 (if (not (and open close))
365 (let ((pair (or (assq last-command-char insert-pair-alist)
366 (assq (event-basic-type last-command-event)
367 insert-pair-alist))))
368 (if pair
369 (if (nth 2 pair)
370 (setq open (nth 1 pair) close (nth 2 pair))
371 (setq open (nth 0 pair) close (nth 1 pair))))))
372 (if (and open close)
373 (if (and transient-mark-mode mark-active)
374 (progn
375 (save-excursion (goto-char (region-end)) (insert close))
376 (save-excursion (goto-char (region-beginning)) (insert open)))
377 (if arg (setq arg (prefix-numeric-value arg))
378 (setq arg 0))
379 (cond ((> arg 0) (skip-chars-forward " \t"))
380 ((< arg 0) (forward-sexp arg) (setq arg (- arg))))
381 (and parens-require-spaces
382 (not (bobp))
383 (memq (char-syntax (preceding-char)) (list ?w ?_ (char-syntax close)))
384 (insert " "))
385 (insert open)
386 (save-excursion
387 (or (eq arg 0) (forward-sexp arg))
388 (insert close)
389 (and parens-require-spaces
390 (not (eobp))
391 (memq (char-syntax (following-char)) (list ?w ?_ (char-syntax open)))
392 (insert " "))))
393 (insert-char (event-basic-type last-command-event)
394 (prefix-numeric-value arg))))
395
396 (defun insert-parentheses (&optional arg)
306 "Enclose following ARG sexps in parentheses. Leave point after open-paren. 397 "Enclose following ARG sexps in parentheses. Leave point after open-paren.
307 A negative ARG encloses the preceding ARG sexps instead. 398 A negative ARG encloses the preceding ARG sexps instead.
308 No argument is equivalent to zero: just insert `()' and leave point between. 399 No argument is equivalent to zero: just insert `()' and leave point between.
309 If `parens-require-spaces' is non-nil, this command also inserts a space 400 If `parens-require-spaces' is non-nil, this command also inserts a space
310 before and after, depending on the surrounding characters." 401 before and after, depending on the surrounding characters.
402 If region is active, insert enclosing characters at region boundaries."
311 (interactive "P") 403 (interactive "P")
312 (if arg (setq arg (prefix-numeric-value arg)) 404 (insert-pair arg ?\( ?\)))
313 (setq arg 0)) 405
314 (cond ((> arg 0) (skip-chars-forward " \t")) 406 (defun delete-pair ()
315 ((< arg 0) (forward-sexp arg) (setq arg (- arg)))) 407 "Delete a pair of characters enclosing the sexp that follows point."
316 (and parens-require-spaces 408 (interactive)
317 (not (bobp)) 409 (save-excursion (forward-sexp 1) (delete-char -1))
318 (memq (char-syntax (preceding-char)) '(?w ?_ ?\) )) 410 (delete-char 1))
319 (insert " ")) 411
320 (insert ?\() 412 (defun raise-sexp (&optional arg)
321 (save-excursion 413 "Raise ARG sexps higher up the tree."
322 (or (eq arg 0) (forward-sexp arg)) 414 (interactive "p")
323 (insert ?\)) 415 (let ((s (if (and transient-mark-mode mark-active)
324 (and parens-require-spaces 416 (buffer-substring (region-beginning) (region-end))
325 (not (eobp)) 417 (buffer-substring
326 (memq (char-syntax (following-char)) '(?w ?_ ?\( )) 418 (point)
327 (insert " ")))) 419 (save-excursion (forward-sexp arg) (point))))))
420 (backward-up-list 1)
421 (delete-region (point) (save-excursion (forward-sexp 1) (point)))
422 (save-excursion (insert s))))
328 423
329 (defun move-past-close-and-reindent () 424 (defun move-past-close-and-reindent ()
330 "Move past next `)', delete indentation before it, then indent after it." 425 "Move past next `)', delete indentation before it, then indent after it."
331 (interactive) 426 (interactive)
332 (up-list 1) 427 (up-list 1)