unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Drew Adams <drew.adams@oracle.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 11571@debbugs.gnu.org
Subject: bug#11571: 24.0.97; doc string of `dired-get-subdir-min'
Date: Fri, 08 Nov 2019 14:30:59 +0100	[thread overview]
Message-ID: <87bltmtrzg.fsf@marxist.se> (raw)
In-Reply-To: <ccc9259e-296e-48a6-ad81-c60f1c040554@default> (Drew Adams's message of "Tue, 5 Nov 2019 08:21:39 -0800 (PST)")

[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]

Drew Adams <drew.adams@oracle.com> writes:

>> Do you have a suggestion for how to rewrite this text without going
>> over the recommended 67 character limit?
>>     Association list of subdirectories and their buffer positions.
>> The best I could come up with is this (exactly 67 characters):
>>     Alist of subdirectories and the buffer positions of their listings.
[...]
> However, the alist contains not only elements for the
> listed subdirs but also an element for the listed main
> dir.  The doc string is unclear about that.
>
> This is clear, I think. And the lines are all less than
> 60 chars wide:
>
>  Alist of listed directory names and their buffer positions.
>  Alist elements have the form (DIRNAME . STARTMARKER), where
>  DIRNAME is the listed absolute name of the directory and
>  STARTMARKER is a marker at the beginning of DIRNAME.
>
>  The elements are in reverse order of the listing.  If no
>  subdirectories are listed then the alist contains only one
>  element, for the listed directory.
>
> That also makes clear that DIRNAME is an absolute file name,
> and it is what is shown in the listing.  And it makes clear
> what the "one element" is when there are no subdir listings. 

Thanks, that's much better.  I've attached an updated patch with a
slightly different wording.  If there are no further comments or
objections, I intend to push this in a couple of days.

Best regards,
Stefan Kangas


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-dired-get-subdir-min-obsolete.patch --]
[-- Type: text/x-diff, Size: 6347 bytes --]

From 181fea4507be10c80981ff7fd650f7d6b82de039 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Thu, 31 Oct 2019 02:39:20 +0100
Subject: [PATCH] Make dired-get-subdir-min obsolete

* lisp/dired.el (dired-get-subdir-min): Redefine as obsolete function
alias for 'cdr'.  (Bug#11571)
(dired-get-subdir, dired-get-subdir-max, dired-clear-alist)
(dired-next-subdir, dired-current-directory):
* lisp/dired-aux.el (dired-rename-subdir-2)
(dired-alist-sort, dired-insert-subdir-del)
(dired-insert-subdir-doupdate, dired-goto-subdir)
(dired-hide-subdir, dired-hide-all): Use 'cdr' instead of
the above obsolete function.
(dired-subdir-alist): Doc fix.
---
 lisp/dired-aux.el | 18 +++++++++---------
 lisp/dired.el     | 20 +++++++++++---------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 722d036e3f..184b507e1d 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1728,7 +1728,7 @@ dired-rename-subdir-2
     (let ((regexp (regexp-quote (directory-file-name dir)))
 	  (newtext (directory-file-name to))
 	  buffer-read-only)
-      (goto-char (dired-get-subdir-min elt))
+      (goto-char (cdr elt))
       ;; Update subdir headerline in buffer
       (if (not (looking-at dired-subdir-regexp))
 	  (error "%s not found where expected - dired-subdir-alist broken?"
@@ -2491,8 +2491,8 @@ dired-alist-sort
   (setq dired-subdir-alist
 	(sort dired-subdir-alist
 	      (lambda (elt1 elt2)
-		(> (dired-get-subdir-min elt1)
-		   (dired-get-subdir-min elt2))))))
+                (> (cdr elt1)
+                   (cdr elt2))))))
 
 (defun dired-kill-tree (dirname &optional remember-marks kill-root)
   "Kill all proper subdirs of DIRNAME, excluding DIRNAME itself.
@@ -2535,7 +2535,7 @@ dired-insert-subdir-newpos
 (defun dired-insert-subdir-del (element)
   ;; Erase an already present subdir (given by ELEMENT) from buffer.
   ;; Move to that buffer position.  Return a mark-alist.
-  (let ((begin-marker (dired-get-subdir-min element)))
+  (let ((begin-marker (cdr element)))
     (goto-char begin-marker)
     ;; Are at beginning of subdir (and inside it!).  Now determine its end:
     (goto-char (dired-subdir-max))
@@ -2566,7 +2566,7 @@ dired-insert-subdir-doupdate
   ;; BEG-END is the subdir-region (as list of begin and end).
   (if elt				; subdir was already present
       ;; update its position (should actually be unchanged)
-      (set-marker (dired-get-subdir-min elt) (point-marker))
+      (set-marker (cdr elt) (point-marker))
     (dired-alist-add dirname (point-marker)))
   ;; The hook may depend on the subdir-alist containing the just
   ;; inserted subdir, so run it after dired-alist-add:
@@ -2680,7 +2680,7 @@ dired-goto-subdir
   (setq dir (file-name-as-directory dir))
   (let ((elt (assoc dir dired-subdir-alist)))
     (and elt
-	 (goto-char (dired-get-subdir-min elt))
+         (goto-char (cdr elt))
 	 ;; dired-subdir-hidden-p and dired-add-entry depend on point being
 	 ;; at \n after this function succeeds.
 	 (progn (end-of-line)
@@ -2778,7 +2778,7 @@ dired-hide-subdir
 	     (end-pos (1- (dired-get-subdir-max elt)))
 	     buffer-read-only)
 	;; keep header line visible, hide rest
-	(goto-char (dired-get-subdir-min elt))
+	(goto-char (cdr elt))
 	(end-of-line)
 	(if hidden-p
 	    (dired--unhide (point) end-pos)
@@ -2797,14 +2797,14 @@ dired-hide-all
       ;; hide
       (let ((pos (point-max)))		; pos of end of last directory
         (dolist (subdir dired-subdir-alist)
-	  (let ((start (dired-get-subdir-min subdir)) ; pos of prev dir
+          (let ((start (cdr subdir)) ; pos of prev dir
 		(end (save-excursion
 		       (goto-char pos) ; current dir
 		       ;; we're somewhere on current dir's line
 		       (forward-line -1)
 		       (point))))
             (dired--hide start end))
-	  (setq pos (dired-get-subdir-min subdir))))))) ; prev dir gets current dir
+          (setq pos (cdr subdir))))))) ; prev dir gets current dir
 
 ;;;###end dired-ins.el
 
diff --git a/lisp/dired.el b/lisp/dired.el
index 05789a3516..8939ea2d88 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -354,8 +354,11 @@ dired-re-dot
 
 ;; The subdirectory names in the next two lists are expanded.
 (defvar dired-subdir-alist nil
-  "Association list of subdirectories and their buffer positions.
-Each subdirectory has an element: (DIRNAME . STARTMARKER).
+  "Alist of listed subdirectories and their buffer positions.
+Alist elements have the form (DIRNAME . STARTMARKER), where
+DIRNAME is the absolute name of the directory and STARTMARKER is
+a marker at the beginning of DIRNAME.
+
 The order of elements is the reverse of the order in the buffer.
 In simple cases, this list contains one element.")
 
@@ -2857,21 +2860,20 @@ dired-get-subdir
     (let ((cur-dir (dired-current-directory)))
       (beginning-of-line)		; alist stores b-o-l positions
       (and (zerop (- (point)
-		     (dired-get-subdir-min (assoc cur-dir
+                     (cdr (assoc cur-dir
 						  dired-subdir-alist))))
 	   cur-dir))))
 
-;; can't use macro,  must be redefinable for other alist format in dired-nstd.
-(defalias 'dired-get-subdir-min 'cdr)
+(define-obsolete-function-alias 'dired-get-subdir-min 'cdr "27.1")
 
 (defun dired-get-subdir-max (elt)
   (save-excursion
-    (goto-char (dired-get-subdir-min elt))
+    (goto-char (cdr elt))
     (dired-subdir-max)))
 
 (defun dired-clear-alist ()
   (while dired-subdir-alist
-    (set-marker (dired-get-subdir-min (car dired-subdir-alist)) nil)
+    (set-marker (cdr (car dired-subdir-alist)) nil)
     (setq dired-subdir-alist (cdr dired-subdir-alist))))
 
 (defun dired-subdir-index (dir)
@@ -2895,7 +2897,7 @@ dired-next-subdir
     ;; nth with negative arg does not return nil but the first element
     (setq index (- (dired-subdir-index this-dir) arg))
     (setq pos (if (>= index 0)
-		  (dired-get-subdir-min (nth index dired-subdir-alist))))
+                  (cdr (nth index dired-subdir-alist))))
     (if pos
 	(progn
 	  (goto-char pos)
@@ -3116,7 +3118,7 @@ dired-current-directory
       (setq elt (car alist)
 	    dir (car elt)
 	    ;; use `<=' (not `<') as subdir line is part of subdir
-	    alist (if (<= (dired-get-subdir-min elt) here)
+	    alist (if (<= (cdr elt) here)
 		      nil		; found
 		    (cdr alist))))
     (if localp
-- 
2.20.1


  reply	other threads:[~2019-11-08 13:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 21:37 bug#11571: 24.0.97; doc string of `dired-get-subdir-min' Drew Adams
2012-05-27 21:41 ` Drew Adams
2012-09-16 23:49   ` Drew Adams
2014-02-09  3:59   ` Lars Ingebrigtsen
2014-02-09 22:25     ` Drew Adams
2019-11-01 18:44     ` Stefan Kangas
2019-11-01 20:54       ` Drew Adams
2019-11-05 15:09         ` Stefan Kangas
2019-11-05 16:21           ` Drew Adams
2019-11-08 13:30             ` Stefan Kangas [this message]
2019-11-08 18:04               ` Drew Adams
2019-11-10 21:17               ` Stefan Kangas
2019-11-02 14:51       ` Lars Ingebrigtsen

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=87bltmtrzg.fsf@marxist.se \
    --to=stefan@marxist.se \
    --cc=11571@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=larsi@gnus.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).