about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-04-13 10:16:19 -0500
committerCase Duckworth2022-04-13 10:16:19 -0500
commitd26bfd92e129887fd3cf088db33a0ad0bbd8d300 (patch)
tree7ae4556b097608d883909bf5786da720f9a0a80f /lisp
parentConfigure org-mode ... some more (diff)
parentDang ol +shr.el file (diff)
downloademacs-d26bfd92e129887fd3cf088db33a0ad0bbd8d300.tar.gz
emacs-d26bfd92e129887fd3cf088db33a0ad0bbd8d300.zip
Merge branch 'main' of tildegit.org:acdw/emacs
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+ispell.el3
-rw-r--r--lisp/+shr.el51
2 files changed, 53 insertions, 1 deletions
diff --git a/lisp/+ispell.el b/lisp/+ispell.el index 697233f..fbfc0f0 100644 --- a/lisp/+ispell.el +++ b/lisp/+ispell.el
@@ -4,7 +4,8 @@
4 4
5;;; Code: 5;;; Code:
6 6
7(require 'cl) 7(require 'cl-lib)
8(require 'seq)
8 9
9;; Utility function TODO: move elsewhere 10;; Utility function TODO: move elsewhere
10(defun +ispell-append-removing-duplicates (&rest lists) 11(defun +ispell-append-removing-duplicates (&rest lists)
diff --git a/lisp/+shr.el b/lisp/+shr.el new file mode 100644 index 0000000..af4bf5b --- /dev/null +++ b/lisp/+shr.el
@@ -0,0 +1,51 @@
1;;; +shr.el --- SHR extras -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7;;; [[https://github.com/oantolin/emacs-config/blob/master/my-lisp/shr-heading.el][shr-heading]], by oantolin
8
9(defun +shr-heading-next (&optional arg)
10 "Move forward by ARG headings (any h1-h4).
11If ARG is negative move backwards, ARG defaults to 1."
12 (interactive "p")
13 (unless arg (setq arg 1))
14 (catch 'return
15 (dotimes (_ (abs arg))
16 (when (> arg 0) (end-of-line))
17 (if-let ((match
18 (funcall (if (> arg 0)
19 #'text-property-search-forward
20 #'text-property-search-backward)
21 'face '(shr-h1 shr-h2 shr-h3 shr-h4)
22 (lambda (tags face)
23 (cl-loop for x in (if (consp face) face (list face))
24 thereis (memq x tags))))))
25 (goto-char
26 (if (> arg 0) (prop-match-beginning match) (prop-match-end match)))
27 (throw 'return nil))
28 (when (< arg 0) (beginning-of-line)))
29 (beginning-of-line)
30 (point)))
31
32(defun +shr-heading-previous (&optional arg)
33 "Move backward by ARG headings (any h1-h4).
34If ARG is negative move forwards instead, ARG defaults to 1."
35 (interactive "p")
36 (+shr-heading-next (- (or arg 1))))
37
38(defun +shr-heading--line-at-point ()
39 "Return the current line."
40 (buffer-substring (line-beginning-position) (line-end-position)))
41
42(defun +shr-heading-setup-imenu ()
43 "Setup imenu for h1-h4 headings in eww buffer.
44Add this function to appropriate major mode hooks such as
45`eww-mode-hook' or `elfeed-show-mode-hook'."
46 (setq-local
47 imenu-prev-index-position-function #'+shr-heading-previous
48 imenu-extract-index-name-function #'+shr-heading--line-at-point))
49
50(provide '+shr)
51;;; +shr.el ends here