diff options
| author | Po Lu | 2023-05-17 09:16:48 +0800 |
|---|---|---|
| committer | Po Lu | 2023-05-17 09:16:48 +0800 |
| commit | bb95cdaa0693ecea2953d14f2808a23b66ac9446 (patch) | |
| tree | 0baff93b05b3d75ce7cec9f491ea7c687942adb5 /lisp | |
| parent | bb8bf9203ed33de0bb269c8ff69067aa7b3a692a (diff) | |
| parent | 6cb963b73c3768958e13e96b2534d1e99239a3ff (diff) | |
| download | emacs-bb95cdaa0693ecea2953d14f2808a23b66ac9446.tar.gz emacs-bb95cdaa0693ecea2953d14f2808a23b66ac9446.zip | |
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/package-vc.el | 40 | ||||
| -rw-r--r-- | lisp/progmodes/eglot.el | 42 | ||||
| -rw-r--r-- | lisp/use-package/use-package-core.el | 111 | ||||
| -rw-r--r-- | lisp/use-package/use-package-ensure.el | 3 | ||||
| -rw-r--r-- | lisp/windmove.el | 2 |
5 files changed, 178 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index beca0bd00e2..35acd493b36 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el | |||
| @@ -344,6 +344,40 @@ asynchronously." | |||
| 344 | "\n") | 344 | "\n") |
| 345 | nil pkg-file nil 'silent)))) | 345 | nil pkg-file nil 'silent)))) |
| 346 | 346 | ||
| 347 | (defcustom package-vc-allow-side-effects nil | ||
| 348 | "Whether to process :make and :shell-command spec arguments. | ||
| 349 | |||
| 350 | It may be necessary to run :make and :shell-command arguments in | ||
| 351 | order to initialize a package or build its documentation, but | ||
| 352 | please be careful when changing this option, as installing and | ||
| 353 | updating a package can run potentially harmful code. | ||
| 354 | |||
| 355 | When set to a list of symbols (packages), run commands for only | ||
| 356 | packages in the list. When nil, never run commands. Otherwise | ||
| 357 | when non-nil, run commands for any package with :make or | ||
| 358 | :shell-command specified. | ||
| 359 | |||
| 360 | Package specs are loaded from trusted package archives." | ||
| 361 | :type '(choice (const :tag "Run for all packages" t) | ||
| 362 | (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) | ||
| 363 | (const :tag "Never run" nil)) | ||
| 364 | :version "30.1") | ||
| 365 | |||
| 366 | (defun package-vc--make (pkg-spec pkg-desc) | ||
| 367 | "Process :make and :shell-command in PKG-SPEC. | ||
| 368 | PKG-DESC is the package descriptor for the package that is being | ||
| 369 | prepared." | ||
| 370 | (let ((target (plist-get pkg-spec :make)) | ||
| 371 | (cmd (plist-get pkg-spec :shell-command)) | ||
| 372 | (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) | ||
| 373 | (when (or cmd target) | ||
| 374 | (with-current-buffer (get-buffer-create buf) | ||
| 375 | (erase-buffer) | ||
| 376 | (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) | ||
| 377 | (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) | ||
| 378 | (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) | ||
| 379 | (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) | ||
| 380 | |||
| 347 | (declare-function org-export-to-file "ox" (backend file)) | 381 | (declare-function org-export-to-file "ox" (backend file)) |
| 348 | 382 | ||
| 349 | (defun package-vc--build-documentation (pkg-desc file) | 383 | (defun package-vc--build-documentation (pkg-desc file) |
| @@ -486,6 +520,12 @@ documentation and marking the package as installed." | |||
| 486 | ;; Generate package file | 520 | ;; Generate package file |
| 487 | (package-vc--generate-description-file pkg-desc pkg-file) | 521 | (package-vc--generate-description-file pkg-desc pkg-file) |
| 488 | 522 | ||
| 523 | ;; Process :make and :shell-command arguments before building documentation | ||
| 524 | (when (or (eq package-vc-allow-side-effects t) | ||
| 525 | (memq (package-desc-name pkg-desc) | ||
| 526 | package-vc-allow-side-effects)) | ||
| 527 | (package-vc--make pkg-spec pkg-desc)) | ||
| 528 | |||
| 489 | ;; Detect a manual | 529 | ;; Detect a manual |
| 490 | (when (executable-find "install-info") | 530 | (when (executable-find "install-info") |
| 491 | (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) | 531 | (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) |
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 52f87c1af5d..a65795f1dfc 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -2371,23 +2371,31 @@ THINGS are either registrations or unregisterations (sic)." | |||
| 2371 | (_server (_method (eql window/showDocument)) &key | 2371 | (_server (_method (eql window/showDocument)) &key |
| 2372 | uri external takeFocus selection) | 2372 | uri external takeFocus selection) |
| 2373 | "Handle request window/showDocument." | 2373 | "Handle request window/showDocument." |
| 2374 | (if (eq external t) (browse-url uri) | 2374 | (let ((success t) |
| 2375 | ;; Use run-with-timer to avoid nested client requests like the | 2375 | (filename)) |
| 2376 | ;; synchronous imenu case caused by which-func-mode. | 2376 | (cond |
| 2377 | (run-with-timer | 2377 | ((eq external t) (browse-url uri)) |
| 2378 | 0 nil | 2378 | ((file-readable-p (setq filename (eglot--uri-to-path uri))) |
| 2379 | (lambda () | 2379 | ;; Use run-with-timer to avoid nested client requests like the |
| 2380 | (with-current-buffer (find-file-noselect (eglot--uri-to-path uri)) | 2380 | ;; "synchronous imenu" floated in bug#62116 presumably caused by |
| 2381 | (cond (takeFocus | 2381 | ;; which-func-mode. |
| 2382 | (pop-to-buffer (current-buffer)) | 2382 | (run-with-timer |
| 2383 | (select-frame-set-input-focus (selected-frame))) | 2383 | 0 nil |
| 2384 | ((display-buffer (current-buffer)))) | 2384 | (lambda () |
| 2385 | (when selection | 2385 | (with-current-buffer (find-file-noselect filename) |
| 2386 | (eglot--widening | 2386 | (cond (takeFocus |
| 2387 | (pcase-let ((`(,beg . ,end) (eglot--range-region selection))) | 2387 | (pop-to-buffer (current-buffer)) |
| 2388 | (goto-char beg) | 2388 | (select-frame-set-input-focus (selected-frame))) |
| 2389 | (pulse-momentary-highlight-region beg end 'highlight)))))))) | 2389 | ((display-buffer (current-buffer)))) |
| 2390 | '(:success t)) | 2390 | (when selection |
| 2391 | (pcase-let ((`(,beg . ,end) (eglot--range-region selection))) | ||
| 2392 | ;; FIXME: it is very naughty to use someone else's `--' | ||
| 2393 | ;; function, but `xref--goto-char' happens to have | ||
| 2394 | ;; exactly the semantics we want vis-a-vis widening. | ||
| 2395 | (xref--goto-char beg) | ||
| 2396 | (pulse-momentary-highlight-region beg end 'highlight))))))) | ||
| 2397 | (t (setq success :json-false))) | ||
| 2398 | `(:success ,success))) | ||
| 2391 | 2399 | ||
| 2392 | (defun eglot--TextDocumentIdentifier () | 2400 | (defun eglot--TextDocumentIdentifier () |
| 2393 | "Compute TextDocumentIdentifier object for current buffer." | 2401 | "Compute TextDocumentIdentifier object for current buffer." |
diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 7ab5bdc276f..0d99e270a3f 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el | |||
| @@ -76,6 +76,7 @@ | |||
| 76 | :functions | 76 | :functions |
| 77 | :preface | 77 | :preface |
| 78 | :if :when :unless | 78 | :if :when :unless |
| 79 | :vc | ||
| 79 | :no-require | 80 | :no-require |
| 80 | :catch | 81 | :catch |
| 81 | :after | 82 | :after |
| @@ -1151,7 +1152,8 @@ meaning: | |||
| 1151 | #'use-package-normalize-paths)) | 1152 | #'use-package-normalize-paths)) |
| 1152 | 1153 | ||
| 1153 | (defun use-package-handler/:load-path (name _keyword arg rest state) | 1154 | (defun use-package-handler/:load-path (name _keyword arg rest state) |
| 1154 | (let ((body (use-package-process-keywords name rest state))) | 1155 | (let ((body (use-package-process-keywords name rest |
| 1156 | (plist-put state :load-path arg)))) | ||
| 1155 | (use-package-concat | 1157 | (use-package-concat |
| 1156 | (mapcar #'(lambda (path) | 1158 | (mapcar #'(lambda (path) |
| 1157 | `(eval-and-compile (add-to-list 'load-path ,path))) | 1159 | `(eval-and-compile (add-to-list 'load-path ,path))) |
| @@ -1577,6 +1579,109 @@ no keyword implies `:all'." | |||
| 1577 | (when use-package-compute-statistics | 1579 | (when use-package-compute-statistics |
| 1578 | `((use-package-statistics-gather :config ',name t)))))) | 1580 | `((use-package-statistics-gather :config ',name t)))))) |
| 1579 | 1581 | ||
| 1582 | ;;;; :vc | ||
| 1583 | |||
| 1584 | (defun use-package-vc-install (arg &optional local-path) | ||
| 1585 | "Install a package with `package-vc.el'. | ||
| 1586 | ARG is a list of the form (NAME OPTIONS REVISION), as returned by | ||
| 1587 | `use-package-normalize--vc-arg'. If LOCAL-PATH is non-nil, call | ||
| 1588 | `package-vc-install-from-checkout'; otherwise, indicating a | ||
| 1589 | remote host, call `package-vc-install' instead." | ||
| 1590 | (pcase-let* ((`(,name ,opts ,rev) arg) | ||
| 1591 | (spec (if opts (cons name opts) name))) | ||
| 1592 | (unless (package-installed-p name) | ||
| 1593 | (if local-path | ||
| 1594 | (package-vc-install-from-checkout local-path (symbol-name name)) | ||
| 1595 | (package-vc-install spec rev))))) | ||
| 1596 | |||
| 1597 | (defun use-package-handler/:vc (name _keyword arg rest state) | ||
| 1598 | "Generate code to install package NAME, or do so directly. | ||
| 1599 | When the use-package declaration is part of a byte-compiled file, | ||
| 1600 | install the package during compilation; otherwise, add it to the | ||
| 1601 | macro expansion and wait until runtime. The remaining arguments | ||
| 1602 | are as follows: | ||
| 1603 | |||
| 1604 | _KEYWORD is ignored. | ||
| 1605 | |||
| 1606 | ARG is the normalized input to the `:vc' keyword, as returned by | ||
| 1607 | the `use-package-normalize/:vc' function. | ||
| 1608 | |||
| 1609 | REST is a plist of other (following) keywords and their | ||
| 1610 | arguments, each having already been normalised by the respective | ||
| 1611 | function. | ||
| 1612 | |||
| 1613 | STATE is a plist of any state that keywords processed before | ||
| 1614 | `:vc' (see `use-package-keywords') may have accumulated. | ||
| 1615 | |||
| 1616 | Also see the Info node `(use-package) Creating an extension'." | ||
| 1617 | (let ((body (use-package-process-keywords name rest state)) | ||
| 1618 | (local-path (car (plist-get state :load-path)))) | ||
| 1619 | ;; See `use-package-handler/:ensure' for an explanation. | ||
| 1620 | (if (bound-and-true-p byte-compile-current-file) | ||
| 1621 | (funcall #'use-package-vc-install arg local-path) ; compile time | ||
| 1622 | (push `(use-package-vc-install ',arg ,local-path) body)))) ; runtime | ||
| 1623 | |||
| 1624 | (defun use-package-normalize--vc-arg (arg) | ||
| 1625 | "Normalize possible arguments to the `:vc' keyword. | ||
| 1626 | ARG is a cons-cell of approximately the form that | ||
| 1627 | `package-vc-selected-packages' accepts, plus an additional `:rev' | ||
| 1628 | keyword. If `:rev' is not given, it defaults to `:last-release'. | ||
| 1629 | |||
| 1630 | Returns a list (NAME SPEC REV), where (NAME . SPEC) is compliant | ||
| 1631 | with `package-vc-selected-packages' and REV is a (possibly nil, | ||
| 1632 | indicating the latest commit) revision." | ||
| 1633 | (cl-flet* ((ensure-string (s) | ||
| 1634 | (if (and s (stringp s)) s (symbol-name s))) | ||
| 1635 | (ensure-symbol (s) | ||
| 1636 | (if (and s (stringp s)) (intern s) s)) | ||
| 1637 | (normalize (k v) | ||
| 1638 | (pcase k | ||
| 1639 | (:rev (cond ((or (eq v :last-release) (not v)) :last-release) | ||
| 1640 | ((eq v :newest) nil) | ||
| 1641 | (t (ensure-string v)))) | ||
| 1642 | (:vc-backend (ensure-symbol v)) | ||
| 1643 | (_ (ensure-string v))))) | ||
| 1644 | (pcase-let ((valid-kws '(:url :branch :lisp-dir :main-file :vc-backend :rev)) | ||
| 1645 | (`(,name . ,opts) arg)) | ||
| 1646 | (if (stringp opts) ; (NAME . VERSION-STRING) ? | ||
| 1647 | (list name opts) | ||
| 1648 | ;; Error handling | ||
| 1649 | (cl-loop for (k _) on opts by #'cddr | ||
| 1650 | if (not (member k valid-kws)) | ||
| 1651 | do (use-package-error | ||
| 1652 | (format "Keyword :vc received unknown argument: %s. Supported keywords are: %s" | ||
| 1653 | k valid-kws))) | ||
| 1654 | ;; Actual normalization | ||
| 1655 | (list name | ||
| 1656 | (cl-loop for (k v) on opts by #'cddr | ||
| 1657 | if (not (eq k :rev)) | ||
| 1658 | nconc (list k (normalize k v))) | ||
| 1659 | (normalize :rev (plist-get opts :rev))))))) | ||
| 1660 | |||
| 1661 | (defun use-package-normalize/:vc (name _keyword args) | ||
| 1662 | "Normalize possible arguments to the `:vc' keyword. | ||
| 1663 | NAME is the name of the `use-package' declaration, _KEYWORD is | ||
| 1664 | ignored, and ARGS it a list of arguments given to the `:vc' | ||
| 1665 | keyword, the cdr of which is ignored. | ||
| 1666 | |||
| 1667 | See `use-package-normalize--vc-arg' for most of the actual | ||
| 1668 | normalization work. Also see the Info | ||
| 1669 | node `(use-package) Creating an extension'." | ||
| 1670 | (let ((arg (car args))) | ||
| 1671 | (pcase arg | ||
| 1672 | ((or 'nil 't) (list name)) ; guess name | ||
| 1673 | ((pred symbolp) (list arg)) ; use this name | ||
| 1674 | ((pred stringp) (list name arg)) ; version string + guess name | ||
| 1675 | ((pred plistp) ; plist + guess name | ||
| 1676 | (use-package-normalize--vc-arg (cons name arg))) | ||
| 1677 | (`(,(pred symbolp) . ,(or (pred plistp) ; plist/version string + name | ||
| 1678 | (pred stringp))) | ||
| 1679 | (use-package-normalize--vc-arg arg)) | ||
| 1680 | (_ (use-package-error "Unrecognised argument to :vc.\ | ||
| 1681 | The keyword wants an argument of nil, t, a name of a package,\ | ||
| 1682 | or a cons-cell as accepted by `package-vc-selected-packages', where \ | ||
| 1683 | the accepted plist is augmented by a `:rev' keyword."))))) | ||
| 1684 | |||
| 1580 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1685 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1581 | ;; | 1686 | ;; |
| 1582 | ;;; The main macro | 1687 | ;;; The main macro |
| @@ -1666,7 +1771,9 @@ Usage: | |||
| 1666 | (compare with `custom-set-variables'). | 1771 | (compare with `custom-set-variables'). |
| 1667 | :custom-face Call `custom-set-faces' with each face definition. | 1772 | :custom-face Call `custom-set-faces' with each face definition. |
| 1668 | :ensure Loads the package using package.el if necessary. | 1773 | :ensure Loads the package using package.el if necessary. |
| 1669 | :pin Pin the package to an archive." | 1774 | :pin Pin the package to an archive. |
| 1775 | :vc Install the package directly from a version control system | ||
| 1776 | (using `package-vc.el')." | ||
| 1670 | (declare (indent defun)) | 1777 | (declare (indent defun)) |
| 1671 | (unless (memq :disabled args) | 1778 | (unless (memq :disabled args) |
| 1672 | (macroexp-progn | 1779 | (macroexp-progn |
diff --git a/lisp/use-package/use-package-ensure.el b/lisp/use-package/use-package-ensure.el index e0ea982594e..395a0bbda00 100644 --- a/lisp/use-package/use-package-ensure.el +++ b/lisp/use-package/use-package-ensure.el | |||
| @@ -182,7 +182,8 @@ manually updated package." | |||
| 182 | 182 | ||
| 183 | ;;;###autoload | 183 | ;;;###autoload |
| 184 | (defun use-package-handler/:ensure (name _keyword ensure rest state) | 184 | (defun use-package-handler/:ensure (name _keyword ensure rest state) |
| 185 | (let* ((body (use-package-process-keywords name rest state))) | 185 | (let* ((body (use-package-process-keywords name rest state)) |
| 186 | (ensure (and (not (plist-member rest :vc)) ensure))) | ||
| 186 | ;; We want to avoid installing packages when the `use-package' macro is | 187 | ;; We want to avoid installing packages when the `use-package' macro is |
| 187 | ;; being macro-expanded by elisp completion (see `lisp--local-variables'), | 188 | ;; being macro-expanded by elisp completion (see `lisp--local-variables'), |
| 188 | ;; but still install packages when byte-compiling, to avoid requiring | 189 | ;; but still install packages when byte-compiling, to avoid requiring |
diff --git a/lisp/windmove.el b/lisp/windmove.el index 06ce16c0d42..746a440bacb 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el | |||
| @@ -724,6 +724,8 @@ from the opposite side of the frame." | |||
| 724 | nil windmove-wrap-around 'nomini))) | 724 | nil windmove-wrap-around 'nomini))) |
| 725 | (cond ((or (null other-window) (window-minibuffer-p other-window)) | 725 | (cond ((or (null other-window) (window-minibuffer-p other-window)) |
| 726 | (user-error "No window %s from selected window" dir)) | 726 | (user-error "No window %s from selected window" dir)) |
| 727 | ((window-minibuffer-p (selected-window)) | ||
| 728 | (user-error "Can't swap window with the minibuffer")) | ||
| 727 | (t | 729 | (t |
| 728 | (window-swap-states nil other-window))))) | 730 | (window-swap-states nil other-window))))) |
| 729 | 731 | ||