Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.3 KiB

  1. ;;; prelude-erc.el --- Emacs Prelude: ERC mode configuration.
  2. ;;
  3. ;; Copyright © 2011-2015 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Some basic configuration for ERC mode, which should make your
  12. ;; IRC experience a bit more pleasant.
  13. ;;; License:
  14. ;; This program is free software; you can redistribute it and/or
  15. ;; modify it under the terms of the GNU General Public License
  16. ;; as published by the Free Software Foundation; either version 3
  17. ;; of the License, or (at your option) any later version.
  18. ;;
  19. ;; This program is distributed in the hope that it will be useful,
  20. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;; GNU General Public License for more details.
  23. ;;
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  26. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  27. ;; Boston, MA 02110-1301, USA.
  28. ;;; Code:
  29. (require 'erc)
  30. (require 'erc-log)
  31. (require 'erc-notify)
  32. (require 'erc-spelling)
  33. (require 'erc-autoaway)
  34. ;; Interpret mIRC-style color commands in IRC chats
  35. (setq erc-interpret-mirc-color t)
  36. ;; The following are commented out by default, but users of other
  37. ;; non-Emacs IRC clients might find them useful.
  38. ;; Kill buffers for channels after /part
  39. (setq erc-kill-buffer-on-part t)
  40. ;; Kill buffers for private queries after quitting the server
  41. (setq erc-kill-queries-on-quit t)
  42. ;; Kill buffers for server messages after quitting the server
  43. (setq erc-kill-server-buffer-on-quit t)
  44. ;; open query buffers in the current window
  45. (setq erc-query-display 'buffer)
  46. ;; exclude boring stuff from tracking
  47. (erc-track-mode t)
  48. (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
  49. "324" "329" "332" "333" "353" "477"))
  50. ;; logging
  51. (setq erc-log-channels-directory "~/.erc/logs/")
  52. (if (not (file-exists-p erc-log-channels-directory))
  53. (mkdir erc-log-channels-directory t))
  54. (setq erc-save-buffer-on-part t)
  55. ;; FIXME - this advice is wrong and is causing problems on Emacs exit
  56. ;; (defadvice save-buffers-kill-emacs (before save-logs (arg) activate)
  57. ;; (save-some-buffers t (lambda () (when (eq major-mode 'erc-mode) t))))
  58. ;; truncate long irc buffers
  59. (erc-truncate-mode +1)
  60. ;; enable spell checking
  61. (erc-spelling-mode 1)
  62. ;; set different dictionaries by different servers/channels
  63. ;;(setq erc-spelling-dictionaries '(("#emacs" "american")))
  64. (defvar erc-notify-nick-alist nil
  65. "Alist of nicks and the last time they tried to trigger a
  66. notification")
  67. (defvar erc-notify-timeout 10
  68. "Number of seconds that must elapse between notifications from
  69. the same person.")
  70. (defun erc-notify-allowed-p (nick &optional delay)
  71. "Return non-nil if a notification should be made for NICK.
  72. If DELAY is specified, it will be the minimum time in seconds
  73. that can occur between two notifications. The default is
  74. `erc-notify-timeout'."
  75. (unless delay (setq delay erc-notify-timeout))
  76. (let ((cur-time (time-to-seconds (current-time)))
  77. (cur-assoc (assoc nick erc-notify-nick-alist))
  78. (last-time nil))
  79. (if cur-assoc
  80. (progn
  81. (setq last-time (cdr cur-assoc))
  82. (setcdr cur-assoc cur-time)
  83. (> (abs (- cur-time last-time)) delay))
  84. (push (cons nick cur-time) erc-notify-nick-alist)
  85. t)))
  86. ;; autoaway setup
  87. (setq erc-auto-discard-away t)
  88. (setq erc-autoaway-idle-seconds 600)
  89. (setq erc-autoaway-use-emacs-idle t)
  90. ;; utf-8 always and forever
  91. (setq erc-server-coding-system '(utf-8 . utf-8))
  92. (defun start-irc ()
  93. "Connect to IRC."
  94. (interactive)
  95. (when (y-or-n-p "Do you want to start IRC? ")
  96. (erc :server "irc.freenode.net" :port 6667 :nick erc-nick)))
  97. (defun filter-server-buffers ()
  98. (delq nil
  99. (mapcar
  100. (lambda (x) (and (erc-server-buffer-p x) x))
  101. (buffer-list))))
  102. (defun stop-irc ()
  103. "Disconnects from all irc servers"
  104. (interactive)
  105. (dolist (buffer (filter-server-buffers))
  106. (message "Server buffer: %s" (buffer-name buffer))
  107. (with-current-buffer buffer
  108. (erc-quit-server "Asta la vista"))))
  109. (setq erc-autojoin-channels-alist '(("freenode.net" "#prelude-emacs" "#projectile")))
  110. (provide 'prelude-erc)
  111. ;;; prelude-erc.el ends here