Browse Source

Use exwm/xelb from GitHub, add -f option to bin/e

master
Peter J. Jones 1 year ago
parent
commit
a83259eed1
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
6 changed files with 70 additions and 206 deletions
  1. 1
    1
      README.md
  2. 16
    4
      bin/e
  3. 53
    6
      default.nix
  4. 0
    19
      modes/eshell-conf.el
  5. 0
    6
      modes/oauth2-conf.el
  6. 0
    170
      modes/rcirc-conf.el

+ 1
- 1
README.md View File

@@ -37,6 +37,6 @@ existing configuartion in any way?
37 37
 
38 38
   3. Start Emacs:
39 39
 
40
-         ./result/bin/emacs -q --load ./result/dot.emacs.el --eval "(run-hooks 'after-init-hook)"
40
+         ./result/bin/e -f
41 41
 
42 42
 [emacs]: http://www.gnu.org/software/emacs/

+ 16
- 4
bin/e View File

@@ -7,6 +7,7 @@ set -e
7 7
 ################################################################################
8 8
 option_server_name="server"
9 9
 option_server_path="$HOME/.cache/emacs/server/"
10
+option_fresh=0
10 11
 option_emacs_opts=()
11 12
 
12 13
 ################################################################################
@@ -15,6 +16,7 @@ cat <<EOF
15 16
 Usage: e [options] [file] -- [emacsclient options]
16 17
 
17 18
   -c      Open a new frame
19
+  -f      Force a fresh Emacs to be started
18 20
   -h      This message
19 21
   -s NAME Connect to server NAME
20 22
   -t      Open a new TTY
@@ -22,11 +24,14 @@ EOF
22 24
 }
23 25
 
24 26
 ################################################################################
25
-while getopts "chs:t" o; do
27
+while getopts "cfhs:t" o; do
26 28
   case "${o}" in
27 29
     c) option_emacs_opts+=("--create-frame" "--no-wait")
28 30
        ;;
29 31
 
32
+    f) option_fresh=1
33
+       ;;
34
+
30 35
     h) usage
31 36
        exit
32 37
        ;;
@@ -44,11 +49,18 @@ done
44 49
 
45 50
 shift $((OPTIND-1))
46 51
 
52
+################################################################################
53
+if [ "$option_fresh" -eq 1 ]; then
54
+  export EMACSLOADPATH=""
55
+  exec @emacspath@/emacs -q --load @out@/dot.emacs.el \
56
+         --eval "(run-hooks 'after-init-hook)" "$@"
57
+fi
58
+
47 59
 ################################################################################
48 60
 if [ ! -e "${option_server_path}${option_server_name}" ]; then
49
-  emacs --daemon="$option_server_name"
61
+  @emacspath@/emacs --daemon="$option_server_name"
50 62
 fi
51 63
 
52 64
 ################################################################################
53
-emacsclient --server-file="${option_server_path}${option_server_name}" \
54
-            "${option_emacs_opts[@]}" "$@"
65
+@emacspath@/emacsclient --server-file="${option_server_path}${option_server_name}" \
66
+   "${option_emacs_opts[@]}" "$@"

+ 53
- 6
default.nix View File

@@ -1,6 +1,8 @@
1 1
 { pkgs ? (import <nixpkgs> {}).pkgs }:
2 2
 
3 3
 let
4
+  ##############################################################################
5
+  # Custom build of Emacs with the settings I like.
4 6
   emacs = pkgs.emacs.override {
5 7
     withX       = true;
6 8
     withGTK2    = false;
@@ -8,8 +10,47 @@ let
8 10
     imagemagick = pkgs.imagemagick;
9 11
   };
10 12
 
13
+  ##############################################################################
14
+  # Function for selecting which packages go into Emacs.
11 15
   emacsWithPackages = (pkgs.emacsPackagesNgGen emacs).emacsWithPackages;
12 16
 
17
+  ##############################################################################
18
+  # Access to the generic Emacs builder so we can override some packages.
19
+  pkgBuilder = import <nixpkgs/pkgs/build-support/emacs/trivial.nix> {
20
+    inherit (pkgs) lib stdenv texinfo;
21
+    inherit emacs;
22
+  };
23
+
24
+  ##############################################################################
25
+  # Latest version of xelb:
26
+  xelbLatest = elpaPkgs: pkgBuilder {
27
+    pname = "xelb";
28
+    version = "git";
29
+    src = pkgs.fetchFromGitHub {
30
+      owner = "ch11ng";
31
+      repo  = "xelb";
32
+      rev   = "8ac915ba1a836d3752ee8de4eb125da7af4dd299";
33
+      sha256 = "1rd2702kygb8g0kpnnr48in6qywad52b1davigkv5p9wmrvm75jd";
34
+    };
35
+    packageRequires = [ elpaPkgs.cl-generic emacs ];
36
+  };
37
+
38
+  ##############################################################################
39
+  # Latest version of exwm:
40
+  exwmLatest = elpaPkgs: pkgBuilder {
41
+    pname = "exwm";
42
+    version = "git";
43
+    src = pkgs.fetchFromGitHub {
44
+      owner  = "ch11ng";
45
+      repo   = "exwm";
46
+      rev    = "df8de921132520cccf4236906bcd37aec83fa0ce";
47
+      sha256 = "01j3s7l4hls5hbsci3af65p0pp8sy3cc5wy9snmz7jadzqg14ll5";
48
+    };
49
+    packageRequires = [ (xelbLatest elpaPkgs) ];
50
+  };
51
+
52
+  ##############################################################################
53
+  # The derivation for building Emacs with packages and my config.
13 54
   pjones = pkgs.stdenv.mkDerivation rec {
14 55
     name = "emacsrc";
15 56
     src = ./.;
@@ -21,19 +62,21 @@ let
21 62
                     pkgs.imagemagick # For image-mode and eimp-mode
22 63
                   ];
23 64
 
65
+    propagatedUserEnvPkgs = [ emacs' ];
66
+
24 67
     installPhase = ''
25 68
       mkdir -p "$out/bin" "$out/emacs.d"
26 69
 
27 70
       export loadpathel="$out/emacs.d/lisp/loadpath.el"
28
-      substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"
71
+      export emacspath="${emacs'}/bin"
29 72
 
73
+      substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"
30 74
       cp -r ${src}/lisp ${src}/modes "$out/emacs.d/"
31
-      cp -r ${src}/bin/* "$out/bin/"
32 75
       chmod u+w "$out"/emacs.d/*
33
-      chmod 0555 "$out"/bin/*
34 76
 
35
-      for f in ${emacs'}/bin/*; do
36
-        ln -nfs "$f" "$out/bin/"
77
+      for f in ${src}/bin/*; do
78
+        substituteAll "$f" "$out/bin/$(basename "$f")"
79
+        chmod 0555 "$out/bin/$(basename "$f")"
37 80
       done
38 81
 
39 82
       for f in $(find "$out/emacs.d" -type f -name "*.el"); do
@@ -43,6 +86,8 @@ let
43 86
     '';
44 87
   };
45 88
 
89
+  ##############################################################################
90
+  # List of Emacs packages I use.
46 91
   emacs' =
47 92
     emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [
48 93
       alect-themes
@@ -105,7 +150,6 @@ let
105 150
       scad-mode
106 151
 
107 152
     ]) ++ (with epkgs.elpaPackages; [
108
-      exwm
109 153
       rainbow-mode
110 154
 
111 155
     ]) ++ (with epkgs.orgPackages; [
@@ -115,8 +159,11 @@ let
115 159
       pdf-tools
116 160
 
117 161
     ]) ++ (with pkgs; [
162
+      (exwmLatest epkgs.elpaPackages)
118 163
       mu
119 164
 
120 165
     ]));
121 166
 
167
+################################################################################
168
+# It all boils down to the derivation.
122 169
 in pjones

+ 0
- 19
modes/eshell-conf.el View File

@@ -1,19 +0,0 @@
1
-;;; eshell-conf.el -- Settings for Eshell
2
-(eval-when-compile
3
-  (require 'eshell))
4
-
5
-(require 'esh-mode)
6
-
7
-(custom-set-variables
8
- '(eshell-prompt-regexp "^❯ ")
9
- '(eshell-review-quick-commands nil)
10
- '(eshell-where-to-jump (quote after))
11
- '(eshell-smart-space-goes-to-end t))
12
-
13
-(defun pjones:eshell-mode-hook ()
14
-  "Customize Eshell."
15
-  (require 'em-smart)
16
-  (eshell-smart-initialize))
17
-
18
-(defvar eshell-mode-hook "Why isn't this defined?" nil)
19
-(add-to-list 'eshell-mode-hook #'pjones:eshell-mode-hook)

+ 0
- 6
modes/oauth2-conf.el View File

@@ -1,6 +0,0 @@
1
-;;; oauth2-conf.el -- OAuth Configuration.
2
-(eval-when-compile
3
-  (require 'oauth2))
4
-
5
-(custom-set-variables
6
- `(oauth2-token-file ,(expand-file-name "~/keys/emacs/oauth2.plstore")))

+ 0
- 170
modes/rcirc-conf.el View File

@@ -1,170 +0,0 @@
1
-;;; rcirc-conf.el -- Settings for rcirc.
2
-(eval-when-compile
3
-  (require 'cl)
4
-  (require 'rcirc))
5
-
6
-;; Silence compiler warnings
7
-(declare-function rcirc-omit-mode "rcirc")
8
-(declare-function rcirc-track-minor-mode "rcirc")
9
-(declare-function rcirc-nick "rcirc")
10
-(declare-function rcirc-server-name "rcirc")
11
-
12
-(defvar pjones-irc-password nil
13
-  "My password for connecting to ZNC.")
14
-
15
-;; Load passwords from a private file
16
-(load "~/keys/emacs/secrets.el")
17
-
18
-(setq rcirc-default-nick "pmade"
19
-      rcirc-default-user-name "pmade"
20
-      rcirc-default-full-name "Peter Jones"
21
-      rcirc-multiline-major-mode 'markdown-mode
22
-      rcirc-fill-flag t)
23
-
24
-;; List of servers to connect to.
25
-::
26
-;; N.B. The first server is the one used when the pjones:irc function
27
-;; is called with a prefix argument.
28
-(setq rcirc-server-alist
29
-      `(("bitlbee.pmade.com"
30
-        :nick "pjones" :user-name "pjones/bitlbee"
31
-        :port 6697 :encryption tls
32
-        :password ,pjones-irc-password)
33
-        ("freenode.pmade.com"
34
-         :nick "pjones" :user-name "pjones/freenode"
35
-         :port 6697 :encryption tls
36
-         :password ,pjones-irc-password)))
37
-
38
-;; Other interesting Freenode channels:
39
-;;
40
-;; #hakyll -- Hakyll static site generator
41
-;; #gnus   -- Gnus news/mail reader
42
-;; #debian -- Obvious
43
-;; #mpd    -- Music player daemon
44
-
45
-(setq rcirc-omit-responses '("JOIN" "PART" "QUIT" "NICK" "AWAY")
46
-      rcirc-buffer-maximum-lines 500)
47
-
48
-(defvar pjones:rcirc-buffers
49
-  '("#derailed@irc.freenode.net"
50
-    "#xmonad@irc.freenode.net"
51
-    "#conkeror@irc.freenode.net"
52
-    "#emacs@irc.freenode.net"
53
-    "&bitlbee@localhost"
54
-    "#haskell@irc.freenode.net")
55
-  "A list of rcirc buffer names in the order in which they should
56
-be placed into the current set of windows.")
57
-
58
-(defvar pjones:rcirc-low-traffic-channels
59
-  '("#haskell-mobile@irc.freenode.net"
60
-    "#hakyll@irc.freenode.net"
61
-    "#derailed@irc.freenode.net"
62
-    "#boulderhs@irc.freenode.net")
63
-  "A list of IRC channels that have low enough traffic that it's
64
-okay to send me notifications of activity.")
65
-
66
-(defun pjones:rcirc-windows ()
67
-  "Split the current frame into several windows and place the
68
-buffers listed in `pjones:rcirc-buffers' in each of the resulting
69
-windows, in the correct order."
70
-  (interactive)
71
-  (let ((wins (window-list nil nil (frame-first-window))))
72
-    (when (= 1 (length wins))
73
-      (split-window-right)
74
-      (dolist (w (window-list))
75
-        (select-window w)
76
-        (dotimes (i 2) (split-window-below)))
77
-      (balance-windows))
78
-      (setq wins (window-list nil nil (frame-first-window)))
79
-      (cl-mapcar 'set-window-buffer wins pjones:rcirc-buffers)))
80
-
81
-(defun pjones:rcirc-cmd-all (input)
82
-  "See the docs for rcirc-cmd-all."
83
-  (let ((buffers (mapcar 'process-buffer (rcirc-process-list))))
84
-    (dolist (buf buffers)
85
-      (with-current-buffer buf
86
-        (goto-char (point-max))
87
-        (insert "/" input)
88
-        (rcirc-send-input)))))
89
-
90
-(defun-rcirc-command all (input)
91
-  "Run the arguments as a command for all connections.
92
-Example use: /all away food or /all quit zzzz."
93
-  (interactive "s")
94
-  (pjones:rcirc-cmd-all input))
95
-
96
-(defun pjones:rcirc-quit ()
97
-  "Quit all rcirc connections."
98
-  (interactive)
99
-  (let ((buffers (mapcar 'process-buffer (rcirc-process-list))))
100
-    (dolist (buf buffers)
101
-      (with-current-buffer buf
102
-        (rcirc-cmd-quit "bye.")))))
103
-
104
-(defun pjones:rcirc-macrumors ()
105
-  "Connect to the macrumors IRC server."
106
-  (interactive)
107
-  (rcirc-connect "irc.macrumorslive.com" nil nil nil nil "#macrumors"))
108
-
109
-(defun pjones:rcirc-update-fill-column (&optional window)
110
-  "Update `rcirc-fill-column' based on the width of WINDOW, or
111
-the current window if WINDOW is nil."
112
-  (with-current-buffer (window-buffer window)
113
-    (if (eq major-mode 'rcirc-mode)
114
-        (setq rcirc-fill-column (- (window-width window) 2)))))
115
-
116
-(defun pjones:rcirc-update-fill-column-all-windows (&optional frame)
117
-  "Call `pjones:rcirc-update-fill-column' for all windows."
118
-  (walk-windows 'pjones:rcirc-update-fill-column 'no-minibuf frame))
119
-
120
-(defun pjones:rcirc-hook ()
121
-  (require 'rcirc-color)
122
-  (when (and (string-match "#" (buffer-name))
123
-             (not (string-match "developers\\|twitter" (buffer-name)))
124
-             (not (member (buffer-name) pjones:rcirc-low-traffic-channels)))
125
-    (setq rcirc-ignore-buffer-activity-flag t)
126
-    (rcirc-omit-mode))
127
-  (define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-browse-url)
128
-  (set (make-local-variable 'scroll-conservatively) 8192)
129
-  (set (make-local-variable 'next-line-add-newlines) nil)
130
-  (setq mode-line-format '("  %b " global-mode-string)
131
-        wrap-prefix "  "
132
-        rcirc-prompt "❯ ")
133
-  (pjones:rcirc-update-fill-column)
134
-  (flyspell-mode)
135
-  (visual-line-mode)
136
-  (rcirc-update-prompt)
137
-  (rcirc-track-minor-mode))
138
-
139
-(defun pjones:rcirc-activity-string ()
140
-  (when (string= "[]" rcirc-activity-string)
141
-    (setq rcirc-activity-string "")))
142
-
143
-(defun pjones:rcirc-notify (sender text)
144
-  "Display an activity notification."
145
-  (pjones:urgency-hint (selected-frame) t))
146
-
147
-(defun pjones:rcirc-print-hook (proc sender response target text)
148
-  "Hook called when a new IRC message is received.  If the
149
-message is either a PRIVMSG or mentions your nick, use the
150
-notification function.  This only happens if the target buffer is
151
-not currently displayed in a window."
152
-  (let ((buf (rcirc-get-buffer proc target)))
153
-    (when (and
154
-           (or (and (string= response "PRIVMSG")
155
-                    (not (string= (rcirc-nick proc) sender))
156
-                    (not (rcirc-channel-p target)))
157
-               (and (string-match (rcirc-nick proc) text)
158
-                    (not (string= (rcirc-nick proc) sender))
159
-                    (not (string= (rcirc-server-name proc) sender)))))
160
-;           (not (get-buffer-window buf)))
161
-      (pjones:rcirc-notify sender text))))
162
-
163
-(add-hook 'rcirc-mode-hook 'pjones:rcirc-hook)
164
-(add-hook 'rcirc-update-activity-string-hook 'pjones:rcirc-activity-string)
165
-(add-hook 'rcirc-print-hooks 'pjones:rcirc-print-hook)
166
-(add-hook 'window-size-change-functions 'pjones:rcirc-update-fill-column-all-windows)
167
-
168
-;; Local Variables:
169
-;; byte-compile-warnings: (not cl-functions noruntime)
170
-;; End:

Loading…
Cancel
Save