Remove unused introspection code and test results

This commit is contained in:
Gerard Vermeulen 2023-08-19 09:56:43 +02:00
parent 9fbc1be8d5
commit a818c5c2d4
1 changed files with 0 additions and 351 deletions

View File

@ -2983,357 +2983,6 @@ Return a list of items where the filename is the `car' of each item and the
("toml"))
#+end_src
#+caption[Jump to an Org =headline=]:
#+caption: Jump to an Org =headline=. A ~mapcan~ filter works on the
#+caption: result of ~cl-loop~ and ~collect~ to return a list containing
#+caption: the position and text of all matching headlines.
#+name: lst:jump-org-headline
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'org-element
(defun jump-org-headline (target)
"Jump to the first org-mode headline matching TARGET."
(interactive "sTarget: ")
(if (derived-mode-p 'org-mode)
(when-let
((ok (mapcan
(lambda (x) (when (car x) (cdr x)))
(cl-loop
for (here . text)
in (org-element-map (org-element-parse-buffer) 'headline
(lambda (hl)
(cons (org-element-property :begin hl)
(org-element-property :raw-value hl))))
collect (list (string= target text) here text))))
(n (/ (length ok) 2)))
(goto-char (car ok))
(when (> n 1)
(user-error "Found %s headlines `%s'" n target)))
(message "Found no `%s' headline (`%s')" target major-mode))))
#+end_src
#+caption[Sync the "#+COLUMNS:" keyword with a ":COLUMNS:" property]:
#+caption: Sync the "#+COLUMNS:" keyword with a ":COLUMNS:" property.
#+name: lst:sync-columns-keyword-with-property
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'org
(defun get-org-columns-property (target level)
"Get headline TARGET \":COLUMNS:\" property at LEVEL."
(let (case-fold-search done (here (point)))
(goto-char (point-max))
(while (re-search-backward org-complex-heading-regexp nil t)
(let ((beginning (match-beginning 1))
(headline (match-string-no-properties 4)))
(when (and (string= headline target)
(= (org-current-level) level))
(goto-char beginning)))
(setq done (plist-get (org-element--get-node-properties) ':COLUMNS)))
(goto-char here)
done))
(defun get-org-columns-keyword-match ()
"Get \"#+COLUMNS:\" keyword match data for replacement."
(org-with-wide-buffer
(goto-char (point-min))
(let ((case-fold-search t) done
(regexp "\\(^[ \t]*#\\+COLUMNS: \\)\\(.+\\)$"))
(while (and (not done) (re-search-forward regexp nil t 1))
(when (eq (org-element-type (org-element-at-point)) 'keyword)
(setq done (list (regexp-quote (match-string 2))
(match-beginning 2) (match-end 2)))))
done)))
(defun sync-org-columns-keyword-property (target level)
"Sync \"#+COLUMNS:\" keyword with \":COLUMNS:\" property.
The property is from the drawer of headline matching TARGET and LEVEL."
(when-let ((property (get-org-columns-property target level))
(match (get-org-columns-keyword-match)))
(org-with-wide-buffer
(goto-char (point-min))
(let ((case-fold-search t) done
(regexp "\\(^[ \t]*#\\+COLUMNS: \\)\\(.+\\)$"))
(while (and (not done) (re-search-forward regexp nil t 1))
(when (eq (org-element-type (org-element-at-point)) 'keyword)
(replace-string
(nth 0 match) property nil (nth 1 match) (nth 2 match))
(setq done t)))))
(unless property (message "Can't find \":COLUMNS:\" property"))
(unless match (message "Can't find \"#+COLUMNS:\" keyword")))))
#+end_src
#+name: lst:tables-and-headings
#+begin_src emacs-lisp -n :exports both :results silent
(with-eval-after-load 'org
(defun all-org-heading-components (max-level)
"Find all MAX-LEVEL `org-heading-components' prefixed by `pos-bol'."
(let ((done nil))
(org-with-point-at 1
(let ((regexp (org-headline-re max-level)))
;; The `noerror' argument must be `t' instead of `noerror':
(while (re-search-forward regexp nil t)
(push (cons (pos-bol) (org-heading-components)) done))))
(sort done (lambda (x y) (< (car x) (car y))))))
(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)
(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)))))
(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-custom-id-info ()
(let ((done nil))
(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~]:
#+caption: Test ~all-org-heading-components~ with ~depth=1~.
#+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 :results value pp :tangle no
(all-org-heading-components depth)
#+end_src
#+caption[Test ~all-org-heading-components~ result]:
#+caption: Test ~all-org-heading-components~ result with ~depth=1~.
#+name: test-all-org-heading-components-result
#+RESULTS: test-all-org-heading-components
#+begin_src emacs-lisp -n :eval never :tangle no
((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)
(195957 1 1 nil nil "Programming Tools" nil)
(205750 1 1 nil nil "Programming Modes" nil)
(279403 1 1 nil nil "[[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]" nil)
(281374 1 1 nil nil "[[info:emacs#Minor Modes][Minor Modes (info)]]" nil)
(294496 1 1 nil nil "[[info:emacs#Display][Display (info)]]" nil)
(299283 1 1 nil nil "Applications" nil)
(323081 1 1 nil nil "[[info:emacs#Init File][Init File (info)]] footer" nil)
(323546 1 1 nil nil "GNU General Public License" nil)
(323710 1 1 nil nil "GNU Free Documentation License" nil)
(323807 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-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 :results value pp :tangle no
(all-org-table-info 'no-contents)
#+end_src
#+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
((44903 45034 45664)
(49325 49459 50191)
(62550 62701 64703)
(68081 68266 71306)
(74854 75085 75577)
(112766 113019 113275)
(271925 272083 272723)
(312218 312349 312793))
#+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")
(181048 "sec:advanced-latex-export-settings")
(183607 "sec:org-syntax")
(186747 "sec:writing-tools")
(186840 "sec:writing-abbreviations")
(189641 "sec:writing-dict")
(192816 "sec:writing-lexic")
(194310 "sec:writing-wordnet")
(195153 "sec:writing-writegood-mode")
(195990 "sec:programming-tools")
(196080 "sec:eglot")
(203982 "sec:format-all")
(205371 "sec:flymake")
(205783 "sec:programming-languages")
(205964 "sec:common-lisp-programming")
(206635 "sec:slime")
(207919 "sec:sly")
(213254 "sec:cs-325-ai-programming")
(213924 "sec:quicklisp")
(217963 "sec:sbcli")
(218935 "sec:lisp-custom-font-locking")
(219275 "sec:cl-custom-font-locking-start")
(221334 "sec:cl-function-names")
(232963 "sec:cl-value-names")
(236179 "sec:cl-custom-font-locking-final")
(237484 "sec:emacs-lisp-programming")
(239022 "sec:disassemble-dynamical-lexical-scope")
(242148 "sec:go-programming")
(242812 "sec:maxima-programming")
(244484 "sec:python-programming")
(247542 "sec:python-mode")
(261985 "sec:obap-test")
(262768 "sec:pip-python")
(268154 "sec:eglot-python")
(272790 "sec:jedi")
(273505 "sec:code-cells")
(274879 "sec:racket-programming")
(276454 "sec:scheme-programming")
(278538 "sec:obas-test")
(279483 "sec:libraries")
(279579 "sec:dash-library")
(280619 "sec:f-library")
(281008 "sec:s-library")
(281436 "sec:minor-modes")
(281569 "sec:synchronal-multiple-region-editing")
(281931 "sec:unobtrusive-whitespace-trimming")
(282489 "sec:structural-editing")
(287518 "sec:electric-operators")
(288264 "sec:smart-snippets")
(288913 "sec:tempo")
(291798 "sec:tempo-latex")
(293038 "sec:tempo-python")
(294550 "sec:display")
(294633 "sec:narrowing")
(297064 "sec:rainbow-mode")
(298088 "sec:flash-line-around-point")
(299311 "sec:applications")
(299440 "sec:hyperlinking-web-navigating")
(299553 "sec:browse-url")
(300565 "sec:emacs-web-wowser")
(302099 "sec:ensure-hyperbole-installation")
(306117 "sec:mailcap")
(306896 "sec:open-street-map")
(307162 "sec:restclient")
(308612 "sec:webjump")
(310985 "sec:reading-news-mail")
(313453 "sec:sending-mail")
(316929 "sec:emacs-web-feed-reader")
(318785 "sec:emacs-multimedia-system")
(320694 "sec:hiding-spurious-buffers")
(322049 "sec:mpd-configuration-file")
(323146 "sec:user-init-file-footer")
(323588 "sec:gnu-gpl")
(323756 "sec:gnu-fdl")
(323927 "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