diff --git a/README.org b/README.org index bf6d9a9..28088bd 100644 --- a/README.org +++ b/README.org @@ -7,31 +7,32 @@ My Emacs configuration, that I'm cheekily calling /hamacs/ is a literate program The other advantage to rolling yer own is that you are more likely to /use/ what you add, leading to less bloat, and a more fun experience. -Why yes, feel free to steal whatever you find interesting, as sharing is what makes our community great. Notice that functions and features that I have written begin with =ha-=, however, everything else is either /stock Emacs/ or a /package/ that I download using [[https://github.com/raxod502/straight.el][straight]] (see [[file:bootstrap.org][bootstrap]] for how) and configured with [[https://github.com/jwiegley/use-package][use-package]] (see either [[https://ianyepan.github.io/posts/setting-up-use-package/][this introduction]] or [[https://www.emacswiki.org/emacs/UsePackage][this wiki page]] for details)... meaning that most blocks of code should /just work/ on its own. +Why yes, feel free to steal whatever you find interesting, as sharing is what makes our community great. Notice that functions and features that I have written begin with ~ha-~, however, everything else is either /stock Emacs/ or a /package/ that I download using [[https://github.com/raxod502/straight.el][straight]] (see [[file:bootstrap.org][bootstrap]] for how) and configured with [[https://github.com/jwiegley/use-package][use-package]] (see either [[https://ianyepan.github.io/posts/setting-up-use-package/][this introduction]] or [[https://www.emacswiki.org/emacs/UsePackage][this wiki page]] for details)... meaning that most blocks of code should /just work/ on its own. Hit me up with questions, =@howardabrams=. If you want to try this out, after installing Emacs, and cloning this repo, run: #+BEGIN_SRC sh ./initialize #+END_SRC This creates [[file:~/.emacs.d/init.el][~/.emacs.d/init.el]] that starts the process loading the files: - - [[file:bootstrap.org][bootstrap.org]] :: configures =straight= and loads basic libraries the rest of the code depends on. It then loads the following files in order: - - [[file:ha-config.org][ha-config.org]] :: contains /most/ of my configuration, setting up my sequence key menus, evil, etc. - - [[file:ha-display.org][ha-display.org]] :: sets up the visual aspects of an Emacs GUI, including themes, fonts and the dashboard. - - [[file:ha-org.org][ha-org.org]] :: configures the basics for org-mode formatted files. Specific features, however, come from their own files, however. - - [[file:ha-org-word-processor.org][ha-org-word-processor.org]] :: attempts to make Org files /visually/ look like what one might see in a word processor, including turning off the colors for headers, and instead increasing their size. - - [[file:ha-org-clipboard.org][ha-org-clipboard.org]] :: automatically converting HTML from a clipboard into Org-formatted content. - - [[file:ha-org-journaling.org][ha-org-journaling.org]] :: for writing journal entries and tasks. - - [[file:ha-org-publishing.org][ha-org-publishing.org]] :: code for publishing my website, [[http://howardism.org][www.howardism.org]]. - - [[file:ha-org-sprint.org][ha-org-sprint.org]] :: functions for working with the my Org-focused sprint files. - - [[file:ha-remoting.org][ha-remoting.org]] :: my interface to systems using SSH and Vterm. - - [[file:ha-email.org][ha-email.org]] :: reading email using =notmuch= in a *Hey* fashion. - - [[file:ha-feed-reader.org][ha-feed-reader.org]] :: configuration of elfeed as well as my RSS feeds. - - [[file:ha-aux-apps.org][ha-aux-apps.org]] :: optional applications, like Twitter and Telegram. - - [[file:ha-capturing-notes.org][ha-capturing-notes.org]] :: my engineering notebook. - - [[file:ha-agendas.org][ha-agendas.org]] :: attempts to "supe-up" my task list. - - [[file:ha-irc.org][ha-irc.org]] :: connection to IRC servers using rcirc and bitlbee. - - [[file:ha-passwords.org][ha-passwords.org]] :: code for generating passwords. - - [[file:ha-programming.org][ha-programming.org]] :: configuration for /all/ programming languages, or at least, the simple ones. - - [[file:ha-programming-python.org][ha-programming-python.org]] :: configuration for working with Python and LSP. + - [[file:bootstrap.org][bootstrap]] :: configures =straight= and loads basic libraries the rest of the code depends on. It then loads the following files in order: + - [[file:ha-config.org][config]] :: contains /most/ of my configuration, setting up my sequence key menus, evil, etc. + - [[file:ha-display.org][display]] :: sets up the visual aspects of an Emacs GUI, including themes, fonts and the dashboard. + - [[file:ha-org.org][org]] :: configures the basics for org-mode formatted files. Specific features, however, come from their own files, however. + - [[file:ha-org-word-processor.org][org-word-processor]] :: attempts to make Org files /visually/ look like what one might see in a word processor, including turning off the colors for headers, and instead increasing their size. + - [[file:ha-org-clipboard.org][org-clipboard]] :: automatically converting HTML from a clipboard into Org-formatted content. + - [[file:ha-org-journaling.org][org-journaling]] :: for writing journal entries and tasks. + - [[file:ha-org-publishing.org][org-publishing]] :: code for publishing my website, [[http://howardism.org][www.howardism.org]]. + - [[file:ha-org-sprint.org][org-sprint]] :: functions for working with the my Org-focused sprint files. + - [[file:ha-remoting.org][remoting]] :: my interface to systems using SSH and Vterm. + - [[file:ha-email.org][email]] :: reading email using =notmuch= in a *Hey* fashion. + - [[file:ha-feed-reader.org][feed-reader]] :: configuration of elfeed as well as my RSS feeds. + - [[file:ha-aux-apps.org][aux-apps]] :: optional applications, like Twitter and Telegram. + - [[file:ha-capturing-notes.org][capturing-notes]] :: my engineering notebook. + - [[file:ha-agendas.org][agendas]] :: attempts to "supe-up" my task list. + - [[file:ha-irc.org][irc]] :: connection to IRC servers using rcirc and bitlbee. + - [[file:ha-passwords.org][passwords]] :: code for generating passwords. + - [[file:ha-programming.org][programming]] :: configuration for /all/ programming languages, or at least, the simple ones. + - [[file:ha-programming-python.org][programming-python]] :: configuration for working with Python and LSP. + - [[file:ha-aux-apps.org][aux-apps]] :: additional application configuration. *Note:* Other functions and files come from essays written on [[http://www.howardism.org][my blog]]. To help with this, see [[file:support/final-initialize.el][support/final-initialize.el]] file. diff --git a/bootstrap.org b/bootstrap.org index 925bc0a..3380222 100644 --- a/bootstrap.org +++ b/bootstrap.org @@ -75,21 +75,23 @@ With the way I start Emacs, I may not have the PATH I /actually/ use (from the s This is particularly useful under Mac OS X and macOS, where GUI apps are not started from a shell." (interactive) - (let ((path-from-shell (replace-regexp-in-string - (rx (zero-or-more space) eol) - "" - (shell-command-to-string "$SHELL --login -c 'echo $PATH'")))) - (setenv "PATH" path-from-shell) - (setq exec-path (split-string path-from-shell path-separator)))) - - (when (ha-running-on-macos?) - (set-exec-path-from-shell)) + (let* ((path-from-shell (shell-command-to-string "echo $PATH")) + (trimmed-path (replace-regexp-in-string (rx (zero-or-more space) eol) + "" path-from-shell)) + (in-fish? (string-match (rx "fish" eol) + (shell-command-to-string "echo $SHELL"))) + (separator (if in-fish? " " ":")) + (env-path (if in-fish? (replace-regexp-in-string " " ":" trimmed-path) trimmed-path))) + (message "PATH=%s" path-from-shell) + (setenv "PATH" env-path) + (setq exec-path (split-string trimmed-path separator)))) #+END_SRC Clear up a Mac-specific issue that sometimes arises since I'm switching to [[http://akrl.sdf.org/gccemacs.html][native compilation project]], as the =Emacs.app= that I use doesn't have its =bin= directory, e.g. =Emacs.app/Contents/MacOS/bin=: #+BEGIN_SRC emacs-lisp (when (ha-running-on-macos?) + (add-to-list 'exec-path "/usr/local/bin") (add-to-list 'exec-path (concat invocation-directory "bin") t)) #+END_SRC @@ -100,6 +102,25 @@ Getting tired off all the packages that I load spewing a bunch of warnings that (setq native-comp-async-report-warnings-errors nil native-comp-deferred-compilation t)) #+END_SRC +** GNU Pretty Good Privacy +On Linux, GPG is pretty straight-forward, but on the Mac, I often have troubles doing: +#+BEGIN_SRC sh +brew install gpg +#+END_SRC +And I need to install the [[https://gpgtools.org/][GPG Suite]]. While very nice, isn't a GUI I really need, but can take advantage when installed: + +#+BEGIN_SRC emacs-lisp + (defun executable (path) + "Return PATH if it is executable, see `file-executable-p'." + (when (file-executable-p path) path)) + + (use-package epa-file + :straight (:type built-in) + :custom (epg-gpg-program (or (executable "/usr/local/MacGPG2/bin/gpg") + (executable "/usr/local/bin/gpg") + (executable "/usr/local/opt/gpg"))) + :config (epa-file-enable)) +#+END_SRC ** Basic Libraries The following packages come with Emacs, but seems like they still need loading: #+BEGIN_SRC emacs-lisp @@ -134,23 +155,26 @@ Hopefully, this will tie me over while I transition. Sure the Emacs application will almost always have the =server-start= going, however, I need to control it just a bit (because I often have two instances running on some of my machines). What /defines/ the Emacs instance for work changes ... often: #+BEGIN_SRC emacs-lisp -(defun ha-emacs-for-work? () - "Return non-nil when the Emacs application's location matches as one for work. -Currently, this is the `emacs-plus' app that I have built with -the native-comp model, but I reserve the right to change this." - (->> Info-default-directory-list - (first) - (s-split "/") - (--filter (s-starts-with? "emacs-plus" it)) - (first))) + (defun ha-emacs-for-work? () + "Return non-nil when the Emacs application's location matches as one for work. + Currently, this is the `emacs-plus' app that I have built with + the native-comp model, but I reserve the right to change this." + (and (f-dir? "~/work") + (->> Info-default-directory-list + (first) + (s-split "/") + (--filter (s-starts-with? "emacs-plus" it)) + (first)))) #+END_SRC #+BEGIN_SRC emacs-lisp -(if (ha-emacs-for-work?) + (if (not (ha-emacs-for-work?)) + (setq server-name "personal") (setq server-name "work") - (setq server-name "personal")) + (when (ha-running-on-macos?) + (set-exec-path-from-shell))) -(server-start) + (server-start) #+END_SRC * Load the Rest The following loads the rest of my org-mode literate files. I add them as they are /ready/, but eventually, I'll trim this up into a nicer pattern. diff --git a/ha-display.org b/ha-display.org index 33b4224..902729c 100644 --- a/ha-display.org +++ b/ha-display.org @@ -161,17 +161,18 @@ My /current/ favorite font is actually the top list of fonts that may be install #+BEGIN_SRC emacs-lisp (defvar ha-fixed-font (when window-system - (cond ((x-list-fonts "Hack Nerd Font") "Hack Nerd Font") - ((x-list-fonts "Cousine Nerd Font") "Cousine Nerd Font") - ((x-list-fonts "Iosevka Nerd Font") "Iosevka Nerd Font") - ((x-list-fonts "Iosevka") "Iosevka") - ((x-list-fonts "FantasqueSansMono Nerd Font") "FantasqueSansMono Nerd Font") - ((x-list-fonts "Monoid Nerd Font") "Monoid Nerd Font") - ((x-list-fonts "Hasklig") "Hasklig") - ((x-list-fonts "Cascadia Code PL") "Cascadia Code PL") - ((x-list-fonts "Source Code Pro") "Source Code Pro") - ((x-list-fonts "Anonymous Pro") "Anonymous Pro") - (t "monospaced"))) + (cond + ((x-list-fonts "Hack Nerd Font") "Hack Nerd Font") + ((x-list-fonts "Cousine Nerd Font") "Cousine Nerd Font") + ((x-list-fonts "Iosevka Nerd Font") "Iosevka Nerd Font") + ((x-list-fonts "Iosevka") "Iosevka") + ((x-list-fonts "FantasqueSansMono Nerd Font") "FantasqueSansMono Nerd Font") + ((x-list-fonts "Monoid Nerd Font") "Monoid Nerd Font") + ((x-list-fonts "Hasklig") "Hasklig") + ((x-list-fonts "Cascadia Code PL") "Cascadia Code PL") + ((x-list-fonts "Source Code Pro") "Source Code Pro") + ((x-list-fonts "Anonymous Pro") "Anonymous Pro") + (t "monospaced"))) "My fixed width font based on what is installed, `nil' if not defined.") #+END_SRC @@ -193,9 +194,7 @@ I probably don't need to have such a ranking system, as chances are really good "My variable width font available to org-mode files and whatnot.") #+END_SRC -Simple function that gives me the font information based on the size I -need. This calls =set-frame-font=, but also sets the monospaced font -for org code blocks. +Simple function that gives me the font information based on the size I need. This calls =set-frame-font=, but also sets the monospaced font for org code blocks. #+BEGIN_SRC emacs-lisp (defun ha-set-favorite-font-size (size) @@ -213,25 +212,30 @@ for org code blocks. Define /interactive/ functions to quickly adjusting the font size based on my computing scenario: #+BEGIN_SRC emacs-lisp -(defun ha-mac-monitor-fontsize () - "Quickly set reset my font size when I connect my laptop to a monitor on a Mac." - (interactive) - (ha-set-favorite-font-size 13)) + (defun ha-mac-monitor-fontsize () + "Quickly set reset my font size when I connect my laptop to a monitor on a Mac." + (interactive) + (ha-set-favorite-font-size 13)) -(defun ha-linux-monitor-fontsize () - "Quickly set reset my font size when I connect my laptop to a monitor on Linux." - (interactive) - (ha-set-favorite-font-size 12)) + (defun ha-linux-monitor-fontsize () + "Quickly set reset my font size when I connect my laptop to a monitor on Linux." + (interactive) + (ha-set-favorite-font-size 12)) -(defun ha-mac-laptop-fontsize () - "Quickly set reset my font size when I disconnect my laptop to a monitor from a Mac." - (interactive) - (ha-set-favorite-font-size 32)) + (defun ha-mac-laptop-fontsize () + "Quickly set reset my font size when I disconnect my laptop to a monitor from a Mac." + (interactive) + (ha-set-favorite-font-size 32)) -(defun ha-linux-laptop-fontsize () - "Quickly set reset my font size when I disconnect my laptop to a monitor from Linux." - (interactive) - (ha-set-favorite-font-size 14)) + (defun ha-linux-laptop-fontsize () + "Quickly set reset my font size when I disconnect my laptop to a monitor from Linux." + (interactive) + (ha-set-favorite-font-size 14)) + + (defun ha-imac-fontsize () + "Quickly set reset my font size when I am on my iMac." + (interactive) + (ha-set-favorite-font-size 16)) #+END_SRC Which font to choose? @@ -240,9 +244,10 @@ Which font to choose? (defun font-monitor-size-default () "Set the default size according to my preference." (interactive) - (if (eq system-type 'gnu/linux) - (ha-linux-monitor-fontsize) - (ha-mac-monitor-fontsize))) + (cond + ((eq system-type 'gnu/linux) (ha-linux-monitor-fontsize)) + ((s-starts-with? "imac" system-name) (ha-imac-fontsize)) + (t (ha-mac-monitor-fontsize)))) (defun font-laptop-size-default () "Set the default size according to my preference."