From 4fc81beb4aee43207dec0d665935d5579ad06818 Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 8 Jun 2022 22:54:49 +0100 Subject: ace-window is evil: it badly messes the keyboard --- attic/misc.el | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ attic/orgs/misc.el | 95 ---------------------------------------- init.el | 53 ++++++----------------- 3 files changed, 137 insertions(+), 135 deletions(-) create mode 100644 attic/misc.el delete mode 100644 attic/orgs/misc.el diff --git a/attic/misc.el b/attic/misc.el new file mode 100644 index 0000000..a872ce7 --- /dev/null +++ b/attic/misc.el @@ -0,0 +1,124 @@ +;;;; ace window +(use-package ace-window + :ensure t + :demand t + :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l) + aw-char-position 'top-left + aw-ignore-current nil + aw-dispatch-when-more-than 2 + aw-leading-char-style 'path + aw-display-mode-overlay t + aw-scope 'frame) + :config + + (defun jao-ace-consult-buffer-other-window (w) + (interactive) + (aw-switch-to-window w) + (consult-buffer)) + + (setf (alist-get ?b aw-dispatch-alist) + '(jao-ace-consult-buffer-other-window "Consult buffer")) + + (setf (alist-get ?B aw-dispatch-alist) + (alist-get ?u aw-dispatch-alist)) + + + :bind (("M-o" . ace-window) + ("M-O" . ace-swap-window) + ("C-x 4 t" . ace-swap-window))) + +;;;; sway +(defun jao-swaymsg (msg) + (shell-command (format "swaymsg '%s' >/dev/null" msg))) + +(defmacro jao-def-swaymsg (name msg) + `(defun ,(intern (format "jao-sway-%s" name)) () + (interactive) + (jao-swaymsg ,msg))) +(jao-def-swaymsg firefox "[app_id=firefox] focus") + +(defvar jao-sway-enabled + (and (eq window-system 'pgtk) (not jao-xmonad-enabled))) + +(defun jao-sway-set-wallpaper (f) + (jao-swaymsg (format "output * bg %s fill" f)) + (make-symbolic-link f "~/.wallpaper.sway" t)) + +(defun jao-sway-run-or-focus (cmd &optional ws) + (if (jao-shell-running-p "firefox") + (jao-swaymsg (format "[app_id=%s] focus" cmd)) + (jao-swaymsg (format "workspace %s" (or ws 2))) + (start-process-shell-command cmd nil cmd))) + +(defun jao-sway-run-or-focus-tidal () + (interactive) + (if (jao-shell-running-p "tidal-hifi") + (jao-swaymsg "[app_id=tidal-hifi] scratchpad show") + (start-process-shell-command "tidal-hifi" nil "tidal-hifi &") + (jao-sway-run-or-focus-tidal))) + +(defun jao-sway-run-or-focus-firefox () + (interactive) + (jao-sway-run-or-focus "firefox")) + +(defun jao-sway-enable () + (setq jao-browse-doc-use-emacs-p t) + (setq jao-wallpaper-random-wake nil) + (jao-trisect) + (jao-set-transparency 85) + (jao-themes-setup) + ;; (display-time-mode 1) + (global-set-key (kbd "s-f") #'jao-sway-run-or-focus-firefox) + (defalias 'jao-streaming-list #'jao-sway-run-or-focus-tidal) + (message "Welcome to sway")) + +(when jao-sway-enabled + (defalias 'x-change-window-property #'ignore) + (add-hook 'after-init-hook #'jao-sway-enable)) + +;;;; time display +(setq display-time-world-list + '(("Europe/Paris" "Barcelona") + ("America/Los_Angeles" "Los Angeles") + ("America/New_York" "New York") + ("Europe/London" "London") + ("Asia/Calcutta" "Bangalore") + ("Asia/Tokyo" "Tokyo"))) + +(defun jao-time--pdt-hour () + (jao-time-at-zone "%H" "America/Los_Angeles")) + +(defun jao-time--chicago-hour () + (jao-time-at-zone "%H" "America/Chicago")) + +(defun jao-time-at-zone (format zone) + (set-time-zone-rule zone) + (prog1 (format-time-string format) + (set-time-zone-rule nil))) + +(defun jao-time-echo-la-time () + (interactive) + (message (jao-time-at-zone "LA %H:%M" "America/Los_Angeles"))) + +(defun jao-time-echo-times () + (interactive) + (let ((msg (format "%s (%s)" + (format-time-string "%a, %e %B - %H:%M") + (jao-time-at-zone "%H:%M" "America/Los_Angeles")))) + (jao-notify msg "" (jao-data-file "clock-world-icon.png")))) + +(defun jao-time-to-epoch (&optional s) + "Transform a time string to an epoch integer in milliseconds." + (interactive) + (let ((s (or s (read-string "Time string: " (thing-at-point 'string))))) + (message "%s = %s" + s + (round (* 1000 (time-to-seconds (parse-time-string s))))))) + +(defun jao-epoch-to-time (&optional v) + "Transform an epoch, given in milliseconds, to a time string." + (interactive) + (let ((v (or v (read-number "Milliseconds: " (thing-at-point 'number))))) + (message "%s = %s" v + (format-time-string "%Y-%m-%d %H:%M:%S" + (seconds-to-time (/ v 1000.0)))))) diff --git a/attic/orgs/misc.el b/attic/orgs/misc.el deleted file mode 100644 index b56c5df..0000000 --- a/attic/orgs/misc.el +++ /dev/null @@ -1,95 +0,0 @@ -;;;; sway -(defun jao-swaymsg (msg) - (shell-command (format "swaymsg '%s' >/dev/null" msg))) - -(defmacro jao-def-swaymsg (name msg) - `(defun ,(intern (format "jao-sway-%s" name)) () - (interactive) - (jao-swaymsg ,msg))) -(jao-def-swaymsg firefox "[app_id=firefox] focus") - -(defvar jao-sway-enabled - (and (eq window-system 'pgtk) (not jao-xmonad-enabled))) - -(defun jao-sway-set-wallpaper (f) - (jao-swaymsg (format "output * bg %s fill" f)) - (make-symbolic-link f "~/.wallpaper.sway" t)) - -(defun jao-sway-run-or-focus (cmd &optional ws) - (if (jao-shell-running-p "firefox") - (jao-swaymsg (format "[app_id=%s] focus" cmd)) - (jao-swaymsg (format "workspace %s" (or ws 2))) - (start-process-shell-command cmd nil cmd))) - -(defun jao-sway-run-or-focus-tidal () - (interactive) - (if (jao-shell-running-p "tidal-hifi") - (jao-swaymsg "[app_id=tidal-hifi] scratchpad show") - (start-process-shell-command "tidal-hifi" nil "tidal-hifi &") - (jao-sway-run-or-focus-tidal))) - -(defun jao-sway-run-or-focus-firefox () - (interactive) - (jao-sway-run-or-focus "firefox")) - -(defun jao-sway-enable () - (setq jao-browse-doc-use-emacs-p t) - (setq jao-wallpaper-random-wake nil) - (jao-trisect) - (jao-set-transparency 85) - (jao-themes-setup) - ;; (display-time-mode 1) - (global-set-key (kbd "s-f") #'jao-sway-run-or-focus-firefox) - (defalias 'jao-streaming-list #'jao-sway-run-or-focus-tidal) - (message "Welcome to sway")) - -(when jao-sway-enabled - (defalias 'x-change-window-property #'ignore) - (add-hook 'after-init-hook #'jao-sway-enable)) - -;;;; time display -(setq display-time-world-list - '(("Europe/Paris" "Barcelona") - ("America/Los_Angeles" "Los Angeles") - ("America/New_York" "New York") - ("Europe/London" "London") - ("Asia/Calcutta" "Bangalore") - ("Asia/Tokyo" "Tokyo"))) - -(defun jao-time--pdt-hour () - (jao-time-at-zone "%H" "America/Los_Angeles")) - -(defun jao-time--chicago-hour () - (jao-time-at-zone "%H" "America/Chicago")) - -(defun jao-time-at-zone (format zone) - (set-time-zone-rule zone) - (prog1 (format-time-string format) - (set-time-zone-rule nil))) - -(defun jao-time-echo-la-time () - (interactive) - (message (jao-time-at-zone "LA %H:%M" "America/Los_Angeles"))) - -(defun jao-time-echo-times () - (interactive) - (let ((msg (format "%s (%s)" - (format-time-string "%a, %e %B - %H:%M") - (jao-time-at-zone "%H:%M" "America/Los_Angeles")))) - (jao-notify msg "" (jao-data-file "clock-world-icon.png")))) - -(defun jao-time-to-epoch (&optional s) - "Transform a time string to an epoch integer in milliseconds." - (interactive) - (let ((s (or s (read-string "Time string: " (thing-at-point 'string))))) - (message "%s = %s" - s - (round (* 1000 (time-to-seconds (parse-time-string s))))))) - -(defun jao-epoch-to-time (&optional v) - "Transform an epoch, given in milliseconds, to a time string." - (interactive) - (let ((v (or v (read-number "Milliseconds: " (thing-at-point 'number))))) - (message "%s = %s" v - (format-time-string "%Y-%m-%d %H:%M:%S" - (seconds-to-time (/ v 1000.0)))))) diff --git a/init.el b/init.el index f64c8b2..f1d5bbb 100644 --- a/init.el +++ b/init.el @@ -124,6 +124,10 @@ ;;;; server (setenv "EDITOR" "emacsclient") + +;;;; timers +(put 'list-timers 'disabled nil) + ;; (unless (daemonp) (server-start)) ;;; System Utilities @@ -182,18 +186,18 @@ (not (string-empty-p (shell-command-to-string "setxkbmap -query|grep variant")))) -(set-keyboard-coding-system 'latin-1) -(set-language-environment "UTF-8") +;; (set-keyboard-coding-system 'latin-1) +;; (set-language-environment "UTF-8") ;; must be set after current-language-environment (customize-set-variable 'default-input-method "catalan-prefix") ;; http://mbork.pl/2022-03-07_Transient_input_method (customize-set-variable 'default-transient-input-method "TeX") -(defun jao--set-kb-system (frame) - (select-frame frame) - (set-keyboard-coding-system 'latin-1) - t) -(add-to-list 'after-make-frame-functions 'jao--set-kb-system) +;; (defun jao--set-kb-system (frame) +;; (select-frame frame) +;; (set-keyboard-coding-system 'utf-8) +;; t) +;; (add-to-list 'after-make-frame-functions 'jao--set-kb-system) (setq echo-keystrokes 1 suggest-key-bindings nil) @@ -214,7 +218,8 @@ (transient-define-prefix ,name () ,(format "Transient ops for %s" mode) [,(format "Operations for %s" mode) :if-derived ',mode ,@suffix]) - (define-key ,mmap (kbd "s-SPC") #',name)))) + (define-key ,mmap (kbd "s-SPC") #',name) + (define-key ,mmap (kbd "C-c SPC") #',name)))) (defmacro jao-transient-major-mode+1 (mode suffix) (declare (indent defun)) @@ -779,9 +784,6 @@ (jao-exec-in-term "curl wttr.in" "*wttr*")))) (global-set-key (kbd "") #'jao-weather) -;;;; timers -(put 'list-timers 'disabled nil) - ;;; Files, dired and scratch buffer ;;;; so-long (setq large-file-warning-threshold (* 200 1024 1024)) @@ -1021,35 +1023,6 @@ (global-set-key (kbd "s-a") #'jao-first-window) (global-set-key (kbd "M-a") #'jao-first-window) -;;;; ace window -(use-package ace-window - :ensure t - :demand t - :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l) - aw-char-position 'top-left - aw-ignore-current nil - aw-dispatch-when-more-than 2 - aw-leading-char-style 'path - aw-display-mode-overlay t - aw-scope 'frame) - :config - - (defun jao-ace-consult-buffer-other-window (w) - (interactive) - (aw-switch-to-window w) - (consult-buffer)) - - (setf (alist-get ?b aw-dispatch-alist) - '(jao-ace-consult-buffer-other-window "Consult buffer")) - - (setf (alist-get ?B aw-dispatch-alist) - (alist-get ?u aw-dispatch-alist)) - - - :bind (("M-o" . ace-window) - ("M-O" . ace-swap-window) - ("C-x 4 t" . ace-swap-window))) - ;;;; window navigation (custom) (defun jao-nth-window (n) (if (zerop n) -- cgit v1.2.3