[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Thu, 18 Mar 2004 15:42:11 +0000
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)
This mainly provides some useful highlighting of writable file
permissions in Dired without offending rms' sensibilities by making
security warnings paramount. There are some other obvious doc and
tidying changes. I think the `U' keybinding as an alternative to `*
!' -- which I can never remember -- is convenient and consistent with
2004-03-05 Dave Love <address@hidden>
* dired.el: Doc fixes.
(dired): Add :link to defgroup.
(dired-font-lock-keywords): Highlight group/world-writable files.
(dired-revert): Use dolist, not mapcar.
(dired-mode-map): Bind `U' to dired-unmark-all-marks.
(dired-mode): Add beginning-of-line to font-lock-defaults as
RCS file: /cvsroot/emacs/emacs/lisp/dired.el,v
retrieving revision 1.272
diff -u -p -u -r1.272 dired.el
--- dired.el 3 Feb 2004 16:55:30 -0000 1.272
+++ dired.el 5 Mar 2004 16:58:59 -0000
@@ -39,6 +39,7 @@
(defgroup dired nil
+ :link '(custom-manual "(emacs)Dired")
(defgroup dired-mark nil
@@ -192,6 +193,7 @@ with the buffer narrowed to the listing.
;; Note this can't simply be run inside function `dired-ls' as the hook
;; functions probably depend on the dired-subdir-alist to be OK.
+;; Fixme: This should use mailcap.
'(("[.]\\(ps\\|ps_pages\\|eps\\)\\'" . "gv -spartan -color -watch %s")
("[.]pdf\\'" . "xpdf %s")
@@ -308,6 +310,16 @@ Subexpression 2 must end right before th
;;; '(1 font-lock-comment-face)
;;; '(".+" (dired-move-to-filename) nil (0 font-lock-comment-face)))
+ ;; However, we don't need to highlight the file name, only the
+ ;; permissions, to win generally. -- fx.
+ ;; Fixme: we could also put text properties on the permission
+ ;; fields with keymaps to frob the permissions, somewhat a la XEmacs.
+ (list (concat dired-re-maybe-mark dired-re-inode-size
+ "[-d]....\\(w\\)..\\(w\\).") ; group writable
+ '(1 font-lock-warning-face))
+ (list (concat dired-re-maybe-mark dired-re-inode-size
+ "[-d]....\\(w\\)....") ; world writable
+ '(1 font-lock-comment-face))
@@ -327,12 +339,12 @@ Subexpression 2 must end right before th
;;; Macros must be defined before they are used, for the byte compiler.
-;; Mark all files for which CONDITION evals to non-nil.
-;; CONDITION is evaluated on each line, with point at beginning of line.
-;; MSG is a noun phrase for the type of files being marked.
-;; It should end with a noun that can be pluralized by adding `s'.
-;; Return value is the number of files marked, or nil if none were marked.
(defmacro dired-mark-if (predicate msg)
+ "Mark all files for which PREDICATE evals to non-nil.
+PREDICATE is evaluated on each line, with point at beginning of line.
+MSG is a noun phrase for the type of files being marked.
+It should end with a noun that can be pluralized by adding `s'.
+Return value is the number of files marked, or nil if none were marked."
`(let (buffer-read-only count)
(setq count 0)
@@ -618,10 +630,12 @@ If DIRNAME is already in a dired buffer,
;; Read in a new dired buffer
-;; dired-readin differs from dired-insert-subdir in that it accepts
-;; wildcards, erases the buffer, and builds the subdir-alist anew
-;; (including making it buffer-local and clearing it first).
(defun dired-readin ()
+ "Read in a new dired buffer.
+Differs from dired-insert-subdir in that it accepts
+wildcards, erases the buffer, and builds the subdir-alist anew
+\(including making it buffer-local and clearing it first)."
;; default-directory and dired-actual-switches must be buffer-local
;; and initialized by now.
@@ -742,6 +756,7 @@ If HDR is non-nil, insert a header line
;; Make the file names highlight when the mouse is on them.
(defun dired-insert-set-properties (beg end)
+ "Make the file names highlight when the mouse is on them."
(while (< (point) end)
@@ -760,10 +775,10 @@ If HDR is non-nil, insert a header line
;; Reverting a dired buffer
(defun dired-revert (&optional arg noconfirm)
- ;; Reread the dired buffer. Must also be called after
- ;; dired-actual-switches have changed.
- ;; Should not fail even on completely garbaged buffers.
- ;; Preserves old cursor, marks/flags, hidden-p.
+ "Reread the dired buffer.
+Must also be called after dired-actual-switches have changed.
+Should not fail even on completely garbaged buffers.
+Preserves old cursor, marks/flags, hidden-p."
(widen) ; just in case user narrowed
(let ((opoint (point))
(ofile (dired-get-filename nil t))
@@ -790,10 +805,9 @@ If HDR is non-nil, insert a header line
(goto-char opoint)) ; was before
(save-excursion ; hide subdirs that were hidden
- (mapcar (function (lambda (dir)
- (if (dired-goto-subdir dir)
- (dired-hide-subdir 1))))
+ (dolist (dir hidden-subdirs)
+ (if (dired-goto-subdir dir)
+ (dired-hide-subdir 1)))))
;; outside of the let scope
;;; Might as well not override the user if the user changed this.
;;; (setq buffer-read-only t)
@@ -803,7 +817,7 @@ If HDR is non-nil, insert a header line
;; Some of these are also used when inserting subdirs.
(defun dired-remember-marks (beg end)
- ;; Return alist of files and their marks, from BEG to END.
+ "Return alist of files and their marks, from BEG to END."
(if selective-display ; must unhide to make this work.
(subst-char-in-region beg end ?\r ?\n)))
@@ -816,9 +830,9 @@ If HDR is non-nil, insert a header line
alist (cons (cons fil chr) alist)))))
-;; Mark all files remembered in ALIST.
-;; Each element of ALIST looks like (FILE . MARKERCHAR).
(defun dired-mark-remembered (alist)
+ "Mark all files remembered in ALIST.
+Each element of ALIST looks like (FILE . MARKERCHAR)."
(let (elt fil chr)
(setq elt (car alist)
@@ -831,8 +845,8 @@ If HDR is non-nil, insert a header line
-;; Return a list of names of subdirs currently hidden.
(defun dired-remember-hidden ()
+ "Return a list of names of subdirs currently hidden."
(let ((l dired-subdir-alist) dir pos result)
(setq dir (car (car l))
@@ -844,9 +858,9 @@ If HDR is non-nil, insert a header line
(setq result (cons dir result))))
-;; Try to insert all subdirs that were displayed before,
-;; according to the former subdir alist OLD-SUBDIR-ALIST.
(defun dired-insert-old-subdirs (old-subdir-alist)
+ "Try to insert all subdirs that were displayed before.
+Do so according to the former subdir alist OLD-SUBDIR-ALIST."
(or (string-match "R" dired-actual-switches)
(let (elt dir)
@@ -859,15 +873,15 @@ If HDR is non-nil, insert a header line
-;; Remove directory DIR from any directory cache.
(defun dired-uncache (dir)
+ "Remove directory DIR from any directory cache."
(let ((handler (find-file-name-handler dir 'dired-uncache)))
(funcall handler 'dired-uncache dir))))
;; dired mode key bindings and initialization
-(defvar dired-mode-map nil "Local keymap for dired-mode buffers.")
+(defvar dired-mode-map nil "Local keymap for `dired-mode' buffers.")
;; This looks ugly when substitute-command-keys uses C-d instead d:
@@ -937,6 +951,7 @@ If HDR is non-nil, insert a header line
(define-key map "*u" 'dired-unmark)
(define-key map "*?" 'dired-unmark-all-files)
(define-key map "*!" 'dired-unmark-all-marks)
+ (define-key map "U" 'dired-unmark-all-marks)
(define-key map "*\177" 'dired-unmark-backward)
(define-key map "*\C-n" 'dired-next-marked-file)
(define-key map "*\C-p" 'dired-prev-marked-file)
@@ -1290,7 +1305,8 @@ Keybindings:
(set (make-local-variable 'dired-actual-switches)
(or switches dired-listing-switches))
- (set (make-local-variable 'font-lock-defaults) '(dired-font-lock-keywords t))
+ (set (make-local-variable 'font-lock-defaults)
+ '(dired-font-lock-keywords t nil nil beginning-of-line))
(dired-sort-other dired-actual-switches t)
(when (featurep 'x-dnd)
@@ -2617,11 +2633,13 @@ A prefix argument says to unflag those f
"auto save file")))
- (concat (regexp-opt
- '(".log" ".toc" ".dvi" ".bak" ".orig" ".rej" ".aux"))
- "*Regular expression to match \"garbage\" files for
+ ;; `log' here is dubious, ssince it's typically used for useful log
+ ;; files, not just TeX stuff. -- fx
+ "*Regular expression to match \"garbage\" files for
+ :type 'regexp
+ :group 'dired)
(defun dired-flag-garbage-files ()
"Flag for deletion all files that match `dired-garbage-files-regexp'."
- Dired changes,
Dave Love <=