Mercurial > emacs
changeset 55699:030ebc46c0c1
(do-auto-fill): Remove unused vars `bol' and `opoint'.
(completion-setup-function): Use with-current-buffer.
Properly save excursion. Simplify.
Don't assume there is necessarily a `mouse-face' property somewhere.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 19 May 2004 19:10:19 +0000 |
parents | dae0dc3dfbad |
children | 4f6f5dd54dab |
files | lisp/simple.el |
diffstat | 1 files changed, 34 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/simple.el Wed May 19 19:06:54 2004 +0000 +++ b/lisp/simple.el Wed May 19 19:10:19 2004 +0000 @@ -3392,15 +3392,14 @@ ;; (Actually some major modes use a different auto-fill function, ;; but this one is the default one.) (defun do-auto-fill () - (let (fc justify bol give-up + (let (fc justify give-up (fill-prefix fill-prefix)) (if (or (not (setq justify (current-justification))) (null (setq fc (current-fill-column))) (and (eq justify 'left) (<= (current-column) fc)) - (save-excursion (beginning-of-line) - (setq bol (point)) - (and auto-fill-inhibit-regexp + (and auto-fill-inhibit-regexp + (save-excursion (beginning-of-line) (looking-at auto-fill-inhibit-regexp)))) nil ;; Auto-filling not required (if (memq justify '(full center right)) @@ -3423,16 +3422,15 @@ ;; Determine where to split the line. (let* (after-prefix (fill-point - (let ((opoint (point))) - (save-excursion - (beginning-of-line) - (setq after-prefix (point)) - (and fill-prefix - (looking-at (regexp-quote fill-prefix)) - (setq after-prefix (match-end 0))) - (move-to-column (1+ fc)) - (fill-move-to-break-point after-prefix) - (point))))) + (save-excursion + (beginning-of-line) + (setq after-prefix (point)) + (and fill-prefix + (looking-at (regexp-quote fill-prefix)) + (setq after-prefix (match-end 0))) + (move-to-column (1+ fc)) + (fill-move-to-break-point after-prefix) + (point)))) ;; See whether the place we found is any good. (if (save-excursion @@ -4265,16 +4263,15 @@ :group 'completion) (defun completion-setup-function () - (save-excursion - (let ((mainbuf (current-buffer)) - (mbuf-contents (minibuffer-contents))) - ;; When reading a file name in the minibuffer, - ;; set default-directory in the minibuffer - ;; so it will get copied into the completion list buffer. - (if minibuffer-completing-file-name - (with-current-buffer mainbuf - (setq default-directory (file-name-directory mbuf-contents)))) - (set-buffer standard-output) + (let ((mainbuf (current-buffer)) + (mbuf-contents (minibuffer-contents))) + ;; When reading a file name in the minibuffer, + ;; set default-directory in the minibuffer + ;; so it will get copied into the completion list buffer. + (if minibuffer-completing-file-name + (with-current-buffer mainbuf + (setq default-directory (file-name-directory mbuf-contents)))) + (with-current-buffer standard-output (completion-list-mode) (make-local-variable 'completion-reference-buffer) (setq completion-reference-buffer mainbuf) @@ -4283,24 +4280,23 @@ ;; use the number of chars before the start of the ;; last file name component. (setq completion-base-size - (save-excursion - (set-buffer mainbuf) - (goto-char (point-max)) - (skip-chars-backward "^/") - (- (point) (minibuffer-prompt-end)))) + (with-current-buffer mainbuf + (save-excursion + (goto-char (point-max)) + (skip-chars-backward "^/") + (- (point) (minibuffer-prompt-end))))) ;; Otherwise, in minibuffer, the whole input is being completed. - (save-match-data - (if (minibufferp mainbuf) - (setq completion-base-size 0)))) - ;; Put faces on first uncommon characters and common parts. + (if (minibufferp mainbuf) + (setq completion-base-size 0))) + ;; Put faces on first uncommon characters and common parts. (when completion-base-size - (let* ((common-string-length (length - (substring mbuf-contents - completion-base-size))) + (let* ((common-string-length + (- (length mbuf-contents) completion-base-size)) (element-start (next-single-property-change (point-min) 'mouse-face)) - (element-common-end (+ element-start common-string-length)) + (element-common-end + (+ (or element-start nil) common-string-length)) (maxp (point-max))) (while (and element-start (< element-common-end maxp)) (when (and (get-char-property element-start 'mouse-face) @@ -4764,5 +4760,5 @@ (provide 'simple) -;;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd +;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd ;;; simple.el ends here