Let's easily edit the files.

Finally upgraded to Emacs 29.2 on the Mac.
This commit is contained in:
Howard Abrams 2024-02-21 16:28:57 -08:00
parent e5522fa0eb
commit a11c9b7290
3 changed files with 65 additions and 2 deletions

View file

@ -5,12 +5,32 @@
These instructions originally came from [[https://jherrlin.github.io/posts/emacs-on-macos-monterey/][this essay]], as it runs Emacs as dæmon with LaunchAgent. Also fetch mails periodically with =mbsync= via LaunchAgent.
* Install
Since Ive been having difficulties installing Emacs from source on a Mac, Im now taking advantage of[[https://github.com/jimeh/emacs-builds][Jim Myhrberg's Emacs Build project]], and it is must nicer to simply, download a pre-built binary with all the bells and whistles.
First, install the Homebrew cask:
#+begin_src sh
brew tap jimeh/emacs-builds
#+end_src
And then, install Emacs:
#+begin_src sh
brew install --cask emacs-app
#+end_src
* Install from Source
If we cant install a binary, we build from source.
** Emacs Plus
No longer need to install [[https://apps.apple.com/us/app/xcode/id497799835?mt=12][Apple XCode]], as these instructions require [[https://brew.sh][Homebrew]].
If I want to build from source (and not build from Homebrew), install all the dependencies first, by running:
#+begin_src sh
brew install pkg-config automake texinfo jpeg giflib\
libtiff jansson libpng librsvg gnutls cmake
#+end_src
To get the native compilation for Emacs working, install:
#+begin_src sh
brew install libgccjit
#+end_src
Oh, and if we are still building with [[https://imagemagick.org/][ImageMagick]], install that first:
#+begin_src sh
brew install imagemagick
@ -29,6 +49,39 @@ And if it fails, choose =shell= and type:
#+begin_src sh
make bootstrap
#+end_src
** Build from Scratch
The failures that I often get from installing the Emacs Plus with Libgccjit, means that we might want to build from soure:
#+begin_src sh
mkdir -p ~/src
git clone https://git.savannah.gnu.org/git/emacs.git ~/src/emacs
cd ~/src/emacs
./autogen.sh
#+end_src
And we can issue the same sort of configure we used for
#+begin_src sh
./configure --disable-dependency-tracking --disable-silent-rules \
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp \
--infodir=/opt/homebrew/Cellar/emacs-plus@29/29.2/share/info/emacs \
--prefix=/opt/homebrew/Cellar/emacs-plus@29/29.2 \
--with-xml2 --with-gnutls --with-native-compilation --without-compress-install \
--without-dbus --without-imagemagick --with-modules --with-rsvg --without-pop \
--with-ns --disable-ns-self-contained
#+end_src
Or to install/build into =/usr/local=:
#+begin_src sh
LDFLAGS=-L/opt/homebrew/opt/libgccjit/lib -L/opt/homebrew/opt/xz/lib
CPPFLAGS=-I/opt/homebrew/opt/libgccjit/include -I/opt/homebrew/opt/xz/include
export LDFLAGS CPPFLAGS
./configure --disable-dependency-tracking --disable-silent-rules \
--prefix=/usr/local \
--with-xml2 --with-gnutls --with-native-compilation --without-compress-install \
--without-dbus --without-imagemagick --with-modules --with-rsvg --without-pop \
--with-ns --disable-ns-self-contained
#+end_src
Assuming that either works, then build it with:
#+begin_src sh
make -j4
#+end_src
** Ouchie
Sometimes get the following error:
#+begin_example

View file

@ -46,7 +46,7 @@ Helper functions to allow code for specific operating systems:
With the way I start Emacs, I may not have the =PATH= I /actually/ use (from the shell) available, so we'll force it (code taken [[https://www.emacswiki.org/emacs/ExecPath][from here]]):
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(defun set-exec-path-from-shell ()
"Set up Emacs' `exec-path' and PATH environment variable to match
that used by the user's shell.
@ -238,7 +238,7 @@ The list of /hamacs/ org-formatted files stored in =ha-hamacs-files= is selectiv
ha-hamacs-files
(thread-last (rx ".org" string-end)
(directory-files "~/other/hamacs" nil)
(directory-files hamacs-source-dir nil)
(append ha-hamacs-files)
(--filter (not (string-match (rx "README") it)))
(-uniq))))
@ -255,6 +255,15 @@ With this function, we can test/debug/reload any individual file, via:
(org-babel-load-file full-file)))))
#+end_src
And the ability to edit the file:
#+begin_src emacs-lisp
(defun ha-hamacs-find-file (file)
"Call `find-file' on relative org-mode FILE containing literate Emacs configuration code."
(interactive (list (completing-read "Org file: " (ha-hamacs-files :all))))
(let ((full-file (f-join hamacs-source-dir file)))
(find-file full-file)))
#+end_src
And this similar function, will /tangle/ one of my files. Notice that in order to increase the speed of the tangling process (and not wanting to pollute a project perspective), I use a /temporary buffer/ instead of =find-file=.
#+begin_src emacs-lisp

View file

@ -189,6 +189,7 @@ And ways to load my tangled org-files:
"h h" '(:ignore t :which-key "hamacs")
"h h <escape>" '(keyboard-escape-quit :which-key t)
"h h f" '("features" . ha-hamacs-features)
"h h e" '("edit" . ha-hamacs-find-file)
"h h h" '("reload" . ha-hamacs-load)
"h h a" '("reload all" . ha-hamacs-reload-all))
#+end_src