2015-10-28 11:55:49 +01:00
|
|
|
|
;;; exwm-config.el --- Predefined configurations -*- lexical-binding: t -*-
|
|
|
|
|
|
2024-01-08 01:00:00 +01:00
|
|
|
|
;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
;; Author: Chris Feng <chris.w.feng@gmail.com>
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2024-06-07 12:04:16 +02:00
|
|
|
|
;; This module contains an example configuration of EXWM. Do not require this
|
|
|
|
|
;; file directly in your user configuration. Instead take it as inspiration and
|
|
|
|
|
;; copy the relevant settings to your user configuration.
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'exwm)
|
2024-06-07 12:04:16 +02:00
|
|
|
|
|
|
|
|
|
(defun exwm-config--warn ()
|
|
|
|
|
"Print obsoletion warning."
|
|
|
|
|
(fset #'exwm-config--warn #'ignore)
|
2024-06-15 09:13:52 +02:00
|
|
|
|
(warn "The `exwm-config' file has been deprecated. We do not recommend requiring
|
|
|
|
|
`exwm-config' directly in your Emacs configuration. Instead copy the relevant
|
|
|
|
|
settings to your configuration and modify them as needed. The code from here
|
|
|
|
|
will be moved out of the source repository to the manual after the next
|
|
|
|
|
release. See https://github.com/emacs-exwm/exwm/issues/57."))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
2020-05-10 02:00:00 +02:00
|
|
|
|
(defun exwm-config-example ()
|
2015-10-28 11:55:49 +01:00
|
|
|
|
"Default configuration of EXWM."
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(exwm-config--warn)
|
2016-07-21 06:48:12 +02:00
|
|
|
|
;; Set the initial workspace number.
|
2019-02-02 01:55:24 +01:00
|
|
|
|
(unless (get 'exwm-workspace-number 'saved-value)
|
|
|
|
|
(setq exwm-workspace-number 4))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
;; Make class name the buffer name
|
|
|
|
|
(add-hook 'exwm-update-class-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(exwm-workspace-rename-buffer exwm-class-name)))
|
2019-02-06 01:00:00 +01:00
|
|
|
|
;; Global keybindings.
|
|
|
|
|
(unless (get 'exwm-input-global-keys 'saved-value)
|
|
|
|
|
(setq exwm-input-global-keys
|
|
|
|
|
`(
|
|
|
|
|
;; 's-r': Reset (to line-mode).
|
|
|
|
|
([?\s-r] . exwm-reset)
|
|
|
|
|
;; 's-w': Switch workspace.
|
|
|
|
|
([?\s-w] . exwm-workspace-switch)
|
|
|
|
|
;; 's-&': Launch application.
|
|
|
|
|
([?\s-&] . (lambda (command)
|
2019-09-14 02:00:00 +02:00
|
|
|
|
(interactive (list (read-shell-command "$ ")))
|
|
|
|
|
(start-process-shell-command command nil command)))
|
2019-02-06 01:00:00 +01:00
|
|
|
|
;; 's-N': Switch to certain workspace.
|
|
|
|
|
,@(mapcar (lambda (i)
|
|
|
|
|
`(,(kbd (format "s-%d" i)) .
|
|
|
|
|
(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(exwm-workspace-switch-create ,i))))
|
|
|
|
|
(number-sequence 0 9)))))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
;; Line-editing shortcuts
|
2019-02-02 01:55:24 +01:00
|
|
|
|
(unless (get 'exwm-input-simulation-keys 'saved-value)
|
|
|
|
|
(setq exwm-input-simulation-keys
|
|
|
|
|
'(([?\C-b] . [left])
|
|
|
|
|
([?\C-f] . [right])
|
|
|
|
|
([?\C-p] . [up])
|
|
|
|
|
([?\C-n] . [down])
|
|
|
|
|
([?\C-a] . [home])
|
|
|
|
|
([?\C-e] . [end])
|
|
|
|
|
([?\M-v] . [prior])
|
|
|
|
|
([?\C-v] . [next])
|
|
|
|
|
([?\C-d] . [delete])
|
|
|
|
|
([?\C-k] . [S-end delete]))))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
;; Enable EXWM
|
|
|
|
|
(exwm-enable)
|
|
|
|
|
;; Configure Ido
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(with-no-warnings (exwm-config-ido))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
;; Other configurations
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(with-no-warnings (exwm-config-misc)))
|
|
|
|
|
(make-obsolete 'exwm-config-example "Copy the relevant settings to your configuration." "0.30")
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-config--fix/ido-buffer-window-other-frame ()
|
|
|
|
|
"Fix `ido-buffer-window-other-frame'."
|
2016-02-21 09:30:08 +01:00
|
|
|
|
(defalias 'exwm-config-ido-buffer-window-other-frame
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(symbol-function 'ido-buffer-window-other-frame))
|
2016-02-21 09:30:08 +01:00
|
|
|
|
(defun ido-buffer-window-other-frame (buffer)
|
|
|
|
|
"This is a version redefined by EXWM.
|
|
|
|
|
|
|
|
|
|
You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
|
|
|
|
|
(with-current-buffer (window-buffer (selected-window))
|
2018-07-14 18:00:00 +02:00
|
|
|
|
(if (and (derived-mode-p 'exwm-mode)
|
2016-02-21 09:30:08 +01:00
|
|
|
|
exwm--floating-frame)
|
|
|
|
|
;; Switch from a floating frame.
|
|
|
|
|
(with-current-buffer buffer
|
2018-07-14 18:00:00 +02:00
|
|
|
|
(if (and (derived-mode-p 'exwm-mode)
|
2016-02-21 09:30:08 +01:00
|
|
|
|
exwm--floating-frame
|
|
|
|
|
(eq exwm--frame exwm-workspace--current))
|
|
|
|
|
;; Switch to another floating frame.
|
|
|
|
|
(frame-root-window exwm--floating-frame)
|
|
|
|
|
;; Do not switch if the buffer is not on the current workspace.
|
|
|
|
|
(or (get-buffer-window buffer exwm-workspace--current)
|
|
|
|
|
(selected-window))))
|
|
|
|
|
(with-current-buffer buffer
|
2018-07-14 18:00:00 +02:00
|
|
|
|
(when (derived-mode-p 'exwm-mode)
|
2016-02-21 09:30:08 +01:00
|
|
|
|
(if (eq exwm--frame exwm-workspace--current)
|
|
|
|
|
(when exwm--floating-frame
|
|
|
|
|
;; Switch to a floating frame on the current workspace.
|
|
|
|
|
(frame-selected-window exwm--floating-frame))
|
|
|
|
|
;; Do not switch to exwm-mode buffers on other workspace (which
|
|
|
|
|
;; won't work unless `exwm-layout-show-all-buffers' is set)
|
|
|
|
|
(unless exwm-layout-show-all-buffers
|
|
|
|
|
(selected-window)))))))))
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-config-ido ()
|
|
|
|
|
"Configure Ido to work with EXWM."
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(exwm-config--warn)
|
|
|
|
|
(declare-function ido-mode "ido")
|
2015-10-28 11:55:49 +01:00
|
|
|
|
(ido-mode 1)
|
|
|
|
|
(add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame))
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(make-obsolete 'exwm-config-ido "Copy the relevant settings to your configuration." "0.30")
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
(defun exwm-config-misc ()
|
|
|
|
|
"Other configurations."
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(exwm-config--warn)
|
2015-10-28 11:55:49 +01:00
|
|
|
|
;; Make more room
|
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
|
(tool-bar-mode -1)
|
|
|
|
|
(scroll-bar-mode -1)
|
2015-11-02 04:19:59 +01:00
|
|
|
|
(fringe-mode 1))
|
2024-06-07 12:04:16 +02:00
|
|
|
|
(make-obsolete 'exwm-config-misc "Copy the relevant settings to your configuration." "0.30")
|
2015-10-28 11:55:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'exwm-config)
|
|
|
|
|
|
2017-02-05 10:50:52 +01:00
|
|
|
|
;;; exwm-config.el ends here
|