Changeset 4d3a58c in dotfiles


Ignore:
Timestamp:
Aug 12, 2022, 11:49:22 AM (2 years ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
b344981
Parents:
54ebfd5
Message:

Add transient fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emacs/.emacs.d/.emacs-config.org

    r54ebfd5 r4d3a58c  
    610610
    611611#+BEGIN_SRC emacs-lisp :tangle init.el
    612   (setq vc-command-messages t)
    613 
    614   ;;(load "git-dwim-autoloads")
    615 
    616   (global-set-key "\C-xvB" 'git-branch-next-action)
    617 
    618   ;; Use magit only when built-in VC fails
    619   (when (package-loaded? "magit")
    620     (progn
    621       (setq magit-refresh-status-buffer nil)
    622       (global-set-key (kbd "C-x g") 'magit-status)))
     612    (setq vc-command-messages t)
     613
     614    ;;(load "git-dwim-autoloads")
     615
     616    (global-set-key "\C-xvB" 'git-branch-next-action)
     617
     618    ;; Fix for transient to behave like a normal buffer
     619  (with-eval-after-load 'transient
     620    (setq
     621     transient--buffer-name "*transient*"
     622     ;; transient-detect-key-conflicts t
     623     ;; transient-highlight-mismatched-keys t
     624     ;; transient--debug t
     625     transient-enable-popup-navigation t
     626     transient-mode-line-format mode-line-format
     627     transient-display-buffer-action '(display-buffer-below-selected))
     628
     629    (let ((map transient-base-map))
     630      (define-key map (kbd "C-g") 'transient-quit-all)
     631      (define-key map (kbd "C-q") 'transient-quit-one)
     632      (define-key map (kbd "DEL") 'transient-quit-one))
     633
     634    (define-key transient-map (kbd "C-h") nil)
     635
     636    (let ((map transient-popup-navigation-map))
     637      (define-key map (kbd "<tab>") 'transient-forward-button)
     638      (define-key map (kbd "<backtab>") 'transient-backward-button ))
     639
     640    (transient-suffix-put 'transient-common-commands
     641                          "C-g" :command 'transient-quit-all)
     642    (transient-suffix-put 'transient-common-commands
     643                          "C-q" :command 'transient-quit-one)
     644
     645    (defun al/transient-fix-window ()
     646      "Return `transient--window' to a 'normal' state."
     647      (set-window-dedicated-p transient--window nil)
     648      (set-window-parameter transient--window 'no-other-window nil)
     649      (with-selected-window transient--window
     650        (setq
     651         window-size-fixed nil
     652         cursor-in-non-selected-windows t
     653         cursor-type (default-value 'cursor-type)
     654         mode-line-buffer-identification
     655         (list ""
     656               (symbol-name (oref transient--prefix command))
     657               " " (default-value 'mode-line-buffer-identification)))))
     658
     659    (define-derived-mode al/transient-mode special-mode "al/transient"
     660      (setq buffer-read-only nil)
     661      (al/transient-fix-window))
     662
     663    (defun al/transient-push-keymap (map)
     664      (with-demoted-errors "al/transient-push-keymap: %S"
     665        (internal-push-keymap (symbol-value map) 'al/transient-mode-map)))
     666
     667    (defun al/transient-pop-keymap (map)
     668      (with-demoted-errors "al/transient-pop-keymap: %S"
     669        (internal-pop-keymap (symbol-value map) 'al/transient-mode-map)))
     670
     671    (defun al/transient-fix-show (&rest _)
     672      (transient--debug 'al/transient-fix-show)
     673      (al/transient-fix-window)
     674      (select-window transient--window))
     675
     676    (defun al/transient-fix-init (&rest _)
     677      (transient--debug 'al/transient-fix-init)
     678      (with-current-buffer transient--buffer-name
     679        (al/transient-mode)))
     680
     681    (defun al/transient-fix-pre/post-command (fun &rest args)
     682      (transient--debug 'al/transient-fix-pre/post-command)
     683      ;; Do anything only for transient commands.
     684      (when (or (get this-command 'transient--prefix)
     685                (string-match-p "\\`transient"
     686                                (symbol-name this-command))
     687                (and transient--transient-map
     688                     (string= (buffer-name) transient--buffer-name)
     689                     (lookup-key transient--transient-map
     690                                 (this-single-command-raw-keys))))
     691        (apply fun args)))
     692
     693    (defun al/transient-fix-delete-window (fun &rest args)
     694      (unless (eq transient--exitp 'suspend)
     695        (apply fun args)))
     696
     697    (advice-add 'transient--minibuffer-setup :override #'ignore)
     698    (advice-add 'transient--minibuffer-exit :override #'ignore)
     699    (advice-add 'transient--push-keymap :override #'al/transient-push-keymap)
     700    (advice-add 'transient--pop-keymap :override #'al/transient-pop-keymap)
     701    (advice-add 'transient--pre-command :around #'al/transient-fix-pre/post-command)
     702    (advice-add 'transient--post-command :around #'al/transient-fix-pre/post-command)
     703    (advice-add 'transient--show :after #'al/transient-fix-show)
     704    (advice-add 'transient--init-transient :after #'al/transient-fix-init)
     705    (advice-add 'transient--delete-window :around #'al/transient-fix-delete-window))
     706
     707    ;; Use magit only when built-in VC fails
     708    (when (package-loaded? "magit")
     709      (progn
     710        (setq magit-refresh-status-buffer nil)
     711        (global-set-key (kbd "C-x g") 'magit-status)))
    623712#+END_SRC
    624713   
Note: See TracChangeset for help on using the changeset viewer.