branch: elpa/helm
commit 9a4b82ec06f131e7ba795ff60c6f70c1d547d52f
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
Improve helm-man-tldr-render
Colorize url and bind RET on it, this when the command exits with zero
status.
---
helm-man.el | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/helm-man.el b/helm-man.el
index 5dd448e08ab..655f11eadfe 100644
--- a/helm-man.el
+++ b/helm-man.el
@@ -108,10 +108,22 @@ source.")
(match-string 2 output))))
(defun helm-man-tldr-render (command)
- (with-current-buffer-window "*tldr*" nil nil
- (call-process "tldr" nil t nil "--color" "always" command)
- (ansi-color-apply-on-region (point-min) (point-max))
- (local-set-key "q" 'quit-window)))
+ (with-current-buffer-window "*tldr*" '(display-buffer-full-frame) nil
+ (let ((status (call-process "tldr" nil t nil "--color" "always" command))
+ map)
+ (when (zerop status)
+ (ansi-color-apply-on-region (point-min) (point-max))
+ (goto-char (point-min))
+ (setq map (let ((m (make-sparse-keymap)))
+ (define-key m (kbd "<return>") #'browse-url-at-point)
+ m))
+ (save-excursion
+ (while (re-search-forward "http[s]://" nil t)
+ (let* ((pos (bounds-of-thing-at-point 'url))
+ (ov (make-overlay (car pos) (cdr pos))))
+ (overlay-put ov 'face 'font-lock-keyword-face)
+ (overlay-put ov 'keymap map))))
+ (local-set-key "q" 'quit-window)))))
(defun helm-man--tldr-cache ()
(when (executable-find "tldr")