diff options
| author | Stefan Monnier | 2004-05-19 19:10:19 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-05-19 19:10:19 +0000 |
| commit | 621a3f6266f9a2ea1e04701c66238cf4b54c2a1f (patch) | |
| tree | 95621925369e0ca421efde3be5feb1484d988bc0 | |
| parent | f0975dfd6c191017c026655bd04611a4d50aaca4 (diff) | |
| download | emacs-621a3f6266f9a2ea1e04701c66238cf4b54c2a1f.tar.gz emacs-621a3f6266f9a2ea1e04701c66238cf4b54c2a1f.zip | |
(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.
| -rw-r--r-- | lisp/simple.el | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 7b9c20c3e17..f76c6662725 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3392,15 +3392,14 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 3392 | ;; (Actually some major modes use a different auto-fill function, | 3392 | ;; (Actually some major modes use a different auto-fill function, |
| 3393 | ;; but this one is the default one.) | 3393 | ;; but this one is the default one.) |
| 3394 | (defun do-auto-fill () | 3394 | (defun do-auto-fill () |
| 3395 | (let (fc justify bol give-up | 3395 | (let (fc justify give-up |
| 3396 | (fill-prefix fill-prefix)) | 3396 | (fill-prefix fill-prefix)) |
| 3397 | (if (or (not (setq justify (current-justification))) | 3397 | (if (or (not (setq justify (current-justification))) |
| 3398 | (null (setq fc (current-fill-column))) | 3398 | (null (setq fc (current-fill-column))) |
| 3399 | (and (eq justify 'left) | 3399 | (and (eq justify 'left) |
| 3400 | (<= (current-column) fc)) | 3400 | (<= (current-column) fc)) |
| 3401 | (save-excursion (beginning-of-line) | 3401 | (and auto-fill-inhibit-regexp |
| 3402 | (setq bol (point)) | 3402 | (save-excursion (beginning-of-line) |
| 3403 | (and auto-fill-inhibit-regexp | ||
| 3404 | (looking-at auto-fill-inhibit-regexp)))) | 3403 | (looking-at auto-fill-inhibit-regexp)))) |
| 3405 | nil ;; Auto-filling not required | 3404 | nil ;; Auto-filling not required |
| 3406 | (if (memq justify '(full center right)) | 3405 | (if (memq justify '(full center right)) |
| @@ -3423,16 +3422,15 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 3423 | ;; Determine where to split the line. | 3422 | ;; Determine where to split the line. |
| 3424 | (let* (after-prefix | 3423 | (let* (after-prefix |
| 3425 | (fill-point | 3424 | (fill-point |
| 3426 | (let ((opoint (point))) | 3425 | (save-excursion |
| 3427 | (save-excursion | 3426 | (beginning-of-line) |
| 3428 | (beginning-of-line) | 3427 | (setq after-prefix (point)) |
| 3429 | (setq after-prefix (point)) | 3428 | (and fill-prefix |
| 3430 | (and fill-prefix | 3429 | (looking-at (regexp-quote fill-prefix)) |
| 3431 | (looking-at (regexp-quote fill-prefix)) | 3430 | (setq after-prefix (match-end 0))) |
| 3432 | (setq after-prefix (match-end 0))) | 3431 | (move-to-column (1+ fc)) |
| 3433 | (move-to-column (1+ fc)) | 3432 | (fill-move-to-break-point after-prefix) |
| 3434 | (fill-move-to-break-point after-prefix) | 3433 | (point)))) |
| 3435 | (point))))) | ||
| 3436 | 3434 | ||
| 3437 | ;; See whether the place we found is any good. | 3435 | ;; See whether the place we found is any good. |
| 3438 | (if (save-excursion | 3436 | (if (save-excursion |
| @@ -4265,16 +4263,15 @@ of the differing parts is, by contrast, slightly highlighted." | |||
| 4265 | :group 'completion) | 4263 | :group 'completion) |
| 4266 | 4264 | ||
| 4267 | (defun completion-setup-function () | 4265 | (defun completion-setup-function () |
| 4268 | (save-excursion | 4266 | (let ((mainbuf (current-buffer)) |
| 4269 | (let ((mainbuf (current-buffer)) | 4267 | (mbuf-contents (minibuffer-contents))) |
| 4270 | (mbuf-contents (minibuffer-contents))) | 4268 | ;; When reading a file name in the minibuffer, |
| 4271 | ;; When reading a file name in the minibuffer, | 4269 | ;; set default-directory in the minibuffer |
| 4272 | ;; set default-directory in the minibuffer | 4270 | ;; so it will get copied into the completion list buffer. |
| 4273 | ;; so it will get copied into the completion list buffer. | 4271 | (if minibuffer-completing-file-name |
| 4274 | (if minibuffer-completing-file-name | 4272 | (with-current-buffer mainbuf |
| 4275 | (with-current-buffer mainbuf | 4273 | (setq default-directory (file-name-directory mbuf-contents)))) |
| 4276 | (setq default-directory (file-name-directory mbuf-contents)))) | 4274 | (with-current-buffer standard-output |
| 4277 | (set-buffer standard-output) | ||
| 4278 | (completion-list-mode) | 4275 | (completion-list-mode) |
| 4279 | (make-local-variable 'completion-reference-buffer) | 4276 | (make-local-variable 'completion-reference-buffer) |
| 4280 | (setq completion-reference-buffer mainbuf) | 4277 | (setq completion-reference-buffer mainbuf) |
| @@ -4283,24 +4280,23 @@ of the differing parts is, by contrast, slightly highlighted." | |||
| 4283 | ;; use the number of chars before the start of the | 4280 | ;; use the number of chars before the start of the |
| 4284 | ;; last file name component. | 4281 | ;; last file name component. |
| 4285 | (setq completion-base-size | 4282 | (setq completion-base-size |
| 4286 | (save-excursion | 4283 | (with-current-buffer mainbuf |
| 4287 | (set-buffer mainbuf) | 4284 | (save-excursion |
| 4288 | (goto-char (point-max)) | 4285 | (goto-char (point-max)) |
| 4289 | (skip-chars-backward "^/") | 4286 | (skip-chars-backward "^/") |
| 4290 | (- (point) (minibuffer-prompt-end)))) | 4287 | (- (point) (minibuffer-prompt-end))))) |
| 4291 | ;; Otherwise, in minibuffer, the whole input is being completed. | 4288 | ;; Otherwise, in minibuffer, the whole input is being completed. |
| 4292 | (save-match-data | 4289 | (if (minibufferp mainbuf) |
| 4293 | (if (minibufferp mainbuf) | 4290 | (setq completion-base-size 0))) |
| 4294 | (setq completion-base-size 0)))) | 4291 | ;; Put faces on first uncommon characters and common parts. |
| 4295 | ;; Put faces on first uncommon characters and common parts. | ||
| 4296 | (when completion-base-size | 4292 | (when completion-base-size |
| 4297 | (let* ((common-string-length (length | 4293 | (let* ((common-string-length |
| 4298 | (substring mbuf-contents | 4294 | (- (length mbuf-contents) completion-base-size)) |
| 4299 | completion-base-size))) | ||
| 4300 | (element-start (next-single-property-change | 4295 | (element-start (next-single-property-change |
| 4301 | (point-min) | 4296 | (point-min) |
| 4302 | 'mouse-face)) | 4297 | 'mouse-face)) |
| 4303 | (element-common-end (+ element-start common-string-length)) | 4298 | (element-common-end |
| 4299 | (+ (or element-start nil) common-string-length)) | ||
| 4304 | (maxp (point-max))) | 4300 | (maxp (point-max))) |
| 4305 | (while (and element-start (< element-common-end maxp)) | 4301 | (while (and element-start (< element-common-end maxp)) |
| 4306 | (when (and (get-char-property element-start 'mouse-face) | 4302 | (when (and (get-char-property element-start 'mouse-face) |
| @@ -4764,5 +4760,5 @@ works by saving the value of `buffer-invisibility-spec' and setting it to nil." | |||
| 4764 | 4760 | ||
| 4765 | (provide 'simple) | 4761 | (provide 'simple) |
| 4766 | 4762 | ||
| 4767 | ;;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd | 4763 | ;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd |
| 4768 | ;;; simple.el ends here | 4764 | ;;; simple.el ends here |