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]]
- [[#focus-new-windows][Focus new windows]]
- [[#support-functions][Support functions]]
- [[#git-package][Git package]]
- [[#emacs-function-launcher][Emacs function launcher]]
- [[#copy-to-clipboard][Copy to clipboard]]
- [[#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))))
#+end_src
* 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
Launches emacs function as a window
#+begin_src emacs-lisp
@ -1366,18 +1377,12 @@ Vterm is a terminal emulator within Emacs. The 'shell-file-name' setting sets t
#+end_src
* CMake Projects
#+begin_src emacs-lisp
(defun eval-elisp-string (code-string)
"Evaluate the Elisp code contained in CODE-STRING and return the result."
(eval (read code-string)))
(defun use-cmake-integration ()
(interactive)
(eval-elisp-string "(use-package cmake-integration \
: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))"))
(git-package "https://github.com/darcamo/cmake-integration.git")
(use-package cmake-integration
:commands (cmake-integration-transient)
:custom
(cmake-integration-generator "Ninja")
(cmake-integration-use-separated-compilation-buffer-for-each-target t))
(defun is-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 ()
"Turn on `cmake-integration-keybindings-mode' in CMake projects."
(when (is-cmake-project?)
(use-cmake-integration)
(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]]
#+begin_src emacs-lisp
(use-package promise :ensure t) ;; nix3 dependency
(eval-elisp-string "(use-package nix3 \
:vc (:url \"https://github.com/emacs-twist/nix3.el\" \
:rev :newest)\
:init \
(let* ((mainpkg-dir (file-name-directory (locate-library \"nix3\"))) \
(subpkg-dir (expand-file-name \"extra\" mainpkg-dir))) \
(add-to-list 'load-path subpkg-dir)))")
(git-package "https://github.com/emacs-twist/nix3.el")
(use-package nix3
:init
(let* ((mainpkg-dir (file-name-directory (locate-library "nix3")))
(subpkg-dir (expand-file-name "extra" mainpkg-dir)))
(add-to-list 'load-path subpkg-dir)))
(use-package magit-nix3
:after magit-status