Fixed a "race condition" startup bug

I wanted to have an icon associated with the major mode hydra, but the
display system wasn't available at this time. So, now we can override it.
This commit is contained in:
Howard Abrams 2024-08-10 21:58:05 -07:00
parent b162327c7d
commit a9ce3c1d27
4 changed files with 40 additions and 21 deletions

View file

@ -116,8 +116,8 @@ The [[help:shell-command][shell-command]] function is useful, but having it spli
(thread-last command (thread-last command
shell-command-to-string shell-command-to-string
s-lines s-lines
(-map 's-trim) (seq-map 's-trim)
(-remove 's-blank-str?))) (seq-remove 's-blank-str?)))
#+end_src #+end_src
And lets see the results: And lets see the results:
@ -156,15 +156,19 @@ I actually run two instances of Emacs on some systems, where one instance has al
#+end_src #+end_src
And now start the server with an appropriate tag name: And now start the server with an appropriate tag name:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(when (display-graphic-p)
(if (not (ha-emacs-for-work?)) (if (not (ha-emacs-for-work?))
(setq server-name "personal") (setq server-name "personal")
(setq server-name "work") (setq server-name "work")
(when (ha-running-on-macos?) (when (ha-running-on-macos?)
(set-exec-path-from-shell))) (set-exec-path-from-shell)))
(server-start) (server-start))
#+end_src #+end_src
*Note:* When starting Emacs as a terminal program (only happens when I am attempting to evaluate code), we dont start the server.
* Load the Rest * Load the Rest
The following /defines/ the rest of my org-mode literate files, that I load later with the =ha-hamacs-load= function: The following /defines/ the rest of my org-mode literate files, that I load later with the =ha-hamacs-load= function:
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -228,13 +232,16 @@ With this function, we can test/debug/reload any individual file, via:
Emacs configuration code." Emacs configuration code."
(interactive (list (completing-read "Org file: " (interactive (list (completing-read "Org file: "
(ha-hamacs-files :all)))) (ha-hamacs-files :all))))
;; TODO: Replace concat here: (let ((full-file (expand-file-name file hamacs-source-dir)))
(let ((full-file (file-name-concat hamacs-source-dir file)))
(when (file-exists-p full-file) (when (file-exists-p full-file)
(ignore-errors (message ">>> %s" full-file)
(org-babel-load-file full-file))))) (if (called-interactively-p)
(org-babel-load-file full-file)
(ignore-errors (org-babel-load-file full-file))))))
#+end_src #+end_src
Notice that when we call this function /non-interactively/ (e.g. from the Lisp function, =ha-hamacs-reload-all=), we suppress any errors. Obviously, I want to see the errors when calling interactively.
** Tangling the Hamacs ** Tangling the Hamacs
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=. 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=.
@ -272,8 +279,7 @@ And we can tangle /all/ the files:
"Tangle all my Org initialization/configuration files." "Tangle all my Org initialization/configuration files."
(interactive) (interactive)
(dolist (file (ha-hamacs-files)) (dolist (file (ha-hamacs-files))
(unless (equal file "bootstrap.org") (ha-hamacs-tangle file)))
(ha-hamacs-tangle file))))
#+end_src #+end_src
** Edit my Files ** Edit my Files
Changing my Emacs configuration is as simple as editing an Org file containing the code, and evaluating that block or expression. Or even /re-loading/ the entire file as described above. Calling =find-file= (or more often [[file:ha-config.org::*Projects][project-find-file]]) is sufficient but quicker if I supply a /focused list/ of just the files in my project: Changing my Emacs configuration is as simple as editing an Org file containing the code, and evaluating that block or expression. Or even /re-loading/ the entire file as described above. Calling =find-file= (or more often [[file:ha-config.org::*Projects][project-find-file]]) is sufficient but quicker if I supply a /focused list/ of just the files in my project:

View file

@ -373,9 +373,7 @@ Since I seldom remember keybindings, or even function names, for major-modes, I
(string-replace "-" " ") (string-replace "-" " ")
(string-replace " mode" "") (string-replace " mode" "")
(s-titleize)))) (s-titleize))))
(s-concat ; (s-repeat 5 " ") (concat "ϻ " title " Commands")))))
(all-the-icons-icon-for-mode mode :v-adjust 0.05)
" " title " Commands")))))
#+end_src #+end_src
For this feature, I may want to pull it out into its own file, so as to keep all of its features together... however, those feature often /depend/ of the functions they are calling. If so, we would have a series like this: For this feature, I may want to pull it out into its own file, so as to keep all of its features together... however, those feature often /depend/ of the functions they are calling. If so, we would have a series like this:

View file

@ -37,10 +37,24 @@ Let's turn off the menu and other settings:
#+end_src #+end_src
And lets make this Emacs look more like a fancy IDE with [[https://github.com/domtronn/all-the-icons.el][all-the-icons]]: And lets make this Emacs look more like a fancy IDE with [[https://github.com/domtronn/all-the-icons.el][all-the-icons]]:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package all-the-icons (use-package all-the-icons
:if (display-graphic-p)) :if (display-graphic-p)
:config
(setq major-mode-hydra-title-generator
'(lambda (mode)
(let ((title (thread-last mode
(symbol-name)
(string-replace "-" " ")
(string-replace " mode" "")
(s-titleize))))
(s-concat ; (s-repeat 5 " ")
(all-the-icons-icon-for-mode mode :v-adjust 0.05)
" " title " Commands")))))
#+end_src #+end_src
This also expands the [[file:ha-config.org::*Leader Sequences][Major Mode Hydra]] title sequence with a pretty icon.
* Mode Line * Mode Line
Let's install and load some of packages from the [[https://github.com/hlissner/doom-emacs][Doom Emacs]] project, like [[https://github.com/seagle0128/doom-modeline][doom-modeline]] and maybe the themes: Let's install and load some of packages from the [[https://github.com/hlissner/doom-emacs][Doom Emacs]] project, like [[https://github.com/seagle0128/doom-modeline][doom-modeline]] and maybe the themes:
#+begin_src emacs-lisp #+begin_src emacs-lisp

View file

@ -1198,7 +1198,8 @@ Support for [[https://docutils.sourceforge.io/rst.html][reStructuredText]] is [[
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package rst (use-package rst
:config :config
(set-face-attribute 'rst-literal nil :font ha-fixed-font)) (when (and (display-graphic-p) (boundp 'ha-fixed-font))
(set-face-attribute 'rst-literal nil :font ha-fixed-font)))
#+end_src #+end_src
** Docker ** Docker
Edit =Dockerfiles= with the [[https://github.com/spotify/dockerfile-mode][dockerfile-mode]] project: Edit =Dockerfiles= with the [[https://github.com/spotify/dockerfile-mode][dockerfile-mode]] project: