diff options
| author | Richard M. Stallman | 1998-03-10 18:30:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-10 18:30:07 +0000 |
| commit | 41b8e71c8886c386264ec9cfab57bb96bf956cb9 (patch) | |
| tree | 5e2cd9a5a5bea2f38ab8e51a8fea4bfd7a850730 | |
| parent | 1c0dde844839669a44a9dcb4686efdeffacd2320 (diff) | |
| download | emacs-41b8e71c8886c386264ec9cfab57bb96bf956cb9.tar.gz emacs-41b8e71c8886c386264ec9cfab57bb96bf956cb9.zip | |
(hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
(hippie-expand-dabbrev-as-symbol): Renamed `he-dabbrev-as-symbol'.
(hippie-expand-no-restriction): New variable.
(hippie-expand-only-buffers): New variable.
(he-init-string,he-line-search,he-list-search,he-dabbrev-search): Use
`buffer-substring-no-properties' to avoid transfer of text properties.
(he-dabbrev-kill-search,he-whole-kill-search): Remove text properties
from search result.
(he-regexp-member): Removed function.
(he-buffer-member): New function used instead of `he-regexp-member'.
(try-expand-line,try-expand-line-all-buffers,try-expand-list,
try-expand-list-all-buffers,try-expand-dabbrev,
try-expand-dabbrev-all-buffers): Depending on
`hippie-expand-no-restriction', widen the buffer before search.
(try-expand-line-all-buffers,try-expand-list-all-buffers,
try-expand-dabbrev-all-buffers): Use `he-buffer-member' and
`hippie-expand-only-buffers'.
| -rw-r--r-- | lisp/hippie-exp.el | 332 |
1 files changed, 195 insertions, 137 deletions
diff --git a/lisp/hippie-exp.el b/lisp/hippie-exp.el index 70a653eb738..3af8e1b270d 100644 --- a/lisp/hippie-exp.el +++ b/lisp/hippie-exp.el | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | ;; Copyright (C) 1992 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Anders Holst <aho@sans.kth.se> | 5 | ;; Author: Anders Holst <aho@sans.kth.se> |
| 6 | ;; Last change: 28 May 1997 | 6 | ;; Last change: 3 March 1998 |
| 7 | ;; Version: 1.5 | 7 | ;; Version: 1.6 |
| 8 | ;; Keywords: abbrev | 8 | ;; Keywords: abbrev |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -49,6 +49,17 @@ | |||
| 49 | ;; matching buffer names (as strings) or major modes (as atoms) of | 49 | ;; matching buffer names (as strings) or major modes (as atoms) of |
| 50 | ;; buffers that should not be searched by the try-functions named | 50 | ;; buffers that should not be searched by the try-functions named |
| 51 | ;; "-all-buffers". | 51 | ;; "-all-buffers". |
| 52 | ;; If set, the variable `hippie-expand-only-buffers' does the opposite | ||
| 53 | ;; of `hippie-expand-ignore-buffers', in that the search is restricted | ||
| 54 | ;; to only the kind of buffers listed. | ||
| 55 | ;; If the variable `hippie-expand-no-restriction' is non-nil, narrowed | ||
| 56 | ;; buffers are widened before they are searched. | ||
| 57 | ;; The variable `hippie-expand-dabbrev-skip-space' controls whether | ||
| 58 | ;; trailing spaces will be included in the abbreviation to search for, | ||
| 59 | ;; which then gives the same behavior as the original `dabbrev-expand'. | ||
| 60 | ;; The variable `hippie-expand-dabbrev-as-symbol' controls whether | ||
| 61 | ;; characters of syntax '_' is considered part of the words to expand | ||
| 62 | ;; dynamically. | ||
| 52 | ;; See also the macro `make-hippie-expand-function' below. | 63 | ;; See also the macro `make-hippie-expand-function' below. |
| 53 | ;; | 64 | ;; |
| 54 | ;; A short description of the current try-functions in this file: | 65 | ;; A short description of the current try-functions in this file: |
| @@ -161,16 +172,6 @@ | |||
| 161 | "Expand text trying various ways to find its expansion." | 172 | "Expand text trying various ways to find its expansion." |
| 162 | :group 'abbrev) | 173 | :group 'abbrev) |
| 163 | 174 | ||
| 164 | (defcustom he-dabbrev-skip-space nil | ||
| 165 | "Non-nil means tolerate trailing spaces in the abbreviation to expand." | ||
| 166 | :group 'hippie-expand | ||
| 167 | :type 'boolean) | ||
| 168 | |||
| 169 | (defcustom he-dabbrev-as-symbol t | ||
| 170 | "Non-nil means expand as symbols, i.e. syntax `_' is considered a letter." | ||
| 171 | :group 'hippie-expand | ||
| 172 | :type 'boolean) | ||
| 173 | |||
| 174 | (defvar he-num -1) | 175 | (defvar he-num -1) |
| 175 | 176 | ||
| 176 | (defvar he-string-beg (make-marker)) | 177 | (defvar he-string-beg (make-marker)) |
| @@ -217,6 +218,24 @@ or insert functions in this list.") | |||
| 217 | :group 'hippie-expand) | 218 | :group 'hippie-expand) |
| 218 | 219 | ||
| 219 | ;;;###autoload | 220 | ;;;###autoload |
| 221 | (defcustom hippie-expand-dabbrev-skip-space nil | ||
| 222 | "*Non-nil means tolerate trailing spaces in the abbreviation to expand." | ||
| 223 | :group 'hippie-expand | ||
| 224 | :type 'boolean) | ||
| 225 | |||
| 226 | ;;;###autoload | ||
| 227 | (defcustom hippie-expand-dabbrev-as-symbol t | ||
| 228 | "*Non-nil means expand as symbols, i.e. syntax `_' is considered a letter." | ||
| 229 | :group 'hippie-expand | ||
| 230 | :type 'boolean) | ||
| 231 | |||
| 232 | ;;;###autoload | ||
| 233 | (defcustom hippie-expand-no-restriction t | ||
| 234 | "*Non-nil means that narrowed buffers are widened during search." | ||
| 235 | :group 'hippie-expand | ||
| 236 | :type 'boolean) | ||
| 237 | |||
| 238 | ;;;###autoload | ||
| 220 | (defcustom hippie-expand-max-buffers () | 239 | (defcustom hippie-expand-max-buffers () |
| 221 | "*The maximum number of buffers (apart from the current) searched. | 240 | "*The maximum number of buffers (apart from the current) searched. |
| 222 | If nil, all buffers are searched." | 241 | If nil, all buffers are searched." |
| @@ -233,6 +252,15 @@ Can contain both regexps matching buffer names (as strings) and major modes | |||
| 233 | :group 'hippie-expand) | 252 | :group 'hippie-expand) |
| 234 | 253 | ||
| 235 | ;;;###autoload | 254 | ;;;###autoload |
| 255 | (defcustom hippie-expand-only-buffers () | ||
| 256 | "*A list specifying the only buffers to search (in addition to current). | ||
| 257 | Can contain both regexps matching buffer names (as strings) and major modes | ||
| 258 | \(as atoms). If non-NIL, this variable overrides the variable | ||
| 259 | `hippie-expand-ignore-buffers'." | ||
| 260 | :type '(repeat (choice regexp (symbol :tag "Major Mode"))) | ||
| 261 | :group 'hippie-expand) | ||
| 262 | |||
| 263 | ;;;###autoload | ||
| 236 | (defun hippie-expand (arg) | 264 | (defun hippie-expand (arg) |
| 237 | "Try to expand text before point, using multiple methods. | 265 | "Try to expand text before point, using multiple methods. |
| 238 | The expansion functions in `hippie-expand-try-functions-list' are | 266 | The expansion functions in `hippie-expand-try-functions-list' are |
| @@ -270,7 +298,7 @@ undoes the expansion." | |||
| 270 | (if (and hippie-expand-verbose | 298 | (if (and hippie-expand-verbose |
| 271 | (not (window-minibuffer-p (selected-window)))) | 299 | (not (window-minibuffer-p (selected-window)))) |
| 272 | (message "Using %s" | 300 | (message "Using %s" |
| 273 | (nth he-num hippie-expand-try-functions-list))))) | 301 | (nth he-num hippie-expand-try-functions-list))))) |
| 274 | (if (and (>= he-num 0) | 302 | (if (and (>= he-num 0) |
| 275 | (eq (marker-buffer he-string-beg) (current-buffer))) | 303 | (eq (marker-buffer he-string-beg) (current-buffer))) |
| 276 | (progn | 304 | (progn |
| @@ -284,7 +312,7 @@ undoes the expansion." | |||
| 284 | (defun he-init-string (beg end) | 312 | (defun he-init-string (beg end) |
| 285 | (set-marker he-string-beg beg) | 313 | (set-marker he-string-beg beg) |
| 286 | (set-marker he-string-end end) | 314 | (set-marker he-string-end end) |
| 287 | (setq he-search-string (buffer-substring beg end))) | 315 | (setq he-search-string (buffer-substring-no-properties beg end))) |
| 288 | 316 | ||
| 289 | ;; Resets the expanded region to its original contents. | 317 | ;; Resets the expanded region to its original contents. |
| 290 | (defun he-reset-string () | 318 | (defun he-reset-string () |
| @@ -356,14 +384,16 @@ undoes the expansion." | |||
| 356 | str) | 384 | str) |
| 357 | lst))) | 385 | lst))) |
| 358 | 386 | ||
| 359 | ;; Check if STR matches any regexp in LST. | 387 | ;; Check if current buffer matches any atom or regexp in LST. |
| 360 | ;; Ignore possible non-strings in LST. | 388 | ;; Atoms are interpreted as major modes, strings as regexps mathing the name. |
| 361 | (defun he-regexp-member (str lst) | 389 | (defun he-buffer-member (lst) |
| 362 | (while (and lst | 390 | (or (memq major-mode lst) |
| 363 | (or (not (stringp (car lst))) | 391 | (progn |
| 364 | (not (string-match (car lst) str)))) | 392 | (while (and lst |
| 365 | (setq lst (cdr lst))) | 393 | (or (not (stringp (car lst))) |
| 366 | lst) | 394 | (not (string-match (car lst) (buffer-name))))) |
| 395 | (setq lst (cdr lst))) | ||
| 396 | lst))) | ||
| 367 | 397 | ||
| 368 | ;; For the real hippie-expand enthusiast: A macro that makes it | 398 | ;; For the real hippie-expand enthusiast: A macro that makes it |
| 369 | ;; possible to use many functions like hippie-expand, but with | 399 | ;; possible to use many functions like hippie-expand, but with |
| @@ -476,8 +506,8 @@ otherwise." | |||
| 476 | (save-excursion | 506 | (save-excursion |
| 477 | (skip-chars-backward he-file-name-chars) | 507 | (skip-chars-backward he-file-name-chars) |
| 478 | (if (> (skip-syntax-backward "w") 0) ;; No words with non-file chars | 508 | (if (> (skip-syntax-backward "w") 0) ;; No words with non-file chars |
| 479 | op | 509 | op |
| 480 | (point))))) | 510 | (point))))) |
| 481 | 511 | ||
| 482 | ;; Thanks go to Richard Levitte <levitte@e.kth.se> who helped to make these | 512 | ;; Thanks go to Richard Levitte <levitte@e.kth.se> who helped to make these |
| 483 | ;; work under VMS, and to David Hughes <ukchugd@ukpmr.cs.philips.nl> who | 513 | ;; work under VMS, and to David Hughes <ukchugd@ukpmr.cs.philips.nl> who |
| @@ -605,24 +635,27 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 605 | 635 | ||
| 606 | (if (not (equal he-search-string "")) | 636 | (if (not (equal he-search-string "")) |
| 607 | (save-excursion | 637 | (save-excursion |
| 608 | ;; Try looking backward unless inhibited. | 638 | (save-restriction |
| 609 | (if he-search-bw | 639 | (if hippie-expand-no-restriction |
| 610 | (progn | 640 | (widen)) |
| 611 | (goto-char he-search-loc) | 641 | ;; Try looking backward unless inhibited. |
| 612 | (setq expansion (he-line-search he-search-string | 642 | (if he-search-bw |
| 613 | strip-prompt t)) | 643 | (progn |
| 614 | (set-marker he-search-loc (point)) | 644 | (goto-char he-search-loc) |
| 615 | (if (not expansion) | 645 | (setq expansion (he-line-search he-search-string |
| 616 | (progn | 646 | strip-prompt t)) |
| 617 | (set-marker he-search-loc he-string-end) | 647 | (set-marker he-search-loc (point)) |
| 618 | (setq he-search-bw ()))))) | 648 | (if (not expansion) |
| 619 | 649 | (progn | |
| 620 | (if (not expansion) ; Then look forward. | 650 | (set-marker he-search-loc he-string-end) |
| 621 | (progn | 651 | (setq he-search-bw ()))))) |
| 622 | (goto-char he-search-loc) | 652 | |
| 623 | (setq expansion (he-line-search he-search-string | 653 | (if (not expansion) ; Then look forward. |
| 624 | strip-prompt nil)) | 654 | (progn |
| 625 | (set-marker he-search-loc (point)))))) | 655 | (goto-char he-search-loc) |
| 656 | (setq expansion (he-line-search he-search-string | ||
| 657 | strip-prompt nil)) | ||
| 658 | (set-marker he-search-loc (point))))))) | ||
| 626 | 659 | ||
| 627 | (if (not expansion) | 660 | (if (not expansion) |
| 628 | (progn | 661 | (progn |
| @@ -656,22 +689,26 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 656 | (< he-searched-n-bufs hippie-expand-max-buffers))) | 689 | (< he-searched-n-bufs hippie-expand-max-buffers))) |
| 657 | (set-buffer (car he-search-bufs)) | 690 | (set-buffer (car he-search-bufs)) |
| 658 | (if (and (not (eq (current-buffer) buf)) | 691 | (if (and (not (eq (current-buffer) buf)) |
| 659 | (not (memq major-mode hippie-expand-ignore-buffers)) | 692 | (if hippie-expand-only-buffers |
| 660 | (not (he-regexp-member (buffer-name) | 693 | (he-buffer-member hippie-expand-only-buffers) |
| 661 | hippie-expand-ignore-buffers))) | 694 | (not (he-buffer-member hippie-expand-ignore-buffers)))) |
| 662 | (save-excursion | 695 | (save-excursion |
| 663 | (goto-char he-search-loc) | 696 | (save-restriction |
| 664 | (setq strip-prompt (and (get-buffer-process (current-buffer)) | 697 | (if hippie-expand-no-restriction |
| 665 | comint-prompt-regexp)) | 698 | (widen)) |
| 666 | (setq expansion (let ((case-fold-search orig-case-fold-search)) | 699 | (goto-char he-search-loc) |
| 667 | (he-line-search he-search-string | 700 | (setq strip-prompt (and (get-buffer-process (current-buffer)) |
| 668 | strip-prompt nil))) | 701 | comint-prompt-regexp)) |
| 669 | (set-marker he-search-loc (point)) | 702 | (setq expansion |
| 670 | (if (not expansion) | 703 | (let ((case-fold-search orig-case-fold-search)) |
| 671 | (progn | 704 | (he-line-search he-search-string |
| 672 | (setq he-search-bufs (cdr he-search-bufs)) | 705 | strip-prompt nil))) |
| 673 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | 706 | (set-marker he-search-loc (point)) |
| 674 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 707 | (if (not expansion) |
| 708 | (progn | ||
| 709 | (setq he-search-bufs (cdr he-search-bufs)) | ||
| 710 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | ||
| 711 | (set-marker he-search-loc 1 (car he-search-bufs)))))) | ||
| 675 | (setq he-search-bufs (cdr he-search-bufs)) | 712 | (setq he-search-bufs (cdr he-search-bufs)) |
| 676 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 713 | (set-marker he-search-loc 1 (car he-search-bufs))))) |
| 677 | 714 | ||
| @@ -694,7 +731,8 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 694 | (re-search-forward | 731 | (re-search-forward |
| 695 | (he-line-search-regexp str strip-prompt) | 732 | (he-line-search-regexp str strip-prompt) |
| 696 | nil t))) | 733 | nil t))) |
| 697 | (setq result (buffer-substring (match-beginning 2) (match-end 2))) | 734 | (setq result (buffer-substring-no-properties (match-beginning 2) |
| 735 | (match-end 2))) | ||
| 698 | (if (he-string-member result he-tried-table t) | 736 | (if (he-string-member result he-tried-table t) |
| 699 | (setq result nil))) ; if already in table, ignore | 737 | (setq result nil))) ; if already in table, ignore |
| 700 | result)) | 738 | result)) |
| @@ -730,22 +768,25 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 730 | 768 | ||
| 731 | (if (not (equal he-search-string "")) | 769 | (if (not (equal he-search-string "")) |
| 732 | (save-excursion | 770 | (save-excursion |
| 733 | ;; Try looking backward unless inhibited. | 771 | (save-restriction |
| 734 | (if he-search-bw | 772 | (if hippie-expand-no-restriction |
| 735 | (progn | 773 | (widen)) |
| 736 | (goto-char he-search-loc) | 774 | ;; Try looking backward unless inhibited. |
| 737 | (setq expansion (he-list-search he-search-string t)) | 775 | (if he-search-bw |
| 738 | (set-marker he-search-loc (point)) | 776 | (progn |
| 739 | (if (not expansion) | 777 | (goto-char he-search-loc) |
| 740 | (progn | 778 | (setq expansion (he-list-search he-search-string t)) |
| 741 | (set-marker he-search-loc he-string-end) | 779 | (set-marker he-search-loc (point)) |
| 742 | (setq he-search-bw ()))))) | 780 | (if (not expansion) |
| 743 | 781 | (progn | |
| 744 | (if (not expansion) ; Then look forward. | 782 | (set-marker he-search-loc he-string-end) |
| 745 | (progn | 783 | (setq he-search-bw ()))))) |
| 746 | (goto-char he-search-loc) | 784 | |
| 747 | (setq expansion (he-list-search he-search-string nil)) | 785 | (if (not expansion) ; Then look forward. |
| 748 | (set-marker he-search-loc (point)))))) | 786 | (progn |
| 787 | (goto-char he-search-loc) | ||
| 788 | (setq expansion (he-list-search he-search-string nil)) | ||
| 789 | (set-marker he-search-loc (point))))))) | ||
| 749 | 790 | ||
| 750 | (if (not expansion) | 791 | (if (not expansion) |
| 751 | (progn | 792 | (progn |
| @@ -777,19 +818,23 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 777 | (< he-searched-n-bufs hippie-expand-max-buffers))) | 818 | (< he-searched-n-bufs hippie-expand-max-buffers))) |
| 778 | (set-buffer (car he-search-bufs)) | 819 | (set-buffer (car he-search-bufs)) |
| 779 | (if (and (not (eq (current-buffer) buf)) | 820 | (if (and (not (eq (current-buffer) buf)) |
| 780 | (not (memq major-mode hippie-expand-ignore-buffers)) | 821 | (if hippie-expand-only-buffers |
| 781 | (not (he-regexp-member (buffer-name) | 822 | (he-buffer-member hippie-expand-only-buffers) |
| 782 | hippie-expand-ignore-buffers))) | 823 | (not (he-buffer-member hippie-expand-ignore-buffers)))) |
| 783 | (save-excursion | 824 | (save-excursion |
| 784 | (goto-char he-search-loc) | 825 | (save-restriction |
| 785 | (setq expansion (let ((case-fold-search orig-case-fold-search)) | 826 | (if hippie-expand-no-restriction |
| 786 | (he-list-search he-search-string nil))) | 827 | (widen)) |
| 787 | (set-marker he-search-loc (point)) | 828 | (goto-char he-search-loc) |
| 788 | (if (not expansion) | 829 | (setq expansion |
| 789 | (progn | 830 | (let ((case-fold-search orig-case-fold-search)) |
| 790 | (setq he-search-bufs (cdr he-search-bufs)) | 831 | (he-list-search he-search-string nil))) |
| 791 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | 832 | (set-marker he-search-loc (point)) |
| 792 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 833 | (if (not expansion) |
| 834 | (progn | ||
| 835 | (setq he-search-bufs (cdr he-search-bufs)) | ||
| 836 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | ||
| 837 | (set-marker he-search-loc 1 (car he-search-bufs)))))) | ||
| 793 | (setq he-search-bufs (cdr he-search-bufs)) | 838 | (setq he-search-bufs (cdr he-search-bufs)) |
| 794 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 839 | (set-marker he-search-loc 1 (car he-search-bufs))))) |
| 795 | 840 | ||
| @@ -821,7 +866,7 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 821 | (setq err t)) | 866 | (setq err t)) |
| 822 | (if (not err) | 867 | (if (not err) |
| 823 | (progn | 868 | (progn |
| 824 | (setq result (buffer-substring beg (point))) | 869 | (setq result (buffer-substring-no-properties beg (point))) |
| 825 | (if (he-string-member result he-tried-table t) | 870 | (if (he-string-member result he-tried-table t) |
| 826 | (setq result nil)))) ; if already in table, ignore | 871 | (setq result nil)))) ; if already in table, ignore |
| 827 | (goto-char pos)) | 872 | (goto-char pos)) |
| @@ -878,22 +923,25 @@ string). It returns t if a new expansion is found, nil otherwise." | |||
| 878 | 923 | ||
| 879 | (if (not (equal he-search-string "")) | 924 | (if (not (equal he-search-string "")) |
| 880 | (save-excursion | 925 | (save-excursion |
| 881 | ;; Try looking backward unless inhibited. | 926 | (save-restriction |
| 882 | (if he-search-bw | 927 | (if hippie-expand-no-restriction |
| 883 | (progn | 928 | (widen)) |
| 884 | (goto-char he-search-loc) | 929 | ;; Try looking backward unless inhibited. |
| 885 | (setq expansion (he-dabbrev-search he-search-string t)) | 930 | (if he-search-bw |
| 886 | (set-marker he-search-loc (point)) | 931 | (progn |
| 887 | (if (not expansion) | 932 | (goto-char he-search-loc) |
| 888 | (progn | 933 | (setq expansion (he-dabbrev-search he-search-string t)) |
| 889 | (set-marker he-search-loc he-string-end) | 934 | (set-marker he-search-loc (point)) |
| 890 | (setq he-search-bw ()))))) | 935 | (if (not expansion) |
| 891 | 936 | (progn | |
| 892 | (if (not expansion) ; Then look forward. | 937 | (set-marker he-search-loc he-string-end) |
| 893 | (progn | 938 | (setq he-search-bw ()))))) |
| 894 | (goto-char he-search-loc) | 939 | |
| 895 | (setq expansion (he-dabbrev-search he-search-string nil)) | 940 | (if (not expansion) ; Then look forward. |
| 896 | (set-marker he-search-loc (point)))))) | 941 | (progn |
| 942 | (goto-char he-search-loc) | ||
| 943 | (setq expansion (he-dabbrev-search he-search-string nil)) | ||
| 944 | (set-marker he-search-loc (point))))))) | ||
| 897 | 945 | ||
| 898 | (if (not expansion) | 946 | (if (not expansion) |
| 899 | (progn | 947 | (progn |
| @@ -925,19 +973,23 @@ string). It returns t if a new expansion is found, nil otherwise." | |||
| 925 | (< he-searched-n-bufs hippie-expand-max-buffers))) | 973 | (< he-searched-n-bufs hippie-expand-max-buffers))) |
| 926 | (set-buffer (car he-search-bufs)) | 974 | (set-buffer (car he-search-bufs)) |
| 927 | (if (and (not (eq (current-buffer) buf)) | 975 | (if (and (not (eq (current-buffer) buf)) |
| 928 | (not (memq major-mode hippie-expand-ignore-buffers)) | 976 | (if hippie-expand-only-buffers |
| 929 | (not (he-regexp-member (buffer-name) | 977 | (he-buffer-member hippie-expand-only-buffers) |
| 930 | hippie-expand-ignore-buffers))) | 978 | (not (he-buffer-member hippie-expand-ignore-buffers)))) |
| 931 | (save-excursion | 979 | (save-excursion |
| 932 | (goto-char he-search-loc) | 980 | (save-restriction |
| 933 | (setq expansion (let ((case-fold-search orig-case-fold-search)) | 981 | (if hippie-expand-no-restriction |
| 934 | (he-dabbrev-search he-search-string nil))) | 982 | (widen)) |
| 935 | (set-marker he-search-loc (point)) | 983 | (goto-char he-search-loc) |
| 936 | (if (not expansion) | 984 | (setq expansion |
| 937 | (progn | 985 | (let ((case-fold-search orig-case-fold-search)) |
| 938 | (setq he-search-bufs (cdr he-search-bufs)) | 986 | (he-dabbrev-search he-search-string nil))) |
| 939 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | 987 | (set-marker he-search-loc (point)) |
| 940 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 988 | (if (not expansion) |
| 989 | (progn | ||
| 990 | (setq he-search-bufs (cdr he-search-bufs)) | ||
| 991 | (setq he-searched-n-bufs (1+ he-searched-n-bufs)) | ||
| 992 | (set-marker he-search-loc 1 (car he-search-bufs)))))) | ||
| 941 | (setq he-search-bufs (cdr he-search-bufs)) | 993 | (setq he-search-bufs (cdr he-search-bufs)) |
| 942 | (set-marker he-search-loc 1 (car he-search-bufs))))) | 994 | (set-marker he-search-loc 1 (car he-search-bufs))))) |
| 943 | 995 | ||
| @@ -1002,20 +1054,21 @@ string). It returns t if a new expansion is found, nil otherwise." | |||
| 1002 | 1054 | ||
| 1003 | (defun he-dabbrev-search (pattern &optional reverse limit) | 1055 | (defun he-dabbrev-search (pattern &optional reverse limit) |
| 1004 | (let ((result ()) | 1056 | (let ((result ()) |
| 1005 | (regpat (cond ((not he-dabbrev-as-symbol) | 1057 | (regpat (cond ((not hippie-expand-dabbrev-as-symbol) |
| 1006 | (concat "\\<" (regexp-quote pattern) "\\sw+")) | 1058 | (concat "\\<" (regexp-quote pattern) "\\sw+")) |
| 1007 | ((eq (char-syntax (aref pattern 0)) ?_) | 1059 | ((eq (char-syntax (aref pattern 0)) ?_) |
| 1008 | (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) | 1060 | (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) |
| 1009 | (t | 1061 | (t |
| 1010 | (concat "\\<" (regexp-quote pattern) | 1062 | (concat "\\<" (regexp-quote pattern) |
| 1011 | "\\(\\sw\\|\\s_\\)+"))))) | 1063 | "\\(\\sw\\|\\s_\\)+"))))) |
| 1012 | (while (and (not result) | 1064 | (while (and (not result) |
| 1013 | (if reverse | 1065 | (if reverse |
| 1014 | (re-search-backward regpat limit t) | 1066 | (re-search-backward regpat limit t) |
| 1015 | (re-search-forward regpat limit t))) | 1067 | (re-search-forward regpat limit t))) |
| 1016 | (setq result (buffer-substring (match-beginning 0) (match-end 0))) | 1068 | (setq result (buffer-substring-no-properties (match-beginning 0) |
| 1017 | (if (or (and he-dabbrev-as-symbol | 1069 | (match-end 0))) |
| 1018 | (> (match-beginning 0) (point-min)) | 1070 | (if (or (and hippie-expand-dabbrev-as-symbol |
| 1071 | (> (match-beginning 0) (point-min)) | ||
| 1019 | (memq (char-syntax (char-after (1- (match-beginning 0)))) | 1072 | (memq (char-syntax (char-after (1- (match-beginning 0)))) |
| 1020 | '(?_ ?w))) | 1073 | '(?_ ?w))) |
| 1021 | (he-string-member result he-tried-table t)) | 1074 | (he-string-member result he-tried-table t)) |
| @@ -1025,9 +1078,11 @@ string). It returns t if a new expansion is found, nil otherwise." | |||
| 1025 | (defun he-dabbrev-beg () | 1078 | (defun he-dabbrev-beg () |
| 1026 | (let ((op (point))) | 1079 | (let ((op (point))) |
| 1027 | (save-excursion | 1080 | (save-excursion |
| 1028 | (if he-dabbrev-skip-space | 1081 | (if hippie-expand-dabbrev-skip-space |
| 1029 | (skip-syntax-backward ". ")) | 1082 | (skip-syntax-backward ". ")) |
| 1030 | (if (= (skip-syntax-backward (if he-dabbrev-as-symbol "w_" "w")) 0) | 1083 | (if (= (skip-syntax-backward (if hippie-expand-dabbrev-as-symbol |
| 1084 | "w_" "w")) | ||
| 1085 | 0) | ||
| 1031 | op | 1086 | op |
| 1032 | (point))))) | 1087 | (point))))) |
| 1033 | 1088 | ||
| @@ -1056,22 +1111,23 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 1056 | 1111 | ||
| 1057 | (defun he-dabbrev-kill-search (pattern) | 1112 | (defun he-dabbrev-kill-search (pattern) |
| 1058 | (let ((result ()) | 1113 | (let ((result ()) |
| 1059 | (regpat (cond ((not he-dabbrev-as-symbol) | 1114 | (regpat (cond ((not hippie-expand-dabbrev-as-symbol) |
| 1060 | (concat "\\<" (regexp-quote pattern) "\\sw+")) | 1115 | (concat "\\<" (regexp-quote pattern) "\\sw+")) |
| 1061 | ((eq (char-syntax (aref pattern 0)) ?_) | 1116 | ((eq (char-syntax (aref pattern 0)) ?_) |
| 1062 | (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) | 1117 | (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) |
| 1063 | (t | 1118 | (t |
| 1064 | (concat "\\<" (regexp-quote pattern) | 1119 | (concat "\\<" (regexp-quote pattern) |
| 1065 | "\\(\\sw\\|\\s_\\)+")))) | 1120 | "\\(\\sw\\|\\s_\\)+")))) |
| 1066 | (killstr (car he-expand-list))) | 1121 | (killstr (car he-expand-list))) |
| 1067 | (while (and (not result) | 1122 | (while (and (not result) |
| 1068 | he-expand-list) | 1123 | he-expand-list) |
| 1069 | (while (and (not result) | 1124 | (while (and (not result) |
| 1070 | (string-match regpat killstr he-search-loc2)) | 1125 | (string-match regpat killstr he-search-loc2)) |
| 1071 | (setq result (substring killstr (match-beginning 0) (match-end 0))) | 1126 | (setq result (substring killstr (match-beginning 0) (match-end 0))) |
| 1127 | (set-text-properties 0 (length result) () result) | ||
| 1072 | (setq he-search-loc2 (1+ (match-beginning 0))) | 1128 | (setq he-search-loc2 (1+ (match-beginning 0))) |
| 1073 | (if (or (and he-dabbrev-as-symbol | 1129 | (if (or (and hippie-expand-dabbrev-as-symbol |
| 1074 | (> (match-beginning 0) 0) | 1130 | (> (match-beginning 0) 0) |
| 1075 | (memq (char-syntax (aref killstr (1- (match-beginning 0)))) | 1131 | (memq (char-syntax (aref killstr (1- (match-beginning 0)))) |
| 1076 | '(?_ ?w))) | 1132 | '(?_ ?w))) |
| 1077 | (he-string-member result he-tried-table t)) | 1133 | (he-string-member result he-tried-table t)) |
| @@ -1130,7 +1186,9 @@ string). It returns t if a new completion is found, nil otherwise." | |||
| 1130 | (eq (char-after (- (point) pos)) (aref killstr 0)) | 1186 | (eq (char-after (- (point) pos)) (aref killstr 0)) |
| 1131 | (search-backward (substring killstr 0 pos) | 1187 | (search-backward (substring killstr 0 pos) |
| 1132 | (- (point) pos) t)) | 1188 | (- (point) pos) t)) |
| 1133 | (setq result (substring killstr pos)))) | 1189 | (progn |
| 1190 | (setq result (substring killstr pos)) | ||
| 1191 | (set-text-properties 0 (length result) () result)))) | ||
| 1134 | (if (and result | 1192 | (if (and result |
| 1135 | (he-string-member result he-tried-table)) | 1193 | (he-string-member result he-tried-table)) |
| 1136 | (setq result nil))) ; ignore if already in table | 1194 | (setq result nil))) ; ignore if already in table |