Bug fixes!

Addresses some compilation warnings and some linting errors.
This commit is contained in:
Howard Abrams 2022-09-02 16:08:58 -07:00
parent 6fb9d25eda
commit 3cad9fdaf6
3 changed files with 24 additions and 53 deletions

View file

@ -197,7 +197,7 @@ Using =emacsclient=, the operating system or other applications can trigger a ca
;; (toggle-frame-fullscreen)) ;; (toggle-frame-fullscreen))
(delete-other-windows) (delete-other-windows)
(flet ((switch-to-buffer-other-window (buf) (switch-to-buffer buf))) (cl-flet ((switch-to-buffer-other-window (buf) (switch-to-buffer buf)))
(org-capture))) (org-capture)))
(defadvice org-capture-finalize (defadvice org-capture-finalize

View file

@ -24,13 +24,12 @@ A literate programming file for configuring Emacs.
;;; Code: ;;; Code:
#+end_src #+end_src
* Basic Configuration * Basic Configuration
I hate a fat-finger that stop Emacs: I begin with configuration of Emacs that isnt /package-specific/. For instance, I hate a fat-finger that stop Emacs:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq confirm-kill-emacs 'yes-or-no-p) (setq confirm-kill-emacs 'yes-or-no-p)
#+end_src #+end_src
New way to display line-numbers. I set mine to =relative= so that I can jump up and down by that value. Set this to =nil= to turn off, or =t= to be absolute. New way to display line-numbers. I set mine to =relative= so that I can jump up and down by that value. Set this to =nil= to turn off, or =t= to be absolute.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq display-line-numbers t (setq display-line-numbers t
display-line-numbers-type 'relative) display-line-numbers-type 'relative)
@ -38,7 +37,7 @@ New way to display line-numbers. I set mine to =relative= so that I can jump up
I like the rendering to curved quotes using [[help:text-quoting-style][text-quoting-style]], because it improves the readability of documentation strings in the =Help= buffer and whatnot. I like the rendering to curved quotes using [[help:text-quoting-style][text-quoting-style]], because it improves the readability of documentation strings in the =Help= buffer and whatnot.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq text-quoting-style 'curve) (setq text-quoting-style 'curve)
#+end_src #+end_src
Changes and settings I like introduced in Emacs 28: Changes and settings I like introduced in Emacs 28:
@ -49,7 +48,6 @@ Changes and settings I like introduced in Emacs 28:
#+end_src #+end_src
As [[https://tecosaur.github.io/emacs-config/config.html][tec wrote]], I want to use =~/.authsource.gpg= as I dont want to accidentaly purge this file cleaning =~/.emacs.d=, and let's cache as much as possible, as my home machine is pretty safe, and my laptop is shutdown a lot. Also, as [[https://www.bytedude.com/gpg-in-emacs/][bytedude]] mentions, I need to se the =epa-pineentry-mode= to =loopback= to actually get a prompt for the password, instead of an error. As [[https://tecosaur.github.io/emacs-config/config.html][tec wrote]], I want to use =~/.authsource.gpg= as I dont want to accidentaly purge this file cleaning =~/.emacs.d=, and let's cache as much as possible, as my home machine is pretty safe, and my laptop is shutdown a lot. Also, as [[https://www.bytedude.com/gpg-in-emacs/][bytedude]] mentions, I need to se the =epa-pineentry-mode= to =loopback= to actually get a prompt for the password, instead of an error.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package epa-file (use-package epa-file
:config :config
@ -60,11 +58,15 @@ As [[https://tecosaur.github.io/emacs-config/config.html][tec wrote]], I want to
auth-source-cache-expiry nil)) auth-source-cache-expiry nil))
#+end_src #+end_src
Unicode ellispis are nicer than three dots:
#+begin_src emacs-lisp
(setq truncate-string-ellipsis "…")
#+end_src
More settings: More settings:
When I get an error, I need a stack trace to figure out the problem. Yeah, when I stop fiddling with Emacs, this should go off:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq truncate-string-ellipsis "…" ; Unicode ellispis are nicer than "..." (setq debug-on-error t)
debug-on-error t)
#+end_src #+end_src
The venerable [[help:hippie-expand][hippie-expand]] function does a better job than the default, [[help:dabbrev-expand][dabbrev-expand]], so lets swap it out (see this [[https://www.masteringemacs.org/article/text-expansion-hippie-expand][essay]] by Mickey Petersen): The venerable [[help:hippie-expand][hippie-expand]] function does a better job than the default, [[help:dabbrev-expand][dabbrev-expand]], so lets swap it out (see this [[https://www.masteringemacs.org/article/text-expansion-hippie-expand][essay]] by Mickey Petersen):
@ -123,12 +125,7 @@ Seems the best [[https://github.com/hlissner/doom-snippets][collection of snippe
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package doom-snippets (use-package doom-snippets
:after yasnippet :after yasnippet
:straight (:host github :repo "doomemacs/snippets") :straight (:host github :repo "doomemacs/snippets"))
:config
(add-to-list 'yas-snippet-dirs (thread-last user-emacs-directory
(expand-file-name "straight")
(expand-file-name "repos")
(expand-file-name "doom-snippets"))))
#+end_src #+end_src
*Note:* Including his snippets also includes some [[https://github.com/hlissner/doom-snippets#snippets-api][helper functions]] and other features. *Note:* Including his snippets also includes some [[https://github.com/hlissner/doom-snippets#snippets-api][helper functions]] and other features.
** Auto Insert Templates ** Auto Insert Templates
@ -832,27 +829,17 @@ Install the [[https://github.com/dajva/rg.el][rg]] package, which builds on the
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package rg (use-package rg
:general (:states 'normal "gr" 'rg-dwim)
:config :config
;; In case I call (or something else) calls `grep':
(grep-apply-setting 'grep-command "rg") ; -n -H --no-heading -e
;; Make an interesting Magit-like menu of options, which I don't use much: ;; Make an interesting Magit-like menu of options, which I don't use much:
(rg-enable-default-bindings (kbd "M-R")) (rg-enable-default-bindings (kbd "M-R"))
;; In case I call (or something else) calls `grep':
(grep-apply-setting 'grep-command "rg -n -H --no-heading -e ")
;; Old habits die hard ... ;; Old habits die hard ...
(define-key global-map [remap xref-find-references] 'rg-dwim) (define-key global-map [remap xref-find-references] 'rg-dwim)
(advice-add 'wgrep-change-to-wgrep-mode :after #'evil-normal-state)
(advice-add 'wgrep-to-original-mode :after #'evil-motion-state)
(defvar rg-mode-map)
(add-to-list 'evil-motion-state-modes 'rg-mode)
(evil-add-hjkl-bindings rg-mode-map 'motion
"e" #'wgrep-change-to-wgrep-mode
"g" #'rg-recompile
"t" #'rg-rerun-change-literal)
(ha-leader (ha-leader
"s" '(:ignore t :which-key "search") "s" '(:ignore t :which-key "search")
"s q" '("close" . ha-rg-close-results-buffer) "s q" '("close" . ha-rg-close-results-buffer)
@ -891,6 +878,12 @@ Install the [[https://github.com/dajva/rg.el][rg]] package, which builds on the
(compile-goto-error))) (compile-goto-error)))
#+end_src #+end_src
Note we bind the key ~M-R~ to the [[help:rg-menu][rg-menu]], which is a Magit-like interface to =ripgrep=. Note we bind the key ~M-R~ to the [[help:rg-menu][rg-menu]], which is a Magit-like interface to =ripgrep=.
I dont understand the bug associated with the =:general= extension to =use-package=, but it /works/, but stops everything else from working, so pulling it out into its own =use-package= section addresses that issue:
#+begin_src emacs-lisp
(use-package rg
:general (:states 'normal "gr" 'rg-dwim))
#+end_src
**** wgrep **** wgrep
The [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep package]] integrates with =ripgrep=. Typically, you hit ~i~ to automatically go into =wgrep-mode= and edit away, but since I typically want to edit everything at the same time, I have a toggle that should work as well: The [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep package]] integrates with =ripgrep=. Typically, you hit ~i~ to automatically go into =wgrep-mode= and edit away, but since I typically want to edit everything at the same time, I have a toggle that should work as well:
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -900,7 +893,7 @@ The [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep package]] integrates wi
:hook (rg-mode-hook . wgrep-rg-setup) :hook (rg-mode-hook . wgrep-rg-setup)
:config :config
(ha-leader (ha-leader
:keymaps 'rg-mode-map ; Actually, `i` works! :keymaps 'rg-mode-map ; Actually, `i' works!
"s w" '("wgrep-mode" . wgrep-change-to-wgrep-mode) "s w" '("wgrep-mode" . wgrep-change-to-wgrep-mode)
"t w" '("wgrep-mode" . wgrep-change-to-wgrep-mode))) "t w" '("wgrep-mode" . wgrep-change-to-wgrep-mode)))
#+end_src #+end_src

View file

@ -138,7 +138,7 @@ I should break this function into smaller bits ...
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun ha-org-special-return (&optional ignore) (defun ha-org-special-return (&optional ignore)
"Add new list item, heading or table row with RET. "Add new list item with RET.
A double return on an empty element deletes it. A double return on an empty element deletes it.
Use a prefix arg to get regular RET." Use a prefix arg to get regular RET."
(interactive "P") (interactive "P")
@ -156,30 +156,11 @@ I should break this function into smaller bits ...
(org-insert-item)) (org-insert-item))
(delete-region (line-beginning-position) (line-end-position)))) (delete-region (line-beginning-position) (line-end-position))))
;; ((org-at-heading-p)
;; (if (string= "" (org-element-property :title (org-element-context)))
;; (delete-region (line-beginning-position) (line-end-position))
;; (org-insert-heading-after-current)))
((org-at-table-p)
(if (-any?
(lambda (x) (not (string= "" x)))
(nth
(- (org-table-current-dline) 1)
(org-table-to-lisp)))
(org-return)
;; empty row
(beginning-of-line)
(setf (buffer-substring
(line-beginning-position) (line-end-position)) "")
(org-return)))
(t (t
(org-return))))) (org-return)))))
#+end_src #+end_src
How do we know if we are in a list item? Lists end with two blank lines, so we need to make sure we are also not at the beginning of a line to avoid a loop where a new entry gets created with one blank line. How do we know if we are in a list item? Lists end with two blank lines, so we need to make sure we are also not at the beginning of a line to avoid a loop where a new entry gets created with one blank line.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun org-really-in-item-p () (defun org-really-in-item-p ()
"Return item beginning position when in a plain list, nil otherwise. "Return item beginning position when in a plain list, nil otherwise.
@ -373,17 +354,14 @@ And turn on ALL the languages:
(plantuml . t))) (plantuml . t)))
#+end_src #+end_src
*** REST Web Services *** REST Web Services
:PROPERTIES: Emacs has two ways to query and investigate REST-oriented web services. The [[https://github.com/zweifisch/ob-http][ob-http]] adds HTTP calls to standard org blocks.
:header-args: :var user-agent="my-super-agent"
:END:
There are many ways in Emacs to query to investigate REST-oriented web services. The [[https://github.com/zweifisch/ob-http][ob-http]] adds HTTP calls to standard org blocks.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ob-http (use-package ob-http
:init :init
(add-to-list 'org-babel-load-languages '(http . t))) (add-to-list 'org-babel-load-languages '(http . t)))
#+end_src #+end_src
And lets see how it works: And lets see how it works:
#+begin_src http :pretty :results value replace :wrap src js #+begin_src http :pretty :results value replace :wrap src js :var user-agent="my-super-agent"
GET https://api.github.com/repos/zweifisch/ob-http/languages GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/json Accept: application/json
User-Agent: ${user-agent} User-Agent: ${user-agent}
@ -405,7 +383,7 @@ Another approach is [[https://github.com/alf/ob-restclient.el][ob-restclient]],
#+end_src #+end_src
And lets try this: And lets try this:
#+begin_src restclient :results value replace :wrap src js #+begin_src restclient :results value replace :wrap src js :var user-agent="my-super-agent"
GET https://api.github.com/repos/zweifisch/ob-http/languages GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/vnd.github.moondragon+json Accept: application/vnd.github.moondragon+json
User-Agent: ${user-agent} User-Agent: ${user-agent}