From 450c3c12da5c71332e51cefab9f8a4d39e4bb89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=E1=BA=A5n-Anh=20Nguy=E1=BB=85n?= Date: Sun, 17 Apr 2022 10:34:21 +0700 Subject: [PATCH] XXX: Trying to upgrade to Emacs 28 --- config/ublt-dvorak.el | 135 ++++++++++++++++------------------- config/ublt-editing.el | 1 + config/ublt-helm.el | 3 + config/ublt-programming.el | 1 + init.el | 38 ++++++++++ straight/versions/default.el | 2 +- 6 files changed, 104 insertions(+), 76 deletions(-) diff --git a/config/ublt-dvorak.el b/config/ublt-dvorak.el index 1ae7016..15d917e 100644 --- a/config/ublt-dvorak.el +++ b/config/ublt-dvorak.el @@ -433,7 +433,9 @@ :config (setq-default ;; We don't use :custom, since this is dynamically set based on whether we are in a GUI. - hydra-hint-display-type (if (memq window-system '(mac ns)) 'posframe 'lv) + hydra-hint-display-type (if (and (memq window-system '(mac ns)) + (version< emacs-version "28")) + 'posframe 'lv) hydra-posframe-show-params (list :internal-border-width 1 :poshandler #'posframe-poshandler-point-bottom-left-corner)) @@ -443,32 +445,15 @@ (append `(:internal-border-color ,(face-attribute 'mode-line :background)) `(:background-color ,(face-attribute 'hl-line :background)) hydra-posframe-show-params))) - (apply f args)))) - -(defhydra ublt/hydra-avy (:exit t :hint nil) - " - ^Line^ ^Region^ ^Goto^ -^^^^^^^^────────────────────────────────────────── - _y_ yank _Y_ yank _c_ 2 chars _C_ char - _m_ move _M_ move _w_ word _W_ any word - _k_ kill _K_ kill _l_ line _L_ end of line -" - ("c" avy-goto-char-2) - ("C" avy-goto-char) - ("w" avy-goto-word-1) - ("W" avy-goto-word-0) - ("l" avy-goto-line) - ("L" avy-goto-end-of-line) - ("m" avy-move-line) - ("M" avy-move-region) - ("k" avy-kill-whole-line) - ("K" avy-kill-region) - ("y" avy-copy-line) - ("Y" avy-copy-region)) - - -(defhydra ublt/hydra-info (:hint nil :color teal) - " + (apply f args))) + + (define-advice ublt/hydra-help/body (:around (f &rest args) ublt/center) + (let ((hydra-posframe-show-params (append '(:poshandler posframe-poshandler-frame-center) + hydra-posframe-show-params))) + (apply f args))) + + (defhydra ublt/hydra-info (:hint nil :color teal) + " Search ^^ Open manual ^^ ^^^^^^─────────────────────────────────────────────────── _e_ elisp _C-e_ elisp _C-v_ evil @@ -480,28 +465,28 @@ [_h_] helm doc [_C-i_] all info " - ("e" helm-info-elisp) - ("o" helm-info-org) - ("g" helm-info-magit) - ("r" helm-info-emacs) - ("s" info-lookup-symbol) - ("l" helm-info-cl) - - ("C-e" (info "elisp")) - ("C-o" (info "org")) - ("G" (info "magit")) - ("C-r" info-emacs-manual) - ("C-l" (info "cl")) - ("C-u" (info "use-package")) - - ("C-v" (info "evil")) - ("C-t" (info "transient")) - - ("C-i" info) - ("h" helm-documentation)) - -(defhydra ublt/hydra-help (:hint nil :color teal) - " + ("e" helm-info-elisp) + ("o" helm-info-org) + ("g" helm-info-magit) + ("r" helm-info-emacs) + ("s" info-lookup-symbol) + ("l" helm-info-cl) + + ("C-e" (info "elisp")) + ("C-o" (info "org")) + ("G" (info "magit")) + ("C-r" info-emacs-manual) + ("C-l" (info "cl")) + ("C-u" (info "use-package")) + + ("C-v" (info "evil")) + ("C-t" (info "transient")) + + ("C-i" info) + ("h" helm-documentation)) + + (defhydra ublt/hydra-help (:hint nil :color teal) + " Describe ^^ Keys ^^ Go to ^^ Docs ^^ ^^^^^^^^──────────────────────────────────────────────────────────────── _f_ function _k_ brief key _C-f_ function _C-i_ info @@ -513,32 +498,32 @@ ^^ ^^ _C-u_ config [_C-h_] use built-in help [_l_] view lossage " - ("f" helpful-callable) - ("c" helpful-command) - ("v" helpful-variable) - ("s" helpful-symbol) - ("m" describe-mode) - ("o" helpful-at-point) - ("p" describe-package) - - ("k" describe-key-briefly) - ("K" helpful-key) - ("w" where-is) - ("b" describe-bindings) - - ("C-f" find-function) - ("C-v" find-variable) - ("C-k" find-function-on-key) - ("C-l" find-library) - ("C-o" find-function-at-point) - ("C-u" use-package-jump-to-package-form) - ("F" find-face-definition) - - ("C-i" ublt/hydra-info/body) - ("C-w" helm-man-woman) - - ("C-h" help-for-help) - ("l" view-lossage)) + ("f" helpful-callable) + ("c" helpful-command) + ("v" helpful-variable) + ("s" helpful-symbol) + ("m" describe-mode) + ("o" helpful-at-point) + ("p" describe-package) + + ("k" describe-key-briefly) + ("K" helpful-key) + ("w" where-is) + ("b" describe-bindings) + + ("C-f" find-function) + ("C-v" find-variable) + ("C-k" find-function-on-key) + ("C-l" find-library) + ("C-o" find-function-at-point) + ("C-u" use-package-jump-to-package-form) + ("F" find-face-definition) + + ("C-i" ublt/hydra-info/body) + ("C-w" helm-man-woman) + + ("C-h" help-for-help) + ("l" view-lossage))) (use-package which-key :disabled diff --git a/config/ublt-editing.el b/config/ublt-editing.el index aad6b79..f8e3315 100644 --- a/config/ublt-editing.el +++ b/config/ublt-editing.el @@ -61,6 +61,7 @@ See `http://ergoemacs.org/emacs/modernization_upcase-word.html' ;;; Copy/cut/duplicate whole line if no region is selected (use-package whole-line-or-region + :disabled (version<= "28" emacs-version) :config (defun ublt/duplicate-line (_) (interactive "p") ;; FIX: This looks dirty diff --git a/config/ublt-helm.el b/config/ublt-helm.el index d7a7bf2..03bfe1d 100644 --- a/config/ublt-helm.el +++ b/config/ublt-helm.el @@ -32,6 +32,9 @@ :fuzzy-match t)))))) (use-package helm-for-files + ;; XXX + :init (when (version<= "28" emacs-version) + (setq browse-url-mosaic-program "xmosaic")) :ensure nil :straight nil :custom ((helm-ff-file-name-history-use-recentf t) ;; helm-ff-auto-update-initial-value t diff --git a/config/ublt-programming.el b/config/ublt-programming.el index 6246f64..00c6d2f 100644 --- a/config/ublt-programming.el +++ b/config/ublt-programming.el @@ -40,6 +40,7 @@ (use-package cc-mode :mode ("\\.m$" . objc-mode)) + (use-package tree-sitter :demand t :hook (tree-sitter-after-on . tree-sitter-hl-mode) diff --git a/init.el b/init.el index 90d20af..f761947 100644 --- a/init.el +++ b/init.el @@ -21,6 +21,44 @@ (defvar ublt/packages '(use-package)) +;;; XXX: Breaking change in Emacs 28. This doesn't work though. +(when (version<= "28" emacs-version) + (eval-and-compile + (defmacro define-obsolete-function-alias (obsolete-name current-name + &optional when docstring) + "Set OBSOLETE-NAME's function definition to CURRENT-NAME and mark it obsolete. + +\(define-obsolete-function-alias \\='old-fun \\='new-fun \"28.1\" \ +\"old-fun's doc.\") + +is equivalent to the following two lines of code: + +\(defalias \\='old-fun \\='new-fun \"old-fun's doc.\") +\(make-obsolete \\='old-fun \\='new-fun \"28.1\") + +WHEN should be a string indicating when the function was first +made obsolete, for example a date or a release number. + +See the docstrings of `defalias' and `make-obsolete' for more details." + (declare (doc-string 4)) + `(progn + (defalias ,obsolete-name ,current-name ,docstring) + (make-obsolete ,obsolete-name ,current-name ,(or when "2022-04-17")))))) + +;; XXX: New load suffix for dynamic module is `.dylib', but `autoload' has not been updated. +;; +;; error: tsc-dyn.dylib:0:0: error: scan-error: (Containing expression ends prematurely 57524 57525) +(when (version<= "28" emacs-version) + (defun ublt/-remove-dylib-suffixes (suffixes) + (cl-remove-if (lambda (s) (string-match-p "dylib" s)) + suffixes)) + + (define-advice make-directory-autoloads (:around (f &rest args) ublt/ignore-dylib) + (advice-add 'get-load-suffixes :filter-return #'ublt/-remove-dylib-suffixes) + (unwind-protect + (apply f args) + (advice-remove 'get-load-suffixes #'ublt/-remove-dylib-suffixes)))) + (pcase (getenv "EMACS_PACKAGE_MANAGER") ("package.el" (progn diff --git a/straight/versions/default.el b/straight/versions/default.el index 631b055..6f9587d 100644 --- a/straight/versions/default.el +++ b/straight/versions/default.el @@ -139,7 +139,7 @@ ("volatile-highlights.el" . "9a20091f0ce7fc0a6b3e641a6a46d5f3ac4d8392") ("wat-mode" . "f34fc84879a99130283a124cd196041b474213e1") ("web-mode" . "b286d682205f86b7fe878a92a5afb510a07cd132") - ("whole-line-or-region" . "15f17488f98868f1628a3f9d91a812b1f89bc73a") + ("whole-line-or-region" . "500ad90695e8a5a0cefabb7500158eab0835a0ce") ("with-editor" . "7e0bf753709f1775d2bbbb6edf4482fca7fd286a") ("yaml-mode" . "40067a10ac1360f0b9533f0bbbb2eea128e2574d") ("yasnippet" . "fc33b2fbaee6c514c91e80f5b1c0210c776b03ed")