[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (interactive) and &optional
From: |
Jean Louis |
Subject: |
Re: (interactive) and &optional |
Date: |
Thu, 30 Mar 2023 22:04:29 +0300 |
User-agent: |
Mutt/2.2.9+54 (af2080d) (2022-11-21) |
* 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/
- Re: (interactive) and &optional, (continued)
Re: (interactive) and &optional, Emanuel Berg, 2023/03/23
Re: (interactive) and &optional, Jean Louis, 2023/03/24
Re: (interactive) and &optional, Emanuel Berg, 2023/03/26
RE: [External] : Re: (interactive) and &optional, Drew Adams, 2023/03/26
Re: [External] : Re: (interactive) and &optional, John Yates, 2023/03/26
Re: (interactive) and &optional, Dr Rainer Woitok, 2023/03/25