Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to suppress X-ExtEditorR-* headers or all headers #139

Open
reagle opened this issue Dec 5, 2023 · 10 comments
Open

How to suppress X-ExtEditorR-* headers or all headers #139

reagle opened this issue Dec 5, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@reagle
Copy link

reagle commented Dec 5, 2023

I recently upgraded to the new plugin and message host and now see lots of X-ExtEditorR-* headers I'd rather not see. How to suppress them?

Environment

| macOS 13.6.1 22G313 arm64
| thunderbird: 115.5.1
| External Editor 1.0
| External Editor Revived native messaging host for macos (aarch64) v1.0.0

SCR-20231205-nzsh SCR-20231205-oadn
@Frederick888
Copy link
Owner

Frederick888 commented Dec 6, 2023

This is not possible directly in EER.

However you can:

  1. Fold them in your editor (best)
    In Vim/Neovim this is as simple as
    setl foldexpr=getline(v:lnum)=~'^X-ExtEditorR'?1:0
    setl foldmethod=expr
    setl foldlevel=0
    I'd be surprised if Sublime doesn't support something similar.
    A more complete setup in Neovim Lua can be (screen recording below):
    local M              = {}
    local api            = vim.api
    
    local MAX_SCAN_LINES = 50
    function M.first_empty_line(bufnr)
      local lines = api.nvim_buf_get_lines(bufnr, 0, MAX_SCAN_LINES, false)
      for i, l in ipairs(lines) do
        if l:len() == 0 then
          return i - 1
        end
      end
      return nil
    end
    
    function M.foldexpr(lnum)
      local line_num = lnum - 1
      local first_empty = M.first_empty_line(0)
      if first_empty ~= nil and line_num >= first_empty then
        return 0
      end
      local line = api.nvim_buf_get_lines(0, line_num, line_num + 1, false)[1]
      if (line:match('^X%-ExtEditorR:') or line:match('^X%-ExtEditorR%-')) and not line:match('^X%-ExtEditorR%-X%-ExtEditorR') then
        return 2
      end
      if line:match('^Cc:') or line:match('^Bcc:') or line:match('^Reply%-To:') then
        return 1
      end
      return 0
    end
    
    function M.setup()
      api.nvim_create_autocmd({ 'FileType' }, {
        pattern = { 'mail' },
        callback = function()
          vim.opt_local.foldmethod = 'expr'
          vim.opt_local.foldexpr = 'v:lua.require("user/mail").foldexpr(v:lnum)'
          --- set to 1 to fold X-ExtEditorR headers; set to 0 to fold Cc/Bcc/Reply-To as well
          vim.opt_local.foldlevel = 1
        end
      })
    end
  2. Have you tried 'Meta Headers'? (better)
    Is it still too overwhelming with it on?
  3. Use a custom script to remove them (meh)
    You can delete the headers if you don't need them. EER won't touch those options just because they are missing.
    Simply something like rg -v '^X-ExtEditorR-' <"$1" | sponge "$1", then start your editor.
record-2023-12-06_20.55.06.mp4

While I agree the headers certainly take a bit more space now, the 'meta headers' were the best I could come up with to ameliorate it.

Offering a 'compact mode' with a subset of the headers? But how do I know which headers are more important? Personally I use Send-On-Exit quite often. Attach-vCard and Delivery-Status-Notification? Maybe. Priority? Rarer. Delivery-Format? You probably don't want to change that. Anyway these are all what I think. I do not know what users think. And I do not want them to manually type up the headers.

Making headers individually configurable? That'd be quite some effort for a very small gain. It won't be as nice as the Vim/Neovim folds, and it'll be a lot more noise in EER's configurations.

@reagle
Copy link
Author

reagle commented Dec 6, 2023

@Frederick888, yikes! I appreciate the help but I want to keep it simple. I'd go back a version if I could but I try to stay up to date with TB and had to upgrade. Some questions.

  1. Could all of these headers be called verbose/advanced mode and disabled with a toggle?
  2. Why is your multi-line format called "meta"?

@ondohotola
Copy link

This is really a nuisance for me as well.

@Frederick888 Frederick888 changed the title How to suppress X-ExtEditorR-* headers How to suppress X-ExtEditorR-* headers or all headers Dec 17, 2023
@Frederick888
Copy link
Owner

Frederick888 commented Dec 17, 2023 via email

@Frederick888 Frederick888 added the enhancement New feature or request label Dec 17, 2023
@ondohotola
Copy link

ondohotola commented Dec 17, 2023 via email

@reagle
Copy link
Author

reagle commented Dec 18, 2023

@Frederick888, my apologies, I didn't mean to offend.

I'll simply note that body, Subject, To, CC, and BCC are the only headers I care to edit and see.

@ondohotola, I find editing To, CC, BCC in TB a nuisance and wonder how you manage? I often have to resort to using my pointer to select addresses (which can be fiddly) or repeatedly alt-clicking to get to "move to". I love editing those in a text editor with keyboard only.

@ondohotola
Copy link

ondohotola commented Dec 18, 2023 via email

@reagle
Copy link
Author

reagle commented Dec 18, 2023

Ah. I don't create many new emails nor add addresses. I do spend a fair amount of time rearranging addresses between the To and CC to be polite, which I do like doing in the text editor.

@Frederick888
Copy link
Owner

Frederick, whether it is a niche project or not, it is highly addictive once discovered :-)-O

Thank you.

I have been unable to find a nice Sublime Text extension to format emails, are you aware of one?

I don't use Sublime so I have no idea ¯\_(ツ)_/¯. Sublime does seem to have some EML syntax support, maybe you can pair one of them with rulers like https://forum.sublimetext.com/t/support-the-popular-git-commit-message-format/39104/2.

@Frederick888, my apologies, I didn't mean to offend.

Nah, I was kinda joking.

I do spend a fair amount of time rearranging addresses between the To and CC to be polite, which I do like doing in the text editor.

Well, case in point... :P

@ondohotola
Copy link

I found (after a little prompting on the Usenet :-)-O) the Command-R 'Rewrap' command in TBird, which in combination with Sublime Text works so well that so would like if you added it to the defaults :-)-O

/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w "/path/to/temp.eml"

(one line, note the \ before the space) works very well though.

Will be playing on the MacBook for a while and if it works well enough will toss Alpha and reconfigure the iMac.

Thank you again, el

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants