Is there some extension that can make calc autocomplete units while value entered as algebraic input? e.g.
' 1 kn<tab>
should be completed to "1 knot".
Most unit descriptions in calc are usually very short. You will find them when typing u v
. In my opinion a completion is here unnecessary, just type a '
(e. g. after typing a number) and specify your unit together with the quantity in algebraic mode.
This is Emacs. So the answer to such questions is almost always "yes".
The extension (not as a package but as code):
(require 'calc)
(require 'calc-aent)
(require 'calc-units)
(defun calc-do-alg-entry-completion (fun &rest args)
"Call `calc-do-alg-entry' as FUN with ARGS.
Wrapp FUN with `minibuffer-completion-table' bound
to a completion table of calc-units and variables."
;; make sure that newly introduced units
;; and variables are completed:
(math-build-units-table)
(let ((minibuffer-completion-table
(append
(mapcar
(lambda (unit)
(setq unit (symbol-name (car unit))))
math-units-table)
(let (ret)
(obarray-map
(lambda (var)
(let ((var-name (symbol-name var)))
(when (string-match "\\`var-\\(.*\\)\\'" var-name)
(push (match-string 1 var-name) ret))))
obarray)))))
(apply fun args)))
(defun calc-aent-complete-word ()
"Complete word at point with entries from `minibuffer-completion-table'."
(interactive)
(when-let ((word-bounds (bounds-of-thing-at-point 'word)))
(completion-in-region (car word-bounds) (cdr word-bounds) minibuffer-completion-table)))
(define-key calc-alg-ent-map "\C-i" #'calc-aent-complete-word)
(advice-add 'calc-do-alg-entry :around #'calc-do-alg-entry-completion)
abbrev
oryas-snippet
work fine. I personally (and frequently) useyas-snippet
to write elements into 3x3 matrices. (if it's in thecalc-edit
with'`
)