fix(docs): use org-fold-core-region

org-flag-region was replaced upstream with org-fold.
This commit is contained in:
Henrik Lissner 2022-06-19 15:38:38 +02:00
parent cf2024b356
commit 4ec0ea963e
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -11,7 +11,7 @@
(let ((case-fold-search t)) (let ((case-fold-search t))
(while (re-search-forward "^[ \t]*\\#" nil t) (while (re-search-forward "^[ \t]*\\#" nil t)
(catch 'abort (catch 'abort
(org-flag-region (org-fold-core-region
(line-beginning-position) (line-beginning-position)
(cond ((looking-at "+\\(?:title\\|subtitle\\): +") (cond ((looking-at "+\\(?:title\\|subtitle\\): +")
(match-end 0)) (match-end 0))
@ -23,18 +23,18 @@
((looking-at "+\\(?:begin\\|end\\)_\\([^ \n]+\\)") ((looking-at "+\\(?:begin\\|end\\)_\\([^ \n]+\\)")
(line-end-position)) (line-end-position))
((line-beginning-position 2))) ((line-beginning-position 2)))
doom-docs-mode t))))))) doom-docs-mode 'doom-doc-hidden)))))))
(defun doom--docs-hide-drawers-h () (defun doom--docs-hide-drawers-h ()
"Hide all property drawers." "Hide all property drawers."
(org-with-wide-buffer (org-with-wide-buffer
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward org-drawer-regexp nil t) (while (re-search-forward org-drawer-regexp nil t)
(let ((beg (1- (match-beginning 0))) (let ((beg (max (point-min) (1- (match-beginning 0))))
(end (re-search-forward org-drawer-regexp nil t))) (end (re-search-forward org-drawer-regexp nil t)))
(when (save-excursion (goto-char beg) (bobp)) (when (save-excursion (goto-char beg) (bobp))
(cl-incf end)) (cl-incf end))
(org-flag-region beg end doom-docs-mode t))))) (org-fold-core-region beg end doom-docs-mode 'doom-doc-hidden)))))
(defun doom--docs-hide-tags-h () (defun doom--docs-hide-tags-h ()
"Hide tags in org headings." "Hide tags in org headings."
@ -47,20 +47,20 @@
;; prevent `org-ellipsis' around hidden regions ;; prevent `org-ellipsis' around hidden regions
(org-show-entry)) (org-show-entry))
(if (member "noorg" tags) (if (member "noorg" tags)
(org-flag-region (line-end-position 0) (org-fold-core-region (line-end-position 0)
(save-excursion (save-excursion
(org-end-of-subtree t) (org-end-of-subtree t)
(forward-line 1) (forward-line 1)
(if (and (bolp) (eolp)) (if (and (bolp) (eolp))
(line-beginning-position) (line-beginning-position)
(line-end-position 0))) (line-end-position 0)))
doom-docs-mode t) doom-docs-mode 'doom-doc-hidden)
(org-flag-region (save-excursion (org-fold-core-region (save-excursion
(goto-char (line-beginning-position)) (goto-char (line-beginning-position))
(re-search-forward " +:[^ ]" (line-end-position)) (re-search-forward " +:[^ ]" (line-end-position))
(match-beginning 0)) (match-beginning 0))
(line-end-position) (line-end-position)
doom-docs-mode t)))))) doom-docs-mode 'doom-doc-hidden))))))
(defun doom--docs-hide-stars-h () (defun doom--docs-hide-stars-h ()
"Update invisible property to VISIBILITY for markers in the current buffer." "Update invisible property to VISIBILITY for markers in the current buffer."
@ -68,10 +68,10 @@
(goto-char (point-min)) (goto-char (point-min))
(with-silent-modifications (with-silent-modifications
(while (re-search-forward "^\\(\\*[ \t]\\|\\*\\*+\\)" nil t) (while (re-search-forward "^\\(\\*[ \t]\\|\\*\\*+\\)" nil t)
(org-flag-region (org-fold-core-region (match-beginning 0)
(match-beginning 0) (match-end 0)
(match-end 0) doom-docs-mode
doom-docs-mode t))))) 'doom-doc-hidden)))))
(defvar doom--docs-babel-cache nil) (defvar doom--docs-babel-cache nil)
(defun doom--docs-hide-src-blocks-h () (defun doom--docs-hide-src-blocks-h ()
@ -112,7 +112,7 @@
(skip-chars-forward "\n") (skip-chars-forward "\n")
(point)))))) (point))))))
(unless (member exports '(nil "both" "code" "t")) (unless (member exports '(nil "both" "code" "t"))
(org-flag-region beg end doom-docs-mode t)))) (org-fold-core-region beg end doom-docs-mode 'doom-doc-hidden))))
(unless doom-docs-mode (unless doom-docs-mode
(save-excursion (save-excursion
(dolist (pos doom--docs-babel-cache) (dolist (pos doom--docs-babel-cache)
@ -200,6 +200,11 @@ This primes `org-mode' for reading."
:after-hook (org-restart-font-lock) :after-hook (org-restart-font-lock)
(unless (derived-mode-p 'org-mode) (unless (derived-mode-p 'org-mode)
(user-error "Not an org mode buffer")) (user-error "Not an org mode buffer"))
(org-fold-add-folding-spec
'doom-doc-hidden '(:visible nil
:alias (hidden)
:isearch-open nil
:font-lock-skip t))
(mapc (lambda (sym) (mapc (lambda (sym)
(if doom-docs-mode (if doom-docs-mode
(set (make-local-variable sym) t) (set (make-local-variable sym) t)