summary refs log tree commit diff stats
path: root/packages.el
blob: 42d8eebb122beaa5d9b90904c6c81528f1a08e3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
;;; packages.el --- my Emacs packages  -*- lexical-binding: t; -*-

(use-package scule
  :load-path "~/src/scule.el/"
  :bind-keymap ("M-c" . scule-map)
  :init
  ;; Use M-u for prefix keys
  (keymap-global-set "M-u" #'universal-argument)
  (keymap-set universal-argument-map "M-u" #'universal-argument-more))

(use-package frowny
  :load-path "~/src/frowny.el/"
  :hook ((jabber-chat-mode . frowny-mode)))

(use-package hippie-completing-read
  :load-path "~/src/hippie-completing-read.el/"
  :bind (("M-/" . hippie-completing-read)))

(use-package mode-line-bell
  :load-path "~/src/mode-line-bell.el/"
  :config
  (setq mode-line-bell-flash-time 0.25)
  (mode-line-bell-mode))

(use-package titlecase
  :load-path "~/src/titlecase.el/"
  :preface
  (defun +titlecase-sentence-style-dwim (&optional arg)
    "Titlecase a sentence.
With prefix ARG, toggle the value of
`titlecase-downcase-sentences' before sentence-casing."
    (interactive "P")
    (let ((titlecase-downcase-sentences (if arg (not titlecase-downcase-sentences)
                                          titlecase-downcase-sentences)))
      (titlecase-dwim 'sentence)))
  (defun +titlecase-org-headings ()
    (interactive)
    (require 'org)
    (save-excursion
      (goto-char (point-min))
      ;; See also `org-map-tree'.  I'm not using that function because I want to
      ;; skip the first headline.  A better solution would be to patch
      ;; `titlecase-line' to ignore org-mode metadata (TODO cookies, tags, etc).
      (let ((level (funcall outline-level))
            (org-special-ctrl-a/e t))
        (while (and (progn (outline-next-heading)
                           (> (funcall outline-level) level))
                    (not (eobp)))
          (titlecase-region (progn (org-beginning-of-line) (point))
                            (progn (org-end-of-line) (point)))))))
  :config
  (with-eval-after-load 'scule
    (keymap-set scule-map "M-t" #'titlecase-dwim)))

;;; Jabber

(use-package jabber
  :load-path  "~/src/jabber.el"
  :defer t
  :bind-keymap (("C-c j" . jabber-global-keymap))
  :preface nil
  (setq-default jabber-chat-buffer-format "*%n*"
                jabber-browse-buffer-format "*%n*"
                jabber-groupchat-buffer-format "*%n*"
                jabber-muc-private-buffer-format "*%n*")
  :custom-face
  (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign
                            :foreground unspecified
                            :weight normal)))
  (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local
                                     :foreground unspecified
                                     :weight bold)))
  (jabber-chat-prompt-local ((t :inherit minibuffer-prompt
                                :foreground unspecified
                                :weight normal
                                :slant italic)))
  (jabber-chat-prompt-foreign ((t :inherit warning
                                  :foreground unspecified
                                  :weight normal)))
  (jabber-chat-prompt-system ((t :inherit font-lock-doc-face
                                 :foreground unspecified)))
  (jabber-rare-time-face ((t :inherit font-lock-comment-face
                             :foreground unspecified
                             :underline nil)))
  :config
  (require 'jabber-httpupload nil t)
  (setopt jabber-auto-reconnect t
          jabber-last-read-marker "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~"
          jabber-muc-decorate-presence-patterns
          '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil)
            ("Mode #.*" . jabber-muc-presence-dim)
            ("." . jabber-muc-presence-dim))
          jabber-activity-make-strings #'jabber-activity-make-strings-shorten
          jabber-rare-time-format
          (format " - - - - - %%H:%d %%F"
                  (let ((min (string-to-number (format-time-string "%M"))))
                    (* 5 (floor min 5))))
          jabber-muc-header-line-format '(" " jabber-muc-topic))

  (setopt jabber-groupchat-prompt-format "%n.  "
          jabber-chat-local-prompt-format "%n.  "
          jabber-chat-foreign-prompt-format "%n.  "
          jabber-muc-private-foreign-prompt-format "%g/%n.  ")

  (keymap-global-set "C-c C-SPC" #'jabber-activity-switch-to)
  (map-keymap (lambda (key command)
                (define-key jabber-global-keymap (vector (+ key #x60)) command))
              jabber-global-keymap)
  (keymap-global-set "C-x C-j" #'dired-jump)

  (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons)
  (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo)
  (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo)
  (add-hook 'jabber-chat-mode-hook 'visual-line-mode)
  (add-hook 'jabber-chat-mode-hook (defun jabber-no-position ()
                                     (setq-local mode-line-position nil)))

  (add-hook 'jabber-alert-muc-hooks
            (defun jabber@highlight-acdw (&optional _ _ buf _ _)
              (when buf
                (with-current-buffer buf
                  (let ((regexp (rx word-boundary
                                    "acdw" ; maybe get from the config?
                                    word-boundary)))
                    (hi-lock-unface-buffer regexp)
                    (highlight-regexp regexp 'jabber-chat-prompt-local))))))

  (when (fboundp 'jabber-chat-update-focus)
    (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus)))