unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32892: 27.0.50; End predicate `dired-in-this-tree' with '-p'
@ 2018-10-01 11:09 Tino Calancha
  2019-07-13  2:04 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Tino Calancha @ 2018-10-01 11:09 UTC (permalink / raw)
  To: 32892

Severity: wishlist

`dired-in-this-tree' is used as a predicate elsewhere.
I suggest to follow the convention on predicates, i.e., to end
its name with '-p'.
--8<-----------------------------cut here---------------start------------->8---
commit 278c6d78c7d27eeb9bba19c5781cc43a5809a0ad
Author: Tino Calancha <tino.calancha@gmail.com>
Date:   Mon Oct 1 19:59:24 2018 +0900

    End predicate `dired-in-this-tree' with '-p'

    Rename `dired-in-this-tree-p' from `dired-in-this-tree'.
    * lisp/dired.el(dired-in-this-tree-p): Rename from `dired-in-this-tree'.
    Add docstring.

    (dired-in-this-tree): Define an alias to `dired-in-this-tree-p'.
    (dired-buffers-for-dir): Change comment into docstring.

    (dired-buffers-for-dir)
    * lisp/dired-aux.el (dired-tree-down, dired-kill-tree)
    (dired-insert-subdir, dired-rename-subdir): Update all callers.

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 1f13204b7c..9925615202 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1622,7 +1622,7 @@ dired-rename-subdir
     (while blist
       (with-current-buffer (car blist)
 	(if (and buffer-file-name
-		 (dired-in-this-tree buffer-file-name expanded-from-dir))
+		 (dired-in-this-tree-p buffer-file-name expanded-from-dir))
 	    (let ((modflag (buffer-modified-p))
 		  (to-file (dired-replace-in-string
 			    (concat "^" (regexp-quote from-dir))
@@ -1641,7 +1641,7 @@ dired-rename-subdir-1
     (while alist
       (setq elt (car alist)
 	    alist (cdr alist))
-      (if (dired-in-this-tree (car elt) expanded-dir)
+      (if (dired-in-this-tree-p (car elt) expanded-dir)
 	  ;; ELT's subdir is affected by the rename
 	  (dired-rename-subdir-2 elt dir to)))
     (if (equal dir default-directory)
@@ -2392,7 +2392,7 @@ dired-insert-subdir
       (setq switches (dired-replace-in-string "R" "" switches))
       (dolist (cur-ass dired-subdir-alist)
 	(let ((cur-dir (car cur-ass)))
-	  (and (dired-in-this-tree cur-dir dirname)
+	  (and (dired-in-this-tree-p cur-dir dirname)
 	       (let ((cur-cons (assoc-string cur-dir dired-switches-alist)))
 		 (if cur-cons
 		     (setcdr cur-cons switches)
@@ -2404,7 +2404,7 @@ dired-insert-subdir
 (defun dired-insert-subdir-validate (dirname &optional switches)
   ;; Check that it is valid to insert DIRNAME with SWITCHES.
   ;; Signal an error if invalid (e.g. user typed `i' on `..').
-  (or (dired-in-this-tree dirname (expand-file-name default-directory))
+  (or (dired-in-this-tree-p dirname (expand-file-name default-directory))
       (error  "%s: not in this directory tree" dirname))
   (let ((real-switches (or switches dired-subdir-switches)))
     (when real-switches
@@ -2445,7 +2445,7 @@ dired-kill-tree
       (setq dir (car (car s-alist))
 	    s-alist (cdr s-alist))
       (and (or kill-root (not (string-equal dir dirname)))
-	   (dired-in-this-tree dir dirname)
+	   (dired-in-this-tree-p dir dirname)
 	   (dired-goto-subdir dir)
 	   (setq m-alist (nconc (dired-kill-subdir remember-marks) m-alist))))
     m-alist))
@@ -2683,7 +2683,7 @@ dired-tree-down
       (while rest
 	(setq elt (car rest)
 	      rest (cdr rest))
-	(if (dired-in-this-tree (directory-file-name (car elt)) dir)
+	(if (dired-in-this-tree-p (directory-file-name (car elt)) dir)
 	    (setq rest nil
 		  pos (dired-goto-subdir (car elt))))))
     (if pos
diff --git a/lisp/dired.el b/lisp/dired.el
index 5c7bb9599c..63d8d4f52c 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2607,12 +2607,12 @@ dired-copy-filename-as-kill
 ;; Keeping Dired buffers in sync with the filesystem and with each other

 (defun dired-buffers-for-dir (dir &optional file)
-;; Return a list of buffers for DIR (top level or in-situ subdir).
-;; If FILE is non-nil, include only those whose wildcard pattern (if any)
-;; matches FILE.
-;; The list is in reverse order of buffer creation, most recent last.
-;; As a side effect, killed dired buffers for DIR are removed from
-;; dired-buffers.
+  "Return a list of buffers for DIR (top level or in-situ subdir).
+If FILE is non-nil, include only those whose wildcard pattern (if any)
+matches FILE.
+The list is in reverse order of buffer creation, most recent last.
+As a side effect, killed dired buffers for DIR are removed from
+dired-buffers."
   (setq dir (file-name-as-directory dir))
   (let (result buf)
     (dolist (elt dired-buffers)
@@ -2621,7 +2621,7 @@ dired-buffers-for-dir
        ((null (buffer-name buf))
 	;; Buffer is killed - clean up:
 	(setq dired-buffers (delq elt dired-buffers)))
-       ((dired-in-this-tree dir (car elt))
+       ((dired-in-this-tree-p dir (car elt))
 	(with-current-buffer buf
 	  (and (assoc dir dired-subdir-alist)
 	       (or (null file)
@@ -2694,11 +2694,13 @@ dired-unadvertise

 ;;; utility functions

-(defun dired-in-this-tree (file dir)
-  ;;"Is FILE part of the directory tree starting at DIR?"
+(defun dired-in-this-tree-p (file dir)
+  "Return non-nil if FILE belongs to the directory tree starting at DIR."
   (let (case-fold-search)
     (string-match-p (concat "^" (regexp-quote dir)) file)))

+(defalias 'dired-in-this-tree 'dired-in-this-tree-p)
+
 (defun dired-normalize-subdir (dir)
   ;; Prepend default-directory to DIR if relative file name.
   ;; dired-get-filename must be able to make a valid file name from a

--8<-----------------------------cut here---------------end--------------->8---

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2018-08-20 built on calancha-pc.dy.bbexcite.jp
Repository revision: 6217746dd64b43a2a2b3b66ab50cfbbfc984f36c





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#32892: 27.0.50; End predicate `dired-in-this-tree' with '-p'
  2018-10-01 11:09 bug#32892: 27.0.50; End predicate `dired-in-this-tree' with '-p' Tino Calancha
@ 2019-07-13  2:04 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-13  2:04 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 32892

Tino Calancha <tino.calancha@gmail.com> writes:

> `dired-in-this-tree' is used as a predicate elsewhere.
> I suggest to follow the convention on predicates, i.e., to end
> its name with '-p'.

Makes sense; I've now applied it to the trunk.

>     (dired-buffers-for-dir): Change comment into docstring.

Except this bit, which seemed unrelated.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-13  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-01 11:09 bug#32892: 27.0.50; End predicate `dired-in-this-tree' with '-p' Tino Calancha
2019-07-13  2:04 ` Lars Ingebrigtsen

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).