Compare commits

...

6 Commits

Author SHA1 Message Date
TEC 9b5d5cbca6
Add support for predicate functions in autocorrect 2024-03-26 17:21:15 +08:00
TEC 30694e8e9e
Add function docstring to magit advice
Without a docstring, thanks to how defadvice! is expanded
the (interactive ...) block is not the first part of the function body,
and instead the symbol "nil" is.
2024-03-26 16:28:16 +08:00
TEC 2d837c61b1
Adding missing :type to font defcustom 2024-03-26 16:28:04 +08:00
TEC 8d3cad7e02
Fix incorrect use of add-to-list
You can't use add-to-list with lexical variables, push should be used
instead with delete-dups later.
2024-03-26 12:23:20 +08:00
TEC bd8fc036bf
Make the byte-compiler happier 2024-03-26 12:23:20 +08:00
TEC 42b5c83bdc
Spelling/typo fixes 2024-03-26 12:10:59 +08:00
1 changed files with 53 additions and 26 deletions

View File

@ -1908,7 +1908,7 @@ files.
***** Emojis
Emacs (28+) has an ~emoji~ script table. We're about to use it, but before doing
so we're going to excise a few characteris that I actually want rendered as
so we're going to excise a few characters that I actually want rendered as
using the symbol font (not as emojis).
#+begin_src emacs-lisp
@ -2034,7 +2034,7 @@ We can then use this to create a =doctor= check.
#+end_src
Furthermore, when fonts /are/ missing, it could be good to check the state of
affairs on statup.
affairs on startup.
#+name: warn-missing-fonts
#+begin_src emacs-lisp :tangle no :noweb yes :noweb-ref none
@ -2311,7 +2311,7 @@ htmlize package doesn't.
Let's make creating an Org buffer just that little bit easier.
#+begin_src emacs-lisp
(evil-define-command +evil-buffer-org-new (count file)
(evil-define-command +evil-buffer-org-new (_count file)
"Creates a new ORG buffer replacing the current window, optionally
editing a certain FILE"
:repeat nil
@ -2340,11 +2340,11 @@ Let's make creating an Org buffer just that little bit easier.
Emacs can render an image as the splash screen, but I think we can do better
than just a completely static image. Since, SVG images in particular are
supported, we can use them as the basis for a fancier splash screen image setup
--- with themable, resizing images.
--- with themeable, resizing images.
With the effort I'm putting into this, it would be nice to have a good image,
and [[https://github.com/MarioRicalde][@MarioRicalde]] came up with a cracker! He's also provided me with a nice
Emacs-style /E/. I was using the blackhole image, but when I stripped down the
Emacs-style /E/. I was using the black-hole image, but when I stripped down the
splash screen to something more minimal I switched to just using the /E/.
#+attr_latex: :width 0.2\linewidth
@ -2496,7 +2496,7 @@ transparent overlay).
(message "Done"))))
#+end_src
To make it easier to produce themable images, we can also provide an Inkscape
To make it easier to produce themeable images, we can also provide an Inkscape
colour palette.
#+begin_src text :tangle ~/.config/inkscape/palettes/Emacs Fancy Splash.gpl :mkdirp yes
@ -2727,7 +2727,7 @@ in hooks that call functions with arguments."
**** ASCII banner
If we're operating in a terminal (or =emacclient=) we see an ascii banner instead
If we're operating in a terminal (or =emacclient=) we see an ASCII banner instead
of the graphical one. I'd also like to use something simple for this.
#+begin_src emacs-lisp
@ -3196,8 +3196,8 @@ to add a few bells and whistles --- namely:
+ Accepting stdin by putting it in a temporary file and immediately opening it.
+ Guessing that the =tty= is a good idea when ~$DISPLAY~ is unset (relevant with SSH
sessions, among other things).
+ With a whiff of 24-bit color support, sets ~TERM~ variable to a =terminfo= that
(probably) announces 24-bit color support.
+ With a whiff of 24-bit colour support, sets ~TERM~ variable to a =terminfo= that
(probably) announces 24-bit colour support.
+ Changes GUI =emacsclient= instances to be non-blocking by default (~--no-wait~),
and instead take a flag to suppress this behaviour (~-w~).
@ -3276,7 +3276,7 @@ else
fi
#+end_src
Now, to set an alias to use =e= with magit, and then for maximum laziness we can
Now, to set an alias to use =e= with Magit, and then for maximum laziness we can
set aliases for the terminal-forced variants.
#+begin_src shell :tangle no
alias m='e --eval "(progn (magit-status) (delete-other-windows))"'
@ -3810,7 +3810,7 @@ There's still a room for a little tweaking though...
:header-args:emacs-lisp: :noweb-ref magit-tweaks
:END:
When creating a new project, I often want the remote to be to my personal forgejo
When creating a new project, I often want the remote to be to my personal Forgejo
instance. Let's make that a bit more streamlined by introducing a quick-entry
"default forge" option.
@ -3820,12 +3820,13 @@ instance. Let's make that a bit more streamlined by introducing a quick-entry
Set to nil to disable this functionality.")
#+end_src
While we're at it, when creating a remote with the same name as my github
username in a project where an https github remote already exists, let's make
the pre-filled remote url use ssh.
While we're at it, when creating a remote with the same name as my Github
username in a project where an HTTPS GitHub remote already exists, let's make
the pre-filled remote URL use ssh.
#+begin_src emacs-lisp
(defadvice! +magit-remote-add--streamline-forge-a (args)
"Prompt to setup a remote using `+magit-default-forge-remote'."
:filter-args #'magit-remote-add
(interactive
(let ((default-name
@ -3923,11 +3924,12 @@ follow [[https://orgmode.org/worg/org-contribute.html#commit-messages][a certain
((string-match-p "\\.el$" last-file)
(when (re-search-backward "^\\(?:[+-]? *\\|@@[ +-\\d,]+@@ \\)(\\(?:cl-\\)?\\(?:defun\\|defvar\\|defmacro\\|defcustom\\)" temp-point t)
(re-search-forward "\\(?:cl-\\)?\\(?:defun\\|defvar\\|defmacro\\|defcustom\\) \\([^[:space:]\n]+\\)" nil t)
(add-to-list 'file-changes (match-string 1))))
(push (match-string 1) file-changes)))
((string-match-p "\\.org$" last-file)
(when (re-search-backward "^[+-]\\*+ \\|^@@[ +-\\d,]+@@ \\*+ " temp-point t)
(re-search-forward "@@ \\*+ " nil t)
(add-to-list 'file-changes (buffer-substring-no-properties (point) (line-end-position)))))))))
(push (buffer-substring-no-properties (point) (line-end-position)) file-changes)))))))
(setq file-changes (delete-dups file-changes))
(push (list last-file file-changes) change-data)
(setq change-data (delete '(nil nil) change-data))
(concat
@ -3962,7 +3964,7 @@ heading line selection for elisp and Org files.
**** Magit delta
[[https://github.com/dandavison/delta/][Delta]] is a git diff syntax highlighter written in rust. The author also wrote a
package to hook this into the magit diff view (which don't get any syntax
package to hook this into the Magit diff view (which don't get any syntax
highlighting by default). This requires the ~delta~ binary. It's packaged on some
distributions, but most reliably installed through Rust's package manager cargo.
@ -3987,7 +3989,7 @@ want to look into later.
It's nice to be able to interact with MPRIS players. This would just be a
dependency of =org-music= or =doom-modeline-media-player=, but I haven't made it
available on any an elisp archives. Thankfully most Emacs package managers make
using Git repository urls pretty easy these days.
using Git repository URLs pretty easy these days.
#+begin_src emacs-lisp :tangle packages.el
(package! mpris :recipe (:local-repo "lisp/mpris"))
@ -4241,9 +4243,23 @@ function, we can create an abbrev minor mode and link that up.
"Turn on `autocorrect-mode' in the current buffer."
(autocorrect-mode 1))
(defun autocorrect--enabled-p ()
"Return non-nil if autocorrect-mode is enabled in the current buffer."
autocorrect-mode)
#+end_src
While we're at it, it would probably be nice to write an abbrev predicate
function that can also take into account a user function that determines if
expansion is appropriate.
#+begin_src emacs-lisp
(defcustom autocorrect-predicates nil
"Predicate functions called at point with argument START.
These functions should return t if autocorrection is valid at START."
:type '(repeat function))
(defun autocorrect--appropriate-p ()
"Return non-nil it is currently appropriate to make an autocorrection.
See `autocorrect-predicates'."
(and autocorrect-mode
(run-hook-with-args-until-failure 'autocorrect-predicates (point))))
#+end_src
Given that our autocorrect abbrev table is operating rather distinctly from the
@ -4268,7 +4284,7 @@ too. We could just not save it, but it seems nice to get the count information.
Also set it as a parent of `global-abbrev-table'."
(unless autocorrect-abbrev-table
(setq autocorrect-abbrev-table
(make-abbrev-table (list :enable-function #'autocorrect--enabled-p)))
(make-abbrev-table (list :enable-function #'autocorrect--appropriate-p)))
(abbrev-table-put
global-abbrev-table :parents
(cons autocorrect-abbrev-table
@ -4459,8 +4475,13 @@ the global abbrev list.
(cl-loop for dict in jinx--dicts
thereis (jinx--mod-check dict word))))
(setq autocorrect-check-spelling-function #'autocorrect-jinx-check-spelling)
(defun autocorrect-jinx-appropriate (pos)
"Return non-nil if it is appropriate to spellcheck at POS according to jinx."
(and (not (jinx--face-ignored-p pos))
(not (jinx--regexp-ignored-p pos))))
(setq autocorrect-check-spelling-function #'autocorrect-jinx-check-spelling)
(add-to-list 'autocorrect-predicates #'autocorrect-jinx-appropriate)
(advice-add 'jinx--correct-replace :before #'autocorrect-jinx-record-correction)
#+end_src
@ -4671,7 +4692,7 @@ For when you want to change the case pattern for a symbol.
:desc "Upper_Score" "u" #'string-inflection-capital-underscore
:desc "UP_CASE" "U" #'string-inflection-upcase)
(after! evil
(evil-define-operator evil-operator-string-inflection (beg end type)
(evil-define-operator evil-operator-string-inflection (beg end _type)
"Define a new evil operator that cycles symbol casing."
:move-point nil
(interactive "<R>")
@ -4875,7 +4896,7 @@ is adjust the size slightly 🙂.
**** Media player
Sometimes (particularly when reading a novel, with Emacs fullscreened) it would
Sometimes (particularly when reading a novel, with Emacs full-screened) it would
be nice to know what I'm listening to. We can put this information in the
modeline with my media player package.
@ -5001,13 +5022,14 @@ We can lazy load this using the start/stop commands.
I initially installed ~scrot~ for this, since it was the default capture program.
However it raised ~glib error: Saving to file ... failed~ each time it was run.
Google didn't reveal any easy fixed, so I switched to [[https://github.com/naelstrof/maim][maim]]. We now need to pass
it the window ID. This doesn't change throughout the lifetime of an emacs
it the window ID. This doesn't change throughout the lifetime of an Emacs
instance, so as long as a single window is used ~xdotool getactivewindow~ will
give a satisfactory result.
It seems that when new colours appear, that tends to make ~gifsicle~ introduce
artefacts. To avoid this we pre-populate the colour map using the current doom
theme.
#+begin_src emacs-lisp
(use-package! gif-screencast
:commands gif-screencast-mode
@ -5113,6 +5135,7 @@ For ease of use, let's also set up an easy way of setting the ~:font~ attribute.
(defcustom variable-pitch-serif-font (font-spec :family "serif")
"The font face used for `variable-pitch-serif'."
:group 'basic-faces
:type '(restricted-sexp :tag "font-spec" :match-alternatives (fontp))
:set (lambda (symbol value)
(set-face-attribute 'variable-pitch-serif nil :font value)
(set-default-toplevel-value symbol value)))
@ -14196,3 +14219,7 @@ which is perfect for our needs.
#+begin_src emacs-lisp
(add-to-list 'magic-mode-alist (cons "\\`GIMP Palette\n" #'gimp-palette-mode))
#+end_src
# Local Variables:
# jinx-local-words: "confpkg confpkgs smartparens tempbuffer"
# End: