Skip to content

Commit

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

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

(defcustom pophint-outline:heading-action 'outline-show-children
"Function to invoke on it when hint selected."
:type 'function
:group 'pophint)

;;;###autoload
(defun pophint:do-outline-heading () (interactive))
(with-no-warnings
(pophint:defsource
:name "outline-heading"
:description "Heading of outline."
:source '((shown . "Heading")
(highlight . nil)
(method . (lambda ()
(let* ((currpt (point))
(startpt (progn (outline-next-visible-heading 1) (+ (point) (funcall outline-level))))
(endpt (progn (outline-end-of-heading) (point)))
(value (buffer-substring-no-properties startpt endpt)))
(when (and (<= currpt startpt)
(outline-on-heading-p))
`(:startpt ,startpt :endpt ,endpt :value ,value)))))
(action . (lambda (hint)
(with-selected-window (pophint:hint-window hint)
(goto-char (pophint:hint-startpt hint))
(when pophint-outline:heading-action
(funcall pophint-outline:heading-action))))))))

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

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


(provide 'pophint-outline)
;;; pophint-outline.el ends here
2 changes: 1 addition & 1 deletion pophint.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; Author: Hiroaki Otsu <ootsuhiroaki@gmail.com>
;; Keywords: popup
;; URL: https://github.com/aki2o/emacs-pophint
;; Version: 1.1.1
;; Version: 1.2.0
;; Package-Requires: ((log4e "0.2.0") (yaxception "0.3"))

;; This program is free software; you can redistribute it and/or modify
Expand Down

0 comments on commit fa28299

Please sign in to comment.