@@ -178,27 +178,29 @@ When nil, you can specify your own at each location like this: _ 5a_.")
178178
179179(defface hydra-face-red
180180 '((t (:foreground " #FF0000" :bold t )))
181- " Red Hydra heads will persist indefinitely."
181+ " Red Hydra heads don't exit the Hydra.
182+ Every other command exits the Hydra."
182183 :group 'hydra )
183184
184185(defface hydra-face-blue
185186 '((t (:foreground " #0000FF" :bold t )))
186- " Blue Hydra heads will vanquish the Hydra." )
187+ " Blue Hydra heads exit the Hydra.
188+ Every other command exits as well." )
187189
188190(defface hydra-face-amaranth
189191 '((t (:foreground " #E52B50" :bold t )))
190192 " Amaranth body has red heads and warns on intercepting non-heads.
191- Vanquishable only through a blue head." )
193+ Exitable only through a blue head." )
192194
193195(defface hydra-face-pink
194196 '((t (:foreground " #FF6EB4" :bold t )))
195- " Pink body has red heads and on intercepting non-heads calls them without quitting .
196- Vanquishable only through a blue head." )
197+ " Pink body has red heads and runs intercepted non-heads.
198+ Exitable only through a blue head." )
197199
198200(defface hydra-face-teal
199201 '((t (:foreground " #367588" :bold t )))
200202 " Teal body has blue heads an warns on intercepting non-heads.
201- Vanquishable only through a blue head." )
203+ Exitable only through a blue head." )
202204
203205; ;* Fontification
204206(defun hydra-add-font-lock ()
@@ -330,57 +332,21 @@ Return DEFAULT if PROP is not in H."
330332
331333(defun hydra--head-color (h body )
332334 " Return the color of a Hydra head H with BODY."
333- (let* ((head-exit (hydra--head-property h :exit 'default ))
334- (foreign-keys (hydra--body-foreign-keys body))
335- (head-color (hydra--head-property h :color ))
335+ (let* ((foreign-keys (hydra--body-foreign-keys body))
336+ (head-exit (hydra--head-property h :exit ))
336337 (head-color
337- (cond ((eq head-exit 'default )
338- (cl-case head-color
339- (blue 'blue )
340- (red 'red )
341- (t
342- (unless (null head-color)
343- (error " Use only :blue or :red for heads: %S " h)))))
344- ((null head-exit)
345- (if head-color
346- (error " Don't mix :color and :exit - they are aliases: %S " h)
347- (cl-case foreign-keys
348- (run 'pink )
349- (warn 'amaranth )
350- (t 'red ))))
351- ((eq head-exit t )
352- (if head-color
353- (error " Don't mix :color and :exit - they are aliases: %S " h)
354- 'blue ))
355- (t
356- (error " Unknown :exit %S " head-exit)))))
357- (cond ((null (cadr h))
358- (when head-color
359- (hydra--complain
360- " Doubly specified blue head - nil cmd is already blue: %S" h))
361- 'blue )
362- ((null head-color)
363- (let ((color (plist-get (cddr body) :color ))
364- (exit (plist-get (cddr body) :exit ))
365- (foreign-keys (plist-get (cddr body) :foreign-keys )))
366- (cond ((eq foreign-keys 'warn )
367- (if exit 'teal 'amaranth ))
368- ((eq foreign-keys 'run ) 'pink )
369- (exit 'blue )
370- (color color)
371- (t 'red ))))
372- ((null foreign-keys)
373- head-color)
374- ((eq foreign-keys 'run )
375- (if (eq head-color 'red )
376- 'pink
377- 'blue ))
378- ((eq foreign-keys 'warn )
379- (if (memq head-color '(red amaranth))
380- 'amaranth
381- 'teal ))
382- (t
383- (error " Unexpected %S %S " h body)))))
338+ (if head-exit
339+ (if (eq foreign-keys 'warn )
340+ 'teal
341+ 'blue )
342+ (cl-case foreign-keys
343+ (warn 'amaranth )
344+ (run 'pink )
345+ (t 'red )))))
346+ (when (and (null (cadr h))
347+ (not (eq head-color 'blue )))
348+ (hydra--complain " nil cmd can only be blue" ))
349+ head-color))
384350
385351(defun hydra--body-foreign-keys (body )
386352 " Return what BODY does with a non-head binding."
@@ -823,7 +789,7 @@ result of `defhydra'."
823789 (hydra--make-funcall body-before-exit)
824790 (hydra--make-funcall body-after-exit)
825791 (dolist (base body-inherit)
826- (setq heads (append heads (eval base))))
792+ (setq heads (append heads (copy-sequence ( eval base) ))))
827793 (dolist (h heads)
828794 (let ((len (length h)))
829795 (cond ((< len 2 )
@@ -832,9 +798,7 @@ result of `defhydra'."
832798 (setcdr (cdr h)
833799 (list
834800 (hydra-plist-get-default body-plist :hint " " )))
835- (setcdr (nthcdr 2 h)
836- (list :cmd-name (hydra--head-name h name body)
837- :exit body-exit)))
801+ (setcdr (nthcdr 2 h) (list :exit body-exit)))
838802 (t
839803 (let ((hint (cl-caddr h)))
840804 (unless (or (null hint)
@@ -844,9 +808,7 @@ result of `defhydra'."
844808 (cddr h)))))
845809 (let ((hint-and-plist (cddr h)))
846810 (if (null (cdr hint-and-plist))
847- (setcdr hint-and-plist
848- (list :cmd-name (hydra--head-name h name body)
849- :exit body-exit))
811+ (setcdr hint-and-plist (list :exit body-exit))
850812 (let* ((plist (cl-cdddr h))
851813 (h-color (plist-get plist :color )))
852814 (if h-color
@@ -860,8 +822,9 @@ result of `defhydra'."
860822 (plist-put plist :exit
861823 (if (eq h-exit 'default )
862824 body-exit
863- h-exit))))
864- (plist-put plist :cmd-name (hydra--head-name h name body)))))))))
825+ h-exit))))))))))
826+ (plist-put (cl-cdddr h) :cmd-name (hydra--head-name h name body))
827+ (when (null (cadr h)) (plist-put (cl-cdddr h) :exit t )))
865828 (let ((doc (hydra--doc body-key body-name heads))
866829 (heads-nodup (hydra--delete-duplicates heads)))
867830 (mapc
0 commit comments