summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-08-16 18:05:58 +0200
committerUlrich Müller <ulm@gentoo.org>2024-08-16 22:47:54 +0200
commit4ece293213432546db9d885999f67cac75258d62 (patch)
tree6c11a2056f1e3fc67d36c010a568a426197918da
parentAdd ebuild commands instprep and nofetch (diff)
downloadebuild-mode-4ece293213432546db9d885999f67cac75258d62.tar.gz
ebuild-mode-4ece293213432546db9d885999f67cac75258d62.tar.bz2
ebuild-mode-4ece293213432546db9d885999f67cac75258d62.zip
Define functions and C-c C-e <letter> keys for ebuild subcommands
* ebuild-mode.el (ebuild-run-command-*): Define functions for ebuild subcommands. (ebuild-mode-prefix-map): New variable, keymap for ebuild-mode commands. Define C-c C-e <letter> keys for the most common ebuild subcommands. (ebuild-mode-map): Use the new keymap. (ebuild-mode-menu): Use ebuild-run-command-* functions in menu items; for the previously used expressions, easy-menu-define would create internal functions anyway. Don't sort ebuild-commands-list because it already is in alphabetical order. * ebuild-mode.texi (ebuild-mode): Update. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog12
-rw-r--r--ebuild-mode.el61
-rw-r--r--ebuild-mode.texi9
3 files changed, 67 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index c682ed2..75bdf0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2024-08-16 Ulrich Müller <ulm@gentoo.org>
+ * ebuild-mode.el (ebuild-run-command-*): Define functions
+ for ebuild subcommands.
+ (ebuild-mode-prefix-map): New variable, keymap for ebuild-mode
+ commands. Define C-c C-e <letter> keys for the most common ebuild
+ subcommands.
+ (ebuild-mode-map): Use the new keymap.
+ (ebuild-mode-menu): Use ebuild-run-command-* functions in menu
+ items; for the previously used expressions, easy-menu-define would
+ create internal functions anyway. Don't sort ebuild-commands-list
+ because it already is in alphabetical order.
+ * ebuild-mode.texi (ebuild-mode): Update.
+
* ebuild-mode.el (ebuild-commands-list): Add "instprep" and
"nofetch" commands.
diff --git a/ebuild-mode.el b/ebuild-mode.el
index 9183c0a..e4cbfb0 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -478,6 +478,17 @@ If nil, `compilation-mode' will be used.")
(compile shell-command)
(compile shell-command ebuild-log-buffer-mode))))
+;; Define functions for all ebuild subcommands
+(dolist (command ebuild-commands-list)
+ (defalias (intern (concat "ebuild-run-command-" command))
+ ;; Backquote for XEmacs compatibility (no lexical binding).
+ ;; Also, defalias in 21.4 accepts only two args, so the docstring
+ ;; must be in the lambda form.
+ `(lambda ()
+ ,(format "Run ebuild command \"%s\"." command)
+ (interactive)
+ (ebuild-run-command ,command))))
+
(define-derived-mode ebuild-compilation-mode compilation-mode "Compilation"
"Like `compilation-mode' but with color support.
Translates ANSI SGR control sequences into text properties (if the
@@ -1000,29 +1011,49 @@ in a Gentoo profile."
;;; Keybindings.
-(dolist (k '(("\C-c\C-e\C-e" ebuild-run-command)
- ("\C-c\C-e\C-p" ebuild-mode-run-pkgdev)
- ("\C-c\C-e\C-c" ebuild-mode-run-pkgcheck)
- ("\C-c\C-e\C-w" ebuild-mode-find-workdir)
- ("\C-c\C-e\C-s" ebuild-mode-find-s)
- ("\C-c\C-e\C-l" ebuild-mode-find-build-log)
- ("\C-c\C-e\C-k" ebuild-mode-keyword)
- ("\C-c\C-e\C-y" ebuild-mode-ekeyword)
- ("\C-c\C-e\C-u" ebuild-mode-all-keywords-unstable)
- ("\C-c\C-e\C-n" ebuild-mode-insert-skeleton)))
- (apply #'define-key ebuild-mode-map k))
-
+(defvar ebuild-mode-prefix-map
+ (let ((map (make-sparse-keymap)))
+ ;; C-<letter> keys for general commands
+ (define-key map "\C-e" #'ebuild-run-command)
+ (define-key map "\C-p" #'ebuild-mode-run-pkgdev)
+ (define-key map "\C-c" #'ebuild-mode-run-pkgcheck)
+ (define-key map "\C-w" #'ebuild-mode-find-workdir)
+ (define-key map "\C-s" #'ebuild-mode-find-s)
+ (define-key map "\C-l" #'ebuild-mode-find-build-log)
+ (define-key map "\C-k" #'ebuild-mode-keyword)
+ (define-key map "\C-y" #'ebuild-mode-ekeyword)
+ (define-key map "\C-u" #'ebuild-mode-all-keywords-unstable)
+ (define-key map "\C-n" #'ebuild-mode-insert-skeleton)
+ ;; <letter> for ebuild subcommands
+ (define-key map "l" 'ebuild-run-command-clean)
+ (define-key map "c" 'ebuild-run-command-compile)
+ (define-key map "g" 'ebuild-run-command-configure)
+ (define-key map "f" 'ebuild-run-command-fetch)
+ (define-key map "i" 'ebuild-run-command-install)
+ (define-key map "d" 'ebuild-run-command-manifest) ; previously "digest"
+ (define-key map "m" 'ebuild-run-command-merge)
+ (define-key map "p" 'ebuild-run-command-prepare)
+ (define-key map "q" 'ebuild-run-command-qmerge)
+ (define-key map "t" 'ebuild-run-command-test)
+ (define-key map "n" 'ebuild-run-command-unmerge)
+ (define-key map "u" 'ebuild-run-command-unpack)
+ map)
+ "Keymap for `ebuild-mode' specific commands.")
+
+(define-key ebuild-mode-map "\C-c\C-e" ebuild-mode-prefix-map)
(define-key ebuild-repo-mode-map "\C-c-" #'ebuild-mode-insert-tag-line)
;; Menu support for both Emacs and XEmacs.
(easy-menu-define ebuild-mode-menu ebuild-mode-map
"Menu for `ebuild-mode'."
`("Ebuild"
+ ["Run ebuild command" ebuild-run-command
+ :active (eq major-mode 'ebuild-mode)]
("ebuild commands"
:active (eq major-mode 'ebuild-mode)
- ["Run ebuild command" ebuild-run-command]
- ,@(mapcar (lambda (c) (vector c (list #'ebuild-run-command c)))
- (sort (copy-sequence ebuild-commands-list) #'string-lessp)))
+ ,@(mapcar (lambda (c)
+ (vector c (intern (concat "ebuild-run-command-" c))))
+ ebuild-commands-list))
["Run pkgdev command" ebuild-mode-run-pkgdev]
["Run pkgcheck command" ebuild-mode-run-pkgcheck]
["Find working directory (WORKDIR)" ebuild-mode-find-workdir
diff --git a/ebuild-mode.texi b/ebuild-mode.texi
index c6d6851..4784157 100644
--- a/ebuild-mode.texi
+++ b/ebuild-mode.texi
@@ -158,6 +158,13 @@ program suite. @kbd{C-c C-e C-e} calls @code{ebuild-run-command} which
asks for one of the possible actions as argument. See the man page of
ebuild what actions are provided.
+Some common action (or subcommands) of the ebuild command can be
+executed via their own key sequences, all of them using @kbd{C-c C-e}
+followed by a letter. For example, the @code{unpack} action is bound
+to @kbd{C-c C-e u}. Subcommands that don't have their own key sequence
+--- but also those that do --- can be executed via the main
+@code{ebuild-run-command} bound to @kbd{C-c C-e C-e}, or via the menu.
+
The commands @code{ebuild-mode-find-workdir} and @code{ebuild-mode-find-s}
(bound to @kbd{C-c C-e C-w} and @kbd{C-c C-e C-s}, respectively) allow
to visit the working directory (@code{$@{WORKDIR@}}) and the temporary
@@ -204,6 +211,8 @@ Visit the @code{build.log} file that belongs to the ebuild.
Run a @command{pkgdev} command.
@item C-c C-e C-c
Run a @command{pkgcheck} command.
+@item C-c C-e LETTER
+Run an ebuild action/subcommand.
@end table
@node ebuild-eclass-mode, ebuild-repo-mode, ebuild-mode, Top