[Emacs] Fix mu4e keybinds, handle screen width better, and stop spam

For some reason, some keybinds in mu4e weren’t getting undefined
anymore, this is now fixed.

Add automatic vertical split if the screen is considered wide
enough (120 characters for the headers mode and 80 characters for the
message view mode). If the screen or the headers mode window are not
wide enough, the window will split horizontally instead of vertically.

This commit also adds a function to quickly insert a response to
spammers to get them trapped in an infinite loop of emails. See the
new links in this commit.
This commit is contained in:
Lucien Cartier-Tilet 2021-09-18 15:45:53 +02:00
parent ac3ece02f0
commit d1dbae1915
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -1231,12 +1231,13 @@ Quick sidenote: on ArchLinux, youll need to install either ~mu~ or
<<mu4e-bookmarks>> <<mu4e-bookmarks>>
;; Keybindings
<<mu4e-keybindings-undef>>
<<mu4e-keybindings-view>> <<mu4e-keybindings-view>>
<<mu4e-keybindings-header>> <<mu4e-keybindings-header>>
<<mu4e-keybindings-header-no-leader>> <<mu4e-keybindings-header-no-leader>>
<<mu4e-keybindings-message>> <<mu4e-keybindings-message>>
(when (fboundp 'imagemagick-register-types) (when (fboundp 'imagemagick-register-types)
(imagemagick-register-types)) (imagemagick-register-types))
@ -1276,6 +1277,9 @@ Quick sidenote: on ArchLinux, youll need to install either ~mu~ or
;; Use fancy icons ;; Use fancy icons
<<mu4e-fancy-marks>> <<mu4e-fancy-marks>>
;; Vertical split
<<mu4e-vertical-split>>
;; mu4e-headers-mode config ;; mu4e-headers-mode config
<<mu4e-headers-mode>> <<mu4e-headers-mode>>
@ -1482,6 +1486,32 @@ We can finally define our bookmarks! The code reads as follows:
| :name | This Month | :key | 109 | :query | date:1m..now AND NOT flag:trashed | | | | | | | | :name | This Month | :key | 109 | :query | date:1m..now AND NOT flag:trashed | | | | | | |
| :name | This Year | :key | 121 | :query | date:1y..now AND NOT flag:trashed | | | | | | | | :name | This Year | :key | 121 | :query | date:1y..now AND NOT flag:trashed | | | | | | |
***** Dealing with spammers
:PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Applications-Email-Mu4e-Dealing-with-spammers-tid4mw51l7j0
:END:
Im sure you have received at least one email recently from a sketchy
email address asking you something that might be completely unrelated
to what you do, or at least somewhat related. Fortunately, [[https://twitter.com/Boris/status/1360208504544444417][we have a
hero]]! Now, let me write a function that will insert their pre-written
text at point so I dont have to go back to their Twitter thread each
time I want to shut spammers up.
#+begin_src emacs-lisp
(defun reply-to-bill ()
(interactive)
(insert "Please forward this email to bill@noprocurement.com,
and delete my email, as Ill be changing jobs soon, and this
email address will no longer be active.
Bill Whiskoney is a senior partner at Nordic Procurement
Services, and he handles our budget and will help you further or
introduce you to someone who can."))
#+end_src
If you want the full story, make sure to read the whole thread, I
guarantee it, its worth your time! And in case the Twitter thread
disappear in the future, [[https://threader.app/thread/1360208504544444417][here is a backup]].
***** Getting Fancy ***** Getting Fancy
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Applications-Email-Mu4e-Getting-Fancyg731fl6184j0 :CUSTOM_ID: Packages-Configuration-Applications-Email-Mu4e-Getting-Fancyg731fl6184j0
@ -1541,6 +1571,27 @@ Lets enable them and set them:
<<mu4e-fancy-marks-gen()>>) <<mu4e-fancy-marks-gen()>>)
#+end_src #+end_src
#+name: mu4e-vertical-split
#+begin_src emacs-lisp
(defun my/set-mu4e-headers-width ()
(let ((width (window-body-width))
(threshold (+ 120 80)))
(setq mu4e-split-view (if (> width threshold)
'vertical
'horizontal))
(message "Window width: %d\tthreshold: %d\nSplit: %S"
width
threshold
mu4e-split-view)))
(setq mu4e-headers-visible-columns 120
mu4e-headers-visible-lines 15)
(add-hook 'mu4e-headers-mode-hook #'my/set-mu4e-headers-width)
#+end_src
#+RESULTS: mu4e-vertical-split
| (lambda nil (toggle-truncate-lines -1)) | (lambda nil (visual-line-mode -1)) | my/set-mu4e-headers-width |
***** Headers mode ***** Headers mode
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Applications-Email-Mu4e-Headers-modeum41fl6184j0 :CUSTOM_ID: Packages-Configuration-Applications-Email-Mu4e-Headers-modeum41fl6184j0
@ -1585,8 +1636,6 @@ bépo layout: ~hjkl~ becomes ~ctsr~ for us. Lets undefine some of these:
"gu" nil) "gu" nil)
#+end_src #+end_src
#+RESULTS: mu4e-keybindings-undef
Now, lets define some keybindings for mu4es view mode, that is when Now, lets define some keybindings for mu4es view mode, that is when
we are viewing an email. All these keybindings will reside between the we are viewing an email. All these keybindings will reside between the
major-mode specific leader key ~,~ and most of these keybindings can be major-mode specific leader key ~,~ and most of these keybindings can be