mirror of
https://codeberg.org/scip/autoscratch.git
synced 2025-12-17 12:30:58 +01:00
added (autoscratch-select) for multiple-choice triggers
This commit is contained in:
@@ -76,14 +76,26 @@
|
|||||||
|
|
||||||
(defcustom autoscratch-triggers-alist
|
(defcustom autoscratch-triggers-alist
|
||||||
'(("[(;]" . (emacs-lisp-mode))
|
'(("[(;]" . (emacs-lisp-mode))
|
||||||
("#" . (conf-unix-mode))
|
("#" . (autoscratch-select
|
||||||
|
'(("perl" . (cperl-mode))
|
||||||
|
("ruby" . (ruby-mode))
|
||||||
|
("python" . (python-mode))
|
||||||
|
("conf" . (conf-unix-mode))
|
||||||
|
("shell" . (shell-script-mode)))))
|
||||||
("[-a-zA-Z0-9]" . (text-mode))
|
("[-a-zA-Z0-9]" . (text-mode))
|
||||||
("/" . (c-mode))
|
("/" . (c-mode))
|
||||||
("*" . (progn (insert " ") (org-mode)))
|
("*" . (progn (insert " ") (org-mode)))
|
||||||
("." . (fundamental-mode)))
|
("." . (fundamental-mode)))
|
||||||
"Default trigger alist for autoscratch mode.
|
"Default trigger alist for autoscratch mode.
|
||||||
|
|
||||||
This list triggers after the first character entered."
|
This list triggers after the first character entered.
|
||||||
|
You can customize this variable directly or use `add-to-list'
|
||||||
|
to add more triggers.
|
||||||
|
|
||||||
|
In case there are more possibilities for a character, you can
|
||||||
|
use `autoscratch-select' to make autoscratch ask interactively
|
||||||
|
for a major mode to switch to, which see. A good example for
|
||||||
|
such a character is # which is the comment-char in many modes."
|
||||||
:group 'autoscratch
|
:group 'autoscratch
|
||||||
:type 'list)
|
:type 'list)
|
||||||
|
|
||||||
@@ -135,6 +147,28 @@ Executes `autoscratch-rename-hook' afterwards."
|
|||||||
(switch-to-buffer buf)
|
(switch-to-buffer buf)
|
||||||
(autoscratch-mode)))
|
(autoscratch-mode)))
|
||||||
|
|
||||||
|
(defun autoscratch-select(modelist)
|
||||||
|
"Interactively ask for major mode to switch to.
|
||||||
|
|
||||||
|
Argument MODELIST must be an alist where the car of each
|
||||||
|
pair must be a name and the cdr some arbitrary emacs lisp
|
||||||
|
form.
|
||||||
|
|
||||||
|
Example for MODELIST:
|
||||||
|
|
||||||
|
'((\"perl\" . (cperl-mode))
|
||||||
|
(\"ruby\" . (ruby-mode))
|
||||||
|
(\"python\" . (python-mode))
|
||||||
|
(\"shell\" . (shell-script-mode))
|
||||||
|
|
||||||
|
This function shall only be called from `autoscratch-triggers-alist'."
|
||||||
|
(interactive)
|
||||||
|
(let ((keys ()))
|
||||||
|
(dolist (e modelist)
|
||||||
|
(push (car e) keys))
|
||||||
|
(eval (cdr (assoc (completing-read "switch mode to: " keys) modelist)))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Internal Functions
|
;;;; Internal Functions
|
||||||
|
|
||||||
(defun autoscratch--fork-and-rename-current ()
|
(defun autoscratch--fork-and-rename-current ()
|
||||||
|
|||||||
Reference in New Issue
Block a user