Edit and test table and heading introspection functions

This commit is contained in:
Gerard Vermeulen 2023-07-08 11:08:15 +02:00
parent a9c5b8306c
commit 9dffbab8d8
1 changed files with 226 additions and 64 deletions

View File

@ -3055,7 +3055,9 @@ The property is from the drawer of headline matching TARGET and LEVEL."
(push (cons (pos-bol) (org-heading-components)) done))))
(sort done (lambda (x y) (< (car x) (car y))))))
(defun all-org-table-indices ()
(defun all-org-table-info (&optional no-contents)
"Find information about all tables with contents when NO-CONTENTS is nil.
When NO-CONTENTS is non-nil, find the same information without contents."
(let ((done nil))
(org-with-point-at 1
(while (re-search-forward org-table-line-regexp nil t)
@ -3066,22 +3068,22 @@ The property is from the drawer of headline matching TARGET and LEVEL."
(org-element-contents-begin table)
(org-element-contents-end table))
done :test 'equal)))))
(cl-loop for (x y z) in (sort done (lambda (x y) (< (car x) (car y))))
collect (list x y z))))
(if no-contents
(cl-loop for (x y z) in (sort done (lambda (x y) (< (car x) (car y))))
collect (list x y z))
(cl-loop for (x y z) in (sort done (lambda (x y) (< (car x) (car y))))
collect (list x y z (buffer-substring-no-properties y z))))))
(defun all-org-table-contents ()
(defun all-org-custom-id-info ()
(let ((done nil))
(org-with-point-at 1
(while (re-search-forward org-table-line-regexp nil t)
(let ((table (org-element-lineage (org-element-at-point) 'table t)))
(when table
;; `org' tables have contents (`table.el' tables have value)
(cl-pushnew (list (org-element-begin table)
(org-element-contents-begin table)
(org-element-contents-end table))
done :test 'equal)))))
(cl-loop for (x y z) in (sort done (lambda (x y) (< (car x) (car y))))
collect (list x y z (buffer-substring-no-properties y z))))))
(save-excursion
(goto-char (point-min))
(let ((case-fold-search t)
(regexp (org-re-property "CUSTOM_ID" nil t nil)))
(while (re-search-forward regexp nil t)
(push (list (pos-bol) (org-entry-get (point) "CUSTOM_ID" nil t))
done))))
(sort done (lambda (x y) (< (car x) (car y)))))))
#+end_src
#+caption[Test ~all-org-heading-components~]:
@ -3089,7 +3091,7 @@ The property is from the drawer of headline matching TARGET and LEVEL."
#+header: :var depth=1
#+header: :wrap "src emacs-lisp -n :eval never :tangle no"
#+name: test-all-org-heading-components
#+begin_src emacs-lisp -n :exports both :lexical t :results value pp :tangle no
#+begin_src emacs-lisp -n :exports both :results value pp :tangle no
(all-org-heading-components depth)
#+end_src
@ -3098,62 +3100,222 @@ The property is from the drawer of headline matching TARGET and LEVEL."
#+name: test-all-org-heading-components-result
#+RESULTS: test-all-org-heading-components
#+begin_src emacs-lisp -n :eval never :tangle no
((569 1 1 nil nil "Copying" nil)
(1874 1 1 nil nil "Quick start" nil)
(3580 1 1 nil nil "Introduction" nil)
(10948 1 1 nil nil "[[info:emacs#Early Init File][Early Init File (info)]]" nil)
(12233 1 1 nil nil "[[info:emacs#Init File][Init File (info)]] header" nil)
(19176 1 1 nil nil "[[info:emacs#Package Installation][Install the selected packages (info)]]" nil)
(22176 1 1 nil nil "[[https://git.savannah.gnu.org/cgit/emacs.git/tree/admin/notes/tree-sitter/starter-guide?h=feature/tree-sitter][Emacs Tree-sitter]]" nil)
(25198 1 1 nil nil "[[info:emacs#Faces][Text faces or styles (info)]]" nil)
(32177 1 1 nil nil "[[info:emacs#Windows][Window management (info)]]" nil)
(35290 1 1 nil nil "[[info:elisp#Advising Functions][Advising functions (info)]]" nil)
(37117 1 1 nil nil "[[info:emacs#Dired][Dired: directory editor as file manager (info)]]" nil)
(42683 1 1 nil nil "[[info:emacs#Completion Styles][Minibuffer completion styles (info)]]" nil)
(43488 1 1 nil nil "[[info:elisp#Processes][Processes (info)]]" nil)
(44281 1 1 nil nil "[[info:emacs#Help][Help (info)]]" nil)
(48866 1 1 nil nil "[[info:emacs#Key Bindings][Key bindings (info)]]" nil)
(53746 1 1 nil nil "[[info:emacs#Emacs Server][Using Emacs as a server (info)]]" nil)
(59498 1 1 nil nil "Completion" nil)
(73230 1 1 nil nil "[[info:emacs#Search][Search and replace (info)]]" nil)
(79650 1 1 nil nil "[[info:emacs#Version Control][Version Control (info)]]" nil)
(84604 1 1 nil nil "Reading" nil)
(87677 1 1 nil nil "Writing" nil)
(189130 1 1 nil nil "Programming Tools" nil)
(198923 1 1 nil nil "Programming Modes" nil)
(279054 1 1 nil nil "[[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]" nil)
(281025 1 1 nil nil "[[info:emacs#Minor Modes][Minor Modes (info)]]" nil)
(294147 1 1 nil nil "[[info:emacs#Display][Display (info)]]" nil)
(298934 1 1 nil nil "Applications" nil)
(322732 1 1 nil nil "[[info:emacs#Init File][Init File (info)]] footer" nil)
(323197 1 1 nil nil "GNU General Public License" nil)
(323361 1 1 nil nil "GNU Free Documentation License" nil)
(323458 1 1 nil nil "Local variables linking to [[#sec:latexmk-save-compile-display-loop][Latexmk save-compile-display-loop]]" nil))
((583 1 1 nil nil "Copying" nil)
(1888 1 1 nil nil "Quick start" nil)
(3594 1 1 nil nil "Introduction" nil)
(10962 1 1 nil nil "[[info:emacs#Early Init File][Early Init File (info)]]" nil)
(12247 1 1 nil nil "[[info:emacs#Init File][Init File (info)]] header" nil)
(19189 1 1 nil nil "[[info:emacs#Package Installation][Install the selected packages (info)]]" nil)
(22189 1 1 nil nil "[[https://git.savannah.gnu.org/cgit/emacs.git/tree/admin/notes/tree-sitter/starter-guide?h=feature/tree-sitter][Emacs Tree-sitter]]" nil)
(25211 1 1 nil nil "[[info:emacs#Faces][Text faces or styles (info)]]" nil)
(32190 1 1 nil nil "[[info:emacs#Windows][Window management (info)]]" nil)
(35303 1 1 nil nil "[[info:elisp#Advising Functions][Advising functions (info)]]" nil)
(37130 1 1 nil nil "[[info:emacs#Bookmarks][Bookmarks (info)]]" nil)
(37476 1 1 nil nil "[[info:emacs#Dired][Dired: directory editor as file manager (info)]]" nil)
(43042 1 1 nil nil "[[info:emacs#Completion Styles][Minibuffer completion styles (info)]]" nil)
(43847 1 1 nil nil "[[info:elisp#Processes][Processes (info)]]" nil)
(44640 1 1 nil nil "[[info:emacs#Help][Help (info)]]" nil)
(49225 1 1 nil nil "[[info:emacs#Key Bindings][Key bindings (info)]]" nil)
(54105 1 1 nil nil "[[info:emacs#Emacs Server][Using Emacs as a server (info)]]" nil)
(59857 1 1 nil nil "Completion" nil)
(73589 1 1 nil nil "[[info:emacs#Search][Search and replace (info)]]" nil)
(80009 1 1 nil nil "[[info:emacs#Version Control][Version Control (info)]]" nil)
(84963 1 1 nil nil "Reading" nil)
(88036 1 1 nil nil "Writing" nil)
(195844 1 1 nil nil "Programming Tools" nil)
(205637 1 1 nil nil "Programming Modes" nil)
(285771 1 1 nil nil "[[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]" nil)
(287742 1 1 nil nil "[[info:emacs#Minor Modes][Minor Modes (info)]]" nil)
(300864 1 1 nil nil "[[info:emacs#Display][Display (info)]]" nil)
(305651 1 1 nil nil "Applications" nil)
(329449 1 1 nil nil "[[info:emacs#Init File][Init File (info)]] footer" nil)
(329914 1 1 nil nil "GNU General Public License" nil)
(330078 1 1 nil nil "GNU Free Documentation License" nil)
(330175 1 1 nil nil "Local variables linking to [[#sec:latexmk-save-compile-display-loop][Latexmk save-compile-display-loop]]" nil))
#+end_src
#+caption[Test ~all-org-table-indices~]:
#+caption: Test ~all-org-table-indices~.
#+name: test-all-org-table-indices
#+caption[Test ~all-org-table-info~]:
#+caption: Test ~all-org-table-info~.
#+name: test-all-org-table-info
#+header: :wrap "src emacs-lisp -n :eval never :tangle no"
#+begin_src emacs-lisp -n :exports both :lexical t :results value pp :tangle no
(all-org-table-indices)
#+begin_src emacs-lisp -n :exports both :results value pp :tangle no
(all-org-table-info 'no-contents)
#+end_src
#+caption[Test ~all-org-table-indices~ result]:
#+caption: Test ~all-org-table-indices~ result.
#+name: test-all-org-table-indices-result
#+RESULTS: test-all-org-table-indices
#+caption[Test ~all-org-table-info~ result]:
#+caption: Test ~all-org-table-info~ result.
#+name: test-all-org-table-info-result
#+RESULTS: test-all-org-table-info
#+begin_src emacs-lisp -n :eval never :tangle no
((44544 44675 45305)
(48966 49100 49832)
(62191 62342 64344)
(67722 67907 70947)
(74495 74726 75218)
(112316 112569 112825)
(271582 271740 272380)
(311875 312006 312450))
((44903 45034 45664)
(49325 49459 50191)
(62550 62701 64703)
(68081 68266 71306)
(74854 75085 75577)
(112766 113019 113275)
(278293 278451 279091)
(318586 318717 319161))
#+end_src
#+caption[Test ~all-org-custom-id-info~]:
#+caption: Test ~all-org-custom-id-info~ but do not export the results to LaTeX.
#+name: test-all-org-custom-id-info
#+header: :wrap "src emacs-lisp -n :eval never :tangle no"
#+begin_src emacs-lisp -n :exports code :results value pp :tangle no
(all-org-custom-id-info)
#+end_src
#+RESULTS: test-all-org-custom-id-info
#+begin_src emacs-lisp -n :eval never :tangle no
((606 "sec:copying")
(1915 "sec:quick-start")
(3622 "sec:introduction")
(11032 "sec:early-init-file")
(12312 "sec:init-file-header")
(19278 "sec:install-selected-packages")
(22336 "sec:emacs-tree-sitter")
(25276 "sec:text-faces-or-styles")
(32254 "sec:window-management")
(35379 "sec:advising-function")
(37188 "sec:bookmarks")
(37560 "sec:file-manager")
(43127 "sec:minibuffer-completion-styles")
(43905 "sec:processes")
(44688 "sec:help")
(46227 "sec:shortdoc-display-group")
(48376 "sec:info")
(49289 "sec:key-bindings")
(50260 "sec:enable-disabled-commands")
(51328 "sec:interaction-log")
(52264 "sec:keycast")
(54180 "sec:using-emacs-server")
(55129 "sec:latexmk-save-compile-display-loop")
(56795 "sec:qutebrowser-userscript")
(58445 "sec:org-protocol-darwin")
(58917 "sec:applescript")
(59883 "sec:completion")
(60939 "sec:company")
(61400 "sec:vertico-configuration")
(64819 "sec:orderless-configuration")
(65627 "sec:embark-configuration")
(67315 "sec:marginalia-configuration")
(67761 "sec:consult-setup")
(72893 "sec:company-setup")
(73653 "sec:search-replace")
(73760 "sec:regexp-replace")
(75717 "sec:deadgrep")
(76760 "sec:occur")
(77558 "sec:ugrep")
(79541 "sec:ensure-xr-installation")
(80079 "sec:version-control")
(80167 "sec:ediff")
(81332 "sec:git")
(83642 "sec:list-all-git-branches")
(84284 "sec:magit")
(84986 "sec:reading")
(85092 "sec:reading-djvu-files")
(85632 "sec:reading-epub-files")
(86183 "sec:reading-pdf-files")
(88059 "sec:writing")
(88126 "sec:writing-latex-files")
(91890 "sec:math-preview")
(95037 "sec:setup-auctex-slowly")
(95265 "sec:writing-markdown-files")
(95587 "sec:writing-org-files")
(95906 "sec:activate-org")
(96400 "sec:setup-org")
(113316 "sec:org-html-style-default")
(119920 "sec:using-properties")
(123458 "sec:org-introspection")
(141955 "sec:citing-bibliography")
(146623 "sec:engrave-faces")
(152860 "sec:org-re-reveal")
(153969 "sec:org-vcard")
(154440 "sec:make-org-hyperlink-types")
(161072 "sec:make-org-yt-link-type")
(163460 "sec:convert-upper-to-lower-case-keywords")
(164507 "sec:load-time-specific-source-block-evaluation")
(166240 "sec:org-macro-utilities")
(167534 "sec:file-inclusion-and-noweb")
(174420 "sec:easy-latex-preamble-editing")
(180411 "sec:html-export")
(180935 "sec:advanced-latex-export-settings")
(183494 "sec:org-syntax")
(186634 "sec:writing-tools")
(186727 "sec:writing-abbreviations")
(189528 "sec:writing-dict")
(192703 "sec:writing-lexic")
(194197 "sec:writing-wordnet")
(195040 "sec:writing-writegood-mode")
(195877 "sec:programming-tools")
(195967 "sec:eglot")
(203869 "sec:format-all")
(205258 "sec:flymake")
(205670 "sec:programming-languages")
(205851 "sec:common-lisp-programming")
(206522 "sec:slime")
(207806 "sec:sly")
(213141 "sec:cs-325-ai-programming")
(213811 "sec:quicklisp")
(217850 "sec:sbcli")
(218822 "sec:lisp-custom-font-locking")
(219162 "sec:cl-custom-font-locking-start")
(221221 "sec:cl-function-names")
(232850 "sec:cl-value-names")
(236066 "sec:cl-custom-font-locking-final")
(237371 "sec:emacs-lisp-programming")
(238909 "sec:disassemble-dynamical-lexical-scope")
(242035 "sec:go-programming")
(242699 "sec:maxima-programming")
(244371 "sec:python-programming")
(247429 "sec:python-mode")
(261872 "sec:obap-test")
(262655 "sec:pip-python")
(274522 "sec:eglot-python")
(279158 "sec:jedi")
(279873 "sec:code-cells")
(281247 "sec:racket-programming")
(282822 "sec:scheme-programming")
(284906 "sec:obas-test")
(285851 "sec:libraries")
(285947 "sec:dash-library")
(286987 "sec:f-library")
(287376 "sec:s-library")
(287804 "sec:minor-modes")
(287937 "sec:synchronal-multiple-region-editing")
(288299 "sec:unobtrusive-whitespace-trimming")
(288857 "sec:structural-editing")
(293886 "sec:electric-operators")
(294632 "sec:smart-snippets")
(295281 "sec:tempo")
(298166 "sec:tempo-latex")
(299406 "sec:tempo-python")
(300918 "sec:display")
(301001 "sec:narrowing")
(303432 "sec:rainbow-mode")
(304456 "sec:flash-line-around-point")
(305679 "sec:applications")
(305808 "sec:hyperlinking-web-navigating")
(305921 "sec:browse-url")
(306933 "sec:emacs-web-wowser")
(308467 "sec:ensure-hyperbole-installation")
(312485 "sec:mailcap")
(313264 "sec:open-street-map")
(313530 "sec:restclient")
(314980 "sec:webjump")
(317353 "sec:reading-news-mail")
(319821 "sec:sending-mail")
(323297 "sec:emacs-web-feed-reader")
(325153 "sec:emacs-multimedia-system")
(327062 "sec:hiding-spurious-buffers")
(328417 "sec:mpd-configuration-file")
(329514 "sec:user-init-file-footer")
(329956 "sec:gnu-gpl")
(330124 "sec:gnu-fdl")
(330295 "sec:local-variables"))
#+end_src
*** [[https://github.com/bdarcus/citar][Citar: citing bibliography]] with [[https://orgmode.org/][Org Mode]]
:PROPERTIES:
:CUSTOM_ID: sec:citing-bibliography