Skip to content
/ huan.el Public

A minimal alternative to grugru.el and cycle-at-point with embark integration in mind

License

Notifications You must be signed in to change notification settings

akirak/huan.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

huan.el

Huàn (换; meaning change in Mandarin) is a tiny library for replacing a symbol at point with one of its predefined alternatives. It is an alternative to grugru and cycle-at-point.

The differences from those options are:

  1. It is created with embark integration in mind. If there are multiple candidates, you will use completing-read for selecting a candidate rather than firing the same command multiple times.
  2. It is minimal. I didn’t consider support for natural languages, because it should be handled by a dedicated package (with spell and grammar checking).

Installation

As huan is an inferior alternative to other packages on MELPA, I probably won’t submit this package to MELPA.

Add huan.el to your load path, or use one of the source-based package managers such as straight.el, borg, quelpa, etc.

Configuration

If you are using embark, you can use the following snippet for integration:

(with-eval-after-load 'embark
  (define-key embark-defun-map "`" #'huan-defun)
  (define-key embark-identifier-map "`" #'huan-symbol))

To define your own substitutions, customize huan-mode-symbols-alist.

setup.el keyword

If you are using setup.el for your init.el, you can define :huan keyword as follows:

(define-setup-macro
 :huan (&rest entries)
 "Add ENTRIES to `huan-mode-symbols-alist'."
 :indent 0
 `(with-eval-after-load 'huan
    (let ((mode ',(setup-get 'mode))
          (entries ',entries))
      (if-let (cell (assq mode huan-mode-symbols-alist))
          (let ((sym (make-symbol "entries")))
            (set sym (cdr cell))
            (dolist (ent (reverse entries))
              (add-to-list sym ent))
            (setcdr cell (symbol-value sym)))
        (push (cons mode entries)
              huan-mode-symbols-alist)))))

define-setup-macro is the alternative macro definer described in the EmacsWiki.

You can use the keyword to add entries to the default settings:

(setup elisp-mode
  (:with-mode emacs-lisp-mode
    (:huan
      ("eval-after-load" "with-eval-after-load")
      ("add-hook" "remove-hook")
      (":around" ":override" ":before" ":after"))))

Usage

The following interactive functions are available:

  • huan-defun
  • huan-symbol

About

A minimal alternative to grugru.el and cycle-at-point with embark integration in mind

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published