EMACS: Add X urgency hint when someone speaks to me on jabber
This commit is contained in:
parent
ad50751c32
commit
9451afae69
1 changed files with 47 additions and 18 deletions
|
@ -3,7 +3,7 @@
|
||||||
(normal-top-level-add-subdirs-to-load-path))
|
(normal-top-level-add-subdirs-to-load-path))
|
||||||
|
|
||||||
;;-----[ Defun ]---------------------------------------------------------
|
;;-----[ Defun ]---------------------------------------------------------
|
||||||
(defun oni/what-face (pos)
|
(defun ext/what-face (pos)
|
||||||
"Find out which face the current position uses"
|
"Find out which face the current position uses"
|
||||||
(interactive "d")
|
(interactive "d")
|
||||||
(let ((face (or (get-char-property (point) 'read-face-name)
|
(let ((face (or (get-char-property (point) 'read-face-name)
|
||||||
|
@ -12,11 +12,11 @@
|
||||||
(message "Face: %s" face)
|
(message "Face: %s" face)
|
||||||
(message "No face at %d" pos))))
|
(message "No face at %d" pos))))
|
||||||
|
|
||||||
(defun oni/what-major-mode (buffer-or-string)
|
(defun ext/what-major-mode (buffer-or-string)
|
||||||
"Find out which major-mode is currently used"
|
"Find out which major-mode is currently used"
|
||||||
(with-current-buffer buffer-or-string major-mode))
|
(with-current-buffer buffer-or-string major-mode))
|
||||||
|
|
||||||
(defun oni/my-comp-finish-function (buf str)
|
(defun ext/my-comp-finish-function (buf str)
|
||||||
"Don't show compilation window if everything went ok"
|
"Don't show compilation window if everything went ok"
|
||||||
(if (string-match "exited abnormally" str)
|
(if (string-match "exited abnormally" str)
|
||||||
;; there were errors
|
;; there were errors
|
||||||
|
@ -25,6 +25,29 @@
|
||||||
(run-at-time 0.5 nil 'delete-windows-on buf)
|
(run-at-time 0.5 nil 'delete-windows-on buf)
|
||||||
(message "NO COMPILATION ERRORS!")))
|
(message "NO COMPILATION ERRORS!")))
|
||||||
|
|
||||||
|
(defun ext/pretty-lambdas ()
|
||||||
|
(font-lock-add-keywords
|
||||||
|
nil `(("(\\(lambda\\>\\)"
|
||||||
|
(0 (progn
|
||||||
|
(compose-region (match-beginning 1)
|
||||||
|
(match-end 1)
|
||||||
|
?λ)))))))
|
||||||
|
|
||||||
|
(defun ext/x-urgency-hint (frame arg &optional source)
|
||||||
|
(let* ((wm-hints (append (x-window-property
|
||||||
|
"WM_HINTS" frame "WM_HINTS"
|
||||||
|
(if source
|
||||||
|
source
|
||||||
|
(string-to-number
|
||||||
|
(frame-parameter frame 'outer-window-id)))
|
||||||
|
nil t) nil))
|
||||||
|
(flags (car wm-hints)))
|
||||||
|
(setcar wm-hints
|
||||||
|
(if arg
|
||||||
|
(logior flags #x00000100)
|
||||||
|
(logand flags #xFFFFFEFF)))
|
||||||
|
(x-change-window-property "WM_HINTS" wm-hints frame "WM_HINTS" 32 t)))
|
||||||
|
|
||||||
(defun oni/c-toggle-header-source ()
|
(defun oni/c-toggle-header-source ()
|
||||||
"Toggle between a C source and header file"
|
"Toggle between a C source and header file"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -49,9 +72,9 @@
|
||||||
(oni/replace-occurrences "é" "é"))
|
(oni/replace-occurrences "é" "é"))
|
||||||
|
|
||||||
(defun oni/before-save-hook ()
|
(defun oni/before-save-hook ()
|
||||||
(if (eq (oni/what-major-mode (current-buffer)) 'html-mode)
|
(if (eq (ext/what-major-mode (current-buffer)) 'html-mode)
|
||||||
(oni/replace-html-special-chars))
|
(oni/replace-html-special-chars))
|
||||||
(if (not (eq (oni/what-major-mode (current-buffer)) 'markdown-mode))
|
(if (not (eq (ext/what-major-mode (current-buffer)) 'markdown-mode))
|
||||||
(delete-trailing-whitespace)))
|
(delete-trailing-whitespace)))
|
||||||
|
|
||||||
(defun oni/after-save-hook ()
|
(defun oni/after-save-hook ()
|
||||||
|
@ -59,14 +82,6 @@
|
||||||
(suffix (file-name-extension fname)))
|
(suffix (file-name-extension fname)))
|
||||||
(if (string-equal suffix "el")
|
(if (string-equal suffix "el")
|
||||||
(byte-compile-file fname))))
|
(byte-compile-file fname))))
|
||||||
|
|
||||||
(defun oni/pretty-lambdas ()
|
|
||||||
(font-lock-add-keywords
|
|
||||||
nil `(("(\\(lambda\\>\\)"
|
|
||||||
(0 (progn
|
|
||||||
(compose-region (match-beginning 1)
|
|
||||||
(match-end 1)
|
|
||||||
?λ)))))))
|
|
||||||
|
|
||||||
;;-----[ Theme ]---------------------------------------------------------
|
;;-----[ Theme ]---------------------------------------------------------
|
||||||
(require 'naquadah-theme)
|
(require 'naquadah-theme)
|
||||||
|
@ -118,7 +133,7 @@
|
||||||
`((,integer-regex-1 0 font-lock-constant-face)
|
`((,integer-regex-1 0 font-lock-constant-face)
|
||||||
(,integer-regex-2 0 font-lock-constant-face)))
|
(,integer-regex-2 0 font-lock-constant-face)))
|
||||||
(rainbow-delimiters-mode)
|
(rainbow-delimiters-mode)
|
||||||
(oni/pretty-lambdas)
|
(ext/pretty-lambdas)
|
||||||
(set-column-markers 73 81))
|
(set-column-markers 73 81))
|
||||||
|
|
||||||
(if (>= emacs-major-version 24)
|
(if (>= emacs-major-version 24)
|
||||||
|
@ -320,6 +335,21 @@
|
||||||
(require 'autosmiley)
|
(require 'autosmiley)
|
||||||
|
|
||||||
;;-----[ Jabber ]--------------------------------------------------------
|
;;-----[ Jabber ]--------------------------------------------------------
|
||||||
|
(defvar ext/jabber-activity-jids-count 0)
|
||||||
|
|
||||||
|
(defun ext/jabber-urgency-hint ()
|
||||||
|
(let ((count (length jabber-activity-jids)))
|
||||||
|
(unless (= ext/jabber-activity-jids-count count)
|
||||||
|
(if (zerop count)
|
||||||
|
(ext/x-urgency-hint (selected-frame) nil)
|
||||||
|
(ext/x-urgency-hint (selected-frame) t))
|
||||||
|
(setq ext/jabber-activity-jids-count count))))
|
||||||
|
|
||||||
|
(defun oni/jabber-chat-mode-hook ()
|
||||||
|
(autosmiley-mode)
|
||||||
|
(local-set-key [S-return] 'newline)
|
||||||
|
(local-set-key [C-return] 'newline))
|
||||||
|
|
||||||
(when (require 'jabber-autoloads nil 'noerror)
|
(when (require 'jabber-autoloads nil 'noerror)
|
||||||
(setq jabber-account-list
|
(setq jabber-account-list
|
||||||
'(("ryuslash@gmail.com"
|
'(("ryuslash@gmail.com"
|
||||||
|
@ -327,9 +357,8 @@
|
||||||
(:connection-type . ssl))))
|
(:connection-type . ssl))))
|
||||||
(setq jabber-history-enabled t)
|
(setq jabber-history-enabled t)
|
||||||
(setq jabber-use-global-history nil)
|
(setq jabber-use-global-history nil)
|
||||||
(define-key jabber-chat-mode-map [S-return] 'newline)
|
(add-hook 'jabber-chat-mode-hook 'oni/jabber-chat-mode-hook)
|
||||||
(define-key jabber-chat-mode-map [C-return] 'newline)
|
(add-hook 'jabber-activity-update-hook 'ext/jabber-urgency-hint))
|
||||||
(add-hook 'jabber-chat-mode-hook 'autosmiley-mode))
|
|
||||||
|
|
||||||
;;-----[ X11 ]-----------------------------------------------------------
|
;;-----[ X11 ]-----------------------------------------------------------
|
||||||
(when window-system
|
(when window-system
|
||||||
|
@ -449,7 +478,7 @@
|
||||||
(delete-selection-mode t)
|
(delete-selection-mode t)
|
||||||
(show-paren-mode t)
|
(show-paren-mode t)
|
||||||
|
|
||||||
(add-to-list 'compilation-finish-functions 'oni/my-comp-finish-function)
|
(add-to-list 'compilation-finish-functions 'ext/my-comp-finish-function)
|
||||||
|
|
||||||
(global-set-key "\C-m" 'newline-and-indent)
|
(global-set-key "\C-m" 'newline-and-indent)
|
||||||
(global-set-key (kbd "C-x n r") 'narrow-to-region)
|
(global-set-key (kbd "C-x n r") 'narrow-to-region)
|
||||||
|
|
Loading…
Reference in a new issue