unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	dgutov@yandex.ru
Subject: Re: scratch/command 064f146 1/2: Change command to interactive ... modes
Date: Wed, 17 Feb 2021 10:58:13 +0200	[thread overview]
Message-ID: <87h7mbdpou.fsf@mail.linkov.net> (raw)
In-Reply-To: <CADwFkmnunmgeXUgZmaUOKt74d=xH80X5FcPSG4e1BB6uYYE2RA@mail.gmail.com> (Stefan Kangas's message of "Tue, 16 Feb 2021 14:30:08 -0600")

> To my mind, if two forms of writing the same thing are equally clear and
> easy to understand, the less verbose one is often the better choice.
> But I would claim that the more verbose form in this case is less clear
> and harder to understand.

The question is how this form is less clear and harder to understand:

(defun Info-follow-reference (footnotename &optional fork)
  (declare (completion Info-mode))
  ================================
  (interactive
   (let ((completion-ignore-case t)
	 (case-fold-search t)
	 completions default alt-default (start-point (point)) str i bol eol)
     (save-excursion
       ;; Store end and beginning of line.
       (setq eol (line-end-position)
             bol (line-beginning-position))
       (goto-char (point-min))
       (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
	 (setq str (match-string-no-properties 1))
	 ;; See if this one should be the default.
	 (and (null default)
	      (<= (match-beginning 0) start-point)
	      (<= start-point (point))
	      (setq default t))
	 ;; See if this one should be the alternate default.
	 (and (null alt-default)
	      (and (<= bol (match-beginning 0))
		   (<= (point) eol))
	      (setq alt-default t))
	 (setq i 0)
	 (while (setq i (string-match "[ \n\t]+" str i))
	   (setq str (concat (substring str 0 i) " "
			     (substring str (match-end 0))))
	   (setq i (1+ i)))
	 ;; Record as a completion and perhaps as default.
	 (if (eq default t) (setq default str))
	 (if (eq alt-default t) (setq alt-default str))
	 ;; Don't add this string if it's a duplicate.
	 (or (assoc-string str completions t)
	     (push str completions))))
     ;; If no good default was found, try an alternate.
     (or default
	 (setq default alt-default))
     ;; If only one cross-reference found, then make it default.
     (if (eq (length completions) 1)
         (setq default (car completions)))
     (if completions
	 (let ((input (completing-read (if default
					   (concat
					    "Follow reference named (default "
					    default "): ")
					 "Follow reference named: ")
				       completions nil t)))
	   (list (if (equal input "")
		     default input)
                 current-prefix-arg))
       (user-error "No cross-references in this node"))))

than what we have now in master (see the difference at the end):

(defun Info-follow-reference (footnotename &optional fork)
  (interactive
   (let ((completion-ignore-case t)
	 (case-fold-search t)
	 completions default alt-default (start-point (point)) str i bol eol)
     (save-excursion
       ;; Store end and beginning of line.
       (setq eol (line-end-position)
             bol (line-beginning-position))
       (goto-char (point-min))
       (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
	 (setq str (match-string-no-properties 1))
	 ;; See if this one should be the default.
	 (and (null default)
	      (<= (match-beginning 0) start-point)
	      (<= start-point (point))
	      (setq default t))
	 ;; See if this one should be the alternate default.
	 (and (null alt-default)
	      (and (<= bol (match-beginning 0))
		   (<= (point) eol))
	      (setq alt-default t))
	 (setq i 0)
	 (while (setq i (string-match "[ \n\t]+" str i))
	   (setq str (concat (substring str 0 i) " "
			     (substring str (match-end 0))))
	   (setq i (1+ i)))
	 ;; Record as a completion and perhaps as default.
	 (if (eq default t) (setq default str))
	 (if (eq alt-default t) (setq alt-default str))
	 ;; Don't add this string if it's a duplicate.
	 (or (assoc-string str completions t)
	     (push str completions))))
     ;; If no good default was found, try an alternate.
     (or default
	 (setq default alt-default))
     ;; If only one cross-reference found, then make it default.
     (if (eq (length completions) 1)
         (setq default (car completions)))
     (if completions
	 (let ((input (completing-read (if default
					   (concat
					    "Follow reference named (default "
					    default "): ")
					 "Follow reference named: ")
				       completions nil t)))
	   (list (if (equal input "")
		     default input)
                 current-prefix-arg))
       (user-error "No cross-references in this node")))
   Info-mode)
   =========



  parent reply	other threads:[~2021-02-17  8:58 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210213141225.11309.86562@vcs0.savannah.gnu.org>
     [not found] ` <20210213141226.EEDFE20999@vcs0.savannah.gnu.org>
2021-02-13 20:04   ` scratch/command 064f146 1/2: Change command to interactive ... modes Dmitry Gutov
2021-02-13 21:05     ` Lars Ingebrigtsen
2021-02-13 21:33       ` Dmitry Gutov
2021-02-14 15:29         ` Stefan Kangas
2021-02-14 16:03           ` Stefan Kangas
2021-02-14 16:05             ` Lars Ingebrigtsen
2021-02-14 16:17               ` Stefan Kangas
2021-02-14 16:20                 ` Lars Ingebrigtsen
2021-02-14 16:24                   ` Stefan Kangas
2021-02-14 17:25                     ` Lars Ingebrigtsen
2021-02-14 20:25                       ` Stefan Kangas
2021-02-15  3:38                         ` Eli Zaretskii
2021-02-16 12:15                           ` Lars Ingebrigtsen
2021-02-16 15:41                             ` Eli Zaretskii
2021-02-16 16:31                               ` Lars Ingebrigtsen
2021-02-16 17:03                                 ` Eli Zaretskii
2021-02-16 17:06                                   ` Lars Ingebrigtsen
2021-02-16 17:36                                     ` Eli Zaretskii
2021-02-16 17:39                                       ` Lars Ingebrigtsen
2021-02-16 17:46                                         ` Eli Zaretskii
2021-02-16 18:10                                           ` Lars Ingebrigtsen
2021-02-16 18:24                                             ` Eli Zaretskii
2021-02-16 18:36                                               ` Lars Ingebrigtsen
2021-02-16 18:49                                                 ` Eli Zaretskii
2021-02-16 19:31                                                   ` Lars Ingebrigtsen
2021-02-16 19:39                                                     ` Eli Zaretskii
2021-02-16 20:30                                                       ` Stefan Kangas
2021-02-16 20:49                                                         ` Eli Zaretskii
2021-02-16 22:00                                                           ` Lars Ingebrigtsen
2021-02-16 22:22                                                             ` Dmitry Gutov
2021-02-16 22:37                                                               ` Lars Ingebrigtsen
2021-02-17  0:48                                                                 ` Dmitry Gutov
2021-02-17 11:02                                                                   ` Lars Ingebrigtsen
2021-02-17 11:30                                                                     ` Dmitry Gutov
2021-02-17  9:10                                                                 ` Juri Linkov
2021-02-17 10:16                                                                   ` Stefan Kangas
2021-02-17 11:08                                                                     ` Lars Ingebrigtsen
2021-02-17 17:45                                                                     ` Juri Linkov
2021-02-17 18:42                                                                       ` Óscar Fuentes
2021-02-17  8:50                                                               ` Stefan Kangas
2021-02-17 13:57                                                                 ` Stefan Monnier
2021-02-17 15:52                                                                 ` Eli Zaretskii
2021-02-17 16:19                                                                 ` Dmitry Gutov
2021-02-16 22:31                                                             ` [External] : " Drew Adams
2021-02-17 16:53                                                               ` Matt Armstrong
2021-02-16 22:47                                                             ` Alan Mackenzie
2021-02-16 22:55                                                               ` Lars Ingebrigtsen
2021-02-16 23:20                                                                 ` Alan Mackenzie
2021-02-16 23:23                                                                   ` Lars Ingebrigtsen
2021-02-17 15:28                                                                   ` Eli Zaretskii
2021-02-19  5:36                                                                     ` Richard Stallman
2021-02-17 15:25                                                               ` Eli Zaretskii
2021-02-17 15:21                                                             ` Eli Zaretskii
2021-02-17 19:01                                                               ` Óscar Fuentes
2021-02-17 19:42                                                                 ` Dmitry Gutov
2021-02-17 19:49                                                                   ` Lars Ingebrigtsen
2021-02-17 19:30                                                               ` Lars Ingebrigtsen
2021-02-17 20:12                                                                 ` Eli Zaretskii
2021-02-18 23:57                                                                   ` Rolf Ade
2021-02-16 21:44                                                         ` Dmitry Gutov
2021-02-17  8:58                                                         ` Juri Linkov [this message]
2021-02-17 10:16                                                           ` Stefan Kangas
2021-02-17 11:05                                                             ` Lars Ingebrigtsen
2021-02-17 17:45                                                             ` Juri Linkov
2021-02-17 19:26                                                               ` Eli Zaretskii
2021-02-16 12:07                         ` Lars Ingebrigtsen
2021-02-17 20:05                         ` Lars Ingebrigtsen
2021-02-17 21:03                           ` Stefan Monnier
2021-02-17 21:06                             ` Lars Ingebrigtsen
2021-02-17 22:26                               ` Stefan Monnier
2021-02-18  3:57                           ` Stefan Kangas
2021-02-18  4:43                             ` Stefan Monnier
2021-02-18  5:20                               ` Stefan Kangas
2021-02-18 10:33                             ` Lars Ingebrigtsen
2021-02-18 10:38                               ` Lars Ingebrigtsen
2021-02-18 10:40                                 ` Lars Ingebrigtsen
2021-02-18 14:01                                 ` Stefan Monnier
2021-02-18 16:03                                   ` Stefan Monnier
2021-02-18 16:47                                     ` Basil L. Contovounesios
2021-02-19 12:07                                     ` Lars Ingebrigtsen
2021-02-19 14:29                                       ` Stefan Monnier
2021-02-20 12:35                                         ` Lars Ingebrigtsen
2021-02-20 14:38                                           ` Stefan Monnier
2021-02-20 15:01                                             ` Lars Ingebrigtsen
2021-02-14 20:37                   ` Jose A. Ortega Ruiz
2021-02-14 23:23                     ` Stefan Monnier
2021-02-14 16:49             ` Basil L. Contovounesios
2021-02-14 17:23               ` Stefan Kangas
2021-02-14 17:52                 ` Basil L. Contovounesios
2021-02-14 19:54                   ` Stefan Kangas
2021-02-14 16:58             ` Alan Mackenzie
2021-02-14 17:23               ` Stefan Kangas
2021-02-14 16:02       ` Óscar Fuentes
2021-02-14 16:07         ` Lars Ingebrigtsen
2021-02-14 16:23           ` Óscar Fuentes
2021-02-14 17:05             ` 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=87h7mbdpou.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=stefankangas@gmail.com \
    /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).