unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: (interactive) and &optional
Date: Thu, 30 Mar 2023 22:04:29 +0300	[thread overview]
Message-ID: <ZCXdPbFcjd/9B6O7@protected.localdomain> (raw)
In-Reply-To: <87o7ogpbl6.fsf@dataswamp.org>

* Emanuel Berg <incal@dataswamp.org> [2023-03-27 08:05]:
> > (defun search-something (&optional query)
> >    "Search something by using QUERY."
> >    (interactive)
> >    (let ((query (or query (read-from-minibuffer "Query: "))))
> >      (message query)))
> 
> This has the same problem as before, it should look something
> like this:
> 
> ;;; -*- lexical-binding: t -*-
> ;;
> ;; this file:
> ;;   https://dataswamp.org/~incal/emacs-init/geh.el
> 
> (defun search-something (&optional query)
>   "Search something by using QUERY."
>   (interactive "sQuery: ")
>   (unless (and (stringp query)
>                (not (string= "" query)) )
>     (setq query "default search") )
>   (message query) )
> 
> ;; (search-something "love")         ; love
> ;; (search-something)                ; default search
> ;; M-x search-something RET RET      ; default search
> ;; M-x search-something RET love RET ; love

That is your design opinion that it should look like that as related to
`interactive', and my design is that I avoid putting questions within
`interactive' declaration. I find it simpler, more visible, easier to
understand, readable, and freeer. For example I can remove
(interactive) from function for function still to work, without
restructuring, sometimes I find I do not want function any more to be
a command.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  reply	other threads:[~2023-03-30 19:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 19:10 (interactive) and &optional Dr Rainer Woitok
2023-03-23 19:20 ` Philip Kaludercic
2023-03-25 12:35   ` Dr Rainer Woitok
2023-03-25 13:12     ` Philip Kaludercic
2023-03-25 14:33       ` [External] : " Drew Adams
2023-03-25 15:36         ` Dr Rainer Woitok
2023-03-25 16:58         ` Philip Kaludercic
2023-03-23 20:01 ` Emanuel Berg
2023-03-24  9:23 ` Jean Louis
2023-03-24 20:52   ` Philip Kaludercic
2023-03-24 21:07     ` Emanuel Berg
2023-03-27  1:52       ` [External] : " Drew Adams
2023-03-27  2:40         ` John Yates
2023-03-24 21:42     ` Jean Louis
2023-03-26  1:04       ` Emanuel Berg
2023-03-30 19:04         ` Jean Louis [this message]
2023-03-25 12:05   ` Dr Rainer Woitok
2023-03-25 14:32     ` Jean Louis
2023-03-25 15:41       ` Dr Rainer Woitok

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=ZCXdPbFcjd/9B6O7@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.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.
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).