Getting the configuration working on my iMac

Each computer seems to be so unique.
This commit is contained in:
Howard Abrams 2022-01-02 22:42:22 -08:00
parent 14e3d5e9d9
commit 129f834812
3 changed files with 104 additions and 74 deletions

View file

@ -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. 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: Hit me up with questions, =@howardabrams=. If you want to try this out, after installing Emacs, and cloning this repo, run:
#+BEGIN_SRC sh #+BEGIN_SRC sh
./initialize ./initialize
#+END_SRC #+END_SRC
This creates [[file:~/.emacs.d/init.el][~/.emacs.d/init.el]] that starts the process loading the files: 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: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][ha-config.org]] :: contains /most/ of my configuration, setting up my sequence key menus, evil, etc. - [[file:ha-config.org][config]] :: 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-display.org][display]] :: 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.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-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][ha-org-clipboard.org]] :: automatically converting HTML from a clipboard into Org-formatted content. - [[file:ha-org-clipboard.org][org-clipboard]] :: 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-journaling.org][org-journaling]] :: 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-publishing.org][org-publishing]] :: 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-org-sprint.org][org-sprint]] :: 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-remoting.org][remoting]] :: 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-email.org][email]] :: 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-feed-reader.org][feed-reader]] :: 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-aux-apps.org][aux-apps]] :: optional applications, like Twitter and Telegram.
- [[file:ha-capturing-notes.org][ha-capturing-notes.org]] :: my engineering notebook. - [[file:ha-capturing-notes.org][capturing-notes]] :: my engineering notebook.
- [[file:ha-agendas.org][ha-agendas.org]] :: attempts to "supe-up" my task list. - [[file:ha-agendas.org][agendas]] :: attempts to "supe-up" my task list.
- [[file:ha-irc.org][ha-irc.org]] :: connection to IRC servers using rcirc and bitlbee. - [[file:ha-irc.org][irc]] :: connection to IRC servers using rcirc and bitlbee.
- [[file:ha-passwords.org][ha-passwords.org]] :: code for generating passwords. - [[file:ha-passwords.org][passwords]] :: 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.org][programming]] :: 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: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. *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.

View file

@ -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 This is particularly useful under Mac OS X and macOS, where GUI
apps are not started from a shell." apps are not started from a shell."
(interactive) (interactive)
(let ((path-from-shell (replace-regexp-in-string (let* ((path-from-shell (shell-command-to-string "echo $PATH"))
(rx (zero-or-more space) eol) (trimmed-path (replace-regexp-in-string (rx (zero-or-more space) eol)
"" "" path-from-shell))
(shell-command-to-string "$SHELL --login -c 'echo $PATH'")))) (in-fish? (string-match (rx "fish" eol)
(setenv "PATH" path-from-shell) (shell-command-to-string "echo $SHELL")))
(setq exec-path (split-string path-from-shell path-separator)))) (separator (if in-fish? " " ":"))
(env-path (if in-fish? (replace-regexp-in-string " " ":" trimmed-path) trimmed-path)))
(when (ha-running-on-macos?) (message "PATH=%s" path-from-shell)
(set-exec-path-from-shell)) (setenv "PATH" env-path)
(setq exec-path (split-string trimmed-path separator))))
#+END_SRC #+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=: 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 #+BEGIN_SRC emacs-lisp
(when (ha-running-on-macos?) (when (ha-running-on-macos?)
(add-to-list 'exec-path "/usr/local/bin")
(add-to-list 'exec-path (concat invocation-directory "bin") t)) (add-to-list 'exec-path (concat invocation-directory "bin") t))
#+END_SRC #+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 (setq native-comp-async-report-warnings-errors nil
native-comp-deferred-compilation t)) native-comp-deferred-compilation t))
#+END_SRC #+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 ** Basic Libraries
The following packages come with Emacs, but seems like they still need loading: The following packages come with Emacs, but seems like they still need loading:
#+BEGIN_SRC emacs-lisp #+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: 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 #+BEGIN_SRC emacs-lisp
(defun ha-emacs-for-work? () (defun ha-emacs-for-work? ()
"Return non-nil when the Emacs application's location matches as one 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 Currently, this is the `emacs-plus' app that I have built with
the native-comp model, but I reserve the right to change this." the native-comp model, but I reserve the right to change this."
(->> Info-default-directory-list (and (f-dir? "~/work")
(first) (->> Info-default-directory-list
(s-split "/") (first)
(--filter (s-starts-with? "emacs-plus" it)) (s-split "/")
(first))) (--filter (s-starts-with? "emacs-plus" it))
(first))))
#+END_SRC #+END_SRC
#+BEGIN_SRC emacs-lisp #+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 "work")
(setq server-name "personal")) (when (ha-running-on-macos?)
(set-exec-path-from-shell)))
(server-start) (server-start)
#+END_SRC #+END_SRC
* Load the Rest * 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. 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.

View file

@ -161,17 +161,18 @@ My /current/ favorite font is actually the top list of fonts that may be install
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defvar ha-fixed-font (defvar ha-fixed-font
(when window-system (when window-system
(cond ((x-list-fonts "Hack Nerd Font") "Hack Nerd Font") (cond
((x-list-fonts "Cousine Nerd Font") "Cousine Nerd Font") ((x-list-fonts "Hack Nerd Font") "Hack Nerd Font")
((x-list-fonts "Iosevka Nerd Font") "Iosevka Nerd Font") ((x-list-fonts "Cousine Nerd Font") "Cousine Nerd Font")
((x-list-fonts "Iosevka") "Iosevka") ((x-list-fonts "Iosevka Nerd Font") "Iosevka Nerd Font")
((x-list-fonts "FantasqueSansMono Nerd Font") "FantasqueSansMono Nerd Font") ((x-list-fonts "Iosevka") "Iosevka")
((x-list-fonts "Monoid Nerd Font") "Monoid Nerd Font") ((x-list-fonts "FantasqueSansMono Nerd Font") "FantasqueSansMono Nerd Font")
((x-list-fonts "Hasklig") "Hasklig") ((x-list-fonts "Monoid Nerd Font") "Monoid Nerd Font")
((x-list-fonts "Cascadia Code PL") "Cascadia Code PL") ((x-list-fonts "Hasklig") "Hasklig")
((x-list-fonts "Source Code Pro") "Source Code Pro") ((x-list-fonts "Cascadia Code PL") "Cascadia Code PL")
((x-list-fonts "Anonymous Pro") "Anonymous Pro") ((x-list-fonts "Source Code Pro") "Source Code Pro")
(t "monospaced"))) ((x-list-fonts "Anonymous Pro") "Anonymous Pro")
(t "monospaced")))
"My fixed width font based on what is installed, `nil' if not defined.") "My fixed width font based on what is installed, `nil' if not defined.")
#+END_SRC #+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.") "My variable width font available to org-mode files and whatnot.")
#+END_SRC #+END_SRC
Simple function that gives me the font information based on the size I 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.
need. This calls =set-frame-font=, but also sets the monospaced font
for org code blocks.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun ha-set-favorite-font-size (size) (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: Define /interactive/ functions to quickly adjusting the font size based on my computing scenario:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun ha-mac-monitor-fontsize () (defun ha-mac-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on a Mac." "Quickly set reset my font size when I connect my laptop to a monitor on a Mac."
(interactive) (interactive)
(ha-set-favorite-font-size 13)) (ha-set-favorite-font-size 13))
(defun ha-linux-monitor-fontsize () (defun ha-linux-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on Linux." "Quickly set reset my font size when I connect my laptop to a monitor on Linux."
(interactive) (interactive)
(ha-set-favorite-font-size 12)) (ha-set-favorite-font-size 12))
(defun ha-mac-laptop-fontsize () (defun ha-mac-laptop-fontsize ()
"Quickly set reset my font size when I disconnect my laptop to a monitor from a Mac." "Quickly set reset my font size when I disconnect my laptop to a monitor from a Mac."
(interactive) (interactive)
(ha-set-favorite-font-size 32)) (ha-set-favorite-font-size 32))
(defun ha-linux-laptop-fontsize () (defun ha-linux-laptop-fontsize ()
"Quickly set reset my font size when I disconnect my laptop to a monitor from Linux." "Quickly set reset my font size when I disconnect my laptop to a monitor from Linux."
(interactive) (interactive)
(ha-set-favorite-font-size 14)) (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 #+END_SRC
Which font to choose? Which font to choose?
@ -240,9 +244,10 @@ Which font to choose?
(defun font-monitor-size-default () (defun font-monitor-size-default ()
"Set the default size according to my preference." "Set the default size according to my preference."
(interactive) (interactive)
(if (eq system-type 'gnu/linux) (cond
(ha-linux-monitor-fontsize) ((eq system-type 'gnu/linux) (ha-linux-monitor-fontsize))
(ha-mac-monitor-fontsize))) ((s-starts-with? "imac" system-name) (ha-imac-fontsize))
(t (ha-mac-monitor-fontsize))))
(defun font-laptop-size-default () (defun font-laptop-size-default ()
"Set the default size according to my preference." "Set the default size according to my preference."