From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#11571: 24.0.97; doc string of `dired-get-subdir-min' Date: Fri, 01 Nov 2019 19:44:24 +0100 Message-ID: <878sozighj.fsf@skangas.se> References: <144EDF3C01664A2180447B02D1A6EB09@us.oracle.com> <484EACDE2A4A4185B158B84473AB1710@us.oracle.com> <871tzdgcmg.fsf@building.gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="269877"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 11571@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 01 19:45:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iQbv8-00184P-Fm for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Nov 2019 19:45:14 +0100 Original-Received: from localhost ([::1]:42122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQbv7-0001CK-CF for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Nov 2019 14:45:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53593) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQbuy-0001C8-Si for bug-gnu-emacs@gnu.org; Fri, 01 Nov 2019 14:45:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQbux-0005sy-68 for bug-gnu-emacs@gnu.org; Fri, 01 Nov 2019 14:45:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQbuw-0005su-WD for bug-gnu-emacs@gnu.org; Fri, 01 Nov 2019 14:45:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iQbuw-0002pk-Rt for bug-gnu-emacs@gnu.org; Fri, 01 Nov 2019 14:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Nov 2019 18:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11571 X-GNU-PR-Package: emacs Original-Received: via spool by 11571-submit@debbugs.gnu.org id=B11571.157263387510837 (code B ref 11571); Fri, 01 Nov 2019 18:45:02 +0000 Original-Received: (at 11571) by debbugs.gnu.org; 1 Nov 2019 18:44:35 +0000 Original-Received: from localhost ([127.0.0.1]:57133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQbuU-0002oi-DU for submit@debbugs.gnu.org; Fri, 01 Nov 2019 14:44:34 -0400 Original-Received: from host.gofardesign.uk ([208.79.239.190]:53543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQbuR-0002oR-Rf for 11571@debbugs.gnu.org; Fri, 01 Nov 2019 14:44:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ikv9JJGjep8EGez/3tpMPKqiL9XViNuC2ZmeRtzkZrU=; b=sUwBB2fz4iRWdMJ8ryDgI7GKr3 y5rJ1mrJY2/jshhTzV5EME3GR20FMfsLHuLGiX8gkqmp3TR6haWpOTWBnLpWJD4X5Nwyt9OEeUUIR 8q4bdfs9LkgxqHNjjdA15czvEqJVqOhBwKvGBTEtfTQ9qpp5mbxyHN7PWjLss2FNZvT4=; Original-Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:48292 helo=localhost) by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iQbuL-0004nW-Nm; Fri, 01 Nov 2019 13:44:26 -0500 In-Reply-To: <871tzdgcmg.fsf@building.gnus.org> (Lars Ingebrigtsen's message of "Sat, 08 Feb 2014 19:59:19 -0800") X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.gofardesign.uk X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marxist.se X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id: stefan@marxist.se X-Authenticated-Sender: host.gofardesign.uk: stefan@marxist.se X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170656 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > "Drew Adams" writes: > >> Actually, the real bug is that `dired-get-subdir-min' has no doc string, so the >> doc string of `cdr' is used in its stead. The whole point of defining and using >> a separate function for this, instead of just coding with `cdr', is to enable >> readers of the code - and a fortiori the doc - to think in terms of the data >> structure of directories and not just abstract cons cells. There should be doc >> at the proper level of abstraction here. [...] > ;; can't use macro, must be redefinable for other alist format in dired-nstd. > (defalias 'dired-get-subdir-min 'cdr) > > Which is kinda er. > > I don't know what nstd is, and the function doesn't seem to be redefined > anywhere, so is this just legacy gunk? Should `dired-get-subdir-min' > just be replaced by `cdr' in all the calling sites? >From searching the web, I think dired-nstd is "dired nested", which indeed seems to be some old, now non-existent stuff from Emacs 19 or older. See this for example: https://www.cs.cmu.edu/cgi-bin/info2www?(dired.info)Dired%20Known%20Problems I therefore think it's safe to obsolete this function, like in the below patch. Comments? Best regards, Stefan Kangas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Make-dired-get-subdir-min-obsolete.patch >From 1a6c799863380e5986f26a9c8fd9d3fc98241bb1 Mon Sep 17 00:00:00 2001 From: Stefan Kangas 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. --- lisp/dired-aux.el | 18 +++++++++--------- lisp/dired.el | 13 ++++++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index b1521ecf01..7f690e7e72 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1713,7 +1713,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?" @@ -2476,8 +2476,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. @@ -2520,7 +2520,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)) @@ -2551,7 +2551,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: @@ -2665,7 +2665,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) @@ -2763,7 +2763,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) @@ -2782,14 +2782,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..a94bf528c2 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2857,21 +2857,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 +2894,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 +3115,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 --=-=-=--