emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: propose: dired-isearch.el --- isearch in Dired


From: Herbert Euler
Subject: RE: propose: dired-isearch.el --- isearch in Dired
Date: Thu, 09 Aug 2007 10:37:16 +0800

Without applying Juri's proposal, this is an implementation that
resolves both the two bugs mentioned in my previous message: the
regexp "^" bug and searching goes into fields other than file names
bug.  I think other functions (e.g. dired-re-search-backward) can be
implemented this way too.

(defun dired-next-file-name (point bound)
 (let* ((start (cond ((= point 1)
                      (if (get-char-property point 'help-echo)
                          point
                        (next-single-property-change point 'help-echo)))
                     ((get-char-property point 'help-echo)
                      (if (get-char-property (1- point) 'help-echo)
                          (progn
                            (setq point
                                  (next-single-property-change point
                                                               'help-echo))
                            (next-single-property-change point 'help-echo))
                        point))
                     (t
                      (next-single-property-change point 'help-echo))))
        (end (when start
               (next-single-property-change start 'help-echo))))
   (when (and end (< end bound))
     (goto-char start)
     (buffer-substring start end))))

(defun dired-re-search-forward (regexp &optional bound noerror count)
 "In Dired, run `re-search-forward' but match only at file names."
 (let ((start (point))
       (not-found nil)
       name
       match-data)
   (save-excursion
     (unless bound
       (setq bound (point-max)))
     (while (and (prog1 (setq name (dired-next-file-name start bound))
                   (unless name (setq not-found t)))
                 (not (string-match regexp name)))
       (setq start (1+ (point))))
     (unless not-found
       (setq match-data (list (+ (point) (match-beginning 0))
                              (+ (point) (match-end 0))))
       (set-match-data match-data)
       (nth 1 match-data)))))

Please consider rewriting other functions this way.

Regards,
Guanpeng Xu

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]