diff options
| author | Stefan Monnier | 2009-12-03 01:33:56 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-12-03 01:33:56 +0000 |
| commit | f72f0c2393770f183c703faa87492978e0e73b9f (patch) | |
| tree | 282ce8d90360d729de2ca883ee40819c051781b8 | |
| parent | 601a9508c91f8a8321f851fb47533356abb45117 (diff) | |
| download | emacs-f72f0c2393770f183c703faa87492978e0e73b9f.tar.gz emacs-f72f0c2393770f183c703faa87492978e0e73b9f.zip | |
(try-expand-dabbrev-visible): Preserve point in the
buffers visited. Remove redundant current-buffer-saving.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/hippie-exp.el | 60 |
2 files changed, 34 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6452e2b8fce..1597c9740da 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-12-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * hippie-exp.el (try-expand-dabbrev-visible): Preserve point in the | ||
| 4 | buffers visited. Remove redundant current-buffer-saving. | ||
| 5 | |||
| 1 | 2009-12-02 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2009-12-02 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | Use completion-in-buffer and remove uses of dynamic scoping. | 8 | Use completion-in-buffer and remove uses of dynamic scoping. |
diff --git a/lisp/hippie-exp.el b/lisp/hippie-exp.el index e52fe07f8ae..0b8f94f5da4 100644 --- a/lisp/hippie-exp.el +++ b/lisp/hippie-exp.el | |||
| @@ -80,8 +80,8 @@ | |||
| 80 | ;; in all buffers (except the current). (This may be a little | 80 | ;; in all buffers (except the current). (This may be a little |
| 81 | ;; slow, don't use it unless you are really fond of `hippie-expand'.) | 81 | ;; slow, don't use it unless you are really fond of `hippie-expand'.) |
| 82 | ;; `try-expand-list' : Tries to expand the text back to the nearest | 82 | ;; `try-expand-list' : Tries to expand the text back to the nearest |
| 83 | ;; open delimiter, to a whole list from the buffer. Convenient for | 83 | ;; open delimiter, to a whole list from the buffer. Convenient for |
| 84 | ;; example when writing lisp or TeX. | 84 | ;; example when writing Lisp or TeX. |
| 85 | ;; `try-expand-list-all-buffers' : Like `try-expand-list' but searches | 85 | ;; `try-expand-list-all-buffers' : Like `try-expand-list' but searches |
| 86 | ;; in all buffers (except the current). | 86 | ;; in all buffers (except the current). |
| 87 | ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of | 87 | ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of |
| @@ -116,7 +116,7 @@ | |||
| 116 | ;; variable with all kinds of try-functions above, it might be an | 116 | ;; variable with all kinds of try-functions above, it might be an |
| 117 | ;; idea to use `make-hippie-expand-function' to construct different | 117 | ;; idea to use `make-hippie-expand-function' to construct different |
| 118 | ;; `hippie-expand'-like functions, with different try-lists and bound | 118 | ;; `hippie-expand'-like functions, with different try-lists and bound |
| 119 | ;; to different keys. It is also possible to make | 119 | ;; to different keys. It is also possible to make |
| 120 | ;; `hippie-expand-try-functions-list' a buffer local variable, and | 120 | ;; `hippie-expand-try-functions-list' a buffer local variable, and |
| 121 | ;; let it depend on the mode (by setting it in the mode-hooks). | 121 | ;; let it depend on the mode (by setting it in the mode-hooks). |
| 122 | ;; | 122 | ;; |
| @@ -928,7 +928,7 @@ string). It returns t if a new expansion is found, nil otherwise." | |||
| 928 | t)))) | 928 | t)))) |
| 929 | 929 | ||
| 930 | (defun try-expand-dabbrev-all-buffers (old) | 930 | (defun try-expand-dabbrev-all-buffers (old) |
| 931 | "Tries to expand word \"dynamically\", searching all other buffers. | 931 | "Try to expand word \"dynamically\", searching all other buffers. |
| 932 | The argument OLD has to be nil the first call of this function, and t | 932 | The argument OLD has to be nil the first call of this function, and t |
| 933 | for subsequent calls (for further possible expansions of the same | 933 | for subsequent calls (for further possible expansions of the same |
| 934 | string). It returns t if a new expansion is found, nil otherwise." | 934 | string). It returns t if a new expansion is found, nil otherwise." |
| @@ -986,39 +986,37 @@ The argument OLD has to be nil the first call of this function, and t | |||
| 986 | for subsequent calls (for further possible expansions of the same | 986 | for subsequent calls (for further possible expansions of the same |
| 987 | string). It returns t if a new expansion is found, nil otherwise." | 987 | string). It returns t if a new expansion is found, nil otherwise." |
| 988 | (let ((expansion ()) | 988 | (let ((expansion ()) |
| 989 | (buf (current-buffer)) | ||
| 990 | (flag (if (frame-visible-p (window-frame (selected-window))) | 989 | (flag (if (frame-visible-p (window-frame (selected-window))) |
| 991 | 'visible t))) | 990 | 'visible t))) |
| 992 | (if (not old) | 991 | (unless old |
| 993 | (progn | 992 | (he-init-string (he-dabbrev-beg) (point)) |
| 994 | (he-init-string (he-dabbrev-beg) (point)) | 993 | (setq he-search-window (selected-window)) |
| 995 | (setq he-search-window (selected-window)) | 994 | (set-marker he-search-loc |
| 996 | (set-marker he-search-loc | 995 | (window-start he-search-window) |
| 997 | (window-start he-search-window) | 996 | (window-buffer he-search-window))) |
| 998 | (window-buffer he-search-window)))) | ||
| 999 | 997 | ||
| 1000 | (while (and (not (equal he-search-string "")) | 998 | (while (and (not (equal he-search-string "")) |
| 1001 | (marker-position he-search-loc) | 999 | (marker-position he-search-loc) |
| 1002 | (not expansion)) | 1000 | (not expansion)) |
| 1003 | (with-current-buffer (marker-buffer he-search-loc) | 1001 | (with-current-buffer (marker-buffer he-search-loc) |
| 1004 | (goto-char he-search-loc) | 1002 | (save-excursion |
| 1005 | (setq expansion (he-dabbrev-search he-search-string () | 1003 | (goto-char he-search-loc) |
| 1006 | (window-end he-search-window))) | 1004 | (setq expansion (he-dabbrev-search he-search-string () |
| 1007 | (if (and expansion | 1005 | (window-end he-search-window))) |
| 1008 | (eq (marker-buffer he-string-beg) (current-buffer)) | 1006 | (if (and expansion |
| 1009 | (eq (marker-position he-string-beg) (match-beginning 0))) | 1007 | (eq (marker-buffer he-string-beg) (current-buffer)) |
| 1010 | (setq expansion (he-dabbrev-search he-search-string () | 1008 | (eq (marker-position he-string-beg) (match-beginning 0))) |
| 1011 | (window-end he-search-window)))) | 1009 | (setq expansion |
| 1012 | (set-marker he-search-loc (point) (current-buffer))) | 1010 | (he-dabbrev-search he-search-string () |
| 1013 | (if (not expansion) | 1011 | (window-end he-search-window)))) |
| 1014 | (progn | 1012 | (set-marker he-search-loc (point) (current-buffer)))) |
| 1015 | (setq he-search-window (next-window he-search-window nil flag)) | 1013 | (unless expansion |
| 1016 | (if (eq he-search-window (selected-window)) | 1014 | (setq he-search-window (next-window he-search-window nil flag)) |
| 1017 | (set-marker he-search-loc nil) | 1015 | (if (eq he-search-window (selected-window)) |
| 1018 | (set-marker he-search-loc (window-start he-search-window) | 1016 | (set-marker he-search-loc nil) |
| 1019 | (window-buffer he-search-window)))))) | 1017 | (set-marker he-search-loc (window-start he-search-window) |
| 1018 | (window-buffer he-search-window))))) | ||
| 1020 | 1019 | ||
| 1021 | (set-buffer buf) | ||
| 1022 | (if (not expansion) | 1020 | (if (not expansion) |
| 1023 | (progn | 1021 | (progn |
| 1024 | (if old (he-reset-string)) | 1022 | (if old (he-reset-string)) |