Skip to content

Commit

Permalink
Add feature for yaol
Browse files Browse the repository at this point in the history
  • Loading branch information
aki2o committed Apr 20, 2020
1 parent fa28299 commit 5e13da4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
55 changes: 55 additions & 0 deletions pophint-yaol.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(require 'yaol)
(require 'pophint)

;;;###autoload
(defcustom pophint-yaol:enable t
"Whether to enable feature."
:type 'boolean
:group 'pophint)

(defcustom pophint-yaol:head-action 'yaol-fold-clear-current
"Function to invoke on it when hint selected."
:type 'function
:group 'pophint)

;;;###autoload
(defun pophint:do-yaol-head () (interactive))
(with-no-warnings
(pophint:defsource
:name "yaol-head"
:description "Head of yaol."
:source '((shown . "Head")
(highlight . nil)
(requires . 1)
(method . (lambda ()
(let* ((startpt (when (yaol-next-head)
(point)))
(endpt (when startpt
(yaol-node-fold-beg (-first-item (yaol-find-deepest-nodes-at (point))))))
(value (when endpt
(buffer-substring-no-properties startpt endpt))))
(when (and startpt endpt
(< startpt endpt))
`(:startpt ,startpt :endpt ,endpt :value ,value)))))
(action . (lambda (hint)
(with-selected-window (pophint:hint-window hint)
(goto-char (pophint:hint-startpt hint))
(when pophint-yaol:head-action
(funcall pophint-yaol:head-action))))))))

;;;###autoload
(defun pophint-yaol:provision (activate)
(interactive)
(if activate
(progn
(add-to-list 'pophint:global-sources 'pophint:source-yaol-head t))
(setq pophint:global-sources
(remove 'pophint:source-yaol-head pophint:global-sources))))

;;;###autoload
(with-eval-after-load 'yaol
(when pophint-yaol:enable (pophint-yaol:provision t)))


(provide 'pophint-yaol)
;;; pophint-yaol.el ends here
6 changes: 3 additions & 3 deletions pophint.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;; Author: Hiroaki Otsu <[email protected]>
;; Keywords: popup
;; URL: https://github.com/aki2o/emacs-pophint
;; Version: 1.2.0
;; Package-Requires: ((log4e "0.2.0") (yaxception "0.3"))
;; Version: 1.3.0
;; Package-Requires: ((log4e "0.3.3") (yaxception "0.3"))

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -754,7 +754,7 @@ If nil, it means limitless."

(defsubst pophint--hintable-location-p (direction currpt startpt endpt)
(when (and (not (ignore-errors (invisible-p startpt)))
(not (ignore-errors (invisible-p endpt)))
(not (ignore-errors (invisible-p (1- endpt))))
(case direction
(around t)
(forward (>= startpt currpt))
Expand Down

0 comments on commit 5e13da4

Please sign in to comment.