Skip to content

Commit

Permalink
[elisp] Improve upgrade procedure
Browse files Browse the repository at this point in the history
- Ensure user PWD is unaffected
- Compile elisp files on build
- Load compiled elisp files
  • Loading branch information
thoni56 committed Jun 19, 2024
1 parent d2466c8 commit 6aee2ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif

all:
$(MAKE) -C src prod
$(MAKE) -C editors/emacs compile

test: all
$(MAKE) -C tests all
Expand Down
37 changes: 20 additions & 17 deletions editors/emacs/c-xref.el
Original file line number Diff line number Diff line change
Expand Up @@ -6532,7 +6532,7 @@ its functions.

(defvar c-xref-elisp-directory
(file-name-directory (or load-file-name (buffer-file-name)))
"The directory where the e-listp files of c-xref are installed")
"The directory where the e-lisp files of c-xref are installed")

(defvar c-xref-install-directory
(directory-file-name
Expand Down Expand Up @@ -6573,29 +6573,32 @@ the reset was performed, nil if the reset was cancelled."
t)))) ; Indicate no changes

(defun c-xref-load-directory (dir)
"Load all Emacs Lisp files in DIR."
(dolist (file (directory-files dir t "\\.elc?$"))
(load file nil t)))
"Load all compiled Emacs Lisp files in DIR."
(dolist (file (directory-files dir t "\\.elc$"))
(message (format "file = %s" file))
(load file nil t))
)

(defun c-xref-upgrade ()
"Upgrade the installed c-xref, if available."
(interactive)
(if (yes-or-no-p (format "Really upgrade c-xref installation in %s ? "
c-xref-install-directory))
(progn
(cd c-xref-install-directory)
(if (c-xref-ok-to-upgrade)
(progn
(shell-command "git pull")
(shell-command "git checkout stable")
(message "Pulled latest stable")
(c-xref-kill-xref-process nil)
(shell-command "make")
(message "Built 'c-xref' in %s" c-xref-install-directory)
(c-xref-load-directory c-xref-elisp-directory)
)
)
)
(let ((default-directory c-xref-install-directory))
(if (c-xref-ok-to-upgrade)
(progn
(shell-command "git pull")
(shell-command "git checkout stable")
(message "Pulled latest stable")
(c-xref-kill-xref-process nil)
(shell-command "make")
(message "Built 'c-xref' in %s" c-xref-install-directory)
(c-xref-load-directory c-xref-elisp-directory)
(message "Loaded compiled e-lisp files")
)
)
))
)
)

Expand Down

0 comments on commit 6aee2ff

Please sign in to comment.