=> take advantage of 'boxes -q "(all)"' when defining boxes-types-alist

=> make boxes-known-modes user customizable
This commit is contained in:
gabriele balducci 2021-08-12 13:21:38 +01:59 committed by Thomas Jensen
parent ecb8132569
commit 7f54baf409

View File

@ -46,28 +46,26 @@
"The boxes command.") "The boxes command.")
(defvar boxes-types-alist (defvar boxes-types-alist
(ignore-errors (let ((the-types (process-lines boxes-command "-q" "(all)"))
(with-temp-buffer (the-alist (list)))
(call-process "boxes" nil t nil "-l") (dolist (el the-types the-alist)
(goto-char (point-min)) (let ((no-alias (replace-regexp-in-string " *\(alias\) *$" "" el)))
(let ((retval nil)) (add-to-list 'the-alist
(while (re-search-forward "^\\([a-zA-Z][a-zA-Z0-9-_]+\\)" nil t) (cons no-alias no-alias)))))
(add-to-list 'retval (cons (match-string 1)
(match-string 1))))
retval)))
"Association of types available to the current boxes implementation." ) "Association of types available to the current boxes implementation." )
(make-variable-buffer-local 'boxes-types-alist) (make-variable-buffer-local 'boxes-types-alist)
(defvar boxes-history nil) (defvar boxes-history nil)
;;;###autoload ;;;###autoload
(defvar boxes-known-modes (defcustom boxes-known-modes
'((c-mode . "c-cmt2") (c++-mode . "c-cmt2") (java-mode . "java-cmt") '((c-mode . "c-cmt2") (c++-mode . "c-cmt2") (java-mode . "java-cmt")
(html-mode . "html-cmt") (sh-mode . "pound-cmt") (perl-mode . "pound-cmt") (html-mode . "html-cmt") (sh-mode . "pound-cmt") (perl-mode . "pound-cmt")
(python-mode . "pound-cmt") (ruby-mode . "pound-cmt") (python-mode . "pound-cmt") (ruby-mode . "pound-cmt")
(emacs-lisp-mode . "lisp-cmt") (lisp-mode . "lisp-cmt")) (emacs-lisp-mode . "lisp-cmt") (lisp-mode . "lisp-cmt"))
"The default comment type based on file names.") "The default comment type based on file names."
(make-variable-buffer-local 'boxes-known-modes) :group 'customize
)
;;;###autoload ;;;###autoload
(defun boxes-set-default-type (mode) (defun boxes-set-default-type (mode)