C
Back - Home

Richard Riley's web site (inprogress)

Dotemacs

Table of Contents

Using Emacs as a programming IDE

Visit the following link to see various set up options when using Emacs as a programmers IDE.

My DotEmacs

Emacs startup file

; -*-no-byte-compile: t; mode:emacs-lisp; -*-
;******************************************
; init.el
;
; Emacs startup file.
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;
;************************************************


(menu-bar-mode t)

(tool-bar-mode 0)
(blink-cursor-mode t)
(setq visible-cursor nil)
(fset 'yes-or-no-p 'y-or-n-p)
(show-paren-mode t)
(savehist-mode t)
(setq scroll-step           1
         scroll-conservatively 10000)

(if (not window-system)
    (progn
      (global-set-key [HOME] 'beginning-of-line)
      (global-set-key [select] 'end-of-line)
      ))

(delete-selection-mode t)

;; (set-frame-font "-*-lucidatypewriter-medium-*-*-*-12-*-*-*-*-*-*-*")
;; (set-frame-font "-*-verdana-medium-r-*-*-12-*-75-*-*-*-*-*") 
;; (set-frame-font "-outline-Bitstream Vera Sans-Mono-normal-r-normal-normal-12-90-96-96-c-*-iso8859-1")
(setq default-frame-alist 
             '(
               (font . "-*-lucida sans typewriter-medium-*-*-*-12-*-*-*-*-*-*-*")
               (cursor-color . "#dcdccc")
               (border-color . "#3f3f3f")
               (background-color . "#3f3f3f")
               (foreground-color . "#dcdccc")
               (mouse-color . "#dcdccc")
               ))


(setq load-path
      (append (list nil
                    "~/.emacs.d"
                    "~/.emacs.d/lisp"
                    "~/.emacs.d/auto-install"
                    "~/.emacs.d/lisp/apel"
                    "~/.emacs.d/lisp/bbdb/lisp"
                    "~/.emacs.d/lisp/elib"
                    "~/.emacs.d/lisp/elscreen"
                    "~/.emacs.d/lisp/g-client"
                    "~/.emacs.d/lisp/remember"
                    "~/.emacs.d/lisp/erc-5.3-extras"
                    "~/.emacs.d/lisp/xslt-process/lisp"
                    "~/.emacs.d/lisp/elite-for-emacs-0.1"
                    )
              load-path))

(require 'xclip)

(setq
 Man-notify-method (quote pushy)
 apropos-do-all t
 backup-by-copying t
 backup-directory-alist  '((".*" . "~/.emacs.d/backup-files/"))
 bbdb-file "~/.emacs.d/.bbdb"
 bookmark-default-file "~/.emacs.d/.emacs.bmk"
 completion-ignore-case t
 confirm-kill-emacs nil
 confirm-nonexistent-file-or-buffer nil
 cursor-type (quote box)
 custom-file "~/.emacs.d/rgr-custom.el"
 debug-on-error nil
 delete-old-versions t
 dired-listing-switches "-al"
 dired-recursive-deletes (quote top)
 ediff-window-setup-function 'ediff-setup-windows-plain
 gnus-directory "~/.emacs.d/"
 gnus-home-directory "~/.emacs.d/"
 gnus-init-file "~/.emacs.d/rgr-gnus.el"
 inhibit-startup-message t
 kept-new-versions 20
 kept-old-versions 0
 message-directory "~/.emacs.d/Maildir/"
 nnfolder-directory "~/.emacs.d/Maildir/archive/"
 printer-name (quote OfficeJet_6100)
 savehist-file      "~/.emacs.d/history"
 show-paren-delay 0.9
 show-paren-style (quote mixed)
 tramp-default-method "ssh"
 version-control t
 visible-bell t
 x-select-enable-clipboard t
)

;; not in gnus as need this maby before gnus loaded
(setq gnus-default-mailto-group "INBOX.mail")

(defun rgr/mailto (to)
  "Send an email to 'to' but prompting for a posting style if not configured. Starts Gnus if not already running."
  (require 'gnus)
  (unless gnus-active-hashtb (gnus)) ;; Better way??
  (let ((gnus-newsgroup-name
         (if gnus-default-mailto-group gnus-default-mailto-group (completing-read "Use posting style of group: "
                          gnus-active-hashtb nil
                          (gnus-read-active-file-p)))))
    (compose-mail to)))

(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(add-hook 'message-mode-hook 'turn-on-flyspell)
(add-hook 'text-mode-hook 'turn-on-flyspell)
(add-hook 'c-mode-common-hook 'flyspell-prog-mode)
(add-hook 'tcl-mode-hook 'flyspell-prog-mode)
(defun turn-on-flyspell ()
   "Force flyspell-mode on using a positive arg.  For use in hooks."
   (interactive)
   (flyspell-mode 1))

;; (defun iswitchb-local-keys ()
;;   (mapc (lambda (K) 
;;        (let* ((key (car K)) (fun (cdr K)))
;;          (define-key iswitchb-mode-map (edmacro-parse-keys key) fun)))
;;      '(("<right>" . iswitchb-next-match)
;;        ("<left>"  . iswitchb-prev-match)
;;        ("<up>"    . ignore             )
;;        ("<down>"  . ignore             ))))
;; (add-hook 'iswitchb-define-mode-map-hook 'iswitchb-local-keys)
;; (defadvice iswitchb-kill-buffer (after rescan-after-kill activate)
;;   "*Regenerate the list of matching buffer names after a kill.
;;     Necessary if using `uniquify' with `uniquify-after-kill-buffer-p'
;;     set to non-nil."
;;   (setq iswitchb-buflist iswitchb-matches)
;;   (iswitchb-rescan))
;; (defun iswitchb-rescan ()
;;   "*Regenerate the list of matching buffer names."
;;   (interactive)
;;   (iswitchb-make-buflist iswitchb-default)
;;   (setq iswitchb-rescan t))
;; (require 'iswitchb-highlight)
;; (iswitchb-mode 1)
;; (ffap-bindings)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point t)
(ido-mode 1)

;;; find file at point
;; (require 'ffap)
;; rebind C-x C-f and others to the ffap bindings (see variable ffap-bindings)
;; (ffap-bindings)

(winner-mode 1)

(require 'uniquify)
(setq uniquify-buffer-name-style (quote forward))

(defalias 'list-buffers 'ibuffer)

(add-to-list 'same-window-buffer-names "*Buffer List*")

;; Generate autoload for locally downloaded and developed elisp files
(defun my-autoloads ()
  "Generate autoloads for code in ~/.emacs.d/."
  (interactive)
  (let ((generated-autoload-file "~/.emacs.d/rgr-autoload.el"))
    (update-directory-autoloads "~/.emacs.d")
    (update-directory-autoloads "~/.emacs.d/lisp")))

(require 'rgr-autoload)

(require 'cl)

(autoload 'elip-session "elip" t)

(require 'bookmark-extensions)


(setq hippie-expand-try-functions-list
      '(
        try-expand-dabbrev-visible
        try-expand-dabbrev
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-complete-file-name
        try-complete-file-name-partially
        try-expand-list
        try-expand-list-all-buffers
        try-expand-line
        try-expand-line-all-buffers
        try-complete-lisp-symbol
        try-complete-lisp-symbol-partially
        try-expand-whole-kill
        ))


(require 'info+)

(load "~/.emacs.d/.e")

(require 'twittering-mode)
(twittering-icon-mode)

(require 'dired+)
(require 'dired-details+)
(require 'dired-open)
(require 'dired-sort-menu+)
(require 'dired-sort-map)

(autoload 'boxquote-region "boxquote" "Text formatting" t)

(require 'syslog-mode)
(add-to-list 'auto-mode-alist '("/var/log.*\\'" . syslog-mode))
(add-hook 'syslog-mode-hook 'auto-revert-tail-mode)
(require 'tail)

;; (require 'multi-term)
;; (multi-term-keystroke-setup) 
;; (setq multi-term-program "/bin/bash") 

(require 'bbdb)
(bbdb-initialize)

(autoload 'gnus "gnus" nil t)
(autoload 'w3m-browse-url "w3m" nil t)
(autoload 'browse-url-interactive-arg "browse-url")

(eval-after-load "w3m" 
  '(progn 
     (require 'manatee)
     (setq w3m-add-user-agent nil
           w3m-default-display-inline-images t
           w3m-default-save-directory "~/.emacs.d/.w3m"
           w3m-favicon-use-cache-file t
           w3m-init-file "~/.emacs.d/.emacs-w3m"
           w3m-key-binding (quote info)
           w3m-profile-directory "~/.emacs.d/.w3m"
           w3m-resize-images t
           w3m-use-cookies t
           w3m-cookie-accept-bad-cookies t
           w3m-key-binding (quote info)
           w3m-display-inline-image t
           browse-url-browser-function (quote w3m-browse-url)
           )))

(eval-after-load "gnus" 
  '(progn 
     (define-key gnus-article-mode-map (kbd "M-w") 'w3m-get-buffer-with-org-style)
     (add-hook 'w3m-mode-hook (lambda() 
                                (define-key w3m-mode-map (kbd "M-w") 'w3m-get-buffer-with-org-style)
                                (define-key w3m-mode-map "f" (lambda()(interactive)( w3m-external-view-current-url)))
                                (define-key w3m-mode-map "l" (lambda()(interactive)(jao-w3m-go-to-linknum)))))))


(setq auto-install-update-emacswiki-package-name-when-startup nil
      auto-install-directory "~/.emacs.d/lisp/"
      auto-install-replace-confirm t
      auto-install-save-confirm t)
(require 'auto-install)

(require 'printing)

(require 'rgr-dict)
(require 'rgr-elscreen)
(require 'rgr-functions)
(require 'rgr-music)
(require 'rgr-latex)
(require 'rgr-org)
(require 'rgr-translation)

(require 'rgr-programming)
(require 'rgr-security)

(require 'rgr-keybindings)

(autoload  'highlight-symbol-at-point  "highlight-symbol" nil t)
(setq highlight-symbol-idle-delay 1.5)
(global-set-key [(control f7)] 'highlight-symbol-at-point)
(global-set-key [f7] 'highlight-symbol-next)
(global-set-key [(shift f7)] 'highlight-symbol-prev)
(global-set-key [(meta f7)] 'highlight-symbol-prev)


(require 'magit)
(require 'rgr-completion)

(setq rgr/gblogger-post-url "http://www.blogger.com/feeds/4166588008280027121/posts/default")
(load "g-loaddefs")
(setq xml-weather-default-icons-directory "~/.emacs.d/lisp/xml-weather/icons/31x31")
(setq xml-weather-default-id  "GMXX0049")
(setq xml-weather-today-favoriteo "Hamburg, Germany")
(require 'xml-weather)

(require 'session)
    (add-hook 'after-init-hook 'session-initialize)

 (autoload 'save-current-configuration "revive" "Save status" t)
 (autoload 'resume "revive" "Resume Emacs" t)
 (autoload 'wipe "revive" "Wipe Emacs" t)
 (define-key ctl-x-map "S" 'save-current-configuration)
 (define-key ctl-x-map "F" 'resume)
 (define-key ctl-x-map "K" 'wipe)

(load-file custom-file)

(put 'upcase-region 'disabled nil)

(setq debug-on-error nil)

(put 'dired-find-alternate-file 'disabled nil)


(defun client-save-kill-emacs(&optional display)
  " This is a function that can bu used to shutdown save buffers and 
shutdown the emacs daemon. It should be called using 
emacsclient -e '(client-save-kill-emacs)'.  This function will
check to see if there are any modified buffers or active clients
or frame.  If so an x window will be opened and the user will
be prompted."
  (interactive)

  (let (new-frame modified-buffers active-clients-or-frames)

    ; Check if there are modified buffers or active clients or frames.
    (setq modified-buffers (modified-buffers-exist))
    (setq active-clients-or-frames ( or (> (length server-clients) 1)
                                        (> (length (frame-list)) 1)
                                       ))  

    ; Create a new frame if prompts are needed.
    (when (or modified-buffers active-clients-or-frames)
      (when (not (eq window-system 'x))
        (message "Initializing x windows system.")
        (x-initialize-window-system))
      (when (not display) (setq display (getenv "DISPLAY")))
      (message "Opening frame on display: %s" display)
      (select-frame (make-frame-on-display display '((window-system . x)))))

    ; Save the current frame.  
    (setq new-frame (selected-frame))


    ; When displaying the number of clients and frames: 
    ; subtract 1 from the clients for this client.
    ; subtract 2 from the frames this frame (that we just created) and the default frame.
    (when ( or (not active-clients-or-frames)
               (yes-or-no-p (format "There are currently %d clients and %d frames. Exit anyway?" (- (length server-clients) 1) (- (length (frame-list)) 2)))) 
      
      ; If the user quits during the save dialog then don't exit emacs.
      ; Still close the terminal though.
      (let((inhibit-quit t))
             ; Save buffers
        (with-local-quit
          (save-some-buffers)) 
              
        (if quit-flag
          (setq quit-flag nil)  
          ; Kill all remaining clients
          (progn
            (dolist (client server-clients)
              (server-delete-client client))
                 ; Exit emacs
            (kill-emacs))) 
        ))

    ; If we made a frame then kill it.
    (when (or modified-buffers active-clients-or-frames) (delete-frame new-frame))
    )
  )


(defun modified-buffers-exist() 
  "This function will check to see if there are any buffers
that have been modified.  It will return true if there are
and nil otherwise. Buffers that have buffer-offer-save set to
nil are ignored."
  (let (modified-found)
    (dolist (buffer (buffer-list))
      (when (and (buffer-live-p buffer)
                 (buffer-modified-p buffer)
                 (not (buffer-base-buffer buffer))
                 (or
                  (buffer-file-name buffer)
                  (progn
                    (set-buffer buffer)
                    (and buffer-offer-save (> (buffer-size) 0))))
                 )
        (setq modified-found t)
        )
      )
    modified-found
    )
  )

(global-set-key (kbd "C-S-q") 'client-save-kill-emacs)



My Gnus startup file.

;;;;;
;************************************************
; rgr-gnus.el
;
; Gnus init file
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************

(setq gnus-novice-user nil)
(setq  gnus-verbose 1)
(setq  gnus-verbose-backends 1)

(require 'gnushush)
(require 'manatee)
(require 'miniedit)

(setq  bbdb/gnus-header-prefer-real-names t
       bbdb-check-zip-codes-p t
       bbdb-complete-name-allow-cycling t
       bbdb-use-pop-up nil
       bbdb/gnus-split-nomatch-function 'nnimap-split-fancy
       bbdb/gnus-split-myaddr-regexp 'gnus-ignored-from-addresses
       bbdb-north-american-phone-numbers-p nil
       bbdb-send-mail-style 'gnus
       bbdb-silent-running t
       bbdb-always-add-addresses nil
       bbdb-offer-save 1                        ;; 1 means save-without-asking
       
       
       bbdb-use-pop-up nil                        ;; allow popups for addresses
       bbdb-electric-p t                        ;; be disposable with SPC
       bbdb-popup-target-lines  1               ;; very small
       
       bbdb-dwim-net-address-allow-redundancy t ;; always use full name
       bbdb-quiet-about-name-mismatches 2       ;; show name-mismatches 2 secs
       
       bbdb-always-add-address t                ;; add new addresses to existing...
       ;; ...contacts automatically
       bbdb-canonicalize-redundant-nets-p t     ;; x@foo.bar.cx => x@bar.cx
       
       bbdb-completion-type nil                 ;; complete on anything
       
       bbdb-complete-name-allow-cycling t       ;; cycle through matches
       ;; this only works partially
       
       bbbd-message-caching-enabled t           ;; be fast
       bbdb-use-alternate-names t               ;; use AKA
       
       
       bbdb-elided-display t                    ;; single-line addresses
       
       ;; auto-create addresses from mail
       bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook   
       bbdb-ignore-some-messages-alist ;; don't ask about fake addresses
       ;; NOTE: there can be only one entry per header (such as To, From)
       ;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html
       
       '(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter"))

       gnus-treat-display-smileys t
       ;; How gnus gets address from the from header.
       gnus-extract-address-components 'mail-extract-address-components
       gnus-buttonized-mime-types  '("multipart/signed" "multipart/alternative")
       gnus-optional-headers 'bbdb/gnus-lines-and-from
       gnus-article-skip-boring t
       gnus-expert-user t
       gnus-treat-strip-multiple-blank-lines 'last
       gnus-fetch-old-headers nil
       gnus-thread-hide-subtree nil
       gnus-indent-thread-level 1
       gnus-build-sparse-threads nil
       gnus-topic-line-format "%i[ %A: %(%{%n%}%) ]%v\n"
       gnus-topic-display-empty-topics nil
       gnus-use-nocem t
       gnus-use-full-window nil
       gnus-use-adaptive-scoring nil
       gnus-thread-sort-functions '(gnus-thread-sort-by-number
        (not gnus-thread-sort-by-date))
       gnus-message-archive-group '((if (message-news-p)
                                        "misc-news"
                                      "sent"
                                      ))
       gnus-update-message-archive-method t
       gnus-message-archive-method '(nnfolder "archive"
                                              (nnfolder-inhibit-expiry t)
                                              (nnfolder-active-file "~/.emacs.d/Maildir/active")
                                              (nnfolder-directory "~/.emacs.d/Maildir/archive/"))
       gnus-kill-files-directory "~/.emacs.d/.gnuskillfiled"
       gnus-use-dribble-file nil
       gnus-gcc-mark-as-read t
       gnus-summary-expunge-below 0
       gnus-group-line-format "%M%S%p%P%(%-40,40G%)%-5uy %ud\n"
       gnus-parameters '(("^\\(nnimap\\|nnfolder\\|nnml\\)"
                          (gnus-ignored-from-addresses ".*riley.*"))
                         )
       
       mail-imenu-generic-expression '(("Subject"  "^Subject: *\\(.*\\)" 1)
                                       ("Cc"     "^C[Cc]: *\\(.*\\)" 1)
                                       ("To"     "^To: *\\(.*\\)" 1)
                                       ("From"  "^From: *\\(.*\\)" 1))
       ;; whether gnus bothers with faces. It should!
       mail-user-agent 'gnus-user-agent
       mail-source-delete-incoming nil
       message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus:\\|^To:\\|^Cc:\\|^From"
       message-make-forward-subject-function (quote message-forward-subject-fwd)
       gnus-visual t
       nnimap-authinfo-file "~/.authinfo"
       gnus-select-method '(nnimap "mymail"
                                   (nnimap-stream tls)
                                   (nnimap-address "richardriley.net")
                                   (nnimap-expunge-on-close always)
                                   (nnimap-nov-is-evil nil)
                                   (nnir-search-engine imap))
       ;; no need for .newsrc - rely on .newsrc.eld instead since only using gnus

       gnus-save-newsrc-file nil
       ;; dont save killed groups - remove them
       ;; http://gnus.org/manual/gnus_12.html
       gnus-save-killed-list nil
       gnus-check-new-newsgroups nil
       ;; Always want to see important groups regardless of whether they are empty.
;;       gnus-permanently-visible-groups (rx(or ".*" "root" "INBOX" "FastSearch" "DevelopmentEmail.mail" ))
       gnus-permanently-visible-groups "\\.*"
       gnus-visible-headers (quote ("^From:" "^Newsgroups:" "^Subject:" "^Date:" "^Followup-To:" "^Reply-To:" "^Organization:" "^Summary:" "^Keywords:" "^To:" "^[BGF]?Cc:" "^Posted-To:" "^Mail-Copies-To:" "^Mail-Followup-To:" "^Apparently-To:" "^Gnus-Warning:" "^Resent-From:" "^X-Sent:" "^User-Agent:"))
       ;; when to prompt for how many
       gnus-large-newsgroup 300
       ;; gnushush provides some privacy.
       gnushush-sender-header (quote none)
       gnushush-user-agent-header (quote none)
       nnimap-split-inbox '("INBOX")
;http://c1.ac-images.myspacecdn.com/images02/91/m_37a92fe2fd7044fab4887fab98a2d4c4.jpg
       nnimap-split-crosspost nil
       nnimap-split-rule '(("mymail" ("INBOX" bbdb/gnus-split-method)))
       nnmail-split-abbrev-alist (quote ((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc") (mail . "mailer-daemon\\|postmaster\\|uucp") (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc") (from . "from\\|sender\\|resent-from") (nato . "to\\|cc\\|resent-to\\|resent-cc") (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc") (rgremail . "richardriley") (privateemail . "rileyrg\\|rgriley" ) (mailinglistfields . "List-id\\|List-Id\\|List-Subscribe") (devapps . "unison\\|planner\\|discuss\\|http\\|lists\\|development\\|-user") (daemon-errors . "Cron daemon\\|mailer-daemon") (german . "Der Tag - SPIEGEL ONLINE\\|Flashcards")))
       nnimap-split-fancy '(|
;;                          (: spam-split)
                            (any "rileyrgdev" "DevelopmentEmail.mail")
                            (mailinglistfields "linux-kernel" "DevelopmentEmail.kernel.digest")
                            (mailinglistfields devapps "DevelopmentEmail.apps.general")
                            (any daemon-errors "daemon-errors")
                            (any german "INBOX.german")
                            (any "xmonad" "DevelopmentEmail.haskell.xmonad")
                            (any "emacs-orgmode" "DevelopmentEmail.apps.emacs.org-mode")
                            (to "root" "root")
                            (to privateemail "INBOX.mail")
                            (to rgremail "INBOX.mail.rgr")
                            ("subject" "register:.*" "INBOX.shamrock.register")
                            (to "shamrock" "INBOX.shamrock.mail")
                            "INBOX.mail.NOT-FILED")
;      when replying we dont want to include peoples signatures.
       message-cite-function 'message-cite-original-without-signature
       message-required-news-headers (remove' Message-ID message-required-news-headers)
       message-required-mail-headers (remove' Message-ID message-required-mail-headers)
       ;; no limit to attachment size
       message-send-mail-partially-limit nil
       ;; Use emacs-w3m to render html mails and display images
       gnus-mime-display-multipart-related-as-mixed t
       mm-text-html-renderer 'w3m
       mm-inline-text-html-with-images t
       mm-inline-large-images t
       mm-verify-option 'always
       mm-decrypt-option nil
       mm-discouraged-alternatives '("text/html" "text/richtext")
       mm-automatic-display '("text/html")
       mm-attachment-override-types '("image/.*")
       mm-external-terminal-program (quote urxvt)
       gnus-ignored-mime-types '("text/x-vcard")
       w3m-w3mkey-binding 'info
       w3m-cookie-accept-bad-cookies t
       w3m-use-cookies t
       w3m-safe-url-regexp nil
       mm-w3m-safe-url-regexp nil
)

; simply not working - back to procmail
;; (require 'spam)
;; (spam-initialize)
;; (setq spam-use-bogofilter t)
;; (setq gnus-install-group-spam-parameters nil)
;; (setq gnus-spam-process-newsgroups
;;        '(("nnimap:.*" (gnus-group-spam-exit-processor-bogofilter
;;                             gnus-group-ham-exit-processor-bogofilter))))
;; (setq gnus-spam-process-destinations '(("nnimap:.*" "nnimap:probably-spam")))
;; (setq gnus-ham-process-destinations '(("nnimap:probably-spam" "nnimap:reclassify")))
;; (setq spam-junk-mailgroups '("nnimap:probably-spam"))
;; (setq spam-split-group "nnimap:probably-spam")


;; which email addresses to detect for special highlighting 
(defvar rgr-mails
        "rileyrg@gmail\\.com\\|rgr@richardriley\\.net\\|rileyrgdev@gmail\\.com")

(defun gnus-user-format-function-j (headers)
;; prefix each post depending on whether to, cc or Bcc to
  (let ((to (gnus-extra-header 'To headers)))
    (if (string-match rgr-mails to)
        (if (string-match "," to) "~" "»")
        (if (or (string-match rgr-mails
                              (gnus-extra-header 'Cc headers))
                (string-match rgr-mails
                              (gnus-extra-header 'BCc headers)))
            "~"
            " "))))

(setq  gnus-user-date-format-alist
;; Format the date so we can see today/tomorrow quickly.
;; See http://emacs.wordpress.com/category/gnus/ for the original.
           '(
             ((gnus-seconds-today) . "Today, %H:%M")
             ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
             (604800 . "%A %H:%M") ;;that's one week
             ((gnus-seconds-month) . "%A %d")
             ((gnus-seconds-year) . "%B %d")
             (t . "%B %d '%y"))) ;;this one is used when no other does match


(setq gnus-summary-line-format "%U%R%z%-2,2uj%-12,12&user-date; %-15,15f %-12,12B %s\n"
          gnus-sum-thread-tree-false-root "  "
          gnus-sum-thread-tree-indent " "
          gnus-sum-thread-tree-root "☢"
          gnus-sum-thread-tree-leaf-with-other "├► "
          gnus-sum-thread-tree-single-leaf "╰► "
          gnus-sum-thread-tree-vertical "│")

;; indexing in mail groups supported by dovecot on the server side.
(require 'nnir)
(setq nnir-search-engine 'imap)

(defun gnus-group-read-group-no-prompt ()
  "Read news in this newsgroup and don't prompt.
Use the value of `gnus-large-newsgroup'."
  (interactive)
  (gnus-group-read-group gnus-large-newsgroup))

(bbdb-insinuate-gnus)

(defun gnus-article-sort-by-chars (h1 h2)
  "Sort articles by size."
  (< (mail-header-chars h1)
     (mail-header-chars h2)))

(defun message-check-news-syntax ()
  "Check the syntax of the message and prompt the user to be sure he wants to send."
  (and
   (save-excursion
     (save-restriction
       (widen)
       (and
        ;; We narrow to the headers and check them first.
        (save-excursion
          (save-restriction
            (message-narrow-to-headers)
            (message-check-news-header-syntax)))
        ;; Check the body.
        (message-check-news-body-syntax))))
                                        ; sm: this last line is my addition
   (y-or-n-p "Post the message? ")
   ))


; for alias field - useful for mailing lists
;; (add-hook 'message-setup-hook 'bbdb-define-all-aliases)
(bbdb-define-all-aliases)


(defun wicked/gnus-add-subject-to-bbdb-record ()
  "Add datestamped subject note for each person this message has been sent to."
  (let* ((subject (concat (format-time-string "%Y.%m.%d")
                          ": E-mail: " (message-fetch-field "Subject") "\n"))
         (bbdb-get-addresses-headers
          (list (assoc 'recipients bbdb-get-addresses-headers)))
         records)
    (setq records
          (bbdb-update-records
           (bbdb-get-addresses nil gnus-ignored-from-addresses 'gnus-fetch-field)
           nil nil))
    (mapc (lambda (rec)
            (bbdb-record-putprop rec
                                 'contact
                                 (concat subject
                                         (or
                                          (bbdb-record-getprop rec 'contact)
                                          ""))))
          records)))

(add-hook 'message-send-hook 'wicked/gnus-add-subject-to-bbdb-record)

(defun DE-bbdb-match-field-recipient (field regexp)
  "Match FIELD for recipient against REGEXP.
FIELD must be a symbol, e.g. 'email-type."
  (let (who rec)
    (when (and
           (gnus-buffer-live-p gnus-article-copy)
           (setq who
                 (with-current-buffer gnus-article-copy
                   (save-restriction
                     (nnheader-narrow-to-headers)
                     (or (message-fetch-field "reply-to")
                         (message-fetch-field "from")))))
           (setq rec
                 (bbdb-search-simple
                  nil
                  (cadr (gnus-extract-address-components who)))))
      (string-match regexp (bbdb-get-field rec field)))))



;; group topics
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

;;hiliting depending on article count
;; (cond (window-system
;;            (setq custom-background-mode 'light)
        (defface my-inbox
          '((t (:foreground "SlateGray"))) "Personal group face")
        (defface my-inbox-unread
          '((t (:foreground "LightGrey" ))) "Personal group face unread")
        (defface my-dev-face
          '((t (:foreground "salmon4"))) "Dev Face")
        (defface my-dev-face-unread
          '((t (:foreground "salmon2" ))) "Dev Face Unread")
        (defface my-spam-face
          '((t (:foreground "DarkGoldenrod4"))) "Spam Face")
        (defface my-spam-face-unread
          '((t (:foreground "DarkGoldenrod3" ))) "Spam Face Unread")
        (defface my-spam-face-empty
          '((t (:foreground "green" ))) "Spam Face Unread")
        (defface my-mail
          '((t (:foreground "IndianRed4"))) "Mail group face")
        (defface my-mail-unread
          '((t (:foreground "IndianRed1" ))) "Mail group face unread")
        (defface my-news-default
          '((t (:foreground "gray"))) "Default group face")
        (defface my-news-default-unread
          '((t (:foreground "lightgray" ))) "Default group face unread")
;;      ))
     
(setq gnus-group-highlight
      '(
        ((and (string-match (rx(or "root" "daemon")) group) (> unread 0)) . my-mail-unread)
        ((string-match (rx(or "root" "daemon")) group)  . my-mail)
        ((and (string-match (rx(or "INBOX")) group) (> unread 0)) . my-inbox-unread)
        ((string-match (rx(or "INBOX")) group)  . my-inbox)
        ((and (string-match (rx(or "Development")) group) (> unread 0)) . my-dev-face-unread)
        ((string-match (rx(or "Development")) group)  . my-dev-face)
        ((and (string-match (rx(or  "spam")) group) (> unread 0)) . my-spam-face-empty)
        ((string-match (rx(or "spam")) group)  . my-spam-face)
        ((and (or nil mailp) (> unread 0)) . gnus-group-mail-1)
        ((or nil mailp)  . widget-inactive)
        ((> unread 0) . my-news-default-unread)
        (t . my-news-default)
))

(defun bzg-gnus-hl-sum-words nil
  "Highlight words in the summary buffer."
  (let* ((group gnus-newsgroup-name)
         (hl-words
          (gnus-group-fast-parameter group 'highlight-words t))
         buffer-read-only hl-word)
    (dolist (hlw hl-words)
      (save-excursion
        (goto-char (point-min))
        (while (re-search-forward (car hlw) nil t)
          (add-text-properties
           (match-beginning 0) (match-end 0)
           (list 'face (car (reverse hlw)))))))
    (setq buffer-read-only t)))

(add-hook 'gnus-summary-prepared-hook 'bzg-gnus-hl-sum-words)


(setq mail-imenu-generic-expression
      '(("Subject"  "^Subject: *\\(.*\\)" 1)
        ("Cc"     "^C[Cc]: *\\(.*\\)" 1)
        ("To"     "^To: *\\(.*\\)" 1)
        ("From"  "^From: *\\(.*\\)" 1)))

(add-hook 'mail-mode-hook 
        (lambda ()
           (setq imenu-generic-expression mail-imenu-generic-expression)))

;; we are all a bit egotistical and interested in our own ...
(add-hook 'message-sent-hook 'gnus-score-followup-article)
(add-hook 'message-sent-hook 'gnus-score-followup-thread) 

(define-key gnus-summary-mode-map (kbd "<f1>") (lambda()(interactive)(jao-gnus-goto-google)))
(define-key gnus-article-mode-map (kbd "<deletechar>") 'gnus-article-goto-prev-page)

;;F6 killfiles a poster, F7 ignores a thread
(define-key gnus-summary-mode-map (kbd "<f6>") "LA")
(define-key gnus-summary-mode-map (kbd "<f7>") 'gnus-summary-kill-thread)
(define-key gnus-summary-mode-map [(backspace)] (lambda ()(interactive)(gnus-summary-delete-article)(next-line)))

;; some comfort keys to scroll article in other window when in summary window
(define-key gnus-summary-mode-map [(meta up)] (lambda() (interactive) (scroll-other-window -1)))
(define-key gnus-summary-mode-map [(meta down)] (lambda() (interactive) (scroll-other-window 1)))
;; thread navigation
(define-key gnus-summary-mode-map [(control down)] 'gnus-summary-next-thread)
(define-key gnus-summary-mode-map [(control up)] 'gnus-summary-prev-thread)

;; Fast index based mail search on nnmairix server.
(define-key gnus-group-mode-map (kbd "<f3>") 'nnmairix-search)
(define-key gnus-group-mode-map (kbd "<C-f3>") 'gnus-group-make-nnir-group)
(require 'nnmairix)


(unless (assoc "audio/x-wav" w3m-content-type-alist)
  (setq w3m-content-type-alist
        (cons '("audio/x-wav" "\\.wav$" ("play" file))
              w3m-content-type-alist)))

(defun playwav (url)
  (interactive)
  (message "url is %s" url)
  (w3m-view-this-url url)
)

;; some trickery to show the newsread people are using and colour code depending on type
;; in this case highlight users of any outlook type dross :-;
(add-to-list
 'gnus-header-face-alist
 (list (concat
        "^"
        (regexp-opt '("User-Agent" "X-Mailer" "Newsreader" "X-Newsreader") t)
        ":.*") ;; other
       nil font-lock-comment-face))

(add-to-list
 'gnus-header-face-alist
 (list (concat
        "^"
        (regexp-opt '("User-Agent" "X-Mailer" "Newsreader" "X-Newsreader") t)
        ":.*Outlook.*")
       nil 'gnus-emphasis-highlight-words))

;; And show any real men who use Gnus!
(add-to-list
 'gnus-header-face-alist
 (list (concat
        "^"
        (regexp-opt '("User-Agent" "X-Mailer" "Newsreader" "X-Newsreader") t)
        ":.*Gnus.*")
       nil 'gnus-server-opened))

(defun jao-gnus-goto-google ()
  (interactive)
  (when (memq major-mode '(gnus-summary-mode gnus-article-mode))
    (when (eq major-mode 'gnus-article-mode)
      (gnus-article-show-summary))
    (let* ((article (gnus-summary-article-number))
           (header (gnus-summary-article-header article))
           (id (substring (mail-header-id header) 1 -1))
           (url (format "http://groups.google.com/groups?selm=%s" id)))
            (if current-prefix-arg
                (when url (browse-url-default-browser url))
              (if  url (browse-url url) (call-interactively 'browse-url))))))


(defun save-to-list ()
  (interactive)
  (bbdb/gnus-show-all-recipients)
  )


;; Format RSS feed titles nicely
(add-hook 'gnus-summary-mode-hook
          (lambda ()
            (if (string-match "^nnrss:.*" gnus-newsgroup-name)
                (progn
                  (make-local-variable 'gnus-show-threads)
                  (make-local-variable 'gnus-article-sort-functions)
                  (make-local-variable 'gnus-use-adaptive-scoring)
                  (make-local-variable 'gnus-use-scoring)
                  (make-local-variable 'gnus-score-find-score-files-function)
                  (make-local-variable 'gnus-summary-line-format)
                  (setq gnus-show-threads nil)
                  (setq gnus-article-sort-functions 'gnus-article-sort-by-date)
                  (setq gnus-use-adaptive-scoring nil)
                  (setq gnus-use-scoring t)
                  (setq gnus-score-find-score-files-function 'gnus-score-find-single)
                  (setq gnus-summary-line-format "%U%R%z%d %I%(%[ %s %]%)\n")))))

;; Gnus has built in support for RSS feeds, just hit "G R" and enter the feed
;; URL. Unfortunately Gnus will check RSS feeds everytime you check your email,
;; which is very impolite.
;;
;; To get around this, you set nnrss into local mode, which will fetch news
;; from locally stored RSS feeds.
(setq nnrss-use-local t)

(require 'nnrss)

(defun browse-nnrss-url (arg)
  (interactive "p")
  (let ((url (assq nnrss-url-field
                   (mail-header-extra
                    (gnus-data-header
                     (assq (gnus-summary-article-number)
                           gnus-newsgroup-data))))))
    (if url
        (browse-url (cdr url))
        (gnus-summary-scroll-up arg))))

(add-hook 'gnus-summary-mode-hook
          (lambda ()
            (define-key gnus-summary-mode-map
                (kbd "C-<return>")
              'browse-nnrss-url)))

(add-to-list 'nnmail-extra-headers nnrss-url-field)

;; The following code (stolen from the Gnus Manual) binds C-<enter>
;; to browse the link associated with the RSS entry using
;; browse-url1 from the Summary buffer:


(defun gnus-user-format-function-X (header)
  (let ((descr
         (assq nnrss-description-field (mail-header-extra header))))
    (if descr (concat "\n\t" (cdr descr)) "")))

(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)

(defun gnus-user-format-function-d (headers)
  (let ((time (gnus-group-timestamp gnus-tmp-group)))
    (if time
        (format-time-string "%b %d  %H:%M" time)
      ""
      )
    )
  )

     ;; Set the default value of `mm-discouraged-alternatives'.
     (eval-after-load "gnus-sum"
       '(add-to-list
         'gnus-newsgroup-variables
         '(mm-discouraged-alternatives
           . '("text/html" "image/.*"))))

     ;; Display `text/html' parts in `nnrss' groups.
     (add-to-list
      'gnus-parameters
      '("\\`nnrss:" (mm-discouraged-alternatives nil)))


(defun gnus-user-format-function-y (headers)
  (if (string-match "^nnfolder" gnus-tmp-group) 
      ""
      (concat "(" gnus-tmp-number-of-unread ")")
    )
  )

(add-hook 'mail-mode-hook 
          (lambda ()
            (setq imenu-generic-expression mail-imenu-generic-expression)))



(add-to-list 'gnus-secondary-select-methods
              '(nntp "motzarella"
                       (nntp-authinfo-file "~/.authinfo")
                       (nntp-address "news.eternal-september.org")
                       (nntp-port-number 119)
                       )
              )

(add-to-list 'gnus-secondary-select-methods
      '(nntp "Gmane"
             (nntp-address "news.gmane.org")))


(add-to-list 'gnus-secondary-select-methods
             '(nnml "nnml-mail-storage"
                    (nnml-directory "~/.emacs.d/nnml-mail-storage")
                    (nnml-active-file "~/.emacs.d/nnml-mail-storage/active")
                    (nnml-newsgroups-file "~/.emacs.d/nnml-mail-storage/newsgroups")))

(setq gnus-posting-styles `((".*"
                            (name "Richard Riley")
                            (from "Richard Riley <rileyrg@gmail.com>")
                            (eval(setq gnushush-user-agent-header (quote real)))
                            (signature-file "~/.emacs.d/.sigs/rgr.sig")
                            (eval (setq mml2015-signers '("b39a104a")))
                            (organization "aich tea tea pea dicky riley dot net"))))

(setq mml2015-verbose nil)

(defvar msmtp-name-list '("root" "richardriley"))

(load-file  "~/.emacs.d/rgr-emails.el") ; not "require" as then an eval wont call it again to customise posting styles

(defun msmtp-change-smtp ()
  
 (setq sendmail-program "/usr/bin/msmtp")
 (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
 (setq smtpmail-smtp-server "smtp.gmail.com")
 (setq message-sendmail-envelope-from 'header)
 
 (if (message-mail-p)
      (save-excursion
        (let* ((from
                (save-restriction    
                  (message-narrow-to-headers)
                  (message-fetch-field "from")))
               (account (catch 'match
                          (dolist (element msmtp-name-list)
                            ;; (message (format "smpt chosen is %s" element))
                            (when (string-match (format ".*%s.*" element) from)
                              (throw 'match element))))))
          (setq message-sendmail-extra-arguments (list "-a" account))
          ))))

(add-hook 'message-send-hook 'msmtp-change-smtp)




General utility functions

;;;;;
;************************************************
; rgr-functions.el
; Misc utility functions
; http://richardriley.net/default/projects/emacs/
;************************************************

(defvar rgr/notify-last '(0 0 0))
(defvar rgr/notify-delay '(0 5 0))
(defvar rgr/notify-cmd "notify-send")
(defvar rgr/notify-icon "~/.emacs.d/images/mail.png")
(defvar rgr/notify-timeout 10000)
(defvar rgr/notify-urgency "low")
(defvar rgr/notify-category "im.received")

(defun rgr/notify(message)
  (shell-command (concat rgr/notify-cmd
                         " -i " rgr/notify-icon
                         " -t " (int-to-string
                                 rgr/notify-timeout)
                         " -c " rgr/notify-category
                         " '" message "'")))

(defun rgr/osd-display (msg &optional id  delay vattrib hattrib font) 
  "Display a message msg using OSD. Currently requires gnome-osd-client"
  (interactive)          
  (unless msg (setq msg "osd-message"))
  (unless id (setq id "osd-message"))
  (unless vattrib (setq vattrib "bottom"))
  (unless hattrib (setq hattrib "left"))
  (unless delay (setq delay 5000))
  (unless font (setq font "Deja Mono 20"))
  (save-window-excursion
    (shell-command
     (format
      "gnome-osd-client -f \"<message id='%s' osd_fake_translucent_bg='off' osd_font='%s' animations='on' hide_timeout='%d' osd_vposition='%s' osd_halignment='%s'>%s</message>\""    
      id
      font
      delay
      vattrib
      hattrib
      (rgr/xml-escape msg)
      ))))


(defun rgr/toggle-always-on-top()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_ABOVE" 1)))

(defun rgr/bring-to-top()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_ACTIVE_WINDOW" 32 '(2 "_NET_ACTIVE_WINDOW" 1)))


(defun rgr/fortune (beg end file)
  (interactive (list (region-beginning) (region-end)
                     (if current-prefix-arg (fortune-ask-file))))
  (fortune-from-region beg end file)
  (save-buffer)
  (fortune-compile file)) 

(defun rgr/xml-escape (s)
  (setq s (replace-regexp-in-string "'" "&apos;" 
  (replace-regexp-in-string "\"" "&quot;"
  (replace-regexp-in-string "&" "&amp;" 
  (replace-regexp-in-string "<" "&lt;"
  (replace-regexp-in-string ">" "&gt;" s)))))))

(defun rgr/html-escape(start end)
  (interactive "r")
  (let ((s (rgr/xml-escape (region-or-word-at-point))))
    (delete-region start end)
    (insert s)))

(defun rgr/blog ()
  (interactive)
  (if current-prefix-arg
      (progn 
        (let ((url(read-from-minibuffer "Post URL:")))
          (gblogger-new-entry url)))
    (gblogger-new-entry rgr/gblogger-post-url)
    ))

(defun rgr/info-link ()
      "Returns a link to current info node."
      (unless (get-buffer "*info*")
        (error "No *info* buffer"))
      (let (output)
        (with-current-buffer "*info*"
          (let* ((file (file-name-nondirectory Info-current-file))
                 (node Info-current-node))
            (setq output (format "(info \"(%s)%s\")"
                                 file node))))
        ))

(defadvice elisp-index-search (before interactive-default activate)
  "Provide the symbol at point as the default when reading TOPIC
interactively."
  (interactive (let ((default (thing-at-point 'symbol)))
                 (list (read-string (if default
                                        (format "Topic (%s): " default)
                                      (format "Topic: "))
                                    default nil default)))))

(defadvice gnus-configure-posting-styles (before make-default-gnus-posting-style first)
  "use default group if none known"
  (let ((group-name (or group-name gnus-newsgroup-name "rgr")))))

(defun rgr/context-buffer()
  (get-buffer-create "*Help*"))

(defun rgr/toggle-context-help()
  "Turn on or off the context help. Note that if ON and you hide the help buffer then you need to manually reshow it. A double toggle will make it reappear"
  (interactive)
  (with-current-buffer (rgr/context-buffer)
    (unless (local-variable-p 'context-help) (set (make-local-variable 'context-help) t))
    (if (setq context-help (not context-help))
        (progn
          (if (not (get-buffer-window (help-buffer)))
              (display-buffer (help-buffer)))))
    (message "Context help %s" (if context-help "ON" "OFF"))))

(defun rgr/context-help()
  " Display function or variable at point in the *Help* buffer if it is visible. Default behaviour can be turned off by setting the buffer local context-help to false"
  (interactive)
  
  (let((helptext nil)( rgr-symbol (symbol-at-point)))(with-current-buffer (rgr/context-buffer)
    (unless (local-variable-p 'context-help) (set (make-local-variable 'context-help) t))
    (if (and context-help (get-buffer-window (help-buffer)) rgr-symbol )
        (setq helptext (if (fboundp  rgr-symbol) (describe-function rgr-symbol) 
          (if (boundp  rgr-symbol) (describe-variable rgr-symbol))))))
      helptext))

;; (defadvice eldoc-print-current-symbol-info
;;   (around eldoc-show-c-tag activate)
;;   (cond 
;;      ((eq major-mode 'emacs-lisp-mode)(rgr/context-help) ad-do-it)
;;      ((eq major-mode 'lisp-interaction-mode)(rgr/context-help) ad-do-it)
;;      ((eq major-mode 'apropos-mode)(rgr/context-help) ad-do-it)
;;      (t ad-do-it)))


(defun twit-query-for-post (prompt-heading initial-input) 
  "Query for a Twitter.com post text in the minibuffer."
  (read-string 
   (concat prompt-heading " (140 char max): ") 
   (if initial-input initial-input 
     (if (zerop(length(region-or-word-at-point)))
         "" 
         (region-or-word-at-point)
         ))))


(defun erc-cmd-SHOWOFF (&rest ignore)
  "Show off implementation"
  (let* ((chnl (erc-buffer-list))
         (srvl (erc-buffer-list 'erc-server-buffer-p))
         (memb (apply '+ (mapcar (lambda (chn)
                                   (with-current-buffer chn
                                     (1- (length (erc-get-channel-user-list)))))
                                 chnl)))
         (show (format "is connected to %i networks and talks in %i chans to %i ppl overall :>"
                       (length srvl)
                       (- (length chnl) (length srvl))
                       memb)))
    (erc-send-action (erc-default-target) show)))
(defalias 'erc-cmd-SO 'erc-cmd-SHOWOFF)


(defun rgr/byte-compile-file ()
  (let ((name (buffer-file-name)))
    (save-buffer)
    (byte-compile-file name)
    (eval-buffer)
    (message "eLisp file %s has been saved, compiled and reloaded." name)
    ))

(defun erc-cmd-DETAILED-SHOWOFF (&rest ignore)
  "Show off implementation enriched with even more with details"
  (let* ((chnl (erc-buffer-list))
         (srvl (erc-buffer-list 'erc-server-buffer-p)))
    (mapcar (lambda (srv)
              (let* ((netn (with-current-buffer srv erc-session-server))
                     (netp (with-current-buffer srv erc-session-port))
                     (chns (remove-if-not
                            (lambda (chn)
                              (and (string= netn (with-current-buffer chn erc-session-server))
                                   (eq netp (with-current-buffer chn erc-session-port))))
                            chnl))
                     (chnn (1- (length chns)))
                     (chnm (remove nil
                                   (mapcar (lambda (chn)
                                             (with-current-buffer chn
                                               (erc-get-channel-user-list)))
                                           chns)))
                     (chnmn (apply '+ (mapcar '1- (mapcar 'length chnm))))
                     (show (format "is connected to %s (%s), talking to %i users in %i chans"
                                   netn
                                   (buffer-name srv)
                                   chnmn
                                   chnn)))
                (erc-send-action (erc-default-target) show)
                (sit-for 1)))
            srvl)))
(defalias 'erc-cmd-DSO 'erc-cmd-DETAILED-SHOWOFF)

(defun rgr/lock-screen ()
   "Lock screen using using xtrlock and turn off monitor"
   (interactive)
   (save-excursion
     (shell-command "xset dpms force off && sleep 1")
     (set-process-sentinel
      (start-process "xtrlock" nilorcrist300167
))))

(defun find-alternative-file-with-sudo ()
  "Open current buffer as root!"
  (interactive)
  (when buffer-file-name
    (find-alternate-file
     (concat "/sudo:root@localhost:"
             buffer-file-name))))


(defface find-file-root-header-face
  '((t (:foreground "white" :background "red3")))
  "*Face use to display header-lines for files opened as root.")

(defun find-file-root-header-warning ()
  "*Display a warning in header line of the current buffer.
   This function is suitable to add to `find-file-root-hook'."
  (let* ((warning "WARNING: EDITING FILE AS ROOT!")
         (space (+ 6 (- (window-width) (length warning))))
         (bracket (make-string (/ space 2) ?-))
         (warning (concat bracket warning bracket)))
    (setq header-line-format
          (propertize  warning 'face 'find-file-root-header-face))))

(defun find-file-hook-root-header-warning ()
  (message buffer-file-name)
  (when (and buffer-file-name (string-match "root@" buffer-file-name))
    (find-file-root-header-warning)))

(add-hook 'find-file-hook 'find-file-hook-root-header-warning)

;; provided by snogglethorpe
(defcustom mode-line-bell-string "ding" ;"♪"
  "Message displayed in mode-line by `mode-line-bell' function."
  :group 'user)
(defcustom mode-line-bell-delay 1.0
  "Number of seconds `mode-line-bell' displays its message."
  :group 'user)

;; internal variables
(defvar mode-line-bell-cached-string nil)
(defvar mode-line-bell-propertized-string nil)

(defun mode-line-bell ()
  "Briefly display a highlighted message in the mode-line.

The string displayed is the value of `mode-line-bell-string',
with a red background; the background highlighting extends to the
right margin.  The string is displayed for `mode-line-bell-delay'
seconds.

This function is intended to be used as a value of `ring-bell-function'."

  (unless (equal mode-line-bell-string mode-line-bell-cached-string)
    (setq mode-line-bell-propertized-string
          (propertize
           (concat
            (propertize
             "x"
             'display
             `(space :align-to (- right ,(string-width mode-line-bell-string))))
            mode-line-bell-string)
           'face '(:background "red")))
    (setq mode-line-bell-cached-string mode-line-bell-string))
  (message mode-line-bell-propertized-string)
  (sit-for mode-line-bell-delay)
  (message ""))

(setq ring-bell-function 'mode-line-bell)

(defun djcb-opacity-modify (&optional dec)
  "modify the transparency of the emacs frame; if DEC is t,
    decrease the transparency, otherwise increase it in 10%-steps"
  (let* ((alpha-or-nil (frame-parameter nil 'alpha)) ; nil before setting
          (oldalpha (if alpha-or-nil alpha-or-nil 100))
          (newalpha (if dec (- oldalpha 10) (+ oldalpha 10))))
    (when (and (>= newalpha frame-alpha-lower-limit) (<= newalpha 100))
      (modify-frame-parameters nil (list (cons 'alpha newalpha))))))

 ;; C-8 will increase opacity (== decrease transparency)
 ;; C-9 will decrease opacity (== increase transparency
 ;; C-0 will returns the state to normal
(global-set-key (kbd "C-8") '(lambda()(interactive)(djcb-opacity-modify)))
(global-set-key (kbd "C-9") '(lambda()(interactive)(djcb-opacity-modify t)))
(global-set-key (kbd "C-0") '(lambda()(interactive)
                               (modify-frame-parameters nil `((alpha . 100)))))

(defvar dired-mplayer-program "mplayer")

(defun dired-mplayer ()
  (interactive)
  (let ((file (expand-file-name (dired-get-filename)))
        ext files basename dir curr-file idx-file sub-file srt-file
command options)
    (setq basename (file-name-nondirectory
(file-name-sans-extension file)))
    (setq dir (file-name-directory file))
    (setq files (directory-files dir t basename))
    (delete file files)
    (while files
      (setq curr-file (car files))
      (if (string= (file-name-extension curr-file) "idx")
        (setq idx-file curr-file))
      (if (string= (file-name-extension curr-file) "sub")
        (setq sub-file curr-file))
      (if (string= (file-name-extension curr-file) "srt")
        (setq srt-file curr-file))
      (setq files (cdr files)))
    (if (and idx-file sub-file)
        (setq options (format "-vobsub \"%s\""
(file-name-sans-extension idx-file))))
    (if (and sub-file
             (not idx-file))
        (setq options (format "-sub \"%s\"" sub-file)))
    (if (and srt-file
             (not sub-file))
        (setq options (format "-sub \"%s\"" srt-file)))
    
    (setq command (format "\"%s\" \"%s\" " dired-mplayer-program
file ))
    
        (shell-command command)))


(provide 'rgr-functions)

Web/Google Integration

Google and other wrapper functions for Emacs. Note the prefix for external browser.

(require 'browse-apropos-url)
(require 'browse-url)
(require 'thingatpt+)
(require 'w3m)

(add-to-list 'apropos-url-alist '("^googledict:? +\\(\\w+\\)|? *\\(\\w+\\) +\\(.*\\)" . "http://www.google.com/dictionary?aq=f&langpair=\\1|\\2&q=\\3&hl=\\1"))
(add-to-list 'apropos-url-alist '("^ewiki2:? +\\(.*\\)" .  "http://www.google.com/cse?cx=004774160799092323420%3A6-ff2s0o6yi&q=\\1&sa=Search"))
 
;;;###autoload
(defun rgr/browse (url)
  "If prefix is specified use the system default browser else use the configured emacs one"
  (if current-prefix-arg
      (when url (browse-url-default-browser url))
    (if  url (browse-url url) (call-interactively 'browse-url))
    ))

;;;###autoload
(defun rgr/browse-url (&optional url)
  "browse the url passed in"
  (interactive)
  (setq url (or url (w3m-url-valid (w3m-anchor)) (browse-url-url-at-point) (region-or-word-at-point)))
  (setq url (read-string (format "Url \"%s\" :" url) url nil url))
  (rgr/browse url))

;;;###autoload
(defun rgr/browse-apropos-url (apropos-prefix prompt)
  (interactive)
  (let* ((default (region-or-word-at-point))
        )
    (setq default (read-string (format prompt default) default nil default))
    (browse-apropos-url  (concat apropos-prefix " " default) nil current-prefix-arg)))
  


;;;###autoload
(defun rgr/google-search-prompt (&optional default)
  (interactive)
  (let* ((default (or default (region-or-word-at-point)))
         (term (read-string (format "Google.com the web for the following phrase (%s): "
                                    default) nil  nil default)))
    (rgr/browse (concat "http://www.google.com/search?q=" ; borrowed from dim
                        (replace-regexp-in-string 
                         "[[:space:]]+"
                         "+"
                         term)))))

 (require 'w3m-lnum)
  (defun jao-w3m-go-to-linknum ()
    "Turn on link numbers and ask for one to go to."
    (interactive)
    (let ((active w3m-link-numbering-mode))
      (when (not active) (w3m-link-numbering-mode))
      (unwind-protect
          (w3m-move-numbered-anchor (read-number "Anchor number: "))
        (when (not active) (w3m-link-numbering-mode)))))



(provide 'rgr-web)

Org-Mode configuration

Including using org-learn to store vocab queried from Babel

;;;;;
;************************************************
; rgr-org.el
;
; org-mode config
; Richard Riley.
;************************************************

(setq load-path
      (append (list nil
                    "~/.emacs.d/lisp/org-mode/lisp"
                    )
              load-path))

(require 'org-install)
(require 'org-annotation-helper)

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cr" 'org-remember)
(global-set-key "\C-cb" 'org-iswitchb)


(setq diary-file "~/.emacs.d/.diary"
      appt-display-diary nil
      calendar-view-diary-initially-flag nil
      mark-diary-entries-incalendar t
      diary-number-of-entries 7
)

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))

(global-font-lock-mode 1)                     ; for all buffers
(add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only

(setq org-directory "~/.emacs.d/org-files"
      org-agenda-show-inherited-tags t
      org-agenda-files (quote ("~/.emacs.d/org-files"))
      org-publish-timestamp-directory "~/.emacs.d/org-files/.org-timestamps/"
      org-publish-use-timestamps-flag nil
      org-agenda-start-with-follow-mode nil
      org-startup-folded nil
      org-clock-in-switch-to-state "STARTED"
      org-agenda-include-diary nil
      org-combined-agenda-icalendar-file "~/webs/richardriley/sync/org.ics"
      org-icalendar-include-todo t
      org-icalendar-combined-name (quote "Richard Riley ORG")
      org-icalendar-use-scheduled '(todo-due  event-if-todo event-if-not-todo)
      org-icalendar-use-deadline '(todo-due event-if-todo event-if-not-todo)
      org-icalendar-timezone "Europe/Berlin"
      org-icalendar-include-bbdb-anniversaries t
      org-icalendar-store-UID t
      org-use-property-inheritance t
      org-log-done '(state)
      org-tab-follows-link t
      org-return-follows-link t
      org-tags-match-list-sublevels t
      org-default-notes-file "refile.org"
      org-remember-store-without-prompt t
      org-agenda-ndays 7
      org-deadline-warning-days 14
      org-completion-use-ido t
      org-agenda-show-all-dates t
      org-agenda-skip-deadline-if-done t
      org-agenda-skip-scheduled-if-done t
      org-agenda-start-on-weekday nil
      org-reverse-note-order t
      org-refile-targets (quote ((org-agenda-files :maxlevel . 5) (nil :maxlevel . 5)))
      org-refile-use-outline-path (quote file)
      org-outline-path-complete-in-steps t
      org-use-fast-todo-selection t
      org-fast-tag-selection-single-key (quote expert)

      org-tag-alist '(
                      (:startgroup . nil) ("@Shamrock" . ?S) ("@Home" . ?H) ("@Dublin" . ?D) (:endgroup . nil) 
                      (:startgroup . nil) ("Online" . ?O) ("Offline" . ?F) (:endgroup . nil) 
                      (:startgroup . nil) ("Business" . ?B) ("Personal" . ?P) (:endgroup . nil) 
                      ("shopping" . ?s) ("general" . ?g) 
                      ("emacs" . ?e)("VOCAB" . ?v)("coding" . ?c) ("webs". ?w) ("idea" . ?i) ("leisure" . ?l)
                      )

      org-agenda-custom-commands 
      (quote (("P" "Projects" tags "PROJECT" ((org-use-tag-inheritance nil)))
              ("s" "Started Tasks" todo "STARTED" ((org-agenda-todo-ignore-with-date nil)))
              ("w" "Tasks waiting on something" tags "WAITING" ((org-use-tag-inheritance nil)))
              ("r" "Refile New Notes and Tasks" tags "REFILE" ((org-agenda-todo-ignore-with-date nil)))
              ("v" "Vocab" tags "VOCAB" ((org-agenda-filter-preset '("+VOCAB"))(org-agenda-todo-ignore-with-date nil)))
              ("j" "Journal" tags "JOURNAL" ((org-use-tag-inheritance t)))
              ("n" "Notes" tags "NOTE" nil)))

      org-remember-templates
      (quote (
              ("todo" ?t "* TODO %?\n  %u\n  %a" nil bottom nil)
              ("vocab" ?v "** TODO Learn %(rgr/orig-word)\t:VOCAB:\n:TRANSLATION:\n:orig:\t%(rgr/orig-word)\n:trans:\t%(rgr/trans-word)\n:from:\t%(rgr/from-lang)\n:to:\t%(rgr/to-lang)\n:END:\n%!" "vocab.org" bottom)
              ("note" ?n "* %?                                        :NOTE:\n  %u\n  %a" nil bottom nil)
              ("phone" ?p "* PHONE Name:%^{name} - Company:%^{company} -                :PHONE:\n  Contact Info: %a\n  %u\n  :CLOCK-IN:\n  %?" nil bottom nil)
              ("register" ?r "* %U Register %^{Firm}p %^{Link} %^{Description}p\n  %^C" nil bottom nil)
              ("Journal" ?j "* %U %?" "journal.org")          
              )
             )
      )

;;(setq org-agenda-filter-preset '("-VOCAB"))

(setq org-clock-persist t)
(org-clock-persistence-insinuate)

(setq org-todo-keywords (quote ((sequence "TODO(t)" "STARTED(s)" "|" "DONE(d!/!)")
 (sequence "WAITING(w@/!)" "SOMEDAY(S!)" "PROJECT(P@)" "OPEN(O@)" "|" "CANCELLED(c@/!)")
 (sequence "QUOTE(q!)" "QUOTED(Q!)" "|" "APPROVED(A@)" "EXPIRED(E@)" "REJECTED(R@)"))))
(setq org-todo-keyword-faces (quote (("TODO" :foreground "red" :weight bold)
 ("STARTED" :foreground "blue" :weight bold)
 ("DONE" :foreground "forest green" :weight bold)
 ("WAITING" :foreground "orange" :weight bold)
 ("SOMEDAY" :foreground "magenta" :weight bold)
 ("CANCELLED" :foreground "forest green" :weight bold)
 ("QUOTE" :foreground "red" :weight bold)
 ("QUOTED" :foreground "magenta" :weight bold)
 ("APPROVED" :foreground "forest green" :weight bold)
 ("EXPIRED" :foreground "forest green" :weight bold)
 ("REJECTED" :foreground "forest green" :weight bold)
 ("OPEN" :foreground "blue" :weight bold)
 ("PROJECT" :foreground "red" :weight bold))))

(setq org-todo-state-tags-triggers
      (quote (("CANCELLED" ("CANCELLED" . t))
              ("WAITING" ("WAITING" . t) ("NEXT"))
              ("SOMEDAY" ("WAITING" . t))
              (done ("NEXT") ("WAITING"))
              ("TODO" ("WAITING") ("CANCELLED"))
              ("STARTED" ("WAITING"))
              ("PROJECT" ("CANCELLED") ("PROJECT" . t)))))

(setq org-export-run-in-background nil)

(load-file "~/.emacs.d/.webvars")

(setq org-publish-project-alist
      `(
        ("web-org"
         :base-directory ,"~/webs/richardriley"
         :publishing-directory ,"~/webs/richardriley"
         :recursive t
         :base-extension "org"
         :publishing-function org-publish-org-to-html
         :section-numbers nil
         :style "<link rel='stylesheet'
                     href=\"./style.css\"
                     type=\"text/css\"/>"
         :auto-preamble t
         :auto-postamble t
         :preamble "<div id='photo'><a href='http://splash-of-open-sauce.blogspot.com'><img src='http://richardriley.net/images/me.gif' alt='C'est Moi'/></a></div><a href='../'>Back</a> - <a href='http://www.richardriley.net'>Home</a><p>Richard Riley's web site (inprogress)</p>"
         :postamble "<div id='hosted'><table><tr><td><img src='http://richardriley.net/images/debian-logo' title='Hosted on Debian Linux' alt='Hosted On Debian Linux' style='width:48px;'/></td><td><img src='http://richardriley.net/images/apache-logo' alt='Served Using Apache2' title ='Served Using Apache2' style='width:48px;'/></td></tr></table></div>"
         :author nil
         ) 
        ("rgrweb"
         :components("web-org")
         :base-directory ,"~/webs/richardriley"
         :publishing-directory ,"~/webs/richardriley"
         :recursive t
         )
        )
      )

(org-remember-insinuate)
(add-hook 'remember-mode-hook 'org-remember-apply-template)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; For org appointment reminders

;;;###autoload
(defun zenity-display (min-to-app new-time msg)      
  "modal display dialog using zenity"
  (interactive "MInput string to display using Zenity:")
  (save-window-excursion (shell-command (concat 
    "/usr/bin/zenity --info --title='Appointment' --text='" msg "' &"
    ) nil nil)
))

; 5 minute warnings
(setq appt-message-warning-time '15)
(setq appt-display-interval '10)

; Update appt each time agenda opened.
(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)

(when window-system

  (setq appt-display-format 'window)
  
;;;###autoload
  (defun rgr/org-display (min-to-app new-time msg)
          (shell-command (concat "notify-send"
                                 " -i " "~/images/clock.png"
                                 " -t " (int-to-string 20000)
                                 " " msg)))
  
  (setq appt-disp-window-function (function rgr/org-display)))

(require 'diary-lib)
(setq  diary-display-function 'fancy-diary-display)

;; ;; Run once, activate and schedule refresh
;; (run-at-time nil 300 'org-agenda-to-appt)
;; (appt-activate t)

;; inline images in org files
;;iimage
(require 'iimage)
(setq iimage-mode-image-search-path (expand-file-name "~/"))
;;Match org file: links
(add-to-list 'iimage-mode-image-regex-alist
            (cons (concat "\\[\\[file:\\(~?" iimage-mode-image-filename-regex
                          "\\)\\]")  1))

(eval-after-load "org"
'(progn
   (define-key org-mode-map [(control c) ?i] 'iimage-mode)
   (define-key org-mode-map "\C-r" 'org-smart-reschedule)))

(eval-after-load "org-agenda"
'(progn
   (define-key org-agenda-mode-map "\C-r" 'org-agenda-smart-reschedule)))

(defface org-canceled ;; originally copied from font-lock-type-face
  (org-compatible-face nil
    '((((class color) (min-colors 16) (background light)) (:foreground "darkgrey" :bold t))
      (((class color) (min-colors 16) (background dark)) (:foreground "grey" :bold t))
      (((class color) (min-colors 8)) (:foreground "grey"))
      (t (:bold t))))
  "Face used for todo keywords that indicate DONE items."
  :group 'org-faces)

(defface org-wait ;; originally copied from font-lock-type-face
  (org-compatible-face nil
    '((((class color) (min-colors 16) (background light)) (:foreground "darkgrey" :bold t))
      (((class color) (min-colors 16) (background dark)) (:foreground "grey" :bold t))
      (((class color) (min-colors 8)) (:foreground "grey"))
      (t (:bold t))))
  "Face used for todo keywords that indicate DONE items."
  :group 'org-faces)

(defun org-bbdb-anniv-export-ical ()
 "Extract anniversaries from BBDB and convert them to icalendar format."
 (require 'bbdb)
 (require 'diary-lib)
 (unless (hash-table-p org-bbdb-anniv-hash)
   (setq org-bbdb-anniv-hash
          (make-hash-table :test 'equal :size 366)))
 (when (or org-bbdb-updated-p
           (= 0 (hash-table-count org-bbdb-anniv-hash)))
   (org-bbdb-make-anniv-hash))
 
 (defun org-bbdb-format-vevent (key recs)
   (while (setq rec (pop recs))
     (setq categ (or (nth 2 rec) org-bbdb-default-anniversary-format))
     (princ (format "BEGIN:VEVENT
UID: ANNIV-%4i%02i%02i-%s
DTSTART:%4i%02i%02i
SUMMARY:%s
DESCRIPTION:%s
CATEGORIES:%s
RRULE:FREQ=YEARLY
END:VEVENT\n"
                      (nth 0 rec) (nth 0 key) (nth 1 key)
                      (mapconcat 'identity
                                 (org-split-string (nth 1 rec) "[^a-zA-Z0-90]+")
                                 "-")
                      (nth 0 rec) (nth 0 key) (nth 1 key)
                      (concat (capitalize categ) " " (nth 1 rec))
                      (concat (capitalize categ) " " (nth 1 rec))
                      categ))))

 (maphash 'org-bbdb-format-vevent org-bbdb-anniv-hash))

(require 'org-learn)

(provide 'rgr-org)

Using web/google and babel for translation services (English German here)

Note the prefix for external browser as with other web services above.

;;;;;
;************************************************
; rgr-translation.el
; provide language tranlsation services
; http://richardriley.net/default/projects/emacs/
;************************************************
(require 'rgr-web)
(require 'babel)
(require 'rgr-functions)

(defvar rgr/orig-text  "The text we wish to translate")
(defvar rgr/trans-text "The translated text")
(defvar rgr/learn-first-lesson 1 "Days in advance to schedule learn for")

(defun rgr/orig-word()
  rgr/orig-text
  )

(defun rgr/trans-word()
  rgr/trans-text
  )

(defun rgr/from-lang()
  babel-preferred-from-language
  )

(defun rgr/to-lang()
  babel-preferred-to-language
  )

(setq babel-echo-area t)
(setq babel-preferred-from-language "English")
(setq babel-preferred-to-language "German")


(defun rgr/babel-language-code (lang)
  (cdr (assoc lang babel-languages)))


(defun rgr/context-babel( &optional usedef )
  (interactive)
  (let* ((default (region-or-word-at-point)))
    (setq default (read-string (format "Translate \"%s\" :" default) nil nil default))
    (when (length default)
      (setq rgr/trans-text (babel default nil usedef))
      (setq rgr/orig-text default)
      (if current-prefix-arg 
          (progn
            (org-remember nil ?v)
            (org-schedule nil (time-add (current-time) (days-to-time rgr/learn-first-lesson)))))
      (rgr/notify rgr/trans-text)
      (message "%s" rgr/trans-text))))

(defun rgr/toggle-languages()
  (interactive)
  (let* ((temp babel-preferred-to-language))(setq babel-preferred-to-language babel-preferred-from-language)(setq babel-preferred-from-language temp))
  (message  "%s to %s " babel-preferred-from-language babel-preferred-to-language))

(provide 'rgr-translation)

My Dictionary/Thesaurus set up

;;;;;
;************************************************
; rgr-dict.el
;
; Dictionary/Thesaurus setup
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************

(add-to-list 'load-path "~/.emacs.d/lisp/dictem/")

(require 'dictem)

; SEARCH = MATCH + DEFINE
; Ask for word, database and search strategy
; and show definitions found
(global-set-key (kbd "C-c s") 'dictem-run-search)

;; ; MATCH
;; ; Ask for word, database and search strategy
;; ; and show matches found
;; (global-set-key "\C-cm" 'dictem-run-match)

;; ; DEFINE
;; ; Ask for word and database name
;; ; and show definitions found
;; (global-set-key "\C-cd" 'dictem-run-define)

;; ; SHOW SERVER
;; ; Show information about DICT server
;; (global-set-key "\C-c\M-r" 'dictem-run-show-server)

;; ; SHOW INFO
;; ; Show information about the database
;; (global-set-key "\C-c\M-i" 'dictem-run-show-info)

; SHOW DB
; Show a list of databases provided by DICT server
(global-set-key "\C-c\M-b" 'dictem-run-show-databases)

(define-key dictem-mode-map [tab] 'dictem-next-link)
(define-key dictem-mode-map [(backtab)] 'dictem-previous-link)
(define-key dictem-mode-map [return] 'dictem-run-search)

(setq
; dictem-server "dict.org"
 dictem-server "localhost"
 dictem-use-existing-buffer t)

(dictem-initialize)


;;;###autoload
(defun rgr/synonyms()
  (interactive)
  (let* ((default (region-or-word-at-point))
         (term (read-string (format "Synonyms for (%s): "
                                    default) default)))
    (dictem-run
     'dictem-base-search
     "moby-thes" term "exact")))

(define-key mode-specific-map [?S] 'rgr/synonyms)

(dictem-initialize)

(add-hook 'dictem-postprocess-match-hook
          'dictem-postprocess-match)

(add-hook 'dictem-postprocess-definition-hook 
          'dictem-postprocess-definition-separator)

(add-hook 'dictem-postprocess-definition-hook 
          'dictem-postprocess-definition-hyperlinks)

(add-hook 'dictem-postprocess-show-info-hook
          'dictem-postprocess-definition-hyperlinks)

(add-hook 'dictem-postprocess-definition-hook 
          'dictem-postprocess-each-definition)

(setq 
 ispell-use-framepop-p t
 ispell-dictionary "british"
 ispell-local-dictionary "british"
 ispell-silently-savep t
 ispell-parser 'tex
 flyspell-sort-corrections nil
 )

 (setq ispell-program-name "aspell")

(define-key flyspell-mode-map (kbd "C-+") 'flyspell-check-previous-highlighted-word)
(define-key flyspell-mode-map (kbd "C-#") 'flyspell-auto-correct-previous-word)
(define-key flyspell-mode-map (kbd "S-<f2>") 'ispell-word)
(define-key flyspell-mode-map (kbd "<f2>") 'flyspell-auto-correct-word)

(define-minor-mode babel-permanent-translation-mode "Bable translate notext")

(define-key mode-specific-map [?o] (lambda()(interactive)(if (babel-permanent-translation-mode) (add-hook 'post-command-hook 'rgr/context-babel nil t)(remove-hook 'post-command-hook 'rgr/context-babel))))

(setq babel-echo-area t)
(setq babel-preferred-from-language "German")
(setq babel-preferred-to-language "English")

(provide 'rgr-dict)

Using ERC for IRC chat rooms

;;;;;
;************************************************
; rgr-erc.el
;
; erc IRC client for emacs
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************
(require 'erc)
(require 'rgr-functions)


 (setq 
      erc-query-display (quote window-noselect)
      erc-hide-list (quote ("353" "JOIN" "KICK" "NICK" "PART" "QUIT" "MODE"))
      erc-track-exclude (quote ("324" "332" "333" "353" "329"))
      erc-join-buffer (quote bury)
      erc-kill-buffer-on-part t
      erc-kill-server-buffer-on-quit t
      erc-kill-queries-on-quit t
      erc-nick-uniquifier ">"
      erc-max-buffer-size 200000
      erc-truncate-buffer-on-save t
      erc-prompt-for-nickserv-password nil
      erc-server-reconnect-attempts t
      erc-autoaway-idle-seconds 600
      erc-autoaway-message "Timed out."
      erc-auto-discard-away t
      erc-modules (quote (completion stamp fill netsplit button match track smiley readonly networks ring autojoin noncommands irccontrols move-to-prompt menu highlight-nicknames))
      erc-prompt-for-password nil)

(erc-update-modules)(erc-match-mode 1)

 (add-hook 'window-configuration-change-hook 
           '(lambda ()
              (setq erc-fill-column (- (window-width) 2))))



(defun my-erc-nick-match (match-type nickuserhost message)
  (cond
   ((eq match-type 'current-nick)
    (if (eq (string-match (concat (erc-current-nick) ":") message) 0) (rgr/notify message)))))

(add-hook 'erc-text-matched-hook 'my-erc-nick-match)

(defvar erc-insert-post-hook)
(add-hook 'erc-insert-post-hook
          'erc-truncate-buffer)

;;;###autoload
(defun rgr/start-erc ()
  (interactive)
  (erc :server "richardriley.net"  :nick erc-nick :password erc-password :port 6667)
;;  (erc :server bitlbee-server :nick erc-nick :password erc-password :port 6667)
;;;   (erc :server gnome-irc-server :nick erc-nick :password erc-password)
 )


;;;###autoload
(defun erc-cmd-INFO (&rest ignore)
  (erc-send-message (format "Evaluate this using C-x C-e with cursor at closing bracket --> %s" (rgr/info-link))))
(defun erc-cmd-RGR (&rest ignore)
  (erc-send-message (format "nickserv ghost rgr %s" erc-password)))

;;(add-hook 'erc-mode-hook (lambda()(interactive)(speck-mode t)))

;;;###autoload
(define-minor-mode erc-h4x0r-mode
  "Toggle automatic usage of h4x0r code for everything you type in ERC.")

;;;###autoload
(defun erc-maybe-h4x0r (ignore)
  "Change the text to h4x0r code, if `erc-h4x0r-mode' is non-nil."
  (when erc-h4x0r-mode
    (with-temp-buffer
      (insert str)
      (erc-h4x0r)
      (setq str (buffer-string)))))

;;;###autoload
(defun erc-h4x0r ()
  "Transform the buffer into h4x0r cod
e."
  (interactive)
  (h4x0r-region (point-min) (point-max)))

(add-hook 'erc-mode-hook (lambda () (set (make-local-variable 'company-backends) '(company-dabbrev company-ispell))))

(provide 'rgr-erc)

Playing music with Emacs using EMMS and the Music Player Daemon (mpd)

I had been procrastinating for ages about controlling music/radio from Emacs and EMMS is not the most user friendly add on out there. But now its working! I use the EMMS mpd system to communicate with the mpd daemon outside of the Emacs process to play - so if I quit Emacs it continues. I can later restart Emacs and I can then reconnect to the daemon and continue with the same playlist. Andy Stewart has come up trumps with his excellent anything-emms extension. I bring up the "anything" interface and now it will instantly list any matching music tracks or albums. Also of interest is his emms-extension library which provide the handy function emms-play-matching which plays all songs matching a certain pattern. I dug around and have a nice mode line progress display now too. Au revoir big fat Amarok. Emacs comes up trumps once more.

;;;;;
;************************************************
; rgr-music.el
;
; Not for the first time Michael Olson config files came to the
; rescue. See this link for more details of the code I borrowed:-
; http://blog.mwolson.org/tech/olpc_as_a_car_audio_player_using_emacs__emms__and_musicpd.html
;
; music using emms in emacs but using a sound server daemon.
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************

;; Initialize
(require 'emms-setup)
(require 'emms-info)
(require 'emms-player-simple)
(require 'emms-player-mpd)
(require 'emms-source-file)
(require 'emms-player-mplayer)
(require 'emms-playing-time)
(require 'emms-playlist-mode)
(require 'emms-mode-line-icon)
(require 'emms-streams)
(require 'emms-stream-info)
(require 'emms-volume)

(require 'anything-emms)

(emms-all)

(setq emms-player-list '(
                         emms-player-mpd
                         emms-player-mplayer))

(add-to-list 'emms-info-functions 'emms-info-mpd)

(emms-player-set emms-player-mpd 'regex
                 "\\.ogg\\|\\.mp3\\|\\.wma\\|\\.ogm\\|\\.asf\\|\\.mkv\\|http://\\|mms://\\|\\.rmvb\\|\\.flac\\|\\.vob\\|\\.m4a\\|\\.ape\\|\\.mpc")
(emms-player-set emms-player-mplayer 'regex
                 "\\.wav\\|\\.pls+\\|\\.mpg\\|\\.mpeg\\|\\.wmv\\|\\.wma\\|\\.mov\\|\\.avi\\|\\.divx\\|\\.ogm\\|\\.asf\\|\\.mkv\\|.rm\\|\\.rmvb\\|\\.mp4|\\.rm")


(define-emms-combined-source all nil
  '((emms-source-directory "/home/shamrock/music/")))

(setq emms-source-file-default-directory "/home/shamrock/multimedia/")
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)

(setq emms-playlist-buffer-name "*Music*")
(setq emms-playlist-buffer "*Music*")

(setq emms-playlist-default-major-mode 'emms-playlist-mode)


;;;###autoload
(defun rgr/track-search()
  (interactive)
  (anything (list anything-c-source-emms-file anything-c-source-emms-directory anything-c-source-emms-playlist)  nil  "Video or even some music Sir? ")
)

(defadvice rgr/track-search (after rgr/track-search) (run-at-time "2 sec" nil 'emms-player-mpd-connect))


;;(add-hook 'emms-player-started-hook 'emms-player-mpd-connect)
(setq emms-show-format "EMMS is now playing : %s")

;; get list back from mpd for proper formatting
;; (defadvice emms-play-file (after emms-play-file activate)
;;     (emms-player-mpd-connect))

(setq emms-playing-time-display-short-p nil
      emms-lyrics-display-on-minibuffer t
      emms-lyrics-display-on-modeline nil)
(emms-lyrics 1)
(emms-lyrics-enable)

(emms-playing-time 1)
(emms-mode-line 1)

(require 'emms-extension)
(ad-unadvise 'emms-play-directory-tree)

(define-key mode-specific-map (kbd "e q") 'my-stop-player)
(define-key mode-specific-map (kbd "e e") 'my-start-player)

(define-key mode-specific-map (kbd "e D") 'emms-mode-line-toggle)

(define-key mode-specific-map (kbd "e R") 'my-emms-streams)

(define-key mode-specific-map (kbd "e c") 'emms-playlist-current-clear)

(define-key mode-specific-map (kbd "e d") (lambda() (interactive)(emms-play-dired)(my-start-player)))
(define-key mode-specific-map (kbd "e a") 'emms-add-dired)
(define-key mode-specific-map (kbd "e m") 'emms-play-matching)
(define-key mode-specific-map (kbd "e f") 'emms-add-find)
(define-key mode-specific-map (kbd "e b") 'emms-browser)
(define-key mode-specific-map (kbd "e s") 'emms-smart-browse)

(define-key mode-specific-map (kbd "e j") 'emms-seek)
(define-key mode-specific-map (kbd "e <right>") (lambda()(interactive)(emms-seek 30)))
(define-key mode-specific-map (kbd "e <left>") (lambda()(interactive)(emms-seek -15)))

(define-key mode-specific-map (kbd "e l") 'my-emms-switch-to-current-playlist)
(define-key mode-specific-map (kbd "e L") 'emms-play-playlist)

(define-key mode-specific-map (kbd "e n") 'emms-next)
(define-key mode-specific-map (kbd "e p") 'emms-previous)

(define-key mode-specific-map (kbd "e +") 'emms-volume-raise)
(define-key mode-specific-map (kbd "e -") 'emms-volume-lower)

(define-key mode-specific-map (kbd "e r") 'emms-random)

(define-key mode-specific-map (kbd "e <SPC>") 'emms-pause)

;; (setq emms-stream-default-list
;;       '(("NDR Info" "http://ndr.ic.llnwd.net/stream/ndr_ndrinfo_hi_mp3" 1 url)
;;      ("NDR Kultur" "http://ndr.ic.llnwd.net/stream/ndr_ndrkultur_hi_mp3" 1 url)
;;      ("BBC Radio 4" "mms://wmlive.bbc.net.uk/wms/bbc_ami/radio4/radio4_bb_live_int_eq1_sl0?BBC-UID=e44a970b22ffbda06a4e058b91802eba1c90682640d091dff269e685b0547800&SSO2-UID=" 1 url)
;;      ("BBC Radio 3" "mms://wmlive.bbc.net.uk/wms/bbc_ami/radio3/radio3_bb_live_int_eq1_sl0?BBC-UID=e44a970b22ffbda06a4e058b91802eba1c90682640d091dff269e685b0547800&SSO2-UID=" 1 url)
;;      ("BBC Radio 1" "mms://wmlive.bbc.net.uk/wms/bbc_ami/radio1/radio1_bb_live_int_eq1_sl0?BBC-UID=e44a970b22ffbda06a4e058b91802eba1c90682640d091dff269e685b0547800&SSO2-UID=" 1 url)
;;      ("BBC Radio 5" "mms://wmlive.bbc.net.uk/wms/bbc_ami/radio5/radio5_bb_live_int_eq1_sl0?BBC-UID=e44a970b22ffbda06a4e058b91802eba1c90682640d091dff269e685b0547800&SSO2-UID=" 1 url))
;;       )

(defun my-emms-info-track-description (track)
  "Return a description of the current track."
  (if (and (emms-track-get track 'info-artist)
           (emms-track-get track 'info-title))
      (let ((pmin (emms-track-get track 'info-playing-time-min))
            (psec (emms-track-get track 'info-playing-time-sec))
            (ptot (emms-track-get track 'info-playing-time))
            (art  (emms-track-get track 'info-artist))
            (tit  (emms-track-get track 'info-title)))
        (cond ((and pmin psec) (format "%s - %s " art tit ))
              (ptot (format  "%s - %s " art tit ))
              (t (emms-track-simple-description track))))))

(setq emms-track-description-function 'my-emms-info-track-description)

(defun my-start-player ()
  "Start MPD and sync to its playlistemms player."
  (interactive)
  (shell-command "mpd") ; uses default ~/.mpdconf
  (emms-player-mpd-connect)
  (switch-to-buffer emms-playlist-buffer)
  (global-set-key (kbd "<M-f1>")   'rgr/track-search)
)

(defun my-stop-player ()
  "Stop emms player."
  (interactive)
  (shell-command "mpd --kill")
  (emms-playlist-current-kill)
  (emms-player-mpd-disconnect))

;; Switch to the radio buffer
(defun my-emms-streams ()
  (interactive)
  (let ((buf (get-buffer emms-stream-buffer-name)))
    (if buf
        (switch-to-buffer buf)
      (emms-streams))))

;; Switch to either the radio buffer or the current EMMS playlist
(defun my-emms-switch-to-current-playlist ()
  (interactive)
  (if (and (boundp 'emms-stream-playlist-buffer)
           (eq emms-stream-playlist-buffer emms-playlist-buffer))
      (switch-to-buffer emms-stream-buffer-name)
    (if (or (null emms-playlist-buffer)
            (not (buffer-live-p emms-playlist-buffer)))
        (error "No current Emms buffer")
      (switch-to-buffer emms-playlist-buffer))))

(setq
 emms-directory  "/home/shamrock/.emacs.d/emms"
 emms-cache-file "/home/shamrock/.emacs.d/.emms-cache"
 emms-info-asynchronously t
 emms-player-mpd-music-directory "/home/shamrock/multimedia/"
 emms-player-mplayer-music-directory "/home/shamrock/multimedia/"
 emms-playlist-default-major-mode (quote emms-playlist-mode)
 emms-playlist-mode-open-playlists t
 emms-stream-default-action "play")

(provide 'rgr-music)

Using "Anything"

Anything is an interesting development. A one key link to pretty much, well, anything. I use it primarily for man pages, bbdb entries and now EMMS track/album selection. See my keybindings file for the autoload. You wont see the emms sources in this config file as they are added only if and when I start up the emms services. See Playing Music above.

;;;;;;;;;;;
;************************************************
; rgr-anything.el
;
; Anything configuration
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************

(require 'anything-config)
(require 'anything-extension)
(require 'anything-etags)
(require 'anything-auto-install)
(require 'anything-emms)
(require 'anything-complete)


(setq ipa-file "~/.emacs.d/.ipa")
(require 'anything-ipa)


(setq anything-sources
      (list
       anything-c-source-bookmark-files&dirs
       anything-c-source-buffers+
       anything-c-source-file-name-history
       anything-c-source-info-pages
       anything-c-source-man-pages
       anything-c-source-info-elisp
       anything-c-source-emacs-commands
       anything-c-source-locate
       anything-c-source-w3m-bookmarks
       anything-c-source-bbdb
       anything-c-source-ipa-global
       anything-c-source-kill-ring
       anything-c-source-org-headline
       anything-c-source-occur
       anything-c-source-ctags
       anything-c-source-emms-streams
       )
      anything-idle-delay 0.2
      anything-samewindow t
      anything-input-idle-delay 0.2
      anything-candidate-number-limit 10)


(defun anything-kill-ring-only ()
  (interactive)
  (anything 'anything-c-source-kill-ring))

(defun anything-show-org-only ()
  (interactive)
  (anything-set-source-filter '("Org HeadLine")))

(defun anything-show-ipa-only ()
  (interactive)
  (anything-set-source-filter '("In Place Annotations (global)")))

(defun anything-tv-show-kill-ring-only ()
  (interactive)
  (anything-set-source-filter '("Kill Ring")))

(defun anything-tv-show-music-only ()
  (interactive)
  (anything-set-source-filter '("EMMS Directory"
                                "Emms Streams")))

(defun anything-tv-show-google-only ()
  (interactive)
  (anything-set-source-filter '("Google Suggest")))

(defun anything-tv-show-bookmarks-only ()
  (interactive)
  (anything-set-source-filter '("W3m Bookmarks"
                                "Bookmark Files&Directories"
                                )))


(defun anything-tv-show-all ()
  (interactive)
  (anything-set-source-filter nil))

(defun anything-tv-show-info-only ()
  (interactive)
  (anything-set-source-filter '("Info Pages"
                                "Info Elisp"
                                "Info Common-Lisp")))

(defun anything-tv-show-man-only ()
  (interactive)
  (anything-set-source-filter '("Manual Pages")))

(defun anything-tv-show-files-only ()
  (interactive)
  (anything-set-source-filter '("File Name History"
                                "Files from Current Directory"
                                "Recentf"
                                "Locate")))

(when anything-c-use-standard-keys
  (setq anything-map
        (let ((map (copy-keymap minibuffer-local-map)))
          (define-key map (kbd "<down>") 'anything-next-line)
          (define-key map (kbd "<up>") 'anything-previous-line)
          (define-key map (kbd "C-n")     'anything-next-line)
          (define-key map (kbd "C-p")     'anything-previous-line)
          (define-key map (kbd "<prior>") 'anything-previous-page)
          (define-key map (kbd "<next>") 'anything-next-page)
          (define-key map (kbd "M-v")     'anything-previous-page)
          (define-key map (kbd "C-v")     'anything-next-page)
          (define-key map (kbd "<right>") 'anything-next-source)
          (define-key map (kbd "<left>") 'anything-previous-source)
          (define-key map (kbd "<RET>") 'anything-exit-minibuffer)
          (define-key map (kbd "C-1") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-2") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-3") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-4") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-5") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-6") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-7") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-8") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "C-9") 'anything-select-with-digit-shortcut)
          (define-key map (kbd "<tab>")   'anything-select-action)
          (define-key map (kbd "C-b") 'anything-tv-show-bbdb-only)
          (define-key map (kbd "C-i") 'anything-tv-show-info-only)
          (define-key map (kbd "C-z") 'anything-execute-persistent-action)
          (define-key map (kbd "C-k") 'anything-delete-minibuffer-content)
          (define-key map (kbd "C-o") 'anything-next-source)
          (define-key map (kbd "<C-M-up>")  'anything-scroll-other-window)
          (define-key map (kbd "<C-M-down>")  'anything-scroll-other-window-down)
          (define-key map (kbd "C-SPC") 'anything-toggle-visible-mark)
          (define-key map (kbd "M-[") 'anything-prev-visible-mark)
          (define-key map (kbd "M-]") 'anything-next-visible-mark)

          (define-key map (kbd "C-s") 'anything-isearch)
          (define-key map (kbd "C-r") 'undefined)
          (define-key map (kbd "C-x C-f") 'anything-quit-and-find-file)
          (define-key map (kbd "C-c C-f") 'anything-follow-mode)
          (define-key map (kbd "C-c C-d") 'anything-delete-current-selection)
          (define-key map (kbd "C-c C-y") 'anything-yank-selection)
          (define-key map (kbd "C-c C-k") 'anything-kill-selection-and-quit)

          ;; the defalias is needed because commands are bound by name when
          ;; using iswitchb, so only commands having the prefix anything-
          ;; get rebound
          (defalias 'anything-previous-history-element 'previous-history-element)
          (defalias 'anything-next-history-element 'next-history-element)
          (define-key map (kbd "M-p") 'anything-previous-history-element)
          (define-key map (kbd "M-n") 'anything-next-history-element)
          map))

  (setq anything-isearch-map
        (let ((map (copy-keymap (current-global-map))))
          (define-key map (kbd "<return>")    'anything-isearch-default-action)
          (define-key map (kbd "<tab>")       'anything-isearch-select-action)
          (define-key map (kbd "C-g")         'anything-isearch-cancel)
          (define-key map (kbd "C-s")         'anything-isearch-again)
          (define-key map (kbd "C-r")         'undefined)
          (define-key map (kbd "<backspace>") 'anything-isearch-delete)
          ;; add printing chars
          (let ((i ?\s))
            (while (< i 256)
              (define-key map (vector i) 'anything-isearch-printing-char)
              (setq i (1+ i))))
          map)))

(global-set-key (kbd "C-M-y") 'anything-kill-ring-only)
(define-key anything-map "A" 'anything-tv-show-all)

(define-key anything-map "E" 'anything-tv-show-music-only)
(define-key anything-map "I" 'anything-tv-show-info-only)
(define-key anything-map "F" 'anything-tv-show-files-only)
(define-key anything-map "K" 'anything-tv-show-kill-ring-only)
(define-key anything-map "M" 'anything-tv-show-man-only)
(define-key anything-map "G" 'anything-tv-show-google-only)
(define-key anything-map "C" 'anything-show-ipa-only)
(define-key anything-map "B" 'anything-tv-show-bookmarks-only)
(define-key anything-map "O" 'anything-show-org-only)
(define-key anything-map "F" 'anything-for-files)


(provide 'rgr-anything)

Key Bindings

;;;;;
;************************************************
; rgr-keybindings.el
;
; various key binding file.
; Richard Riley.
; http://richardriley.net/default/projects/emacs/
;************************************************

(define-key w3m-mode-map [down] 'next-line)
(define-key w3m-mode-map [up] 'previous-line)
(define-key w3m-mode-map [right] 'forward-char)
(define-key w3m-mode-map [left] 'backward-char)
;;(define-key w3m-mode-map [?q] (lambda()(interactive)(delete-frame)))
(define-key w3m-mode-map [?f] 'jao-w3m-go-to-linknum)



(global-set-key (kbd "<f2>") 'other-window)
(global-set-key (kbd "<f6>") 'delete-frame)
(global-set-key (kbd "<f12>") 'eshell)
(global-set-key (kbd "<f11>") 'next-error)
(global-set-key [(f9)] 'menu-bar-open)

(global-set-key (kbd "<f5>") (lambda()(interactive)(rgr/context-babel t)))
(global-set-key (kbd "C-<f5>") (lambda()(interactive)(rgr/context-babel)))

(global-set-key (kbd "M-<f5>") 'rgr/toggle-languages)

(global-set-key (kbd "<home>") 'beginning-of-line)

; google keys and url keys
; prefix (ctl-u) to use external browser.
(global-set-key (kbd "<f4>") 'rgr/browse-url)
(global-set-key (kbd "<f3>") 'rgr/google-search-prompt)
;; (global-set-key (kbd "M-<f3>") 'browse-apropos-url)
;; (global-set-key (kbd "C-S-<f3>") 'w3m-search-emacswiki)

(require 'ipa)
(setq ipa-file "~/.emacs.d/.ipa")
(define-key mode-specific-map [?A] 'ipa-insert) 
(define-key mode-specific-map [?E] 'ipa-edit) 
(define-key mode-specific-map [?T] 'ipa-toggle) 
(define-key mode-specific-map [?b] 'gblogger-blog)
(define-key mode-specific-map [?B] 'rgr/blog)

(define-key mode-specific-map [?c] 'calendar)
(define-key mode-specific-map [?C] 'ediff-revision)
(define-key mode-specific-map [?D] 'epa-decrypt-region)

(define-key mode-specific-map [?f] 'describe-face)
(global-set-key (kbd "C-c h") 'rgr/toggle-context-help)
(define-key mode-specific-map [?g] 'magit-status)
(define-key mode-specific-map [?F] (lambda()(interactive)(rgr/fortune (mark) (point) "/home/shamrock/.emacs.d/.sigs/fortunes")))
(define-key mode-specific-map [?i] 'rgr/start-erc)
(define-key mode-specific-map [?I] (lambda()(interactive)(ido-buffer-internal ido-default-buffer-method nil nil nil "#")))

(define-key mode-specific-map [?l] 'rgr/lock-screen)
(define-key mode-specific-map [?L] 'paste2-buffer-create)
(define-key mode-specific-map [?m] 'gnus)
(define-key mode-specific-map [?M] (lambda ()(interactive)(message "Start getmails")(start-process-shell-command "GetMails" "*Messages*" "/home/shamrock/bin/getmails") ))

(define-key mode-specific-map [?O] 'rgr/toggle-always-on-top)
(define-key mode-specific-map [?p] 'pr-ps-buffer-preview)
(define-key mode-specific-map [?P] 'ps-print-buffer)
(define-key mode-specific-map [?R] 'greader-reading-list)
(define-key mode-specific-map [?q] 'boxquote-region)
(define-key mode-specific-map [?Q] 'sql-mysql)
(define-key mode-specific-map [?S] 'apt-utils-search)

(define-key mode-specific-map [?t] 'twit)

(define-key mode-specific-map [?u] 'w3m-browse-url)

(define-key mode-specific-map [?v] 'volume)

(define-key mode-specific-map [?w] 'xml-weather-today-favorite)
(define-key mode-specific-map [?W] 'w3m-bookmark-view)

(global-set-key (kbd "C-x C-r") 'find-alternative-file-with-sudo)

(global-set-key (kbd "C-h a") 'apropos)
(global-set-key (kbd "C-x D") 'dired-jump)

;; (global-set-key (kbd "<f1>")   '(lambda()(interactive)(anything  anything-sources (region-or-word-at-point) "Yes Mlud? ")))
(global-set-key (kbd "<f1>")   '(lambda()(interactive)(company-mode 0)(anything  anything-sources nil "Yes Mlud? ")))

(global-set-key (kbd "M-<f1>")   'anything-for-files)


(global-set-key (kbd "S-<f1>") 'devhelp-word-at-point)
(global-set-key (kbd "C-<f1>") 'elisp-index-search)

(define-key emacs-lisp-mode-map
  (kbd "C-c C-b") (lambda()(interactive)(rgr/byte-compile-file)))
(define-key emacs-lisp-mode-map
  (kbd "<f11>") 'next-error)
(define-key emacs-lisp-mode-map
  (kbd "M-+") 'pop-tag-mark)
(define-key emacs-lisp-mode-map
  (kbd "<f11>") 'next-error)


;X Windows focus
(when window-system
  (define-key mode-specific-map [?O] 'rgr/toggle-always-on-top)
  (add-hook 'speedbar-after-create-hook 'rgr/toggle-always-on-top)
)

(autoload 'bm-toggle   "bm" "Toggle bookmark in current buffer." t)
(autoload 'bm-next     "bm" "Goto bookmark."                     t)
(autoload 'bm-previous "bm" "Goto previous bookmark."            t)
(global-set-key (kbd "<f8>")   'bm-next)
(global-set-key (kbd "<M-f8>") 'bm-previous)
(global-set-key (kbd "<C-f8>") 'bm-toggle)
(setq-default bm-buffer-persistence t)

(setq  grep-command "grep -niH -e ")
(global-set-key (kbd "C-<f3>") 'lgrep)
(global-set-key (kbd "C-S-<f3>") 'grep)

(provide 'rgr-keybindings)

Date: 2009-11-30 19:25:43 CET

HTML generated by org-mode 6.33trans in emacs 23

Hosted On Debian LinuxServed Using Apache2