Compare commits

...

4 commits

Author SHA1 Message Date
2e2783b291 fix typo 2024-06-28 15:29:18 +08:00
a293015346 updated my/list-package-and-versions 2024-06-28 12:20:20 +08:00
95f25de948 test cscope 2024-06-28 12:19:34 +08:00
117be3a752 updated my/list-packages-and-versions 2024-06-27 23:31:08 +08:00
2 changed files with 24 additions and 4 deletions

View file

@ -54,6 +54,10 @@
:windows-command "npm install -g bash-language-server"
:message nil
:enabled t)
;; (cscope
;; :linux-command "sudo pacman -S --noconfirm cscope"
;; :message nil
;; :enabled t)
(ctags
:darwin-command "brew install universal-ctags"
:linux-command "sudo pacman -S --noconfirm ctags"

View file

@ -357,13 +357,29 @@ DIRECTORY is the directory where the org files are located."
(org-mode)))
(defun my/list-packages-and-versions ()
(defun my/list-packages-and-versions (&optional filepath)
"List installed packages and their versions.
If FILEPATH is provided, export the output to the specified file.
If the file is an org file, insert a title with the Emacs version at the beginning.
Otherwise, output to the message buffer."
(interactive)
(package-initialize)
(let ((pkgs (mapcar 'car package-alist)))
(dolist (pkg pkgs)
(message "%s - %s"
pkg (package-desc-version (cadr (assq pkg package-alist)))))))
(with-temp-buffer
;; Insert title if the output is an org file
(when (and filepath (string-suffix-p ".org" filepath))
(insert (format "#+TITLE: My Packages and Versions on Emacs %s\n" emacs-version))
(insert (format "#+DATE: %s\n" (format-time-string "%Y-%m-%d %H:%M:%S"))))
;; Insert package and version information
(dolist (pkg pkgs)
(insert (format "%s - %s\n"
pkg (package-desc-version (cadr (assq pkg package-alist))))))
;; Output to message buffer or write to file
(if (or (called-interactively-p 'interactive) (not filepath))
(message "%s" (buffer-string))
(when filepath
(set-buffer-file-coding-system 'utf-8-unix)
(write-file filepath))))))
(defun my/copy-org-id-at-point ()