comparison lisp/simple.el @ 83397:693e794b57bf

Merged from miles@gnu.org--gnu-2005 (patch 149-151, 629-641) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-629 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-631 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-632 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-633 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-634 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-635 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-636 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-637 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-638 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-639 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-640 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-641 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-149 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-150 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-151 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-437
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 07 Nov 2005 14:56:19 +0000
parents b31326248cf6 be6d79a520af
children 03934708f1e9
comparison
equal deleted inserted replaced
83396:201f610eb492 83397:693e794b57bf
991 (let ((char-string 991 (let ((char-string
992 (if (or (if (boundp 'edebug-active) edebug-active) 992 (if (or (if (boundp 'edebug-active) edebug-active)
993 (memq this-command '(eval-last-sexp eval-print-last-sexp))) 993 (memq this-command '(eval-last-sexp eval-print-last-sexp)))
994 (prin1-char value)))) 994 (prin1-char value))))
995 (if char-string 995 (if char-string
996 (format " (0%o, 0x%x) = %s" value value char-string) 996 (format " (#o%o, #x%x, %s)" value value char-string)
997 (format " (0%o, 0x%x)" value value))))) 997 (format " (#o%o, #x%x)" value value)))))
998 998
999 ;; We define this, rather than making `eval' interactive, 999 ;; We define this, rather than making `eval' interactive,
1000 ;; for the sake of completion of names like eval-region, eval-current-buffer. 1000 ;; for the sake of completion of names like eval-region, eval-current-buffer.
1001 (defun eval-expression (eval-expression-arg 1001 (defun eval-expression (eval-expression-arg
1002 &optional eval-expression-insert-value) 1002 &optional eval-expression-insert-value)
1342 ;; If we get to the end of the undo history and get an error, 1342 ;; If we get to the end of the undo history and get an error,
1343 ;; another undo command will find the undo history empty 1343 ;; another undo command will find the undo history empty
1344 ;; and will get another error. To begin undoing the undos, 1344 ;; and will get another error. To begin undoing the undos,
1345 ;; you must type some other command. 1345 ;; you must type some other command.
1346 (let ((modified (buffer-modified-p)) 1346 (let ((modified (buffer-modified-p))
1347 (recent-save (recent-auto-save-p))) 1347 (recent-save (recent-auto-save-p))
1348 message)
1348 ;; If we get an error in undo-start, 1349 ;; If we get an error in undo-start,
1349 ;; the next command should not be a "consecutive undo". 1350 ;; the next command should not be a "consecutive undo".
1350 ;; So set `this-command' to something other than `undo'. 1351 ;; So set `this-command' to something other than `undo'.
1351 (setq this-command 'undo-start) 1352 (setq this-command 'undo-start)
1352 1353
1371 (setq this-command 'undo) 1372 (setq this-command 'undo)
1372 ;; Check to see whether we're hitting a redo record, and if 1373 ;; Check to see whether we're hitting a redo record, and if
1373 ;; so, ask the user whether she wants to skip the redo/undo pair. 1374 ;; so, ask the user whether she wants to skip the redo/undo pair.
1374 (let ((equiv (gethash pending-undo-list undo-equiv-table))) 1375 (let ((equiv (gethash pending-undo-list undo-equiv-table)))
1375 (or (eq (selected-window) (minibuffer-window)) 1376 (or (eq (selected-window) (minibuffer-window))
1376 (message (if undo-in-region 1377 (setq message (if undo-in-region
1377 (if equiv "Redo in region!" "Undo in region!") 1378 (if equiv "Redo in region!" "Undo in region!")
1378 (if equiv "Redo!" "Undo!")))) 1379 (if equiv "Redo!" "Undo!"))))
1379 (when (and (consp equiv) undo-no-redo) 1380 (when (and (consp equiv) undo-no-redo)
1380 ;; The equiv entry might point to another redo record if we have done 1381 ;; The equiv entry might point to another redo record if we have done
1381 ;; undo-redo-undo-redo-... so skip to the very last equiv. 1382 ;; undo-redo-undo-redo-... so skip to the very last equiv.
1382 (while (let ((next (gethash equiv undo-equiv-table))) 1383 (while (let ((next (gethash equiv undo-equiv-table)))
1383 (if next (setq equiv next)))) 1384 (if next (setq equiv next))))
1415 (setq tail nil))) 1416 (setq tail nil)))
1416 (setq prev tail tail (cdr tail)))) 1417 (setq prev tail tail (cdr tail))))
1417 ;; Record what the current undo list says, 1418 ;; Record what the current undo list says,
1418 ;; so the next command can tell if the buffer was modified in between. 1419 ;; so the next command can tell if the buffer was modified in between.
1419 (and modified (not (buffer-modified-p)) 1420 (and modified (not (buffer-modified-p))
1420 (delete-auto-save-file-if-necessary recent-save)))) 1421 (delete-auto-save-file-if-necessary recent-save))
1422 ;; Display a message announcing success.
1423 (if message
1424 (message message))))
1421 1425
1422 (defun buffer-disable-undo (&optional buffer) 1426 (defun buffer-disable-undo (&optional buffer)
1423 "Make BUFFER stop keeping undo information. 1427 "Make BUFFER stop keeping undo information.
1424 No argument or nil as argument means do this for the current buffer." 1428 No argument or nil as argument means do this for the current buffer."
1425 (interactive) 1429 (interactive)
2391 (list string "yank-handler specified for empty string")))) 2395 (list string "yank-handler specified for empty string"))))
2392 (if (fboundp 'menu-bar-update-yank-menu) 2396 (if (fboundp 'menu-bar-update-yank-menu)
2393 (menu-bar-update-yank-menu string (and replace (car kill-ring)))) 2397 (menu-bar-update-yank-menu string (and replace (car kill-ring))))
2394 (if (and replace kill-ring) 2398 (if (and replace kill-ring)
2395 (setcar kill-ring string) 2399 (setcar kill-ring string)
2396 (setq kill-ring (cons string kill-ring)) 2400 (push string kill-ring)
2397 (if (> (length kill-ring) kill-ring-max) 2401 (if (> (length kill-ring) kill-ring-max)
2398 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) 2402 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
2399 (setq kill-ring-yank-pointer kill-ring) 2403 (setq kill-ring-yank-pointer kill-ring)
2400 (if interprogram-cut-function 2404 (if interprogram-cut-function
2401 (funcall interprogram-cut-function string (not replace)))) 2405 (funcall interprogram-cut-function string (not replace))))
3001 When calling from a program, give three arguments: 3005 When calling from a program, give three arguments:
3002 BUFFER (or buffer name), START and END. 3006 BUFFER (or buffer name), START and END.
3003 START and END specify the portion of the current buffer to be copied." 3007 START and END specify the portion of the current buffer to be copied."
3004 (interactive "BCopy to buffer: \nr") 3008 (interactive "BCopy to buffer: \nr")
3005 (let ((oldbuf (current-buffer))) 3009 (let ((oldbuf (current-buffer)))
3006 (save-excursion 3010 (with-current-buffer (get-buffer-create buffer)
3007 (set-buffer (get-buffer-create buffer))
3008 (barf-if-buffer-read-only) 3011 (barf-if-buffer-read-only)
3009 (erase-buffer) 3012 (erase-buffer)
3010 (save-excursion 3013 (save-excursion
3011 (insert-buffer-substring oldbuf start end))))) 3014 (insert-buffer-substring oldbuf start end)))))
3012 3015
3114 (setq mark-active t) 3117 (setq mark-active t)
3115 (run-hooks 'activate-mark-hook) 3118 (run-hooks 'activate-mark-hook)
3116 (unless nomsg 3119 (unless nomsg
3117 (message "Mark activated"))))) 3120 (message "Mark activated")))))
3118 3121
3122 (defcustom set-mark-command-repeat-pop nil
3123 "*Non-nil means that repeating \\[set-mark-command] after popping will pop.
3124 This means that if you type C-u \\[set-mark-command] \\[set-mark-command]
3125 will pop twice."
3126 :type 'boolean
3127 :group 'editing)
3128
3119 (defun set-mark-command (arg) 3129 (defun set-mark-command (arg)
3120 "Set mark at where point is, or jump to mark. 3130 "Set mark at where point is, or jump to mark.
3121 With no prefix argument, set mark, and push old mark position on local 3131 With no prefix argument, set mark, and push old mark position on local
3122 mark ring; also push mark on global mark ring if last mark was set in 3132 mark ring; also push mark on global mark ring if last mark was set in
3123 another buffer. Immediately repeating the command activates 3133 another buffer. Immediately repeating the command activates
3146 (push-mark-command nil)) 3156 (push-mark-command nil))
3147 ((not (eq this-command 'set-mark-command)) 3157 ((not (eq this-command 'set-mark-command))
3148 (if arg 3158 (if arg
3149 (pop-to-mark-command) 3159 (pop-to-mark-command)
3150 (push-mark-command t))) 3160 (push-mark-command t)))
3151 ((eq last-command 'pop-to-mark-command) 3161 ((and set-mark-command-repeat-pop
3162 (eq last-command 'pop-to-mark-command))
3152 (setq this-command 'pop-to-mark-command) 3163 (setq this-command 'pop-to-mark-command)
3153 (pop-to-mark-command)) 3164 (pop-to-mark-command))
3154 ((and (eq last-command 'pop-global-mark) (not arg)) 3165 ((and set-mark-command-repeat-pop
3166 (eq last-command 'pop-global-mark)
3167 (not arg))
3155 (setq this-command 'pop-global-mark) 3168 (setq this-command 'pop-global-mark)
3156 (pop-global-mark)) 3169 (pop-global-mark))
3157 (arg 3170 (arg
3158 (setq this-command 'pop-to-mark-command) 3171 (setq this-command 'pop-to-mark-command)
3159 (pop-to-mark-command)) 3172 (pop-to-mark-command))
4886 is the substring.)") 4899 is the substring.)")
4887 4900
4888 ;; This function goes in completion-setup-hook, so that it is called 4901 ;; This function goes in completion-setup-hook, so that it is called
4889 ;; after the text of the completion list buffer is written. 4902 ;; after the text of the completion list buffer is written.
4890 (defun completion-setup-function () 4903 (defun completion-setup-function ()
4891 (let ((mainbuf (current-buffer)) 4904 (let* ((mainbuf (current-buffer))
4892 (mbuf-contents (minibuffer-contents))) 4905 (mbuf-contents (minibuffer-contents))
4906 (common-string-length (length mbuf-contents)))
4893 ;; When reading a file name in the minibuffer, 4907 ;; When reading a file name in the minibuffer,
4894 ;; set default-directory in the minibuffer 4908 ;; set default-directory in the minibuffer
4895 ;; so it will get copied into the completion list buffer. 4909 ;; so it will get copied into the completion list buffer.
4896 (if minibuffer-completing-file-name 4910 (if minibuffer-completing-file-name
4897 (with-current-buffer mainbuf 4911 (with-current-buffer mainbuf
4899 ;; If partial-completion-mode is on, point might not be after the 4913 ;; If partial-completion-mode is on, point might not be after the
4900 ;; last character in the minibuffer. 4914 ;; last character in the minibuffer.
4901 ;; FIXME: This still doesn't work if the text to be completed 4915 ;; FIXME: This still doesn't work if the text to be completed
4902 ;; starts with a `-'. 4916 ;; starts with a `-'.
4903 (when (and partial-completion-mode (not (eobp))) 4917 (when (and partial-completion-mode (not (eobp)))
4904 (setq mbuf-contents 4918 (setq common-string-length
4905 (substring mbuf-contents 0 (- (point) (point-max))))) 4919 (- common-string-length (- (point) (point-max)))))
4906 (with-current-buffer standard-output 4920 (with-current-buffer standard-output
4907 (completion-list-mode) 4921 (completion-list-mode)
4908 (make-local-variable 'completion-reference-buffer) 4922 (set (make-local-variable 'completion-reference-buffer) mainbuf)
4909 (setq completion-reference-buffer mainbuf)
4910 (if minibuffer-completing-file-name 4923 (if minibuffer-completing-file-name
4911 ;; For file name completion, 4924 ;; For file name completion,
4912 ;; use the number of chars before the start of the 4925 ;; use the number of chars before the start of the
4913 ;; last file name component. 4926 ;; last file name component.
4914 (setq completion-base-size 4927 (setq completion-base-size
4924 (setq completion-base-size 4937 (setq completion-base-size
4925 (funcall (get minibuffer-completion-table 'completion-base-size-function))) 4938 (funcall (get minibuffer-completion-table 'completion-base-size-function)))
4926 (setq completion-base-size 0)))) 4939 (setq completion-base-size 0))))
4927 ;; Put faces on first uncommon characters and common parts. 4940 ;; Put faces on first uncommon characters and common parts.
4928 (when (or completion-common-substring completion-base-size) 4941 (when (or completion-common-substring completion-base-size)
4929 (let* ((common-string-length 4942 (setq common-string-length
4930 (if completion-common-substring 4943 (if completion-common-substring
4931 (length completion-common-substring) 4944 (length completion-common-substring)
4932 (- (length mbuf-contents) completion-base-size))) 4945 (- common-string-length completion-base-size)))
4933 (element-start (next-single-property-change 4946 (let ((element-start (point-min))
4934 (point-min) 4947 (maxp (point-max))
4935 'mouse-face)) 4948 element-common-end)
4936 (element-common-end 4949 (while (and (setq element-start
4937 (and element-start 4950 (next-single-property-change
4938 (+ (or element-start nil) common-string-length))) 4951 element-start 'mouse-face))
4939 (maxp (point-max))) 4952 (< (setq element-common-end
4940 (while (and element-start (< element-common-end maxp)) 4953 (+ element-start common-string-length))
4954 maxp))
4941 (when (and (get-char-property element-start 'mouse-face) 4955 (when (and (get-char-property element-start 'mouse-face)
4942 (get-char-property element-common-end 'mouse-face)) 4956 (get-char-property element-common-end 'mouse-face))
4943 (put-text-property element-start element-common-end 4957 (put-text-property element-start element-common-end
4944 'font-lock-face 'completions-common-part) 4958 'font-lock-face 'completions-common-part)
4945 (put-text-property element-common-end (1+ element-common-end) 4959 (put-text-property element-common-end (1+ element-common-end)
4946 'font-lock-face 'completions-first-difference)) 4960 'font-lock-face 'completions-first-difference)))))
4947 (setq element-start (next-single-property-change
4948 element-start
4949 'mouse-face))
4950 (if element-start
4951 (setq element-common-end (+ element-start common-string-length))))))
4952 ;; Insert help string. 4961 ;; Insert help string.
4953 (goto-char (point-min)) 4962 (goto-char (point-min))
4954 (if (display-mouse-p) 4963 (if (display-mouse-p)
4955 (insert (substitute-command-keys 4964 (insert (substitute-command-keys
4956 "Click \\[mouse-choose-completion] on a completion to select it.\n"))) 4965 "Click \\[mouse-choose-completion] on a completion to select it.\n")))
4958 "In this buffer, type \\[choose-completion] to \ 4967 "In this buffer, type \\[choose-completion] to \
4959 select the completion near point.\n\n"))))) 4968 select the completion near point.\n\n")))))
4960 4969
4961 (add-hook 'completion-setup-hook 'completion-setup-function) 4970 (add-hook 'completion-setup-hook 'completion-setup-function)
4962 4971
4963 (define-key minibuffer-local-completion-map [prior] 4972 (define-key minibuffer-local-completion-map [prior] 'switch-to-completions)
4964 'switch-to-completions) 4973 (define-key minibuffer-local-completion-map "\M-v" 'switch-to-completions)
4965 (define-key minibuffer-local-must-match-map [prior]
4966 'switch-to-completions)
4967 (define-key minibuffer-local-completion-map "\M-v"
4968 'switch-to-completions)
4969 (define-key minibuffer-local-must-match-map "\M-v"
4970 'switch-to-completions)
4971 4974
4972 (defun switch-to-completions () 4975 (defun switch-to-completions ()
4973 "Select the completion list window." 4976 "Select the completion list window."
4974 (interactive) 4977 (interactive)
4975 ;; Make sure we have a completions window. 4978 ;; Make sure we have a completions window.