Gnus development mailing list
 help / color / mirror / Atom feed
* gnus-alias-get-something
@ 2023-08-09 20:17 Bob Newell
  2023-08-10  4:32 ` gnus-alias-get-something Bob Newell
  0 siblings, 1 reply; 6+ messages in thread
From: Bob Newell @ 2023-08-09 20:17 UTC (permalink / raw)
  To: ding

Aloha everyone,

The docs for gnus-alias-identity-alist seem to indicate that
an element of the list can be a function that returns a
string.  I have a need for that in the signature field, which
gnus-alias.el accesses like this:

(defun gnus-alias-get-sig (ID)
  "Return the SIGNATURE portion of ID."
  (gnus-alias-get-something ID 6))

But we also have this:

(defsubst gnus-alias-get-something (ID N)
  "Return the Nth something from ID."
  (let ((rv (nth N ID)))
    (if (and (stringp rv) (= (length rv) 0)) nil rv)))

I tried this on the signature field:

(concat start-lisp-home ".signature")

where start-lisp-home is previously defined as

"~/data/elisp"

and got a symbolp error.

Any insights appreciated.  Probably user error!

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB


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

* Re: gnus-alias-get-something
  2023-08-09 20:17 gnus-alias-get-something Bob Newell
@ 2023-08-10  4:32 ` Bob Newell
  2023-08-10  4:40   ` gnus-alias-get-something Emanuel Berg
  2023-08-10  7:31   ` gnus-alias-get-something Björn Bidar
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Newell @ 2023-08-10  4:32 UTC (permalink / raw)
  To: ding


Bob Newell <bobnewell@bobnewell.net> writes:

> Aloha everyone,
>
> The docs for gnus-alias-identity-alist seem to indicate that
> an element of the list can be a function that returns a
> string.  I have a need for that in the signature field, which
> gnus-alias.el accesses like this:
>
> (defun gnus-alias-get-sig (ID)
>   "Return the SIGNATURE portion of ID."
>   (gnus-alias-get-something ID 6))
>
> But we also have this:
>
> (defsubst gnus-alias-get-something (ID N)
>   "Return the Nth something from ID."
>   (let ((rv (nth N ID)))
>     (if (and (stringp rv) (= (length rv) 0)) nil rv)))
>
> I tried this on the signature field:
>
> (concat start-lisp-home ".signature")
>
> where start-lisp-home is previously defined as
>
> "~/data/elisp"
>
> and got a symbolp error.
>
> Any insights appreciated.  Probably user error!

To "clarify" further, the following works and does what I
want.

(defun rjn-make-sig-string ()

"Based on 'identity' from gnus-alias-identity-alist, insert a sig
from a file .signatureidentity in the start-lisp-home directory,
as defined globally elsewhere.  If the appropriate .signatureidentity
doesn't exist just use .signature and assume it exists."

	   (let ((try-file (concat start-lisp-home ".signature" identity))) 
                 (if (not (file-exists-p try-file))
		     (setq try-file (concat start-lisp-home ".signature")))
 	         (with-temp-buffer
                     (insert-file-contents try-file)
	             (buffer-string))  ))

(setq gnus-alias-identity-alist
   '( 
      ("aol"
       nil
       "Bob Newell <newell.bob@aol.com>"
       nil
       (("BCC" . "bobnewell@bobnewell.net")) ;; extra headers
       nil
       rjn-make-sig-string
       )
 ... etc.

However this seems like REALLY the long way around for
something maybe not terribly important.  Is there something
better?

Mahalo

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB


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

* Re: gnus-alias-get-something
  2023-08-10  4:32 ` gnus-alias-get-something Bob Newell
@ 2023-08-10  4:40   ` Emanuel Berg
  2023-08-10  7:26     ` gnus-alias-get-something Bob Newell
  2023-08-10  7:31   ` gnus-alias-get-something Björn Bidar
  1 sibling, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2023-08-10  4:40 UTC (permalink / raw)
  To: ding

Bob Newell wrote:

> However this seems like REALLY the long way around for
> something maybe not terribly important. Is there
> something better?

(info "(gnus) Posting Styles")

?

-- 
underground experts united
https://dataswamp.org/~incal



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

* Re: gnus-alias-get-something
  2023-08-10  4:40   ` gnus-alias-get-something Emanuel Berg
@ 2023-08-10  7:26     ` Bob Newell
  0 siblings, 0 replies; 6+ messages in thread
From: Bob Newell @ 2023-08-10  7:26 UTC (permalink / raw)
  To: ding


Emanuel Berg <incal@dataswamp.org> writes:

> Bob Newell wrote:
>
>> However this seems like REALLY the long way around for
>> something maybe not terribly important. Is there
>> something better?
>
> (info "(gnus) Posting Styles")

I get the point, but I extensively use the gnus-alias
features so posting styles in and of itself doesn't resolve
the issue.

>
> ?
-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB


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

* Re: gnus-alias-get-something
  2023-08-10  4:32 ` gnus-alias-get-something Bob Newell
  2023-08-10  4:40   ` gnus-alias-get-something Emanuel Berg
@ 2023-08-10  7:31   ` Björn Bidar
  2023-08-10 18:16     ` gnus-alias-get-something Bob Newell
  1 sibling, 1 reply; 6+ messages in thread
From: Björn Bidar @ 2023-08-10  7:31 UTC (permalink / raw)
  To: Bob Newell; +Cc: ding


Should it be?
(setq gnus-alias-identity-alist
   '( 
      ("aol"
       nil
       "Bob Newell <newell.bob@aol.com>"
       nil
       (("BCC" . "bobnewell@bobnewell.net")) ;; extra headers
       nil
       #'rjn-make-sig-string
       )

You have write the function name as a reference, the bare name makes it
look like a variable.



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

* Re: gnus-alias-get-something
  2023-08-10  7:31   ` gnus-alias-get-something Björn Bidar
@ 2023-08-10 18:16     ` Bob Newell
  0 siblings, 0 replies; 6+ messages in thread
From: Bob Newell @ 2023-08-10 18:16 UTC (permalink / raw)
  To: ding


Björn Bidar <bjorn.bidar@thaodan.de> writes:

> Should it be?
> (setq gnus-alias-identity-alist
>    '( 
>       ("aol"
>        nil
>        "Bob Newell <newell.bob@aol.com>"
>        nil
>        (("BCC" . "bobnewell@bobnewell.net")) ;; extra headers
>        nil
>        #'rjn-make-sig-string
>        )
>
> You have write the function name as a reference, the bare name makes it
> look like a variable.
>

I've tried it both ways and #'rjn-make-sig-string returns a
symbolp error while the bare rjn-make-sig-string works!  Yes,
I know, this is absolutely contrary to expectations.

The relevant code fragment from gnus-alias.el is this

      ;; what is it, list or function?
      (cond
       ;; .........................
       ;; a function
       ((functionp first-elem)
        ;; call function; if it returns non-nil, use the identity
        (when (funcall first-elem)
          (setq identity (cadr current-choice))
          ))

The functionp test passes and then the funcall works on the
bare name but not on the #' prefixed name.

The ways of Gnus!

-- 
Bob Newell
Honolulu, Hawai`i

- Via GNU/Linux/Emacs/Gnus/BBDB


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

end of thread, other threads:[~2023-08-10 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 20:17 gnus-alias-get-something Bob Newell
2023-08-10  4:32 ` gnus-alias-get-something Bob Newell
2023-08-10  4:40   ` gnus-alias-get-something Emanuel Berg
2023-08-10  7:26     ` gnus-alias-get-something Bob Newell
2023-08-10  7:31   ` gnus-alias-get-something Björn Bidar
2023-08-10 18:16     ` gnus-alias-get-something Bob Newell

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 NNTP newsgroup(s).