git-package instead of string evaluation

This commit is contained in:
Aleksandr Lebedev 2025-07-23 12:52:06 +02:00
parent b1bc2752fb
commit db9f6ecadc

View file

@ -10,6 +10,7 @@
- [[#keybindings][Keybindings]] - [[#keybindings][Keybindings]]
- [[#focus-new-windows][Focus new windows]] - [[#focus-new-windows][Focus new windows]]
- [[#support-functions][Support functions]] - [[#support-functions][Support functions]]
- [[#git-package][Git package]]
- [[#emacs-function-launcher][Emacs function launcher]] - [[#emacs-function-launcher][Emacs function launcher]]
- [[#copy-to-clipboard][Copy to clipboard]] - [[#copy-to-clipboard][Copy to clipboard]]
- [[#detect-wsl][Detect WSL]] - [[#detect-wsl][Detect WSL]]
@ -174,6 +175,16 @@ Found this [[https://emacs.stackexchange.com/questions/21770/automatically-switc
(lambda (&rest _) (select-window (get-lru-window)))) (lambda (&rest _) (select-window (get-lru-window))))
#+end_src #+end_src
* Support functions * Support functions
** Git package
#+begin_src emacs-lisp
(defun git-package (url)
(let* ((pkg-name (file-name-base (directory-file-name url)))
(pkg-sym (intern pkg-name)))
(eval
`(use-package ,pkg-sym
:vc (:url ,url :rev :newest)
:ensure nil))))
#+end_src
** Emacs function launcher ** Emacs function launcher
Launches emacs function as a window Launches emacs function as a window
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -1366,18 +1377,12 @@ Vterm is a terminal emulator within Emacs. The 'shell-file-name' setting sets t
#+end_src #+end_src
* CMake Projects * CMake Projects
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun eval-elisp-string (code-string) (git-package "https://github.com/darcamo/cmake-integration.git")
"Evaluate the Elisp code contained in CODE-STRING and return the result." (use-package cmake-integration
(eval (read code-string))) :commands (cmake-integration-transient)
(defun use-cmake-integration () :custom
(interactive) (cmake-integration-generator "Ninja")
(eval-elisp-string "(use-package cmake-integration \ (cmake-integration-use-separated-compilation-buffer-for-each-target t))
:vc (:url \"https://github.com/darcamo/cmake-integration.git\" \
:rev :newest) \
:commands (cmake-integration-transient) \
:custom \
(cmake-integration-generator \"Ninja\") \
(cmake-integration-use-separated-compilation-buffer-for-each-target t))"))
(defun is-cmake-project? () (defun is-cmake-project? ()
"Determine if the current directory is a CMake project." "Determine if the current directory is a CMake project."
@ -1391,7 +1396,6 @@ Vterm is a terminal emulator within Emacs. The 'shell-file-name' setting sets t
(defun cmake-integration-keybindings-mode-turn-on-in-cmake-projects () (defun cmake-integration-keybindings-mode-turn-on-in-cmake-projects ()
"Turn on `cmake-integration-keybindings-mode' in CMake projects." "Turn on `cmake-integration-keybindings-mode' in CMake projects."
(when (is-cmake-project?) (when (is-cmake-project?)
(use-cmake-integration)
(cmake-integration-keybindings-mode 1))) (cmake-integration-keybindings-mode 1)))
@ -1494,13 +1498,12 @@ Emacs has built-in programming language modes for Lisp, Scheme, DSSSL, Ada, ASM,
[[https://github.com/emacs-twist/nix3.el][nix3.el]] [[https://github.com/emacs-twist/nix3.el][nix3.el]]
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package promise :ensure t) ;; nix3 dependency (use-package promise :ensure t) ;; nix3 dependency
(eval-elisp-string "(use-package nix3 \ (git-package "https://github.com/emacs-twist/nix3.el")
:vc (:url \"https://github.com/emacs-twist/nix3.el\" \ (use-package nix3
:rev :newest)\ :init
:init \ (let* ((mainpkg-dir (file-name-directory (locate-library "nix3")))
(let* ((mainpkg-dir (file-name-directory (locate-library \"nix3\"))) \ (subpkg-dir (expand-file-name "extra" mainpkg-dir)))
(subpkg-dir (expand-file-name \"extra\" mainpkg-dir))) \ (add-to-list 'load-path subpkg-dir)))
(add-to-list 'load-path subpkg-dir)))")
(use-package magit-nix3 (use-package magit-nix3
:after magit-status :after magit-status