The Lambda Lab
/
projects
/
elpher.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
be2df97
)
Jump to a heading using imenu
author
Omar Polo
<op@omarpolo.com>
Mon, 28 Jun 2021 10:31:10 +0000
(10:31 +0000)
committer
Alex Schroeder
<alex@gnu.org>
Mon, 28 Jun 2021 11:33:05 +0000
(13:33 +0200)
elpher.el
patch
|
blob
|
history
diff --git
a/elpher.el
b/elpher.el
index
1bace1b
..
5dc0bdf
100644
(file)
--- a/
elpher.el
+++ b/
elpher.el
@@
-135,6
+135,10
@@
;;; Internal variables
;;
;;; Internal variables
;;
+;; buffer-local
+(defvar elpher--gemini-page-headings '()
+ "Interval variable containing list of headings on page.")
+
(defvar elpher--gemini-page-links '()
"Internal variable containing list of links on page.")
(defvar elpher--gemini-page-links '()
"Internal variable containing list of links on page.")
@@
-1457,6
+1461,8
@@
by HEADER-LINE."
(/ (* fill-column
(font-get (font-spec :name (face-font 'default)) :size))
(font-get (font-spec :name (face-font face)) :size)) fill-column)))
(/ (* fill-column
(font-get (font-spec :name (face-font 'default)) :size))
(font-get (font-spec :name (face-font face)) :size)) fill-column)))
+ (setq elpher--gemini-page-headings (cons (cons header (point))
+ elpher--gemini-page-headings))
(unless (display-graphic-p)
(insert (make-string level ?#) " "))
(insert (propertize header 'face face))
(unless (display-graphic-p)
(insert (make-string level ?#) " "))
(insert (propertize header 'face face))
@@
-1487,6
+1493,7
@@
width defined by elpher-gemini-max-fill-width."
(defun elpher-render-gemini-map (data _parameters)
"Render DATA as a gemini map file, PARAMETERS is currently unused."
(elpher-with-clean-buffer
(defun elpher-render-gemini-map (data _parameters)
"Render DATA as a gemini map file, PARAMETERS is currently unused."
(elpher-with-clean-buffer
+ (setq elpher--gemini-page-headings nil)
(let ((preformatted nil)
(link-counter 1))
(auto-fill-mode 1)
(let ((preformatted nil)
(link-counter 1))
(auto-fill-mode 1)
@@
-1510,6
+1517,7
@@
width defined by elpher-gemini-max-fill-width."
(elpher-gemini-insert-link line)))
((string-prefix-p "#" line) (elpher-gemini-insert-header line))
(t (elpher-gemini-insert-text line)))))
(elpher-gemini-insert-link line)))
((string-prefix-p "#" line) (elpher-gemini-insert-header line))
(t (elpher-gemini-insert-text line)))))
+ (setq elpher--gemini-page-headings (nreverse elpher--gemini-page-headings))
(elpher-cache-content
(elpher-page-address elpher-current-page)
(buffer-string))
(elpher-cache-content
(elpher-page-address elpher-current-page)
(buffer-string))
@@
-2159,9
+2167,14
@@
When run interactively HOST-OR-URL is read from the minibuffer."
This mode is automatically enabled by the interactive
functions which initialize the gopher client, namely
`elpher', `elpher-go' and `elpher-bookmarks'."
This mode is automatically enabled by the interactive
functions which initialize the gopher client, namely
`elpher', `elpher-go' and `elpher-bookmarks'."
+ (setq-local elpher--gemini-page-headings nil)
(setq-local elpher-current-page nil)
(setq-local elpher-history nil)
(setq-local elpher-current-page nil)
(setq-local elpher-history nil)
- (setq-local elpher-buffer-name (buffer-name)))
+ (setq-local elpher-buffer-name (buffer-name))
+
+ (setq-local imenu-create-index-function
+ (lambda ()
+ elpher--gemini-page-headings)))
(when (fboundp 'evil-set-initial-state)
(evil-set-initial-state 'elpher-mode 'motion))
(when (fboundp 'evil-set-initial-state)
(evil-set-initial-state 'elpher-mode 'motion))