Giter Site home page Giter Site logo

Comments (2)

gajama avatar gajama commented on June 12, 2024

The code in the README didn't work for me*, but I can share how I've set this up.

My org-msg-signature defaults to some html wrapped in export_begin html and end_export tags, that I keep in a file:

(setq org-msg-signature (with-current-buffer (find-file-noselect (expand-file-name ".html-signature" org-roam-directory) t) (buffer-string))))

Then I used the example code in the README to come up with the following:

(defun gjm/org-msg-signature-switch (orig-fun &rest args)
    "No signature for replies. Text signature for new plain text emails."
    (let ((res (apply orig-fun args))
           (is-reply (not (equal (car args) 'new)))
           (is-text (equal (last (cadr args)) '(text)))
           (text-sig "\n\n--\nGav Massingham\nTechnology Development Officer\nCarers' Resource"))
      (if is-reply (setf (alist-get 'signature res) "")
        (if is-text (setf (alist-get 'signature res) text-sig)))
      res))
  (advice-add 'org-msg-composition-parameters
              :around #'gjm/org-msg-signature-switch)

First, I set a couple of local convenience variables for whether it's a reply email, whether it's a plain text email, and to hold a basic signature for plain text emails. Then there are a couple of nested if statements. The first check if it's a reply email, and set the signature to be empty if so, as I don't want a signature on replies. The second checks if we're sending a plain text email and sets the signature to the variable created earlier, if so.

This works for setting the signature of the message being edited.

What doesn't seem to happen is for separate text and HTML signatures to be added to the relevant parts of the message if there are both HTML and text versions (at least it doesn't for me using mu4e with org-msg). I don't know if this is the expected behaviour, or a bug. A quick scan of the code suggests the signature is only inserted once, into the buffer for editing the message. It would be good to have both versions of the signature included in emails that send both text and HTML parts, so I'll look into this further.


*because args was set to '(new (text)) at the time, and (cadr args) is nil if args is a list with a single element

from org-msg.

benthamite avatar benthamite commented on June 12, 2024

If you use mu4e, you can also do this with the “contexts” function; here’s the key part from my config:

(defun mu4e-extras-set-contexts ()
  "Set `mu4e-contexts'."
  (setq mu4e-contexts
	`(,(make-mu4e-context
            :name "Personal HTML"
            :match-func #'mu4e-extras-msg-is-personal-and-html-p
            :vars `((user-mail-address . ,(getenv "PERSONAL_GMAIL"))
		    (org-msg-signature . ,org-msg-extras-personal-html-signature)))
	  ,(make-mu4e-context
            :name "Personal plain text"
            :match-func #'mu4e-extras-msg-is-personal-and-plain-text-p
            :vars `((user-mail-address . ,(getenv "PERSONAL_GMAIL"))
		    (org-msg-signature . ,org-msg-extras-personal-plain-text-signature)))
	  ,(make-mu4e-context
            :name "Work HTML"
            :match-func #'mu4e-extras-msg-is-work-and-html-p
            :vars `((user-mail-address . ,(getenv "WORK_EMAIL"))
		    (org-msg-signature . ,org-msg-extras-work-html-signature)))
	  ,(make-mu4e-context
            :name "Work plain text"
            :match-func #'mu4e-extras-msg-is-work-and-plain-text-p
            :vars `((user-mail-address . ,(getenv "WORK_EMAIL"))
		    (org-msg-signature . ,org-msg-extras-work-plain-text-signature))))))
			
(defun org-msg-extras-msg-is-html-p ()
  "Return t iff the current message is an HTML message."
  (not (null (condition-case nil
		 (org-msg-mua-call 'article-htmlp)
	       (error nil)))))
			

The other relevant functions are defined here.

from org-msg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.