all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* hook run just in message-mode just before user begins composing/replying?
@ 2023-05-09 13:02 Gregor Zattler
  2023-05-09 13:20 ` Tim Landscheidt
  2023-05-09 13:28 ` Manuel Giraud via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 10+ messages in thread
From: Gregor Zattler @ 2023-05-09 13:02 UTC (permalink / raw)
  To: help-gnu-emacs

I wrote two functions which, manually called in a
buffer just set up by message-mode for me to start
typing my message/reply, manipulate the headers of said
message.

ATM I call them in message-send-hook but then I do not
see the result of the manipulations and sometimes I would
like to adjust headers after these functions run.

I did not find a hook for this purpose.  I experimented
with message-signature-setup-hook but then one function
mangles the headers, the other function does nothing,
indicating that the headers are not setup or not
accessible as at the moment the user (I) starts to
type.

Any ideas how to solve this puzzle?



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 13:02 hook run just in message-mode just before user begins composing/replying? Gregor Zattler
@ 2023-05-09 13:20 ` Tim Landscheidt
  2023-05-09 14:03   ` Gregor Zattler
  2023-05-09 13:28 ` Manuel Giraud via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 10+ messages in thread
From: Tim Landscheidt @ 2023-05-09 13:20 UTC (permalink / raw)
  To: help-gnu-emacs

Gregor Zattler <telegraph@gmx.net> wrote:

> I wrote two functions which, manually called in a
> buffer just set up by message-mode for me to start
> typing my message/reply, manipulate the headers of said
> message.

> ATM I call them in message-send-hook but then I do not
> see the result of the manipulations and sometimes I would
> like to adjust headers after these functions run.

> I did not find a hook for this purpose.  I experimented
> with message-signature-setup-hook but then one function
> mangles the headers, the other function does nothing,
> indicating that the headers are not setup or not
> accessible as at the moment the user (I) starts to
> type.

> Any ideas how to solve this puzzle?

There are also (in Emacs 28.2) message-header-setup-hook and
message-setup-hook that look promising.  Do they work for
you?

Tim



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 13:02 hook run just in message-mode just before user begins composing/replying? Gregor Zattler
  2023-05-09 13:20 ` Tim Landscheidt
@ 2023-05-09 13:28 ` Manuel Giraud via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 10+ messages in thread
From: Manuel Giraud via Users list for the GNU Emacs text editor @ 2023-05-09 13:28 UTC (permalink / raw)
  To: help-gnu-emacs

Gregor Zattler <telegraph@gmx.net> writes:

> I wrote two functions which, manually called in a
> buffer just set up by message-mode for me to start
> typing my message/reply, manipulate the headers of said
> message.
>
> ATM I call them in message-send-hook but then I do not
> see the result of the manipulations and sometimes I would
> like to adjust headers after these functions run.
>
> I did not find a hook for this purpose.  I experimented
> with message-signature-setup-hook but then one function
> mangles the headers, the other function does nothing,
> indicating that the headers are not setup or not
> accessible as at the moment the user (I) starts to
> type.
>
> Any ideas how to solve this puzzle?

Hi,

I don't know how you compose your mail but for 'compose-mail' (looking
at code) it seems that your looking for 'mail-setup-hook'.  For
message.el there is 'message-setup-hook' also.
-- 
Manuel Giraud



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 13:20 ` Tim Landscheidt
@ 2023-05-09 14:03   ` Gregor Zattler
  2023-05-09 17:40     ` Eric Abrahamsen
  2023-05-09 18:30     ` Tim Landscheidt
  0 siblings, 2 replies; 10+ messages in thread
From: Gregor Zattler @ 2023-05-09 14:03 UTC (permalink / raw)
  To: Tim Landscheidt, help-gnu-emacs

Hi Tim, Manuel,
* Tim Landscheidt <tim@tim-landscheidt.de> [2023-05-09; 13:20 GMT]:
> Gregor Zattler <telegraph@gmx.net> wrote:
>> I wrote two functions which, manually called in a
>> buffer just set up by message-mode for me to start
>> typing my message/reply, manipulate the headers of said
>> message.
>
>> ATM I call them in message-send-hook but then I do not
>> see the result of the manipulations and sometimes I would
>> like to adjust headers after these functions run.
>
>> I did not find a hook for this purpose.  I experimented
>> with message-signature-setup-hook but then one function
>> mangles the headers, the other function does nothing,
>> indicating that the headers are not setup or not
>> accessible as at the moment the user (I) starts to
>> type.
>
>> Any ideas how to solve this puzzle?
>
> There are also (in Emacs 28.2) message-header-setup-hook and
> message-setup-hook that look promising.  Do they work for
> you?

sadly no.  These are the hooks I already tested (should
have be more specific in my original post).  Somehow
the functions don't work there.  The more basic one
simply does nothing, the other one mangles the headers
which it does not, if called manually in the
"*unsent mail to..." buffer.

Any ideas how to actually see the buffer when the hooks
are run?  Then I could adjust my functions or decide
that it's simply the wrong hook.

A message-just-before-user-is-allowed-to-type-hook
would be great...


Thanks for your attention, Gregor



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 14:03   ` Gregor Zattler
@ 2023-05-09 17:40     ` Eric Abrahamsen
  2023-05-10  8:37       ` Gregor Zattler
  2023-05-09 18:30     ` Tim Landscheidt
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2023-05-09 17:40 UTC (permalink / raw)
  To: Tim Landscheidt; +Cc: help-gnu-emacs

Gregor Zattler <telegraph@gmx.net> writes:

> Hi Tim, Manuel,
> * Tim Landscheidt <tim@tim-landscheidt.de> [2023-05-09; 13:20 GMT]:
>> Gregor Zattler <telegraph@gmx.net> wrote:
>>> I wrote two functions which, manually called in a
>>> buffer just set up by message-mode for me to start
>>> typing my message/reply, manipulate the headers of said
>>> message.
>>
>>> ATM I call them in message-send-hook but then I do not
>>> see the result of the manipulations and sometimes I would
>>> like to adjust headers after these functions run.
>>
>>> I did not find a hook for this purpose.  I experimented
>>> with message-signature-setup-hook but then one function
>>> mangles the headers, the other function does nothing,
>>> indicating that the headers are not setup or not
>>> accessible as at the moment the user (I) starts to
>>> type.
>>
>>> Any ideas how to solve this puzzle?
>>
>> There are also (in Emacs 28.2) message-header-setup-hook and
>> message-setup-hook that look promising.  Do they work for
>> you?
>
> sadly no.  These are the hooks I already tested (should
> have be more specific in my original post).  Somehow
> the functions don't work there.  The more basic one
> simply does nothing, the other one mangles the headers
> which it does not, if called manually in the
> "*unsent mail to..." buffer.
>
> Any ideas how to actually see the buffer when the hooks
> are run?  Then I could adjust my functions or decide
> that it's simply the wrong hook.
>
> A message-just-before-user-is-allowed-to-type-hook
> would be great...

Maybe just the `message-mode-hook'?



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 14:03   ` Gregor Zattler
  2023-05-09 17:40     ` Eric Abrahamsen
@ 2023-05-09 18:30     ` Tim Landscheidt
  2023-05-10  8:43       ` Gregor Zattler
  1 sibling, 1 reply; 10+ messages in thread
From: Tim Landscheidt @ 2023-05-09 18:30 UTC (permalink / raw)
  To: help-gnu-emacs

Gregor Zattler <telegraph@gmx.net> wrote:

> […]

> Any ideas how to actually see the buffer when the hooks
> are run?  Then I could adjust my functions or decide
> that it's simply the wrong hook.

> […]

You should be able to use Edebug to step through your func-
tion (with edebug-defun), but looking at the big picture I
typically just add calls à la:

| (message "buffer = %S" (buffer-name))

or:

| (message "bufferstring = %S" (buffer-string))

to my code.

Tim



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 17:40     ` Eric Abrahamsen
@ 2023-05-10  8:37       ` Gregor Zattler
  0 siblings, 0 replies; 10+ messages in thread
From: Gregor Zattler @ 2023-05-10  8:37 UTC (permalink / raw)
  To: help-gnu-emacs

* Eric Abrahamsen <eric@ericabrahamsen.net> [2023-05-09; 10:40 -07]:
> Gregor Zattler <telegraph@gmx.net> writes:
>> A message-just-before-user-is-allowed-to-type-hook
>> would be great...
>
> Maybe just the `message-mode-hook'?

this is called while the buffer is empty, as I learned
with Tim's the neat trick of

(message "bufferstring = %S" (buffer-string))



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-09 18:30     ` Tim Landscheidt
@ 2023-05-10  8:43       ` Gregor Zattler
  2023-05-10  8:59         ` Manuel Giraud via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Gregor Zattler @ 2023-05-10  8:43 UTC (permalink / raw)
  To: help-gnu-emacs

* Tim Landscheidt <tim@tim-landscheidt.de> [2023-05-09; 18:30 GMT]:
> You should be able to use Edebug to step through your func-
> tion (with edebug-defun), but looking at the big picture I
> typically just add calls à la:
>
> | (message "buffer = %S" (buffer-name))
>
> or:
>
> | (message "bufferstring = %S" (buffer-string))
>
> to my code.

this did the trick.  Thanks so much.

Now I learned, that message-header-setup-hook is the
right one.  My function failed, because the headers at
the time of calling that hook are actually arranged in
a different order, than shown in the final version of
the buffer which the user is proposed to edit.

While it works now as I hoped for, there is a flicker.
Now I have to learn how to disable display update while
my functions are evaluated...



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-10  8:43       ` Gregor Zattler
@ 2023-05-10  8:59         ` Manuel Giraud via Users list for the GNU Emacs text editor
  2023-05-10  9:22           ` Gregor Zattler
  0 siblings, 1 reply; 10+ messages in thread
From: Manuel Giraud via Users list for the GNU Emacs text editor @ 2023-05-10  8:59 UTC (permalink / raw)
  To: help-gnu-emacs

Gregor Zattler <telegraph@gmx.net> writes:

[...]

> While it works now as I hoped for, there is a flicker.
> Now I have to learn how to disable display update while
> my functions are evaluated...

Maybe, you can have a "(let ((inhibit-redisplay t))…)" at the top of
your function.
-- 
Manuel Giraud



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

* Re: hook run just in message-mode just before user begins composing/replying?
  2023-05-10  8:59         ` Manuel Giraud via Users list for the GNU Emacs text editor
@ 2023-05-10  9:22           ` Gregor Zattler
  0 siblings, 0 replies; 10+ messages in thread
From: Gregor Zattler @ 2023-05-10  9:22 UTC (permalink / raw)
  To: help-gnu-emacs

* Manuel Giraud via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2023-05-10; 10:59 +02]:
> Gregor Zattler <telegraph@gmx.net> writes:
> [...]
>
>> While it works now as I hoped for, there is a flicker.
>> Now I have to learn how to disable display update while
>> my functions are evaluated...
>
> Maybe, you can have a "(let ((inhibit-redisplay t))…)" at the top of
> your function.

thanks, works like a charm now.



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

end of thread, other threads:[~2023-05-10  9:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09 13:02 hook run just in message-mode just before user begins composing/replying? Gregor Zattler
2023-05-09 13:20 ` Tim Landscheidt
2023-05-09 14:03   ` Gregor Zattler
2023-05-09 17:40     ` Eric Abrahamsen
2023-05-10  8:37       ` Gregor Zattler
2023-05-09 18:30     ` Tim Landscheidt
2023-05-10  8:43       ` Gregor Zattler
2023-05-10  8:59         ` Manuel Giraud via Users list for the GNU Emacs text editor
2023-05-10  9:22           ` Gregor Zattler
2023-05-09 13:28 ` Manuel Giraud via Users list for the GNU Emacs text editor

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.