Prune unused elisp code and update introspection results

This commit is contained in:
Gerard Vermeulen 2023-07-13 14:46:12 +02:00
parent 1d40e05905
commit e2a459f286

View File

@ -3122,16 +3122,16 @@ When NO-CONTENTS is non-nil, find the same information without contents."
(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))
(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~]:
@ -3153,8 +3153,8 @@ When NO-CONTENTS is non-nil, find the same information without contents."
(68081 68266 71306)
(74854 75085 75577)
(112766 113019 113275)
(278293 278451 279091)
(318586 318717 319161))
(271925 272083 272723)
(312218 312349 312793))
#+end_src
#+caption[Test ~all-org-custom-id-info~]:
@ -3239,80 +3239,80 @@ When NO-CONTENTS is non-nil, find the same information without contents."
(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"))
(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
@ -6043,12 +6043,9 @@ pip list --outdated
#+name: lst:shell-pip-list-outdated-results
#+RESULTS: lst:shell-pip-list-outdated
#+begin_src text -n
Package Version Latest Type
------------- ------- ------ -----
aiofiles 22.1.0 23.1.0 wheel
jupyter-ydoc 0.2.4 1.0.2 wheel
y-py 0.5.9 0.6.0 wheel
ypy-websocket 0.8.2 0.9.0 wheel
Package Version Latest Type
--------- ------- ------ -----
pyparsing 3.0.9 3.1.0 wheel
#+end_src
#+caption[Show how to use =pip index versions=]:
@ -6160,165 +6157,6 @@ buffer to check whether upgrading has made the dependencies incompatible."
(message "`pip-upgrade-maybe' found no packages to install"))))
#+end_src
#+caption[Emacs interface to the =PyPI= simple =JSON= =API=]:
#+caption: Emacs interface to the =PyPI= simple =JSON= =API=.
#+name: lst:pip-pypi-simple-json-api
#+begin_src emacs-lisp -n :lexical t :results silent
;; https://emacs.stackexchange.com/questions/61754/
;; "How can I enable lexical binding for elisp code in Org mode?"
(defvar pip--simple-details-cache (make-hash-table :test 'equal)
"Cache for PyPI project details")
(defun pip-simple-get-json ()
(save-excursion
(goto-char (point-min))
(and (re-search-forward "^HTTP/.+ 200 OK$" nil (line-end-position))
(search-forward "\n\n" nil t)
(json-parse-buffer :array-type 'list))))
(defun pip-simple-details-retrieve (name callback &optional cbargs)
(pip--simple-details-prune-cache)
(if-let ((cached (gethash name pip--simple-details-cache)))
(apply callback (cdr cached) cbargs)
(let ((url (format "https://pypi.org/simple/%s" name))
(url-request-method "GET")
(url-mime-accept-string "application/vnd.pypi.simple.latest+json"))
(url-retrieve
url
(lambda (status)
(let ((details (and (not (plist-get status :error))
(pip-simple-get-json))))
(when details
(setf (gethash name pip--simple-details-cache)
(cons (time-convert nil 'integer) details)))
(prog1
(apply callback (or details 'error) cbargs)
(kill-buffer))))
nil t))))
(defun pip--simple-details-prune-cache ()
(let ((expired nil)
(time (- (time-convert nil 'integer)
;; Ten minutes
(* 10 60))))
(maphash (lambda (key val)
(when (< (car val) time)
(push key expired)))
pip--simple-details-cache)
(dolist (key expired)
(remhash key pip--simple-details-cache))))
#+end_src
#+caption[Using the Emacs interface to the =PyPI= simple =JSON= =API=]:
#+caption: Using the Emacs interface to the =PyPI= simple =JSON= =API=.
#+name: lst:using-pip-pypi-simple-json-api
#+begin_src emacs-lisp -n :lexical t :results silent
;; https://emacs.stackexchange.com/questions/61754/
;; "How can I enable lexical binding for elisp code in Org mode?"
(defun pip-simple-project-versions (name)
"Return the versions of Python package NAME."
(interactive "sPython package name: ")
(pip-simple-details-retrieve
name
(lambda (details)
(when-let ((versions (reverse (cdr (gethash "versions" details)))))
(message "`%s' versions: %S" name versions)))))
(defun pip-simple-project-list ()
"Get the Python package project list (PEP-691 and PEP-700)."
(interactive)
(let ((url-request-method "GET")
(url-mime-accept-string "application/vnd.pypi.simple.latest+json"))
(url-retrieve "https://pypi.org/simple"
(lambda (status) (switch-to-buffer (current-buffer))))))
#+end_src
#+caption[Emacs interface to get the dependency tree of installed packages]:
#+caption: Emacs interface to get the dependency tree of installed packages.
#+name: lst:pip-dependency-tree
#+begin_src emacs-lisp -n :results silent
(defvar pip-package-dependency-tree nil
"Python package dependency tree.")
(defun pip--dependency-tree-sentinel (process event)
(when (and (eq (process-status process) 'exit)
(zerop (process-exit-status process))
(buffer-live-p (process-buffer process)))
(with-current-buffer (process-buffer process)
(goto-char (point-min))
(setq pip-package-dependency-tree
(json-parse-buffer :array-type 'list :object-type 'alist))
(kill-buffer)
(message "Calling `%S' succeeded" #'pip-dependency-tree))))
(defun pip-dependency-tree ()
"Save the Python package dependency tree in `pip-package-dependency-tree'."
(interactive)
(let ((command '("pipdeptree" "--json-tree")))
(make-process
:name "pip-dependency-tree"
:buffer (generate-new-buffer-name "*pip-dependency-tree-output*")
:command command
:sentinel #'pip--dependency-tree-sentinel)
(message "Running `%s' asynchonously" (string-join command " "))))
#+end_src
#+caption[Emacs functions to flatten the Python package dependency tree]:
#+caption: Emacs functions to flatten the Python package dependency tree.
#+name: lst:pip-python-interface
#+begin_src emacs-lisp -n :results silent
(defun pip--flatten-dependencies (parents found)
(dolist (parent parents)
(when-let ((children (alist-get 'dependencies parent)))
(setq found (pip--flatten-dependencies children found)))
(if-let* ((pair `(key . ,(alist-get 'key parent)))
(old (cl-loop for alist in found thereis (member pair alist)))
(rvs (split-string (alist-get 'required_version parent) "[,]+")))
(dolist (rv rvs)
(cl-pushnew rv (alist-get 'required_version old) :test #'equal))
(let* ((new (assq-delete-all 'dependencies (copy-alist parent)))
(rvs (split-string (alist-get 'required_version new) "[,]+")))
(setcdr (assq 'required_version new) rvs)
(push new found))))
found)
(defun pip-flatten-package-dependency-tree ()
(let (found)
(dolist (package pip-package-dependency-tree)
(when-let ((children (alist-get 'dependencies package)))
(setq found (pip--flatten-dependencies children found))))
found))
(defconst pip-canonical-version-regexp-alist
'(("^[.]dev$" . -4)
("^a$" . -3)
("^b$" . -2)
("^rc$" . -1)
("^[.]post$" . 1))
"Specify association between canonical \"PEP-440\" version and its priority.")
(defun pip-canonical-version-to-list (version)
(let ((version-regexp-alist pip-canonical-version-regexp-alist))
(version-to-list version)))
;; https://peps.python.org/pep-0440/
(defun pip-pep-440 (clauses)
(let (compatibles exclusions greater-equals less-thans unknowns)
(dolist (clause clauses)
(cond ((string-prefix-p "~=" clause)
(push (substring clause 2) compatibles))
((string-prefix-p "!=" clause)
(push (substring clause 2) exclusions))
((string-prefix-p ">=" clause)
(push (substring clause 2) greater-equals))
((string-prefix-p "<" clause)
(push (substring clause 1) less-thans))
(t (push clause unknowns))))
(list compatibles exclusions greater-equals less-thans unknowns)))
#+end_src
*** [[https://github.com/joaotavora/eglot][Eglot]] for [[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/python.el][python-mode]]
:PROPERTIES:
:CUSTOM_ID: sec:eglot-python