From 546d89e98fbd290469e7d414930a1f0430b43abc Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Fri, 18 Nov 2011 17:16:50 +0200 Subject: [PATCH 1/4] added basic support for Python programming and an extensive ERC config (to be refined) --- init.el | 2 + modules/prelude-erc.el | 178 ++++++++++++++++++++++++++++++++++++ modules/prelude-packages.el | 2 +- modules/prelude-python.el | 56 ++++++++++++ 4 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 modules/prelude-erc.el create mode 100644 modules/prelude-python.el diff --git a/init.el b/init.el index a557aee..07bcb70 100644 --- a/init.el +++ b/init.el @@ -76,11 +76,13 @@ by Prelude.") (require 'prelude-coffee) (require 'prelude-common-lisp) (require 'prelude-emacs-lisp) +(require 'prelude-erc) (require 'prelude-haskell) (require 'prelude-js) (require 'prelude-latex) (require 'prelude-markdown) (require 'prelude-perl) +(require 'prelude-python) (require 'prelude-ruby) (require 'prelude-scheme) (require 'prelude-xml) diff --git a/modules/prelude-erc.el b/modules/prelude-erc.el new file mode 100644 index 0000000..293daf9 --- /dev/null +++ b/modules/prelude-erc.el @@ -0,0 +1,178 @@ +;;; prelude-erc.el --- Emacs Prelude: ERC mode configuration. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for ERC mode, which should make your +;; IRC experience a bit more pleasant. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'erc) +(require 'erc-log) +(require 'erc-notify) +(require 'erc-spelling) +(require 'erc-autoaway) + +;; Join the a couple of interesting channels whenever connecting to Freenode. +(setq erc-autojoin-channels-alist '(("freenode.net" + "#emacs" "#ruby" "#lisp"))) + +;; Interpret mIRC-style color commands in IRC chats +(setq erc-interpret-mirc-color t) + +;; The following are commented out by default, but users of other +;; non-Emacs IRC clients might find them useful. +;; Kill buffers for channels after /part +(setq erc-kill-buffer-on-part t) +;; Kill buffers for private queries after quitting the server +(setq erc-kill-queries-on-quit t) +;; Kill buffers for server messages after quitting the server +(setq erc-kill-server-buffer-on-quit t) + +;; open query buffers in the current window +(setq erc-query-display 'buffer) + +;; exclude boring stuff from tracking +(erc-track-mode t) +(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" + "324" "329" "332" "333" "353" "477")) + +;; logging +(setq erc-log-channels-directory "~/.erc/logs/") + +(if (not (file-exists-p erc-log-channels-directory)) + (mkdir erc-log-channels-directory t)) + +(setq erc-save-buffer-on-part t) +(defadvice save-buffers-kill-emacs (before save-logs (arg) activate) + (save-some-buffers t (lambda () (when (eq major-mode 'erc-mode) t)))) + +;; truncate long irc buffers +(erc-truncate-mode +1) + +;; share my real name +(setq erc-user-full-name "Bozhidar Batsov") + +;; enable spell checking +(erc-spelling-mode 1) +;; set different dictionaries by different servers/channels +;;(setq erc-spelling-dictionaries '(("#emacs" "american"))) + +;; TODO - replace this with use of notify.el +;; Notify my when someone mentions my nick. +(defun call-libnotify (matched-type nick msg) + (let* ((cmsg (split-string (clean-message msg))) + (nick (first (split-string nick "!"))) + (msg (mapconcat 'identity (rest cmsg) " "))) + (shell-command-to-string + (format "notify-send -u critical '%s says:' '%s'" nick msg)))) + +(when (eq system-type 'linux) + (add-hook 'erc-text-matched-hook 'call-libnotify)) + +(defvar erc-notify-nick-alist nil + "Alist of nicks and the last time they tried to trigger a +notification") + +(defvar erc-notify-timeout 10 + "Number of seconds that must elapse between notifications from +the same person.") + +(defun erc-notify-allowed-p (nick &optional delay) + "Return non-nil if a notification should be made for NICK. +If DELAY is specified, it will be the minimum time in seconds +that can occur between two notifications. The default is +`erc-notify-timeout'." + (unless delay (setq delay erc-notify-timeout)) + (let ((cur-time (time-to-seconds (current-time))) + (cur-assoc (assoc nick erc-notify-nick-alist)) + (last-time nil)) + (if cur-assoc + (progn + (setq last-time (cdr cur-assoc)) + (setcdr cur-assoc cur-time) + (> (abs (- cur-time last-time)) delay)) + (push (cons nick cur-time) erc-notify-nick-alist) + t))) + +;; private message notification +(defun erc-notify-on-private-msg (proc parsed) + (let ((nick (car (erc-parse-user (erc-response.sender parsed)))) + (target (car (erc-response.command-args parsed))) + (msg (erc-response.contents parsed))) + (when (and (erc-current-nick-p target) + (not (erc-is-message-ctcp-and-not-action-p msg)) + (erc-notify-allowed-p nick)) + (shell-command-to-string + (format "notify-send -u critical '%s says:' '%s'" nick msg)) + nil))) + +(add-hook 'erc-server-PRIVMSG-functions 'erc-notify-on-private-msg) + +;; autoaway setup +(setq erc-auto-discard-away t) +(setq erc-autoaway-idle-seconds 600) +(setq erc-autoaway-use-emacs-idle t) + +;; auto identify +(when (file-exists-p (expand-file-name "~/.ercpass")) + (load "~/.ercpass") + (require 'erc-services) + (erc-services-mode 1) + (setq erc-prompt-for-nickserv-password nil) + (setq erc-nickserv-passwords + `((freenode (("bozhidar" . ,bozhidar-pass))))) +) + +;; utf-8 always and forever +(setq erc-server-coding-system '(utf-8 . utf-8)) + +(defun start-irc () + "Connect to IRC." + (interactive) + (when (y-or-n-p "Do you want to start IRC? ") + (erc :server "irc.freenode.net" :port 6667 :nick "bozhidar"))) + +(defun filter-server-buffers () + (delq nil + (mapcar + (lambda (x) (and (erc-server-buffer-p x) x)) + (buffer-list)))) + +(defun stop-irc () + "Disconnects from all irc servers" + (interactive) + (dolist (buffer (filter-server-buffers)) + (message "Server buffer: %s" (buffer-name buffer)) + (with-current-buffer buffer + (erc-quit-server "Asta la vista")))) + +(provide 'prelude-erc) + +;;; prelude-erc.el ends here diff --git a/modules/prelude-packages.el b/modules/prelude-packages.el index ee56078..be5c4e3 100644 --- a/modules/prelude-packages.el +++ b/modules/prelude-packages.el @@ -45,7 +45,7 @@ (defvar prelude-packages '(auctex clojure-mode coffee-mode deft gist haml-mode haskell-mode magit markdown-mode paredit projectile - sass-mode scss-mode yaml-mode yari yasnippet) + python sass-mode scss-mode yaml-mode yari yasnippet) "A list of packages to ensure are installed at launch.") (dolist (p prelude-packages) diff --git a/modules/prelude-python.el b/modules/prelude-python.el new file mode 100644 index 0000000..ab1eff3 --- /dev/null +++ b/modules/prelude-python.el @@ -0,0 +1,56 @@ +;;; prelude-python.el --- Emacs Prelude: python.el configuration. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for python.el (the latest and greatest +;; Python mode Emacs has to offer). + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +;; customize +(defgroup python nil + "Emacs Prelude C programming support" + :group 'prelude) + +(defcustom prelude-enable-python-hook t + "Enable Prelude's default Python hook." + :type 'boolean + :group 'python) + +(require 'python) + +;; (defun prelude-python-coding-hook () +;; ) + +;; (when prelude-enable-python-hook +;; (add-hook 'python-mode-hook 'prelude-python-coding-hook)) + +(provide 'prelude-python) + +;;; prelude-python.el ends here From f51ae0cc6b75a783e8009b208538bda4327d0391 Mon Sep 17 00:00:00 2001 From: Mathieu Braem Date: Wed, 23 Nov 2011 11:13:32 +0100 Subject: [PATCH 2/4] tool-bar-mode does not properly work in a tty --- modules/prelude-ui.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/prelude-ui.el b/modules/prelude-ui.el index 0c43d69..2db356a 100644 --- a/modules/prelude-ui.el +++ b/modules/prelude-ui.el @@ -39,7 +39,7 @@ :group 'prelude) (defcustom prelude-use-minimalistic-ui t - "If set to true Prelude will dispense of most the UI that's mouse related - + "If set to true Prelude will dispense of most the UI that's mouse related - menu bar, tool bar, etc" :type 'boolean :group 'ui) @@ -63,7 +63,10 @@ instead of Emacs's default theme." (when prelude-use-minimalistic-ui ;; the toolbar is just a waste of valuable screen estate - (tool-bar-mode -1) + ;; in a tty tool-bar-mode does not properly auto-load, and is + ;; already disabled anyway + (when (fboundp 'tool-bar-mode) + (tool-bar-mode -1)) ;; the menu bar is mostly useless as well ;; but removing it under OS X doesn't make much sense (unless (eq system-type 'darwin) From 54bf2a37531916392b2fee17c4dfc982ea16de0f Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Wed, 23 Nov 2011 12:39:50 +0200 Subject: [PATCH 3/4] fixed #25 - problem with python indentation --- modules/prelude-python.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/prelude-python.el b/modules/prelude-python.el index ab1eff3..b37074e 100644 --- a/modules/prelude-python.el +++ b/modules/prelude-python.el @@ -45,11 +45,11 @@ (require 'python) -;; (defun prelude-python-coding-hook () -;; ) +(defun prelude-python-coding-hook () + (electric-indent-mode -1)) -;; (when prelude-enable-python-hook -;; (add-hook 'python-mode-hook 'prelude-python-coding-hook)) +(when prelude-enable-python-hook + (add-hook 'python-mode-hook 'prelude-python-coding-hook)) (provide 'prelude-python) From 5c716ea493eca589355bd84b640eb2ec45e42732 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Wed, 23 Nov 2011 12:48:09 +0200 Subject: [PATCH 4/4] fixed #24 - added some basic org-mode config --- init.el | 1 + modules/prelude-org.el | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 modules/prelude-org.el diff --git a/init.el b/init.el index 07bcb70..d19b8d9 100644 --- a/init.el +++ b/init.el @@ -81,6 +81,7 @@ by Prelude.") (require 'prelude-js) (require 'prelude-latex) (require 'prelude-markdown) +(require 'prelude-org) (require 'prelude-perl) (require 'prelude-python) (require 'prelude-ruby) diff --git a/modules/prelude-org.el b/modules/prelude-org.el new file mode 100644 index 0000000..968e863 --- /dev/null +++ b/modules/prelude-org.el @@ -0,0 +1,47 @@ +;;; prelude-org.el --- Emacs Prelude: org-mode configuration. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for org-mode. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(add-to-list 'auto-mode-alist '("\\.org\\’" . org-mode)) +(global-set-key "\C-cl" 'org-store-link) +(global-set-key "\C-ca" 'org-agenda) +(global-set-key "\C-cb" 'org-iswitchb) + +(defun prelude-org-mode-hook () + (electric-indent-mode -1)) + +(add-hook 'org-mode-hook 'prelude-org-mode-hook) + +(provide 'prelude-org) + +;;; prelude-org.el ends here