emacs-devel
[Top][All Lists]
Advanced

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

Re: next-error refactoring


From: Ted Zlatanov
Subject: Re: next-error refactoring
Date: Wed, 15 Sep 2004 14:08:24 -0400
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

On Tue, 14 Sep 2004, address@hidden wrote:

> I think dired-use-next-error would be a better name.
> 
> First line of doc string should be on one line.

Here's the corrected version of the patch. Thank you for the help.

In case anyone is wondering, this is generally useful for visiting the
next/previous file listed in dired (only next works now).

Ted

*** /usr/src/emacs/lisp/dired.el        Wed Jul 14 18:59:08 2004
--- /home/tzz/emacs/mine/dired.el       Wed Sep 15 14:13:25 2004
***************
*** 215,220 ****
--- 215,228 ----
    :type '(alist :key-type regexp :value-type string)
    :version "21.4")
  
+ ;; should we use next-error support?
+ (defcustom dired-use-next-error nil
+   "Non-nil means to enable `next-error' in dired buffers.
+ You can then use \\[next-error] to visit the matches
+ found by `grep-find-dired', `dired-do-search', etc."
+   :group 'dired
+   :type 'boolean)
+ 
  ;; Internal variables
  
  (defvar dired-marker-char ?*          ; the answer is 42
***************
*** 1397,1402 ****
--- 1405,1412 ----
        selective-display t             ; for subdirectory hiding
        mode-line-buffer-identification
        (propertized-buffer-identification "%17b"))
+   (when dired-next-error-support
+     (setq next-error-function 'dired-next-error))
    (set (make-local-variable 'revert-buffer-function)
         (function dired-revert))
    (set (make-local-variable 'buffer-stale-function)
***************
*** 1450,1455 ****
--- 1460,1491 ----
    (message "Change in Dired buffer undone.
  Actual changes in files cannot be undone by Emacs."))
  
+ (defun dired-next-error (&optional argp reset)
+   "Move to the ARGP (default 1) next match in an Dired mode buffer.
+ When RESET is given, starts from the beginning.
+ Compatibility function for \\[next-error] invocations."
+   (interactive "p")
+ 
+   (when reset
+     ;; go to beginning of buffer
+     (goto-char (point-min)))
+   
+   (dired-next-error-move-n-file-lines 
+    (prefix-numeric-value argp))
+ 
+   ;; visit file if possible
+   (when (dired-get-filename nil t)
+     (dired-find-file)))
+ 
+ (defun dired-next-error-move-n-file-lines (argp)
+   "Move ARGP file lines from the current line.
+ File lines are lines with a file listed in them.
+ ONLY SUPPORT POSITIVE MOTION FOR NOW"
+   (when (> argp 0)
+     (dotimes (n argp)
+       (forward-line 1)
+       (dired-goto-next-nontrivial-file))))
+ 
  (defun dired-next-line (arg)
    "Move down lines then position at filename.
  Optional prefix ARG says how many lines to move; default is one line."

reply via email to

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