/[emacs]/emacs/lisp/hippie-exp.el
ViewVC logotype

Diff of /emacs/lisp/hippie-exp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by pj, Thu Dec 20 18:41:15 2001 UTC revision 1.24.4.1 by miles, Fri Apr 4 06:20:06 2003 UTC
# Line 28  Line 28 
28    
29  ;;  `hippie-expand' is a single function for a lot of different kinds  ;;  `hippie-expand' is a single function for a lot of different kinds
30  ;;  of completions and expansions.  Called repeatedly it tries all  ;;  of completions and expansions.  Called repeatedly it tries all
31  ;;  possible completions in succession.  ;;  possible completions in succession.
32  ;;  Which kinds of completions to try, and in which order, is  ;;  Which kinds of completions to try, and in which order, is
33  ;;  determined by the contents of `hippie-expand-try-functions-list'.  ;;  determined by the contents of `hippie-expand-try-functions-list'.
34  ;;  Much customization of `hippie-expand' can be made by changing the  ;;  Much customization of `hippie-expand' can be made by changing the
# Line 61  Line 61 
61  ;;  characters of syntax '_' is considered part of the words to expand  ;;  characters of syntax '_' is considered part of the words to expand
62  ;;  dynamically.  ;;  dynamically.
63  ;;  See also the macro `make-hippie-expand-function' below.  ;;  See also the macro `make-hippie-expand-function' below.
64  ;;    ;;
65  ;;  A short description of the current try-functions in this file:  ;;  A short description of the current try-functions in this file:
66  ;;    `try-complete-file-name' : very convenient to have in any buffer,  ;;    `try-complete-file-name' : very convenient to have in any buffer,
67  ;;      and not just in the minibuffer or (some) shell-mode.  It goes  ;;      and not just in the minibuffer or (some) shell-mode.  It goes
# Line 72  Line 72 
72  ;;      a file name completed only as many characters as is unique.  ;;      a file name completed only as many characters as is unique.
73  ;;    `try-expand-all-abbrevs' : can be removed if you don't use abbrevs.  ;;    `try-expand-all-abbrevs' : can be removed if you don't use abbrevs.
74  ;;      Otherwise it looks through all abbrev-tables, starting with  ;;      Otherwise it looks through all abbrev-tables, starting with
75  ;;      the local followed by the global.  ;;      the local followed by the global.
76  ;;    `try-expand-line' : Searches the buffer for an entire line that  ;;    `try-expand-line' : Searches the buffer for an entire line that
77  ;;      begins exactly as the current line.  Convenient sometimes, for  ;;      begins exactly as the current line.  Convenient sometimes, for
78  ;;      example as a substitute for (or complement to) the history  ;;      example as a substitute for (or complement to) the history
79  ;;      list in shell-like buffers.  At other times, only confusing.  ;;      list in shell-like buffers.  At other times, only confusing.
80  ;;    `try-expand-line-all-buffers' : Like `try-expand-line' but searches  ;;    `try-expand-line-all-buffers' : Like `try-expand-line' but searches
# Line 83  Line 83 
83  ;;    `try-expand-list' : Tries to expand the text back to the nearest  ;;    `try-expand-list' : Tries to expand the text back to the nearest
84  ;;      open delimiter, to a whole list from the buffer. Convenient for  ;;      open delimiter, to a whole list from the buffer. Convenient for
85  ;;      example when writing lisp or TeX.  ;;      example when writing lisp or TeX.
86  ;;    `try-expand-list-all-buffers' : Like `try-expand-list' but searches  ;;    `try-expand-list-all-buffers' : Like `try-expand-list' but searches
87  ;;      in all buffers (except the current).    ;;      in all buffers (except the current).
88  ;;    `try-expand-dabbrev' : works exactly as dabbrev-expand (but of  ;;    `try-expand-dabbrev' : works exactly as dabbrev-expand (but of
89  ;;      course in a way compatible with the other try-functions).  ;;      course in a way compatible with the other try-functions).
90  ;;    `try-expand-dabbrev-all-buffers' : perhaps the most useful of them,  ;;    `try-expand-dabbrev-all-buffers' : perhaps the most useful of them,
91  ;;      like `dabbrev-expand' but searches all Emacs buffers (except the  ;;      like `dabbrev-expand' but searches all Emacs buffers (except the
92  ;;      current) for matching words.  (No, I don't find this one  ;;      current) for matching words.  (No, I don't find this one
93  ;;      particularly slow.)  ;;      particularly slow.)
94  ;;    `try-expand-dabbrev-visible': Searches the currently visible parts of  ;;    `try-expand-dabbrev-visible': Searches the currently visible parts of
95  ;;      all windows.  Can be put before `try-expand-dabbrev-all-buffers' to  ;;      all windows.  Can be put before `try-expand-dabbrev-all-buffers' to
96  ;;      first try the expansions you can see.  ;;      first try the expansions you can see.
# Line 108  Line 108 
108  ;;      already has a key of its own, you might want to remove this.  ;;      already has a key of its own, you might want to remove this.
109  ;;    `try-complete-lisp-symbol-partially' : To insert in the list just  ;;    `try-complete-lisp-symbol-partially' : To insert in the list just
110  ;;      before `try-complete-lisp-symbol' for those who first want to get  ;;      before `try-complete-lisp-symbol' for those who first want to get
111  ;;      completion of what is unique in the name.    ;;      completion of what is unique in the name.
112  ;;  ;;
113  ;;  Not all of the above functions are by default in  ;;  Not all of the above functions are by default in
114  ;;  `hippie-expand-try-functions-list'.  This variable is better set  ;;  `hippie-expand-try-functions-list'.  This variable is better set
# Line 143  Line 143 
143  ;;    `he-reset-string' : Resets the initialized region to its original  ;;    `he-reset-string' : Resets the initialized region to its original
144  ;;      contents.  ;;      contents.
145  ;;  There is also a variable: `he-tried-table' which is meant to contain  ;;  There is also a variable: `he-tried-table' which is meant to contain
146  ;;  all tried expansions so far.  The try-function can check this  ;;  all tried expansions so far.  The try-function can check this
147  ;;  variable to see whether an expansion has already been tried  ;;  variable to see whether an expansion has already been tried
148  ;;  (hint: `he-string-member').  ;;  (hint: `he-string-member').
149  ;;  ;;
150  ;;  Known bugs  ;;  Known bugs
151  ;;  ;;
152  ;;  It may happen that some completion suggestion occurs twice, in  ;;  It may happen that some completion suggestion occurs twice, in
153  ;;  spite of the use of `he-tried-table' to prevent that.  This is  ;;  spite of the use of `he-tried-table' to prevent that.  This is
154  ;;  because different try-functions may try to complete different  ;;  because different try-functions may try to complete different
155  ;;  lengths of text, and thus put different amounts of the  ;;  lengths of text, and thus put different amounts of the
156  ;;  text in `he-tried-table'.  Anyway this seems to occur seldom enough  ;;  text in `he-tried-table'.  Anyway this seems to occur seldom enough
# Line 274  Can contain both regexps matching buffer Line 274  Can contain both regexps matching buffer
274  The expansion functions in `hippie-expand-try-functions-list' are  The expansion functions in `hippie-expand-try-functions-list' are
275  tried in order, until a possible expansion is found.  Repeated  tried in order, until a possible expansion is found.  Repeated
276  application of `hippie-expand' inserts successively possible  application of `hippie-expand' inserts successively possible
277  expansions.    expansions.
278  With a positive numeric argument, jumps directly to the ARG next  With a positive numeric argument, jumps directly to the ARG next
279  function in this list.  With a negative argument or just \\[universal-argument],  function in this list.  With a negative argument or just \\[universal-argument],
280  undoes the expansion."  undoes the expansion."
281    (interactive "P")    (interactive "P")
282    (if (or (not arg)    (if (or (not arg)
283            (and (integerp arg) (> arg 0)))            (and (integerp arg) (> arg 0)))
284        (let ((first (or (= he-num -1)        (let ((first (or (= he-num -1)
285                         (not (equal this-command last-command)))))                         (not (equal this-command last-command)))))
# Line 292  undoes the expansion." Line 292  undoes the expansion."
292              (setq arg 0))              (setq arg 0))
293          (let ((i (max (+ he-num arg) 0)))          (let ((i (max (+ he-num arg) 0)))
294            (while (not (or (>= i (length hippie-expand-try-functions-list))            (while (not (or (>= i (length hippie-expand-try-functions-list))
295                            (apply (nth i hippie-expand-try-functions-list)                            (apply (nth i hippie-expand-try-functions-list)
296                                   (list (= he-num i)))))                                   (list (= he-num i)))))
297              (setq i (1+ i)))              (setq i (1+ i)))
298            (setq he-num i))            (setq he-num i))
# Line 331  undoes the expansion." Line 331  undoes the expansion."
331      (goto-char newpos)))      (goto-char newpos)))
332    
333  ;; Substitutes an expansion STR into the correct region (the region  ;; Substitutes an expansion STR into the correct region (the region
334  ;; initialized with `he-init-string').  ;; initialized with `he-init-string').
335  ;; An optional argument TRANS-CASE means that it is ok to transfer case  ;; An optional argument TRANS-CASE means that it is ok to transfer case
336  ;; from the abbreviation to the expansion if that is possible, and is  ;; from the abbreviation to the expansion if that is possible, and is
337  ;; enabled in the buffer.  ;; enabled in the buffer.
# Line 413  undoes the expansion." Line 413  undoes the expansion."
413  ;;    (fset 'my-complete-line (make-hippie-expand-function  ;;    (fset 'my-complete-line (make-hippie-expand-function
414  ;;                             '(try-expand-line  ;;                             '(try-expand-line
415  ;;                               try-expand-line-all-buffers)))  ;;                               try-expand-line-all-buffers)))
416  ;;    ;;
417  ;;;###autoload  ;;;###autoload
418  (defmacro make-hippie-expand-function (try-list &optional verbose)  (defmacro make-hippie-expand-function (try-list &optional verbose)
419    "Construct a function similar to `hippie-expand'.    "Construct a function similar to `hippie-expand'.
420  Make it use the expansion functions in TRY-LIST.  An optional second  Make it use the expansion functions in TRY-LIST.  An optional second
421  argument VERBOSE non-nil makes the function verbose."  argument VERBOSE non-nil makes the function verbose."
422    `(function (lambda (arg)    `(function (lambda (arg)
423      ,(concat      ,(concat
424        "Try to expand text before point, using the following functions: \n"        "Try to expand text before point, using the following functions: \n"
425        (mapconcat 'prin1-to-string (eval try-list) ", "))        (mapconcat 'prin1-to-string (eval try-list) ", "))
426      (interactive "P")      (interactive "P")
# Line 438  The argument OLD has to be nil the first Line 438  The argument OLD has to be nil the first
438  for subsequent calls (for further possible completions of the same  for subsequent calls (for further possible completions of the same
439  string).  It returns t if a new completion is found, nil otherwise."  string).  It returns t if a new completion is found, nil otherwise."
440    (if (not old)    (if (not old)
441        (progn        (progn
442          (he-init-string (he-file-name-beg) (point))          (he-init-string (he-file-name-beg) (point))
443          (let ((name-part (he-file-name-nondirectory he-search-string))          (let ((name-part (he-file-name-nondirectory he-search-string))
444                (dir-part (expand-file-name (or (he-file-name-directory                (dir-part (expand-file-name (or (he-file-name-directory
# Line 447  string).  It returns t if a new completi Line 447  string).  It returns t if a new completi
447                (setq he-tried-table (cons name-part he-tried-table)))                (setq he-tried-table (cons name-part he-tried-table)))
448            (if (and (not (equal he-search-string ""))            (if (and (not (equal he-search-string ""))
449                     (he-file-directory-p dir-part))                     (he-file-directory-p dir-part))
450                (setq he-expand-list (sort (file-name-all-completions                (setq he-expand-list (sort (file-name-all-completions
451                                            name-part                                            name-part
452                                            dir-part)                                            dir-part)
453                                           'string-lessp))                                           'string-lessp))
# Line 471  string).  It returns t if a new completi Line 471  string).  It returns t if a new completi
471  (defun try-complete-file-name-partially (old)  (defun try-complete-file-name-partially (old)
472    "Try to complete text as a file name, as many characters as unique.    "Try to complete text as a file name, as many characters as unique.
473  The argument OLD has to be nil the first call of this function.  It  The argument OLD has to be nil the first call of this function.  It
474  returns t if a unique, possibly partial, completion is found, nil  returns t if a unique, possibly partial, completion is found, nil
475  otherwise."  otherwise."
476    (let ((expansion ()))    (let ((expansion ()))
477      (if (not old)      (if (not old)
478          (progn          (progn
479            (he-init-string (he-file-name-beg) (point))            (he-init-string (he-file-name-beg) (point))
480            (let ((name-part (he-file-name-nondirectory he-search-string))            (let ((name-part (he-file-name-nondirectory he-search-string))
481                  (dir-part (expand-file-name (or (he-file-name-directory                  (dir-part (expand-file-name (or (he-file-name-directory
# Line 503  otherwise." Line 503  otherwise."
503  (defvar he-file-name-chars  (defvar he-file-name-chars
504    (cond ((memq system-type '(vax-vms axp-vms))    (cond ((memq system-type '(vax-vms axp-vms))
505           "-a-zA-Z0-9_/.,~^#$+=:\\[\\]")           "-a-zA-Z0-9_/.,~^#$+=:\\[\\]")
506          ((memq system-type '(ms-dos windows-nt))          ((memq system-type '(ms-dos windows-nt cygwin))
507           "-a-zA-Z0-9_/.,~^#$+=:\\\\")           "-a-zA-Z0-9_/.,~^#$+=:\\\\")
508          (t                          ;; More strange file formats ?          (t                          ;; More strange file formats ?
509           "-a-zA-Z0-9_/.,~^#$+="))           "-a-zA-Z0-9_/.,~^#$+="))
# Line 518  otherwise." Line 518  otherwise."
518          (point)))))          (point)))))
519    
520  ;; Thanks go to Richard Levitte <levitte@e.kth.se> who helped to make these  ;; Thanks go to Richard Levitte <levitte@e.kth.se> who helped to make these
521  ;; work under VMS, and to David Hughes <ukchugd@ukpmr.cs.philips.nl> who  ;; work under VMS, and to David Hughes <ukchugd@ukpmr.cs.philips.nl> who
522  ;; helped to make it work on PC.  ;; helped to make it work on PC.
523  (defun he-file-name-nondirectory (file)  (defun he-file-name-nondirectory (file)
524    "Fix to make `file-name-nondirectory' work for hippie-expand under VMS."    "Fix to make `file-name-nondirectory' work for hippie-expand under VMS."
# Line 545  otherwise." Line 545  otherwise."
545        (or (file-directory-p file)        (or (file-directory-p file)
546            (file-directory-p (concat file "[000000]")))            (file-directory-p (concat file "[000000]")))
547      (file-directory-p file)))      (file-directory-p file)))
548      
549  (defun he-concat-directory-file-name (dir-part name-part)  (defun he-concat-directory-file-name (dir-part name-part)
550    "Try to slam together two parts of a file specification, system dependently."    "Try to slam together two parts of a file specification, system dependently."
551    (cond ((null dir-part) name-part)    (cond ((null dir-part) name-part)
# Line 560  otherwise." Line 560  otherwise."
560                    (= (aref name-part (1- (length name-part))) ?/))                    (= (aref name-part (1- (length name-part))) ?/))
561               (aset name-part (1- (length name-part)) ?\\))               (aset name-part (1- (length name-part)) ?\\))
562           (concat dir-part name-part))           (concat dir-part name-part))
563          (t          (t
564           (concat dir-part name-part))))           (concat dir-part name-part))))
565                            
566  (defun try-complete-lisp-symbol (old)  (defun try-complete-lisp-symbol (old)
567    "Try to complete word as an Emacs Lisp symbol.    "Try to complete word as an Emacs Lisp symbol.
568  The argument OLD has to be nil the first call of this function, and t  The argument OLD has to be nil the first call of this function, and t
569  for subsequent calls (for further possible completions of the same  for subsequent calls (for further possible completions of the same
570  string).  It returns t if a new completion is found, nil otherwise."  string).  It returns t if a new completion is found, nil otherwise."
571    (if (not old)    (if (not old)
572        (progn        (progn
573          (he-init-string (he-lisp-symbol-beg) (point))          (he-init-string (he-lisp-symbol-beg) (point))
574          (if (not (he-string-member he-search-string he-tried-table))          (if (not (he-string-member he-search-string he-tried-table))
575              (setq he-tried-table (cons he-search-string he-tried-table)))              (setq he-tried-table (cons he-search-string he-tried-table)))
576          (setq he-expand-list          (setq he-expand-list
577                (and (not (equal he-search-string ""))                (and (not (equal he-search-string ""))
578                     (sort (all-completions he-search-string obarray                     (sort (all-completions he-search-string obarray
579                                            (function (lambda (sym)                                            (function (lambda (sym)
# Line 596  string).  It returns t if a new completi Line 596  string).  It returns t if a new completi
596  (defun try-complete-lisp-symbol-partially (old)  (defun try-complete-lisp-symbol-partially (old)
597    "Try to complete as an Emacs Lisp symbol, as many characters as unique.    "Try to complete as an Emacs Lisp symbol, as many characters as unique.
598  The argument OLD has to be nil the first call of this function.  It  The argument OLD has to be nil the first call of this function.  It
599  returns t if a unique, possibly partial, completion is found, nil  returns t if a unique, possibly partial, completion is found, nil
600  otherwise."  otherwise."
601    (let ((expansion ()))    (let ((expansion ()))
602      (if (not old)      (if (not old)
603          (progn          (progn
604            (he-init-string (he-lisp-symbol-beg) (point))            (he-init-string (he-lisp-symbol-beg) (point))
605            (if (not (string= he-search-string ""))            (if (not (string= he-search-string ""))
606                (setq expansion                (setq expansion
607                      (try-completion he-search-string obarray                      (try-completion he-search-string obarray
608                                      (function (lambda (sym)                                      (function (lambda (sym)
609                                        (or (boundp sym)                                        (or (boundp sym)
# Line 649  string).  It returns t if a new completi Line 649  string).  It returns t if a new completi
649                  (widen))                  (widen))
650              ;; Try looking backward unless inhibited.              ;; Try looking backward unless inhibited.
651              (if he-search-bw              (if he-search-bw
652                  (progn                  (progn
653                    (goto-char he-search-loc)                    (goto-char he-search-loc)
654                    (setq expansion (he-line-search he-search-string                    (setq expansion (he-line-search he-search-string
655                                                    strip-prompt t))                                                    strip-prompt t))
# Line 660  string).  It returns t if a new completi Line 660  string).  It returns t if a new completi
660                          (setq he-search-bw ())))))                          (setq he-search-bw ())))))
661    
662              (if (not expansion) ; Then look forward.              (if (not expansion) ; Then look forward.
663                  (progn                  (progn
664                    (goto-char he-search-loc)                    (goto-char he-search-loc)
665                    (setq expansion (he-line-search he-search-string                    (setq expansion (he-line-search he-search-string
666                                                    strip-prompt nil))                                                    strip-prompt nil))
667                    (set-marker he-search-loc (point)))))))                    (set-marker he-search-loc (point)))))))
668    
# Line 693  string).  It returns t if a new completi Line 693  string).  It returns t if a new completi
693            (set-marker he-search-loc 1 (car he-search-bufs))))            (set-marker he-search-loc 1 (car he-search-bufs))))
694    
695      (if (not (equal he-search-string ""))      (if (not (equal he-search-string ""))
696          (while (and he-search-bufs          (while (and he-search-bufs
697                      (not expansion)                      (not expansion)
698                      (or (not hippie-expand-max-buffers)                      (or (not hippie-expand-max-buffers)
699                          (< he-searched-n-bufs hippie-expand-max-buffers)))                          (< he-searched-n-bufs hippie-expand-max-buffers)))
# Line 710  string).  It returns t if a new completi Line 710  string).  It returns t if a new completi
710                    (setq strip-prompt (and (get-buffer-process (current-buffer))                    (setq strip-prompt (and (get-buffer-process (current-buffer))
711                                            comint-use-prompt-regexp-instead-of-fields                                            comint-use-prompt-regexp-instead-of-fields
712                                            comint-prompt-regexp))                                            comint-prompt-regexp))
713                    (setq expansion                    (setq expansion
714                          (let ((case-fold-search orig-case-fold-search))                          (let ((case-fold-search orig-case-fold-search))
715                            (he-line-search he-search-string                            (he-line-search he-search-string
716                                            strip-prompt nil)))                                            strip-prompt nil)))
# Line 732  string).  It returns t if a new completi Line 732  string).  It returns t if a new completi
732            (he-substitute-string expansion t)            (he-substitute-string expansion t)
733            t))))            t))))
734    
735  (defun he-line-search (str strip-prompt reverse)  (defun he-line-search (str strip-prompt reverse)
736    (let ((result ()))    (let ((result ()))
737      (while (and (not result)      (while (and (not result)
738                  (if reverse                  (if reverse
739                      (re-search-backward                      (re-search-backward
740                       (he-line-search-regexp str strip-prompt)                       (he-line-search-regexp str strip-prompt)
741                       nil t)                       nil t)
742                      (re-search-forward                      (re-search-forward
# Line 750  string).  It returns t if a new completi Line 750  string).  It returns t if a new completi
750    
751  (defun he-line-beg (strip-prompt)  (defun he-line-beg (strip-prompt)
752    (save-excursion    (save-excursion
753      (if (re-search-backward (he-line-search-regexp "" strip-prompt)      (if (re-search-backward (he-line-search-regexp "" strip-prompt)
754                              (save-excursion (beginning-of-line)                              (save-excursion (beginning-of-line)
755                                              (point)) t)                                              (point)) t)
756          (match-beginning 2)          (match-beginning 2)
# Line 761  string).  It returns t if a new completi Line 761  string).  It returns t if a new completi
761        (concat "\\(" comint-prompt-regexp "\\|^\\s-*\\)\\("        (concat "\\(" comint-prompt-regexp "\\|^\\s-*\\)\\("
762                (regexp-quote pat)                (regexp-quote pat)
763                "[^\n]*[^ \t\n]\\)")                "[^\n]*[^ \t\n]\\)")
764        (concat "^\\(\\s-*\\)\\("        (concat "^\\(\\s-*\\)\\("
765                (regexp-quote pat)                (regexp-quote pat)
766                "[^\n]*[^ \t\n]\\)")))                "[^\n]*[^ \t\n]\\)")))
767    
# Line 784  string).  It returns t if a new completi Line 784  string).  It returns t if a new completi
784                  (widen))                  (widen))
785              ;; Try looking backward unless inhibited.              ;; Try looking backward unless inhibited.
786              (if he-search-bw              (if he-search-bw
787                  (progn                  (progn
788                    (goto-char he-search-loc)                    (goto-char he-search-loc)
789                    (setq expansion (he-list-search he-search-string t))                    (setq expansion (he-list-search he-search-string t))
790                    (set-marker he-search-loc (point))                    (set-marker he-search-loc (point))
# Line 794  string).  It returns t if a new completi Line 794  string).  It returns t if a new completi
794                          (setq he-search-bw ())))))                          (setq he-search-bw ())))))
795    
796              (if (not expansion) ; Then look forward.              (if (not expansion) ; Then look forward.
797                  (progn                  (progn
798                    (goto-char he-search-loc)                    (goto-char he-search-loc)
799                    (setq expansion (he-list-search he-search-string nil))                    (setq expansion (he-list-search he-search-string nil))
800                    (set-marker he-search-loc (point)))))))                    (set-marker he-search-loc (point)))))))
# Line 823  string).  It returns t if a new completi Line 823  string).  It returns t if a new completi
823            (set-marker he-search-loc 1 (car he-search-bufs))))            (set-marker he-search-loc 1 (car he-search-bufs))))
824    
825      (if (not (equal he-search-string ""))      (if (not (equal he-search-string ""))
826          (while (and he-search-bufs          (while (and he-search-bufs
827                      (not expansion)                      (not expansion)
828                      (or (not hippie-expand-max-buffers)                      (or (not hippie-expand-max-buffers)
829                          (< he-searched-n-bufs hippie-expand-max-buffers)))                          (< he-searched-n-bufs hippie-expand-max-buffers)))
# Line 837  string).  It returns t if a new completi Line 837  string).  It returns t if a new completi
837                    (if hippie-expand-no-restriction                    (if hippie-expand-no-restriction
838                        (widen))                        (widen))
839                    (goto-char he-search-loc)                    (goto-char he-search-loc)
840                    (setq expansion                    (setq expansion
841                          (let ((case-fold-search orig-case-fold-search))                          (let ((case-fold-search orig-case-fold-search))
842                            (he-list-search he-search-string nil)))                            (he-list-search he-search-string nil)))
843                    (set-marker he-search-loc (point))                    (set-marker he-search-loc (point))
# Line 858  string).  It returns t if a new completi Line 858  string).  It returns t if a new completi
858            (he-substitute-string expansion t)            (he-substitute-string expansion t)
859            t))))            t))))
860    
861  (defun he-list-search (str reverse)  (defun he-list-search (str reverse)
862    (let ((result ())    (let ((result ())
863          beg pos err)          beg pos err)
864      (while (and (not result)      (while (and (not result)
# Line 872  string).  It returns t if a new completi Line 872  string).  It returns t if a new completi
872        (condition-case ()        (condition-case ()
873            (forward-list 1)            (forward-list 1)
874          (error (setq err t)))          (error (setq err t)))
875        (if (and reverse        (if (and reverse
876                 (> (point) he-string-beg))                 (> (point) he-string-beg))
877            (setq err t))            (setq err t))
878        (if (not err)        (if (not err)
# Line 898  string).  It returns t if a new expansio Line 898  string).  It returns t if a new expansio
898    (if (not old)    (if (not old)
899        (progn        (progn
900          (he-init-string (he-dabbrev-beg) (point))          (he-init-string (he-dabbrev-beg) (point))
901          (setq he-expand-list          (setq he-expand-list
902                (and (not (equal he-search-string ""))                (and (not (equal he-search-string ""))
903                     (mapcar (function (lambda (sym)                     (mapcar (function (lambda (sym)
904                               (if (and (boundp sym) (vectorp (eval sym)))                               (if (and (boundp sym) (vectorp (eval sym)))
905                                   (abbrev-expansion (downcase he-search-string)                                   (abbrev-expansion (downcase he-search-string)
906                                                     (eval sym)))))                                                     (eval sym)))))
907                             (append '(local-abbrev-table                             (append '(local-abbrev-table
908                                       global-abbrev-table)                                       global-abbrev-table)
909                                     abbrev-table-name-list))))))                                     abbrev-table-name-list))))))
910    (while (and he-expand-list    (while (and he-expand-list
# Line 939  string).  It returns t if a new expansio Line 939  string).  It returns t if a new expansio
939                  (widen))                  (widen))
940              ;; Try looking backward unless inhibited.              ;; Try looking backward unless inhibited.
941              (if he-search-bw              (if he-search-bw
942                  (progn                  (progn
943                    (goto-char he-search-loc)                    (goto-char he-search-loc)
944                    (setq expansion (he-dabbrev-search he-search-string t))                    (setq expansion (he-dabbrev-search he-search-string t))
945                    (set-marker he-search-loc (point))                    (set-marker he-search-loc (point))
# Line 949  string).  It returns t if a new expansio Line 949  string).  It returns t if a new expansio
949                          (setq he-search-bw ())))))                          (setq he-search-bw ())))))
950    
951              (if (not expansion) ; Then look forward.              (if (not expansion) ; Then look forward.
952                  (progn                  (progn
953                    (goto-char he-search-loc)                    (goto-char he-search-loc)
954                    (setq expansion (he-dabbrev-search he-search-string nil))                    (setq expansion (he-dabbrev-search he-search-string nil))
955                    (set-marker he-search-loc (point)))))))                    (set-marker he-search-loc (point)))))))
956            
957      (if (not expansion)      (if (not expansion)
958          (progn          (progn
959            (if old (he-reset-string))            (if old (he-reset-string))
# Line 978  string).  It returns t if a new expansio Line 978  string).  It returns t if a new expansio
978            (set-marker he-search-loc 1 (car he-search-bufs))))            (set-marker he-search-loc 1 (car he-search-bufs))))
979    
980      (if (not (equal he-search-string ""))      (if (not (equal he-search-string ""))
981          (while (and he-search-bufs          (while (and he-search-bufs
982                      (not expansion)                      (not expansion)
983                      (or (not hippie-expand-max-buffers)                      (or (not hippie-expand-max-buffers)
984                          (< he-searched-n-bufs hippie-expand-max-buffers)))                          (< he-searched-n-bufs hippie-expand-max-buffers)))
# Line 1047  string).  It returns t if a new expansio Line 1047  string).  It returns t if a new expansio
1047                                                 (window-end he-search-window))))                                                 (window-end he-search-window))))
1048          (set-marker he-search-loc (point) (current-buffer)))          (set-marker he-search-loc (point) (current-buffer)))
1049        (if (not expansion)        (if (not expansion)
1050            (progn            (progn
1051              (setq he-search-window (next-window he-search-window nil flag))              (setq he-search-window (next-window he-search-window nil flag))
1052              (if (eq he-search-window (selected-window))              (if (eq he-search-window (selected-window))
1053                  (set-marker he-search-loc nil)                  (set-marker he-search-loc nil)
1054                (set-marker he-search-loc (window-start he-search-window)                (set-marker he-search-loc (window-start he-search-window)
1055                            (window-buffer he-search-window))))))                            (window-buffer he-search-window))))))
1056        
1057      (set-buffer buf)      (set-buffer buf)
1058      (if (not expansion)      (if (not expansion)
1059          (progn          (progn
# Line 1072  string).  It returns t if a new expansio Line 1072  string).  It returns t if a new expansio
1072                        (t                        (t
1073                         (concat "\\<" (regexp-quote pattern)                         (concat "\\<" (regexp-quote pattern)
1074                                 "\\(\\sw\\|\\s_\\)+")))))                                 "\\(\\sw\\|\\s_\\)+")))))
1075      (while (and (not result)      (while (and (not result)
1076                  (if reverse                  (if reverse
1077                       (re-search-backward regpat limit t)                       (re-search-backward regpat limit t)
1078                       (re-search-forward regpat limit t)))                       (re-search-forward regpat limit t)))
# Line 1104  for subsequent calls (for further possib Line 1104  for subsequent calls (for further possib
1104  string).  It returns t if a new completion is found, nil otherwise."  string).  It returns t if a new completion is found, nil otherwise."
1105    (let ((expansion ()))    (let ((expansion ()))
1106      (if (not old)      (if (not old)
1107          (progn          (progn
1108            (he-init-string (he-dabbrev-beg) (point))            (he-init-string (he-dabbrev-beg) (point))
1109            (setq he-expand-list            (setq he-expand-list
1110                  (if (not (equal he-search-string ""))                  (if (not (equal he-search-string ""))
# Line 1130  string).  It returns t if a new completi Line 1130  string).  It returns t if a new completi
1130                         (concat "\\<" (regexp-quote pattern)                         (concat "\\<" (regexp-quote pattern)
1131                                 "\\(\\sw\\|\\s_\\)+"))))                                 "\\(\\sw\\|\\s_\\)+"))))
1132          (killstr (car he-expand-list)))          (killstr (car he-expand-list)))
1133      (while (and (not result)      (while (and (not result)
1134                  he-expand-list)                  he-expand-list)
1135        (while (and (not result)        (while (and (not result)
1136                    (string-match regpat killstr he-search-loc2))                    (string-match regpat killstr he-search-loc2))
# Line 1143  string).  It returns t if a new completi Line 1143  string).  It returns t if a new completi
1143                             '(?_ ?w)))                             '(?_ ?w)))
1144                  (he-string-member result he-tried-table t))                  (he-string-member result he-tried-table t))
1145              (setq result nil)))     ; ignore if bad prefix or already in table              (setq result nil)))     ; ignore if bad prefix or already in table
1146        (if (and (not result)        (if (and (not result)
1147                  he-expand-list)                  he-expand-list)
1148            (progn            (progn
1149              (setq he-expand-list (cdr he-expand-list))              (setq he-expand-list (cdr he-expand-list))
1150              (setq killstr (car he-expand-list))              (setq killstr (car he-expand-list))
1151              (setq he-search-loc2 0))))              (setq he-search-loc2 0))))
1152      result))      result))
# Line 1158  for subsequent calls (for further possib Line 1158  for subsequent calls (for further possib
1158  string).  It returns t if a new completion is found, nil otherwise."  string).  It returns t if a new completion is found, nil otherwise."
1159    (let ((expansion ()))    (let ((expansion ()))
1160      (if (not old)      (if (not old)
1161          (progn          (progn
1162            (he-init-string (he-kill-beg) (point))            (he-init-string (he-kill-beg) (point))
1163            (if (not (he-string-member he-search-string he-tried-table))            (if (not (he-string-member he-search-string he-tried-table))
1164                (setq he-tried-table (cons he-search-string he-tried-table)))                (setq he-tried-table (cons he-search-string he-tried-table)))
1165            (setq he-expand-list            (setq he-expand-list
1166                  (if (not (equal he-search-string ""))                  (if (not (equal he-search-string ""))
1167                      kill-ring))                      kill-ring))
1168            (setq he-search-loc2 ())))            (setq he-search-loc2 ())))
# Line 1206  string).  It returns t if a new completi Line 1206  string).  It returns t if a new completi
1206        (if (and (not result)        (if (and (not result)
1207                  he-expand-list)                  he-expand-list)
1208            (progn            (progn
1209              (setq he-expand-list (cdr he-expand-list))              (setq he-expand-list (cdr he-expand-list))
1210              (setq killstr (car he-expand-list))              (setq killstr (car he-expand-list))
1211              (setq pos -1))))              (setq pos -1))))
1212      result))      result))

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.24.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26