Subject: bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name

From: Stephen Berman <[email-masked]>
Date: Thu, 05 Dec 2024 11:42:50 +0100

On Thu, 05 Dec 2024 11:24:23 +0200 Eli Zaretskii <[email-masked]> wrote:

>> From: Visuwesh <[email-masked]>
>> Cc: [email-masked]
>> Date: Thu, 05 Dec 2024 14:32:18 +0530
>> 
>> [வியாழன் டிசம்பர் 05, 2024] Eli Zaretskii wrote:
>> 
>> >> I removed the whitespace.  But isn't that way to make lists such as
>> >> 
>> >>     ( 1
>> >>       2
>> >>       3)
>> >> 
>> >> aligned without manual intervention?
>> >
>> > Typing something like
>> >
>> >    (setq foo (1
>> >               2
>> >               3)
>> >
>> > aligns the members for me.  So I don't think I understand what you are
>> > saying here.
>> 
>> Try to align
>> 
>>     (setq foo '(1 2
>>                 3))
>> 
>> instead.  3 would end up aligning at 2 instead of 1.
>
> Yes, and why is that a problem?  This is the standard Lisp indentation
> in Emacs.  It makes it easy to find the end of the sexps.
>
>> Adding a space after ( prevents this.
>
> I'm not sure I understand why overriding the standard indentation
> would be a good idea.

Sometimes the standard indentation makes the code harder to read, e.g.,
the sexp that the indentation in Visuwesh's patch took as an example is
this (starting at column 10):

(add-text-properties
 segment-start (1- (point))
 `( mouse-face highlight
    help-echo "mouse-1: goto this directory"
    keymap ,(let* ((current-dir dir)
                   (click (lambda ()
                            (interactive)
                            (cond
                             ((assoc current-dir dired-subdir-alist)
                              (dired-goto-subdir current-dir))
                             ;; If there is a wildcard chars
                             ;; in the directory name, don't
                             ;; use the alternate file machinery
                             ;; which tries to keep only one
                             ;; dired buffer open at once.
                             ;;
                             ;; FIXME: Is this code path reachable?
                             ((insert-directory-wildcard-in-dir-p
                               current-dir)
                              (dired current-dir))
                             (t
                              (dired--find-possibly-alternative-file
                               current-dir))))))
              (define-keymap
                "<mouse-2>" click
                "<follow-link>" 'mouse-face
                "RET" click))))

Here is the indentation without the space (in dired.el several lines of
this code extend well beyond column 80):

(add-text-properties
 segment-start (1- (point))
 `(mouse-face highlight
              help-echo "mouse-1: goto this directory"
              keymap ,(let* ((current-dir dir)
                             (click (lambda ()
                                      (interactive)
                                      (cond
                                       ((assoc current-dir dired-subdir-alist)
                                        (dired-goto-subdir current-dir))
                                       ;; If there is a wildcard chars
                                       ;; in the directory name, don't
                                       ;; use the alternate file machinery
                                       ;; which tries to keep only one
                                       ;; dired buffer open at once.
                                       ;;
                                       ;; FIXME: Is this code path reachable?
                                       ((insert-directory-wildcard-in-dir-p
                                         current-dir)
                                        (dired current-dir))
                                       (t
                                        (dired--find-possibly-alternative-file
                                         current-dir))))))
                        (define-keymap
                          "<mouse-2>" click
                          "<follow-link>" 'mouse-face
                          "RET" click))))

Steve Berman