From 17fa842b79503dfa9972f3bfa3d5a96610263378 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Mon, 12 Oct 2015 12:06:32 +0300 Subject: emacs: devel: Add indentation rules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Ludovic Courtès . * emacs/guix-devel.el: Add indentation rules for Guix macros/procedures. (guix-devel-scheme-indent): New macro. (guix-devel-indent-package): New function. --- emacs/guix-devel.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'emacs') diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index b8330289c5..c8bfbb0a8a 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -24,6 +24,7 @@ ;;; Code: +(require 'lisp-mode) (require 'guix-guile) (require 'guix-geiser) (require 'guix-utils) @@ -188,6 +189,69 @@ to find 'modify-phases' keywords." (0 'guix-devel-modify-phases-keyword nil t)))) "A list of `font-lock-keywords' for `guix-devel-mode'.") + +;;; Indentation + +(defmacro guix-devel-scheme-indent (&rest rules) + "Set `scheme-indent-function' according to RULES. +Each rule should have a form (SYMBOL VALUE). See `put' for details." + (declare (indent 0)) + `(progn + ,@(mapcar (lambda (rule) + `(put ',(car rule) 'scheme-indent-function ,(cadr rule))) + rules))) + +(defun guix-devel-indent-package (state indent-point normal-indent) + "Indentation rule for 'package' form." + (let* ((package-eol (line-end-position)) + (count (if (and (ignore-errors (down-list) t) + (< (point) package-eol) + (looking-at "inherit\\>")) + 1 + 0))) + (lisp-indent-specform count state indent-point normal-indent))) + +(guix-devel-scheme-indent + (bag 0) + (build-system 0) + (call-with-compressed-output-port 2) + (call-with-container 1) + (call-with-decompressed-port 2) + (call-with-error-handling 0) + (container-excursion 1) + (emacs-batch-edit-file 1) + (emacs-batch-eval 0) + (emacs-substitute-sexps 1) + (emacs-substitute-variables 1) + (file-system 0) + (graft 0) + (manifest-entry 0) + (manifest-pattern 0) + (mbegin 1) + (mlet 2) + (mlet* 2) + (modify-phases 1) + (munless 1) + (mwhen 1) + (operating-system 0) + (origin 0) + (package 'guix-devel-indent-package) + (run-with-state 1) + (run-with-store 1) + (signature-case 1) + (substitute* 1) + (substitute-keyword-arguments 1) + (test-assertm 1) + (with-atomic-file-output 1) + (with-derivation-narinfo 1) + (with-derivation-substitute 2) + (with-directory-excursion 1) + (with-error-handling 0) + (with-monad 1) + (with-mutex 1) + (with-store 1) + (wrap-program 1)) + (defvar guix-devel-keys-map (let ((map (make-sparse-keymap))) -- cgit v1.2.3 From b1b53df382deaeb849241f44581421704245483d Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 15 Oct 2015 23:41:27 +0300 Subject: emacs: init: Add "share/emacs/site-lisp" to 'load-path'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a regression introduced in 7741139080a6b00aa4f1846fe7668859e91bec58. Reported by Ludovic Courtès . Not all emacs packages have "...-autoloads.el" files, so there is a chance that "~/.guix-profile/share/emacs/site-lisp" will not be added to 'load-path', so add it unconditionally. * emacs/guix-init.el: Add guix emacs directory to 'load-path'. Move requiring 'guix-emacs' to the top-level. --- emacs/guix-init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'emacs') diff --git a/emacs/guix-init.el b/emacs/guix-init.el index 96aa0c2ffc..4b3d9c281c 100644 --- a/emacs/guix-init.el +++ b/emacs/guix-init.el @@ -1,4 +1,5 @@ (require 'guix-autoloads) +(require 'guix-emacs) (defcustom guix-package-enable-at-startup t "If non-nil, activate Emacs packages installed in a user profile. @@ -8,8 +9,9 @@ avoid loading autoloads of Emacs packages installed in :type 'boolean :group 'guix) +(add-to-list 'load-path (guix-emacs-directory)) + (when guix-package-enable-at-startup - (require 'guix-emacs) (guix-emacs-load-autoloads 'all)) (add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe) -- cgit v1.2.3 From e0c5309a8363b218452a225cdb51e4f681bf4628 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 15 Oct 2015 21:09:33 +0300 Subject: emacs: Disambiguate "d" key in 'system' popup. * emacs/guix-command.el (guix-command-improve-system-argument): Use "D" key for 'disk-image' action (leave "d" for 'dmd-graph'). --- emacs/guix-command.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'emacs') diff --git a/emacs/guix-command.el b/emacs/guix-command.el index b679ad9b1e..3ae779185e 100644 --- a/emacs/guix-command.el +++ b/emacs/guix-command.el @@ -249,7 +249,8 @@ to be modified." (guix-command-define-argument-improver guix-command-improve-system-argument - '(("vm-image" :char ?V) + '(("disk-image" :char ?D) + ("vm-image" :char ?V) ("--on-error" :char ?E) ("--no-grub" :char ?g) ("--full-boot" :char ?b))) -- cgit v1.2.3 From 727495757f7eca872cb5cb6603223e5a421cd26d Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Thu, 15 Oct 2015 22:10:32 +0300 Subject: emacs: Add "View graph" actions to system graph commands. * emacs/guix-command.el (guix-command-additional-execute-arguments, guix-command-special-executors): Add "View graph" actions for 'dmd-graph' and 'extension-graph' commands. --- emacs/guix-command.el | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'emacs') diff --git a/emacs/guix-command.el b/emacs/guix-command.el index 3ae779185e..1a42594b68 100644 --- a/emacs/guix-command.el +++ b/emacs/guix-command.el @@ -499,15 +499,17 @@ to be modified." "List of default 'execute' action arguments.") (defvar guix-command-additional-execute-arguments - `((("build") - ,(guix-command-make-argument - :name "log" :char ?l :doc "View build log")) - (("graph") - ,(guix-command-make-argument - :name "view" :char ?v :doc "View graph")) - (("size") - ,(guix-command-make-argument - :name "view" :char ?v :doc "View map"))) + (let ((graph-arg (guix-command-make-argument + :name "view" :char ?v :doc "View graph"))) + `((("build") + ,(guix-command-make-argument + :name "log" :char ?l :doc "View build log")) + (("graph") ,graph-arg) + (("size") + ,(guix-command-make-argument + :name "view" :char ?v :doc "View map")) + (("system" "dmd-graph") ,graph-arg) + (("system" "extension-graph") ,graph-arg))) "Alist of guix commands and additional 'execute' action arguments.") (defun guix-command-execute-arguments (commands) @@ -531,7 +533,11 @@ to be modified." (("graph") ("view" . guix-run-view-graph)) (("size") - ("view" . guix-run-view-size-map))) + ("view" . guix-run-view-size-map)) + (("system" "dmd-graph") + ("view" . guix-run-view-graph)) + (("system" "extension-graph") + ("view" . guix-run-view-graph))) "Alist of guix commands and alists of special executers for them. See also `guix-command-default-executors'.") -- cgit v1.2.3 From 7c0b02f5ae94bd9da1c2ee43cebbef28407f71a8 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Fri, 16 Oct 2015 17:27:58 +0300 Subject: emacs: Improve file names of generated graphs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Ludovic Courtès . * emacs/guix-external.el (guix-png-file-name): Change prefix of a file name to "guix-emacs-graph-" to avoid possible conflicts. --- emacs/guix-external.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'emacs') diff --git a/emacs/guix-external.el b/emacs/guix-external.el index d233473abe..580676ef91 100644 --- a/emacs/guix-external.el +++ b/emacs/guix-external.el @@ -64,7 +64,7 @@ If ARGS is nil, use `guix-dot-default-arguments'." "Return '.png' file name in the `temporary-file-directory'." (concat (make-temp-name (concat (file-name-as-directory temporary-file-directory) - "graph-")) + "guix-emacs-graph-")) ".png")) (provide 'guix-external) -- cgit v1.2.3 From 5d86684ddfe7ed27b37fa4b29c602b45756cc5be Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Fri, 16 Oct 2015 23:38:38 +0300 Subject: emacs: devel: Highlight Guix keywords. * emacs/guix-devel.el (guix-devel-keywords): New constant. (guix-devel-font-lock-keywords): Use it. --- emacs/guix-devel.el | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'emacs') diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index c8bfbb0a8a..f3ad4b9255 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -178,9 +178,52 @@ to find 'modify-phases' keywords." (ignore-errors (forward-sexp)) (save-excursion (up-list) (point))))) +(defconst guix-devel-keywords + '("call-with-compressed-output-port" + "call-with-container" + "call-with-decompressed-port" + "call-with-derivation-narinfo" + "call-with-derivation-substitute" + "call-with-error-handling" + "call-with-temporary-directory" + "call-with-temporary-output-file" + "define-enumerate-type" + "define-gexp-compiler" + "define-lift" + "define-monad" + "define-operation" + "define-record-type*" + "emacs-substitute-sexps" + "emacs-substitute-variables" + "mbegin" + "mlet" + "mlet*" + "munless" + "mwhen" + "run-with-state" + "run-with-store" + "signature-case" + "substitute*" + "substitute-keyword-arguments" + "test-assertm" + "use-package-modules" + "use-service-modules" + "use-system-modules" + "with-atomic-file-output" + "with-atomic-file-replacement" + "with-derivation-narinfo" + "with-derivation-substitute" + "with-directory-excursion" + "with-error-handling" + "with-monad" + "with-mutex" + "with-store")) + (defvar guix-devel-font-lock-keywords `((,(rx (or "#~" "#$" "#$@" "#+" "#+@")) . 'guix-devel-gexp-symbol) + (,(guix-guile-keyword-regexp (regexp-opt guix-devel-keywords)) + (1 'font-lock-keyword-face)) (,(guix-guile-keyword-regexp "modify-phases") (1 'font-lock-keyword-face) (guix-devel-modify-phases-font-lock-matcher -- cgit v1.2.3