all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* A completing read to set message-mode or Gnus "from"
@ 2015-08-11 22:58 Tory S. Anderson
  2015-08-12  6:01 ` Ian Zimmerman
  2015-08-12  7:34 ` Thierry Volpiatto
  0 siblings, 2 replies; 4+ messages in thread
From: Tory S. Anderson @ 2015-08-11 22:58 UTC (permalink / raw)
  To: Emacs Help List

As a Helm user with 7 or so email addresses I might be sending 
with, I wanted to put together a quick completing-read to fill in 
my from address with a keystroke; however, it's not working and 
I'm not sure why. It complains about wanting a list, but when I 
return a list it complains about wanting a string.

--8<---------------cut here---------------start------------->8---
(defun tsa/message-choose-from ()
  (interactive
   (let ((my-name "Joseph Smith")
	 (my-from-list '("abc@gmail.com" "def@gmail.com" 
	 "xyz@gmail.com")))
     (message-make-from my-name (completing-read "From:" 
     my-from-list nil t)))))

(add-hook 'message-mode-hook
	  (lambda ()
	    (local-set-key (kbd "C-c f") 
	    'tsa/message-choose-from)))
--8<---------------cut here---------------end--------------->8---

Error:
> command-execute: Wrong type argument: listp, "Joseph Smith 
> <abc@gmail.com>"

Is this to do with "interactive" vs "message-make-from"? The 
completing-read seems to work, but the final step is blocked by 
the error. 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A completing read to set message-mode or Gnus "from"
  2015-08-11 22:58 A completing read to set message-mode or Gnus "from" Tory S. Anderson
@ 2015-08-12  6:01 ` Ian Zimmerman
  2015-08-12  6:06   ` Ian Zimmerman
  2015-08-12  7:34 ` Thierry Volpiatto
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Zimmerman @ 2015-08-12  6:01 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-08-11 16:58 -0600, Tory S. Anderson wrote:

> As a Helm user with 7 or so email addresses I might be sending with,
> I wanted to put together a quick completing-read to fill in my from
> address with a keystroke; however, it's not working and I'm not sure
> why. It complains about wanting a list, but when I return a list it
> complains about wanting a string.
> 
> --8<---------------cut here---------------start------------->8---
> (defun tsa/message-choose-from ()
>  (interactive
>   (let ((my-name "Joseph Smith")
> 	 (my-from-list '("abc@gmail.com" "def@gmail.com" 	
> "xyz@gmail.com")))
>     (message-make-from my-name (completing-read "From:"
> my-from-list nil t)))))
> 
> (add-hook 'message-mode-hook
> 	  (lambda ()
> 	    (local-set-key (kbd "C-c f") 	    'tsa/message-choose-from)))

I think you don't understand what the interactive declaration is for.

It doesn't mean "this code interacts with the user".  It means it can be
invoked as a command, with a keybinding or via M-x.  In your case,
you're calling your function from a hook, which is as non-interactive as
it gets :-)

When we clarify that point, we can get to _how_ to use interactive; you
don't do that right either, even if it made sense to provide the
function as a command.

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A completing read to set message-mode or Gnus "from"
  2015-08-12  6:01 ` Ian Zimmerman
@ 2015-08-12  6:06   ` Ian Zimmerman
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Zimmerman @ 2015-08-12  6:06 UTC (permalink / raw)
  To: help-gnu-emacs

On 2015-08-11 23:01 -0700, Ian Zimmerman wrote:

Tory> As a Helm user with 7 or so email addresses I might be sending
Tory> with, I wanted to put together a quick completing-read to fill in
Tory> my from address with a keystroke; however, it's not working and
Tory> I'm not sure why. It complains about wanting a list, but when I
Tory> return a list it complains about wanting a string.

> > --8<---------------cut here---------------start------------->8---
> > (defun tsa/message-choose-from ()
> >  (interactive
> >   (let ((my-name "Joseph Smith")
> > 	 (my-from-list '("abc@gmail.com" "def@gmail.com" 	
> > "xyz@gmail.com")))
> >     (message-make-from my-name (completing-read "From:"
> > my-from-list nil t)))))
> > 
> > (add-hook 'message-mode-hook
> > 	  (lambda ()
> > 	    (local-set-key (kbd "C-c f") 	    'tsa/message-choose-from)))
> 

Ian> I think you don't understand what the interactive declaration is
Ian> for.
Ian> 
Ian> It doesn't mean "this code interacts with the user".  It means it
Ian> can be invoked as a command, with a keybinding or via M-x.  In your
Ian> case, you're calling your function from a hook, which is as
Ian> non-interactive as it gets :-)

Eh, forget this part.  It's quite late here :-(

Ian> When we clarify that point, we can get to _how_ to use interactive

This, though, is valid.  Have you looked at some Emacs source to see how
(interactive) is used?

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A completing read to set message-mode or Gnus "from"
  2015-08-11 22:58 A completing read to set message-mode or Gnus "from" Tory S. Anderson
  2015-08-12  6:01 ` Ian Zimmerman
@ 2015-08-12  7:34 ` Thierry Volpiatto
  1 sibling, 0 replies; 4+ messages in thread
From: Thierry Volpiatto @ 2015-08-12  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

Tory S. Anderson <torys.anderson@gmail.com> writes:

> As a Helm user with 7 or so email addresses I might be sending 
> with, I wanted to put together a quick completing-read to fill in 
> my from address with a keystroke; however, it's not working and 
> I'm not sure why. It complains about wanting a list, but when I 
> return a list it complains about wanting a string.
>
> (defun tsa/message-choose-from ()
>   (interactive
>    (let ((my-name "Joseph Smith")
> 	 (my-from-list '("abc@gmail.com" "def@gmail.com" 
> 	 "xyz@gmail.com")))
>      (message-make-from my-name (completing-read "From:" 
>      my-from-list nil t)))))

(defun tsa/message-choose-from (address)
  (interactive (list (completing-read
                      "From: "
                      '("abc@gmail.com" "def@gmail.com" "xyz@gmail.com"))))
  (message "Joseph Smith with %s" address))

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-12  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 22:58 A completing read to set message-mode or Gnus "from" Tory S. Anderson
2015-08-12  6:01 ` Ian Zimmerman
2015-08-12  6:06   ` Ian Zimmerman
2015-08-12  7:34 ` Thierry Volpiatto

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.