unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Hansen <larsh@math.ku.dk>
Cc: emacs-devel@gnu.org
Subject: Re: desktop.el and minor modes
Date: Mon, 31 May 2004 18:38:22 +0200	[thread overview]
Message-ID: <40BB5F7E.9040900@math.ku.dk> (raw)
In-Reply-To: <87zn7opuu2.fsf@mail.jurta.org>

Juri Linkov wrote:

>Could you show a patch before installing it?  I doubt that your
>solution will be backward compatible.
>
The patch is shown below.

The dired-omit-files-p is kept as variable alias for backwards 
compatibility.
Function dired-omit-toggle has been replaced by functions 
dired-omit-mode and dired-mark-omitted. Clearly that is not backwards 
compatible. If that is a problem, we can simply keep dired-omit-toggle 
and remove dired-mark-omitted. IMHO it is a bit confusing to have 
dired-omit-mode as well as dired-omit-toggle, that's why I removed 
dired-omit-toggle. But I don't have a strong opinion on that.


diff -u -r1.54 dired-x.el
--- lisp/dired-x.el    31 Mar 2004 16:09:18 -0000    1.54
+++ lisp/dired-x.el    31 May 2004 16:26:51 -0000
@@ -50,7 +50,7 @@
 ;; (add-hook 'dired-mode-hook
 ;;           (function (lambda ()
 ;;                       ;; Set buffer-local variables here.  For example:
-;;                       ;; (setq dired-omit-files-p t)
+;;                       ;; (dired-omit-mode 1)
 ;;                       )))
 ;;
 ;; At load time dired-x.el will install itself, redefine some 
functions, and
@@ -74,7 +74,7 @@
 ;;      dired-guess-shell-znew-switches
 ;;      dired-guess-shell-alist-user
 ;;      dired-clean-up-buffers-too
-;;      dired-omit-files-p
+;;      dired-omit-mode
 ;;      dired-omit-files
 ;;      dired-omit-extensions
 ;;      dired-omit-size-limit
@@ -154,19 +154,23 @@
          (other :tag "non-writable only" if-file-read-only))
   :group 'dired-x)
 
-(defcustom dired-omit-files-p nil
+(defcustom dired-omit-mode nil
   "*If non-nil, \"uninteresting\" files are not listed (buffer-local).
-Use \\[dired-omit-toggle] to toggle its value.
+Use \\[dired-omit-mode] to toggle its value.
 Uninteresting files are those whose filenames match regexp 
`dired-omit-files',
 plus those ending with extensions in `dired-omit-extensions'."
   :type 'boolean
   :group 'dired-x)
-(make-variable-buffer-local 'dired-omit-files-p)
+(make-variable-buffer-local 'dired-omit-mode)
+
+;; Maintained for backward compatibility
+(defvaralias 'dired-omit-files-p 'dired-omit-mode)
+(make-obsolete-variable 'dired-omit-files-p 'dired-omit-mode)
 
 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$"
   "*Filenames matching this regexp will not be displayed.
-This only has effect when `dired-omit-files-p' is t.  See interactive 
function
-`dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable
+This only has effect when `dired-omit-mode' is t.  See interactive function
+`dired-omit-mode' \(\\[dired-omit-mode]\) and variable
 `dired-omit-extensions'.  The default is to omit  `.', `..', auto-save
 files and lock files."
   :type 'regexp
@@ -230,7 +234,7 @@
 
 ;;; KEY BINDINGS.
 
-(define-key dired-mode-map "\M-o" 'dired-omit-toggle)
+(define-key dired-mode-map "\M-o" 'dired-omit-mode)
 (define-key dired-mode-map "\M-(" 'dired-mark-sexp)
 (define-key dired-mode-map "*(" 'dired-mark-sexp)
 (define-key dired-mode-map "*." 'dired-mark-extension)
@@ -268,7 +272,7 @@
   \\[dired-info]\t-- run info on file
   \\[dired-man]\t-- run man on file
   \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously
-  \\[dired-omit-toggle]\t-- toggle omitting of files
+  \\[dired-omit-mode]\t-- toggle omitting of files
   \\[dired-mark-sexp]\t-- mark by Lisp expression
   \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names 
into the kill ring.
   \t   You can feed it to other commands using \\[yank].
@@ -280,7 +284,7 @@
   `dired-bind-info'
   `dired-bind-man'
   `dired-vm-read-only-folders'
-  `dired-omit-files-p'
+  `dired-omit-mode'
   `dired-omit-files'
   `dired-omit-extensions'
   `dired-omit-size-limit'
@@ -450,9 +454,9 @@
                 (dired-insert-subdir (file-name-directory file))
                 (dired-goto-file file))
               ;; Toggle omitting, if it is on, and try again.
-          (if dired-omit-files-p
+          (if dired-omit-mode
           (progn
-            (dired-omit-toggle)
+            (dired-omit-mode)
             (dired-goto-file file))))))))
 
 (defun dired-jump-other-window ()
@@ -479,31 +483,34 @@
 Should never be used as marker by the user or other packages.")
 
 (defun dired-omit-startup ()
-  (or (assq 'dired-omit-files-p minor-mode-alist)
+  (or (assq 'dired-omit-mode minor-mode-alist)
       (setq minor-mode-alist
-            (append '((dired-omit-files-p
+            (append '((dired-omit-mode
                (:eval (if (eq major-mode 'dired-mode)
                   " Omit" ""))))
             minor-mode-alist))))
 
-(defun dired-omit-toggle (&optional flag)
-  "Toggle omitting files matching `dired-omit-files' and 
`dired-omit-extensions'.
-With an arg, and if omitting was off, don't toggle and just mark the
-  files but don't actually omit them.
-With an arg, and if omitting was on, turn it off but don't refresh the 
buffer."
+(defun dired-omit-mode (&optional arg)
+  "Toggle Dired Omit Mode.
+With numeric ARG, turn Dired Omit Mode on if ARG is positive, off 
otherwise.
+
+In Dired Omit Mode, files matching `dired-omit-files' and 
`dired-omit-extensions'
+are omitted."
   (interactive "P")
-  (if flag
-      (if dired-omit-files-p
-          (setq dired-omit-files-p (not dired-omit-files-p))
-        (dired-mark-unmarked-files (dired-omit-regexp) nil nil
-                                   dired-omit-localp))
-    ;; no FLAG
-    (setq dired-omit-files-p (not dired-omit-files-p))
-    (if (not dired-omit-files-p)
-        (revert-buffer)
-      ;; this will mention how many were omitted:
-      (let ((dired-omit-size-limit nil))
-        (dired-omit-expunge)))))
+  (setq dired-omit-mode
+        (if (null arg) (not dired-omit-mode) (> (prefix-numeric-value 
arg) 0)))
+  (if dired-omit-mode
+      ;; This will mention how many lines were omitted:
+      (let ((dired-omit-size-limit nil)) (dired-omit-expunge))
+    (revert-buffer)
+    (message "Omit Mode disabled"))
+  (force-mode-line-update))
+
+(defun dired-mark-omitted ()
+  "Mark files matching `dired-omit-files' and `dired-omit-extensions'."
+  (interactive)
+  (let ((dired-omit-mode nil)) (revert-buffer)) ;; Show omitted files
+  (dired-mark-unmarked-files (dired-omit-regexp) nil nil 
dired-omit-localp))
 
 (defvar dired-omit-extensions
   (append completion-ignored-extensions
@@ -515,12 +522,12 @@
 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and
 `dired-texinfo-unclean-extensions'.
 
-See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and
-variables `dired-omit-files-p' and `dired-omit-files'.")
+See interactive function `dired-omit-mode' \(\\[dired-omit-mode]\) and
+variables `dired-omit-mode' and `dired-omit-files'.")
 
 (defun dired-omit-expunge (&optional regexp)
   "Erases all unmarked files matching REGEXP.
-Does nothing if global variable `dired-omit-files-p' is nil, or if called
+Does nothing if global variable `dired-omit-mode' is nil, or if called
   non-interactively and buffer is bigger than `dired-omit-size-limit'.
 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
   filenames ending in `dired-omit-extensions'.
@@ -529,14 +536,14 @@
 This functions works by temporarily binding `dired-marker-char' to
 `dired-omit-marker-char' and calling `dired-do-kill-lines'."
   (interactive "sOmit files (regexp): ")
-  (if (and dired-omit-files-p
+  (if (and dired-omit-mode
            (or (interactive-p)
                (not dired-omit-size-limit)
                (< (buffer-size) dired-omit-size-limit)
            (progn
          (message "Not omitting: directory larger than %d characters."
               dired-omit-size-limit)
-         (setq dired-omit-files-p nil)
+         (setq dired-omit-mode nil)
          nil)))
       (let ((omit-re (or regexp (dired-omit-regexp)))
             (old-modified-p (buffer-modified-p))
@@ -589,7 +596,7 @@
 (defun dired-omit-new-add-entry (filename &optional marker-char relative)
   ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for
   ;; files that are going to be omitted anyway.
-  (if dired-omit-files-p
+  (if dired-omit-mode
       ;; perhaps return t without calling ls
       (let ((omit-re (dired-omit-regexp)))
         (if (or (string= omit-re "")
@@ -842,7 +849,7 @@
     (save-excursion
       (set-buffer (get-buffer-create " *dot-dired*"))
       (erase-buffer)
-      (insert "Local Variables:\ndired-omit-files-p: t\nEnd:\n")
+      (insert "Local Variables:\ndired-omit-mode: t\nEnd:\n")
       (write-file dired-local-variables-file)
       (kill-buffer (current-buffer)))
 
@@ -1692,7 +1699,7 @@
    'dired-guess-shell-znew-switches
    'dired-guess-shell-alist-user
    'dired-clean-up-buffers-too
-   'dired-omit-files-p
+   'dired-omit-mode
    'dired-omit-files
    'dired-omit-extensions
    )

  reply	other threads:[~2004-05-31 16:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-30 20:11 desktop.el and minor modes Juri Linkov
2004-05-31 10:20 ` Lars Hansen
2004-05-31 13:16   ` Lars Hansen
2004-05-31 13:52     ` Juri Linkov
2004-05-31 16:38       ` Lars Hansen [this message]
2004-05-31 19:26         ` Miles Bader
2004-05-31 21:22           ` Lars Hansen
2004-05-31 13:52   ` Juri Linkov
2004-05-31 21:48     ` Lars Hansen
     [not found]       ` <87vfici4md.fsf@mail.jurta.org>
2004-06-01  6:22         ` Lars Hansen
2004-06-01 16:34           ` Juri Linkov
2004-06-02  5:50             ` Lars Hansen
2004-06-05  1:05               ` Juri Linkov
2004-06-05 16:24                 ` {Spam?} " Stefan
2004-06-05 18:02                   ` Lars Hansen
2004-06-07  2:07                     ` Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2004-06-05 17:59 Lars Hansen
2004-06-05 18:03 ` David Kastrup
2004-06-05 18:14   ` Lars Hansen
2004-06-05 18:47 ` Juri Linkov
2004-06-07  8:09 ` Juri Linkov
2004-06-08  6:49   ` Lars Hansen
2004-06-08  8:02     ` Juri Linkov
2004-06-08 16:10       ` Lars Hansen
2004-06-08 18:43         ` Juri Linkov
2004-06-08 19:24           ` Lars Hansen
2004-06-08 20:11             ` Juri Linkov
2004-06-08 20:22               ` Lars Hansen
2004-06-08 20:32   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40BB5F7E.9040900@math.ku.dk \
    --to=larsh@math.ku.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).