about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+circe.el16
-rw-r--r--lisp/+emacs.el31
2 files changed, 45 insertions, 2 deletions
diff --git a/lisp/+circe.el b/lisp/+circe.el index d9ea9cf..9078907 100644 --- a/lisp/+circe.el +++ b/lisp/+circe.el
@@ -48,7 +48,21 @@
48(defun +circe-current-topic (&optional message) 48(defun +circe-current-topic (&optional message)
49 "Return the topic of the current channel. 49 "Return the topic of the current channel.
50When called with optional MESSAGE non-nil, or interactively, also 50When called with optional MESSAGE non-nil, or interactively, also
51message the current topic.") 51message the current topic."
52 (interactive "p")
53 (let ((topic
54 (save-excursion
55 (goto-char (point-max))
56 (or (re-search-backward
57 (rx (group "*** "
58 (or "Topic" "topic" "TOPIC")
59 (* (not ":")) ": ")
60 (group (+ nonl)))))
61 (buffer-substring-no-properties
62 (match-beginning 2) (match-end 2)))))
63 (when message
64 (message "%s" topic))
65 topic))
52 66
53;;; Formatting messages 67;;; Formatting messages
54 68
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 15e23da..3fe243c 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el
@@ -120,7 +120,8 @@ Do this only if the buffer is not visiting a file."
120(when (version< emacs-version "28") 120(when (version< emacs-version "28")
121 (fset 'yes-or-no-p 'y-or-n-p)) 121 (fset 'yes-or-no-p 'y-or-n-p))
122 122
123;; Encoding -- UTF-8 everywhere 123;;; Encodings
124
124(setq-default locale-coding-system 'utf-8-unix 125(setq-default locale-coding-system 'utf-8-unix
125 coding-system-for-read 'utf-8-unix 126 coding-system-for-read 'utf-8-unix
126 coding-system-for-write 'utf-8-unix 127 coding-system-for-write 'utf-8-unix
@@ -174,8 +175,36 @@ Do this only if the buffer is not visiting a file."
174(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) 175(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
175(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) 176(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode)
176 177
178;;; Better-default functions
179
180(defun +cycle-spacing (&optional n preserve-nl-back mode)
181 "Negate N argument on `cycle-spacing'.
182That is, with a positive N, deletes newlines as well, leaving -N
183spaces. If N is negative, it will not delete newlines and leave
184N spaces. See docstring of `cycle-spacing' for the meaning of
185PRESERVE-NL-BACK and MODE."
186 (interactive "*p")
187 (cycle-spacing (- n) preserve-nl-back mode))
188
189(defun +save-buffers-quit (&optional arg)
190 "Silently save each buffer, then kill the current connection.
191If the current frame has no client, kill Emacs itself using
192`save-buffers-kill-emacs' after confirming with the user.
193
194With prefix ARG, silently save all file-visiting buffers, then
195kill without asking."
196 (interactive "P")
197 (save-some-buffers t)
198 (if (and (not (frame-parameter nil 'client))
199 (and (not arg)))
200 (when (yes-or-no-p "Sure you want to quit? ")
201 (save-buffers-kill-emacs))
202 (server-save-buffers-kill-terminal nil)))
203
177;;; Bindings 204;;; Bindings
178 205
206(global-set-key (kbd "C-x C-c") '+save-buffers-quit)
207(global-set-key (kbd "M-SPC") '+cycle-spacing)
179(global-set-key (kbd "M-/") 'hippie-expand) 208(global-set-key (kbd "M-/") 'hippie-expand)
180(global-set-key (kbd "M-=") 'count-words) 209(global-set-key (kbd "M-=") 'count-words)
181(global-set-key (kbd "C-x C-b") 'ibuffer) 210(global-set-key (kbd "C-x C-b") 'ibuffer)