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?

3. Start Emacs:

./result/bin/emacs -q --load ./result/dot.emacs.el --eval "(run-hooks 'after-init-hook)"
./result/bin/e -f

[emacs]: http://www.gnu.org/software/emacs/

+ 16
- 4
bin/e View File

@@ -7,6 +7,7 @@ set -e
################################################################################
option_server_name="server"
option_server_path="$HOME/.cache/emacs/server/"
option_fresh=0
option_emacs_opts=()

################################################################################
@@ -15,6 +16,7 @@ cat <<EOF
Usage: e [options] [file] -- [emacsclient options]

-c Open a new frame
-f Force a fresh Emacs to be started
-h This message
-s NAME Connect to server NAME
-t Open a new TTY
@@ -22,11 +24,14 @@ EOF
}

################################################################################
while getopts "chs:t" o; do
while getopts "cfhs:t" o; do
case "${o}" in
c) option_emacs_opts+=("--create-frame" "--no-wait")
;;

f) option_fresh=1
;;

h) usage
exit
;;
@@ -44,11 +49,18 @@ done

shift $((OPTIND-1))

################################################################################
if [ "$option_fresh" -eq 1 ]; then
export EMACSLOADPATH=""
exec @emacspath@/emacs -q --load @out@/dot.emacs.el \
--eval "(run-hooks 'after-init-hook)" "$@"
fi

################################################################################
if [ ! -e "${option_server_path}${option_server_name}" ]; then
emacs --daemon="$option_server_name"
@emacspath@/emacs --daemon="$option_server_name"
fi

################################################################################
emacsclient --server-file="${option_server_path}${option_server_name}" \
"${option_emacs_opts[@]}" "$@"
@emacspath@/emacsclient --server-file="${option_server_path}${option_server_name}" \
"${option_emacs_opts[@]}" "$@"

+ 53
- 6
default.nix View File

@@ -1,6 +1,8 @@
{ pkgs ? (import <nixpkgs> {}).pkgs }:

let
##############################################################################
# Custom build of Emacs with the settings I like.
emacs = pkgs.emacs.override {
withX = true;
withGTK2 = false;
@@ -8,8 +10,47 @@ let
imagemagick = pkgs.imagemagick;
};

##############################################################################
# Function for selecting which packages go into Emacs.
emacsWithPackages = (pkgs.emacsPackagesNgGen emacs).emacsWithPackages;

##############################################################################
# Access to the generic Emacs builder so we can override some packages.
pkgBuilder = import <nixpkgs/pkgs/build-support/emacs/trivial.nix> {
inherit (pkgs) lib stdenv texinfo;
inherit emacs;
};

##############################################################################
# Latest version of xelb:
xelbLatest = elpaPkgs: pkgBuilder {
pname = "xelb";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "ch11ng";
repo = "xelb";
rev = "8ac915ba1a836d3752ee8de4eb125da7af4dd299";
sha256 = "1rd2702kygb8g0kpnnr48in6qywad52b1davigkv5p9wmrvm75jd";
};
packageRequires = [ elpaPkgs.cl-generic emacs ];
};

##############################################################################
# Latest version of exwm:
exwmLatest = elpaPkgs: pkgBuilder {
pname = "exwm";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "ch11ng";
repo = "exwm";
rev = "df8de921132520cccf4236906bcd37aec83fa0ce";
sha256 = "01j3s7l4hls5hbsci3af65p0pp8sy3cc5wy9snmz7jadzqg14ll5";
};
packageRequires = [ (xelbLatest elpaPkgs) ];
};

##############################################################################
# The derivation for building Emacs with packages and my config.
pjones = pkgs.stdenv.mkDerivation rec {
name = "emacsrc";
src = ./.;
@@ -21,19 +62,21 @@ let
pkgs.imagemagick # For image-mode and eimp-mode
];

propagatedUserEnvPkgs = [ emacs' ];

installPhase = ''
mkdir -p "$out/bin" "$out/emacs.d"

export loadpathel="$out/emacs.d/lisp/loadpath.el"
substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"
export emacspath="${emacs'}/bin"

substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"
cp -r ${src}/lisp ${src}/modes "$out/emacs.d/"
cp -r ${src}/bin/* "$out/bin/"
chmod u+w "$out"/emacs.d/*
chmod 0555 "$out"/bin/*

for f in ${emacs'}/bin/*; do
ln -nfs "$f" "$out/bin/"
for f in ${src}/bin/*; do
substituteAll "$f" "$out/bin/$(basename "$f")"
chmod 0555 "$out/bin/$(basename "$f")"
done

for f in $(find "$out/emacs.d" -type f -name "*.el"); do
@@ -43,6 +86,8 @@ let
'';
};

##############################################################################
# List of Emacs packages I use.
emacs' =
emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [
alect-themes
@@ -105,7 +150,6 @@ let
scad-mode

]) ++ (with epkgs.elpaPackages; [
exwm
rainbow-mode

]) ++ (with epkgs.orgPackages; [
@@ -115,8 +159,11 @@ let
pdf-tools

]) ++ (with pkgs; [
(exwmLatest epkgs.elpaPackages)
mu

]));

################################################################################
# It all boils down to the derivation.
in pjones

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

@@ -1,19 +0,0 @@
;;; eshell-conf.el -- Settings for Eshell
(eval-when-compile
(require 'eshell))

(require 'esh-mode)

(custom-set-variables
'(eshell-prompt-regexp "^❯ ")
'(eshell-review-quick-commands nil)
'(eshell-where-to-jump (quote after))
'(eshell-smart-space-goes-to-end t))

(defun pjones:eshell-mode-hook ()
"Customize Eshell."
(require 'em-smart)
(eshell-smart-initialize))

(defvar eshell-mode-hook "Why isn't this defined?" nil)
(add-to-list 'eshell-mode-hook #'pjones:eshell-mode-hook)

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

@@ -1,6 +0,0 @@
;;; oauth2-conf.el -- OAuth Configuration.
(eval-when-compile
(require 'oauth2))

(custom-set-variables
`(oauth2-token-file ,(expand-file-name "~/keys/emacs/oauth2.plstore")))

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

@@ -1,170 +0,0 @@
;;; rcirc-conf.el -- Settings for rcirc.
(eval-when-compile
(require 'cl)
(require 'rcirc))

;; Silence compiler warnings
(declare-function rcirc-omit-mode "rcirc")
(declare-function rcirc-track-minor-mode "rcirc")
(declare-function rcirc-nick "rcirc")
(declare-function rcirc-server-name "rcirc")

(defvar pjones-irc-password nil
"My password for connecting to ZNC.")

;; Load passwords from a private file
(load "~/keys/emacs/secrets.el")

(setq rcirc-default-nick "pmade"
rcirc-default-user-name "pmade"
rcirc-default-full-name "Peter Jones"
rcirc-multiline-major-mode 'markdown-mode
rcirc-fill-flag t)

;; List of servers to connect to.
::
;; N.B. The first server is the one used when the pjones:irc function
;; is called with a prefix argument.
(setq rcirc-server-alist
`(("bitlbee.pmade.com"
:nick "pjones" :user-name "pjones/bitlbee"
:port 6697 :encryption tls
:password ,pjones-irc-password)
("freenode.pmade.com"
:nick "pjones" :user-name "pjones/freenode"
:port 6697 :encryption tls
:password ,pjones-irc-password)))

;; Other interesting Freenode channels:
;;
;; #hakyll -- Hakyll static site generator
;; #gnus -- Gnus news/mail reader
;; #debian -- Obvious
;; #mpd -- Music player daemon

(setq rcirc-omit-responses '("JOIN" "PART" "QUIT" "NICK" "AWAY")
rcirc-buffer-maximum-lines 500)

(defvar pjones:rcirc-buffers
'("#derailed@irc.freenode.net"
"#xmonad@irc.freenode.net"
"#conkeror@irc.freenode.net"
"#emacs@irc.freenode.net"
"&bitlbee@localhost"
"#haskell@irc.freenode.net")
"A list of rcirc buffer names in the order in which they should
be placed into the current set of windows.")

(defvar pjones:rcirc-low-traffic-channels
'("#haskell-mobile@irc.freenode.net"
"#hakyll@irc.freenode.net"
"#derailed@irc.freenode.net"
"#boulderhs@irc.freenode.net")
"A list of IRC channels that have low enough traffic that it's
okay to send me notifications of activity.")

(defun pjones:rcirc-windows ()
"Split the current frame into several windows and place the
buffers listed in `pjones:rcirc-buffers' in each of the resulting
windows, in the correct order."
(interactive)
(let ((wins (window-list nil nil (frame-first-window))))
(when (= 1 (length wins))
(split-window-right)
(dolist (w (window-list))
(select-window w)
(dotimes (i 2) (split-window-below)))
(balance-windows))
(setq wins (window-list nil nil (frame-first-window)))
(cl-mapcar 'set-window-buffer wins pjones:rcirc-buffers)))

(defun pjones:rcirc-cmd-all (input)
"See the docs for rcirc-cmd-all."
(let ((buffers (mapcar 'process-buffer (rcirc-process-list))))
(dolist (buf buffers)
(with-current-buffer buf
(goto-char (point-max))
(insert "/" input)
(rcirc-send-input)))))

(defun-rcirc-command all (input)
"Run the arguments as a command for all connections.
Example use: /all away food or /all quit zzzz."
(interactive "s")
(pjones:rcirc-cmd-all input))

(defun pjones:rcirc-quit ()
"Quit all rcirc connections."
(interactive)
(let ((buffers (mapcar 'process-buffer (rcirc-process-list))))
(dolist (buf buffers)
(with-current-buffer buf
(rcirc-cmd-quit "bye.")))))

(defun pjones:rcirc-macrumors ()
"Connect to the macrumors IRC server."
(interactive)
(rcirc-connect "irc.macrumorslive.com" nil nil nil nil "#macrumors"))

(defun pjones:rcirc-update-fill-column (&optional window)
"Update `rcirc-fill-column' based on the width of WINDOW, or
the current window if WINDOW is nil."
(with-current-buffer (window-buffer window)
(if (eq major-mode 'rcirc-mode)
(setq rcirc-fill-column (- (window-width window) 2)))))

(defun pjones:rcirc-update-fill-column-all-windows (&optional frame)
"Call `pjones:rcirc-update-fill-column' for all windows."
(walk-windows 'pjones:rcirc-update-fill-column 'no-minibuf frame))

(defun pjones:rcirc-hook ()
(require 'rcirc-color)
(when (and (string-match "#" (buffer-name))
(not (string-match "developers\\|twitter" (buffer-name)))
(not (member (buffer-name) pjones:rcirc-low-traffic-channels)))
(setq rcirc-ignore-buffer-activity-flag t)
(rcirc-omit-mode))
(define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-browse-url)
(set (make-local-variable 'scroll-conservatively) 8192)
(set (make-local-variable 'next-line-add-newlines) nil)
(setq mode-line-format '(" %b " global-mode-string)
wrap-prefix " "
rcirc-prompt "❯ ")
(pjones:rcirc-update-fill-column)
(flyspell-mode)
(visual-line-mode)
(rcirc-update-prompt)
(rcirc-track-minor-mode))

(defun pjones:rcirc-activity-string ()
(when (string= "[]" rcirc-activity-string)
(setq rcirc-activity-string "")))

(defun pjones:rcirc-notify (sender text)
"Display an activity notification."
(pjones:urgency-hint (selected-frame) t))

(defun pjones:rcirc-print-hook (proc sender response target text)
"Hook called when a new IRC message is received. If the
message is either a PRIVMSG or mentions your nick, use the
notification function. This only happens if the target buffer is
not currently displayed in a window."
(let ((buf (rcirc-get-buffer proc target)))
(when (and
(or (and (string= response "PRIVMSG")
(not (string= (rcirc-nick proc) sender))
(not (rcirc-channel-p target)))
(and (string-match (rcirc-nick proc) text)
(not (string= (rcirc-nick proc) sender))
(not (string= (rcirc-server-name proc) sender)))))
; (not (get-buffer-window buf)))
(pjones:rcirc-notify sender text))))

(add-hook 'rcirc-mode-hook 'pjones:rcirc-hook)
(add-hook 'rcirc-update-activity-string-hook 'pjones:rcirc-activity-string)
(add-hook 'rcirc-print-hooks 'pjones:rcirc-print-hook)
(add-hook 'window-size-change-functions 'pjones:rcirc-update-fill-column-all-windows)

;; Local Variables:
;; byte-compile-warnings: (not cl-functions noruntime)
;; End:

Loading…
Cancel
Save