Remove non-text-editor features

This commit is contained in:
Camden Dixie O'Brien 2021-01-01 00:00:33 +00:00
parent e5d3179ebb
commit e1477bfc7a

View File

@ -507,285 +507,3 @@ needs to be set up to install them if they aren't already.
(add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
#+end_src
* Desktop
** EXWM
One must fulfil the meme of doing everything with Emacs... still
got a lot of tweaking to do here before I'm happy.
#+begin_src emacs-lisp
(use-package exwm
:config
(require 'exwm-config)
(exwm-config-default))
#+end_src
*** Multi-monitor
Multi-monitor support is provided in =exwm-randr=:
#+begin_src emacs-lisp
(require 'exwm-randr)
(exwm-randr-enable)
#+end_src
When I have my laptop connected to a monitor I want the built-in
display to turn off, but turn back on when it's disconnected. Turns
out this is a total pain.
To start with we need a function to tell whether a monitor's
attached. =exwm-randr= provides [[help:exwm-randr--get-monitors][exwm-randr--get-monitors]], but its
result is not -- as I'd expect -- a list of monitors, but instead a
rather complicated mess that is (as far as I can tell)
undocumented. Rather than trying to figure out what was going on
there, I opted for the search-in-shell-command-output route
#+begin_src emacs-lisp
(defun hdmi-connected-p ()
(string-match-p "HDMI-2 connected"
(shell-command-to-string "xrandr")))
#+end_src
With that defined, an [[help:exwm-randr-screen-change-hook][exwm-randr-screen-change-hook]] can then be
added to turn the built-in display on and off appropriately.
#+begin_src emacs-lisp
(add-hook 'exwm-randr-screen-change-hook
(lambda ()
(let ((xrandr-command
(if (hdmi-connected-p)
"xrandr --output eDP-1 --off --output HDMI-2 --auto"
"xrandr --output eDP-1 --auto")))
(start-process-shell-command "xrandr" nil xrandr-command))))
#+end_src
*** Extra Simulation Keys
The ones provided by the default are very nice, but I also want to
use =C-w=, =M-w= and =C-y= for cut, copy and paste and =C-s= for
searching. This is done by setting [[help:exwm-input-simulation-keys][exwm-input-simulation-keys]]
#+begin_src emacs-lisp
(nconc exwm-input-simulation-keys
(list (cons (kbd "C-w") (kbd "C-x"))
(cons (kbd "M-w") (kbd "C-c"))
(cons (kbd "C-y") (kbd "C-v"))
(cons (kbd "C-s") (kbd "C-f"))))
#+end_src
** Mode Line
*** Clock
The time is a useful thing to know... and 12-hour clock is for
losers.
#+begin_src emacs-lisp
(setq display-time-24hr-format t)
(display-time-mode 1)
#+end_src
*** Battery
Also useful to know, but only on a laptop... once I'm using this
configuration on Mandarax as well I'll probably have to
conditionally disable it.
#+begin_src emacs-lisp
(display-battery-mode 1)
#+end_src
* Passwords
This was a little more work than I expected... =password-store=
provides a nice interface to =pass=, but annoyingly appears to
depend on =f= without declaring so.
#+begin_src emacs-lisp
(use-package password-store)
(use-package f)
#+end_src
However, in order for it to actually work, EasyPG had to be
configured to use loopback for pinentry.
#+begin_src emacs-lisp
(setq epa-pinentry-mode 'loopback)
#+end_src
=gpg-agent= also had to be configured to allow loopback for
pinentry -- this was done by adding =allow-loopback-pinentry= to
[[file:~/.gnupg/gpg-agent.conf::allow-loopback-pinentry][gpg-agent.conf]].
With that all working, all that remains is to add a convenient
keybinding for getting a password, which is done by the function
=password-store-copy=. =C-c C-p= does conflict with /some/ modal
bindings, but I think that's fine as most of the time I'll need a
password it'll be in some X window anyway... and besides, =M-x
pass-co RET= isn't bad for when it does happen to conflict.
#+begin_src emacs-lisp
(global-set-key (kbd "C-c C-p") 'password-store-copy)
#+end_src
** TODO Pinentry prompt bugginess
When =pass= tries to bring up the the pinentry prompt it freezes
everything up and I have to =C-g= to get the prompt to
appear. Definitely not ideal but it does work so imma fix that at
some other time.
* Mail
Currently using =mu4e= for mail. Not sure whether this is my 'final'
set up, I might give =notmuch= a try at some point.
=mu4e= is a bit annoying as it's bundled along with =mu= rather than
being loaded from ELPA or MELPA, so it can't be loaded with
=use-package=. Indeed, how to load it depends on how =mu= was
packaged. On NixOS, =mu4e= gets automagically introduced to Emacs,
but on OpenBSD we have to add its location to =load-path= ourselves.
#+begin_src emacs-lisp
(let ((uname-output (shell-command-to-string "uname -a")))
(cond ((string-match-p "NixOS" uname-output) nil)
((string-match-p "OpenBSD" uname-output)
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e"))))
(require 'mu4e)
#+end_src
To get the correct address by default:
#+begin_src emacs-lisp
(setq user-mail-address "cdo@wip.sh")
#+end_src
And to avoid being tickled:
#+begin_src emacs-lisp
(setq mail-host-address (shell-command-to-string "hostname"))
#+end_src
** Automatic updating
For updating through =mu4e= to actually work, [[help:mu4e-get-mail-command][mu4e-get-mail-command]]
needs to be set to =offlineimap=. New mail can be then fetched
with [[help:mu4e-update-mail-and-index][mu4e-update-mail-and-index]].
#+begin_src emacs-lisp
(setq mu4e-get-mail-command "offlineimap")
#+end_src
Sometimes (like when waiting for on a particular email) it might be
useful to have the update run periodically. This can be done with
[[help:run-with-timer][run-with-timer]]. By only actually updating if ~fetch-mail~
non-~nil~, we give ourselves a way to turn it off.
#+begin_src emacs-lisp
(defvar fetch-mail nil "Controls whether mail is periodically fetched.")
(run-with-timer 0 120 (lambda ()
(when fetch-mail
(mu4e-update-mail-and-index t))))
#+end_src
And then we need something to run through =M-x= to do that:
#+begin_src emacs-lisp
(defun toggle-mail-fetching ()
"Toggle periodic mail fetching."
(interactive)
(setq fetch-mail (not fetch-mail))
(message "Mail fetching %s"
(if fetch-mail "enabled" "disabled")))
#+end_src
** Mode-line alert
=mu4e-alert= provides a convenient little icon that shows up
whenever =mu4e= has unread mail.
#+begin_src emacs-lisp
(use-package mu4e-alert
:config
(add-hook 'after-init-hook
#'mu4e-alert-enable-mode-line-display))
#+end_src
** Sending with =sendmail=
I have =msmtp= set up so use that to send mail.
#+begin_src emacs-lisp
(setq send-mail-function 'sendmail-send-it)
#+end_src
** Archiving
The folder archived mail gets saved into is determined by
[[help:mu4e-refile-folder][mu4e-refile-folder]]. I prefer to have archived mail stored on the
remove since then it's accessible from every machine (the default
is =/archive=, which won't get synced to any remote by
=offlineimap=), so imma set this to =/wip/archive=.
#+begin_src emacs-lisp
(setq mu4e-refile-folder "/wip/archive")
#+end_src
Really, it would be better to determine which archive to move into
based off what account the mail was received from, which I believe
would be done with [[info:mu4e#Dynamic folders][dynamic folders]], but I cannot be bothered right
now since I only have my cdo@wip.sh mail set up on this machine
(mandarax) atm.
* Multimedia
EMMS seems like a decent multimedia system for Emacs and why not
enable all the stable features to start with. Also, =mplayer= makes
a good fallback player.
#+begin_src emacs-lisp
(use-package emms
:config
(emms-all)
(add-to-list 'emms-player-list 'emms-player-mplayer))
#+end_src
** Browser
To actually get stuff to show up in the browser it seems you have
to define a filter that includes everything, because fuck sane
defaults.
#+begin_src emacs-lisp
(emms-browser-make-filter "all" 'ignore)
#+end_src
** MPD
To get EMMS to talk to MPD, we need to tell it how to connect to
it, and to use it for getting track info and playing tracks:
#+begin_src emacs-lisp
(add-to-list 'emms-info-functions 'emms-info-mpd)
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-server-name "localhost"
emms-player-mpd-server-port "6600"
emms-player-mpd-music-directory "~/mus")
#+end_src
With those options in place, connecting should work fine (assuming
the underlying system has MPD running).
#+begin_src emacs-lisp
(emms-player-mpd-connect)
(emms-cache-set-from-mpd-all)
#+end_src
** Podcasts / RSS
Elfeed supports media enclosures, so it's ideal for podcasts
out-of-the-box.
#+begin_src emacs-lisp
(use-package elfeed
:config
(setq elfeed-feeds
'("https://www.patreon.com/rss/seanmcarroll?auth=xZISWBuCvZ1rKXy547HnRXQVyBIscY1P"
"https://www.patreon.com/rss/plasticpills?auth=S0ExMga6Cco6F4DN30W6Sg9kUciLdjXR"
"https://feeds.transistor.fm/on-the-metal-0294649e-ec23-4eab-975a-9eb13fd94e06"
"https://esoteric.codes/rss"
"https://pluralistic.net/feed/"
"https://tlbhit.libsyn.com/rss"
"https://dataswamp.org/~solene/rss.xml")))
#+end_src
* Gopher
[[https://thelambdalab.xyz/elpher/][Elpher]] is a gopher and gemini browser for Emacs that looks rather
nice.
#+begin_src emacs-lisp
(use-package elpher)
#+end_src