store: Clarify 'query-path-hash' docstring.
[guix.git] / gnu / packages / patches / emacs-constants-lisp-like.patch
blob5ec37f3adfa821cdde738ceb14c905cb8fb19f65
1 Add Scheme support
3 --- constants/constants.el.orig 2015-12-26 17:44:31.734520833 +0100
4 +++ constants/constants.el 2015-12-30 17:41:28.402871263 +0100
5 @@ -684,6 +684,33 @@
7 (eval-when-compile (defvar ctable))
9 +(defun constants-is-lisp-like (mode)
10 + (save-match-data
11 + (string-match "\\(lisp\\|scheme\\)" (symbol-name mode))))
13 +(defun constants-is-set-like ()
14 + (save-excursion
15 + (condition-case nil
16 + (save-match-data
17 + (progn (up-list -1)
18 + (or (looking-at "(set[qf!]?\\>") (looking-at "(define\\>"))))
19 + (error nil)))) ; return value nil means use default
21 +;;;###autoload
22 +(defun constants-lisp-like-function ()
23 + "Check context for constants insertion."
24 + (if (constants-is-set-like)
25 + '(emacs-lisp-mode "%n %v%t; %d %u" "e" "(* %p %v)")
26 + '(emacs-lisp-mode "(%n %v)%t; %d %u" "e" "(* %p %v)")))
28 +;;;###autoload
29 +(mapc (lambda (mode-hook)
30 + (add-hook mode-hook
31 + (lambda ()
32 + (setq constants-language-function
33 + 'constants-lisp-like-function))))
34 + '(scheme-mode-hook emacs-lisp-mode-hook lisp-mode-hook))
36 ;;;###autoload
37 (defun constants-insert (&optional unit-system names)
38 "Insert one or more natural constant definitions in source code.
39 @@ -826,8 +853,9 @@
40 (funcall process-func ins))
41 ;; Here comes the insertion stuff for source code editing modes.
42 ;; First make sure we start a new line
43 - (if (string-match
44 - "\\S-" (buffer-substring (point-at-bol) (point-at-eol)))
45 + (if (and (string-match
46 + "\\S-" (buffer-substring (point-at-bol) (point-at-eol)))
47 + (not (constants-is-lisp-like mode)))
48 ;; non-empty line, insert after this line
49 (progn
50 (end-of-line 1)
51 @@ -841,13 +869,24 @@
52 (if (string-match "\\(.*\\)%t\\(.*\\)" line)
53 (let ((comment-column 42))
54 (insert (match-string 1 line))
55 - (indent-to comment-column)
56 - (insert (match-string 2 line)))
57 + (if (and (constants-is-lisp-like mode)
58 + (or (constants-is-set-like)
59 + (null clist)))
60 + (save-excursion
61 + (progn
62 + (move-to-column comment-column t)
63 + (insert (match-string 2 line))
64 + ;; insert a newline such that paredit's M-) can mode
65 + ;; the closing parentheses to the next line.
66 + (newline-and-indent)))
67 + (progn
68 + (indent-to comment-column)
69 + (insert (match-string 2 line)))))
70 (insert line)))
71 - (if constants-indent-code
72 - (newline-and-indent)
73 - (newline))))))
75 + (unless (and (constants-is-lisp-like mode) (null clist))
76 + (if constants-indent-code
77 + (newline-and-indent)
78 + (newline)))))))
79 ;;;###autoload
80 (defun constants-get (&optional const message)
81 "Return the value of CONST as defined in the constants package.