최근 편집
요약: updates...
변경됨:
< ;; Currently for GNU Emacs 23.1.50.1 (i386-mingw-nt5.1.2600) of 2009-11-04 on LENNART-69DE564 (patched)
< ;; ╭∩╮⎝⏠_⏠⎠╭∩╮
(으)로
> ;; Currently for GNU Emacs 24.2.1 (i386-mingw-nt5.1.2600) of 2012-08-29 on MARVIN
변경됨:
< (setq sql-user "ci" sql-password "cipw" sql-database "BSICRM.VD_5164")
(으)로
> (setq sql-user "pista" sql-password "pista" sql-database "PISTA_11")
> ;; (setq sql-user "ci" sql-password "cipw" sql-database "BSICRM.VD_5164")
삭제됨:
< (eval-after-load 'eshell
< '(require 'eshell-autojump nil t))
변경됨:
< (eval-after-load 'rcirc '(require 'rcirc-color))
< (eval-after-load 'rcirc '(require 'rcirc-controls))
(으)로
> (eval-after-load 'rcirc '(require 'rcirc-color nil t))
> (eval-after-load 'rcirc '(require 'rcirc-controls nil t))
;;; .emacs for Alex Schroeder's machine at work -*- coding: utf-8 -*- ;; Copy to the following URL from time to time: ;; http://www.emacswiki.org/cgi-bin/wiki?action=edit;id=AlexSchroederConfigWindows ;; This is free software. ;; Currently for GNU Emacs 24.2.1 (i386-mingw-nt5.1.2600) of 2012-08-29 on MARVIN ;; ▇█▓▒░◕~◕░▒▓█▇ (require 'cl) (add-to-list 'load-path (expand-file-name "elisp" (getenv "HOME"))) (add-to-list 'exec-path "C:/Programme/cygwin/bin") (add-to-list 'exec-path "C:/Programme/GnuWin32/bin") (add-to-list 'exec-path "C:/Programme/Growl for Windows") (setenv "RSH" "SSH") (let (seen) (dolist (path (mapcar 'file-truename (append exec-path (split-string (getenv "PATH") ";" t)))) (when (and (file-exists-p path) (not (member path seen))) (setq seen (cons path seen)))) (setenv "PATH" (mapconcat 'identity (nreverse seen) ";" ))) (setenv "CYGWIN" "nodosfilewarning") (prefer-coding-system 'utf-8) (setq default-file-name-coding-system 'cp1252) (setenv "CVS_RSH" "ssh") (setenv "WikiDataDir" "test-data") (setq visible-bell t) (setq mouse-drag-copy-region t) ;; (set-face-attribute 'default nil :family "Garamond" :height 140) (set-face-attribute 'default nil :family "Consolas" :height 110) ;; Tramp ;; Download http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ;; Docs http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html#plink (setq tramp-auto-save-directory (getenv "TEMP")) (setq tramp-default-method "plink") ;;; pink-bliss color-theme ; (autoload 'pink-bliss "pink-bliss" "Feeling funny today?" t) ; (require 'pink-bliss) ; (pink-bliss) ;; minor modes (show-paren-mode 1) (tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) (blink-cursor-mode -1) (winner-mode 1) (windmove-default-keybindings) (column-number-mode 1) (savehist-mode 1) (when (fboundp 'mac-print-mode) (mac-print-mode 1) (global-set-key (kbd "M-p") 'mac-print-buffer)) (require 'generic-x) (setq vc-follow-symlinks t read-quoted-char-radix 10) ;; Less glaring face for minibuffer prompts. ;; (set-face-foreground 'minibuffer-noticeable-prompt "purple") ;; (set-face-background 'minibuffer-noticeable-prompt nil) (global-set-key (kbd "C-c i") 'indent-region) (global-set-key (kbd "C-c c") 'comment-region) (global-set-key (kbd "C-c s") 'ispell-word) (global-set-key (kbd "C-c n") (lambda () (interactive) (find-file "~/NOTES"))) (global-set-key (kbd "C-h a") 'apropos) (global-set-key (kbd "C-c r") 'replace-word-at-point) (global-set-key (kbd "C-x 8 1 / 3") "⅓") (global-set-key (kbd "C-x 8 1 / 5") "⅕") (global-set-key (kbd "C-x 8 1 / 6") "⅙") (global-set-key (kbd "C-x 8 2 / 3") "⅔") (global-set-key (kbd "C-x 8 2 / 5") "⅖") (global-set-key (kbd "C-x 8 3 / 5") "⅗") (global-set-key (kbd "C-x 8 4 / 5") "⅘") (global-set-key (kbd "C-x 8 5 / 6") "⅚") (autoload 'word-at-point "thingatpt" nil t) (defun replace-word-at-point (from to) "Replace word at point." (interactive (let ((from (word-at-point))) (list from (query-replace-read-to from "Replace" nil)))) (query-replace from to)) ;; printing PDF (setq ps-printer-name "\\\\fileserver03\\PDF_FOR_ALL" ps-spool-duplex t ps-print-header nil ps-use-face-background t) ;; iswitchb (iswitchb-mode 1) ;; FIXME: This doesn't seem to work. Grr. ;; (add-hook 'iswitchb-mode-hook 'iswitchb-my-keys) ;; (defun iswitchb-my-keys () ;; "Add my keybindings for iswitchb." ;; (define-key iswitchb-mode-map (kbd "C-m") 'my-bs-show)) ;; (defun my-bs-show () ;; "Run `bs-show' for the buffers currently shown by `iswitchb'." ;; (interactive) ;; (exit-minibuffer) ;; (message iswitchb-common-match-string)) ;;; bs instead of buffer-menu (global-set-key (kbd "C-x C-b") 'bs-show) (defvar sqlplus-connect-string nil) (setq bs-configurations '(("all" nil nil nil nil nil) ("files" nil nil nil bs-visits-non-file bs-sort-buffer-interns-are-last) ("dired" nil nil nil (lambda (buf) (with-current-buffer buf (not (eq major-mode 'dired-mode)))) nil) ("sql" nil nil nil (lambda (buf) (with-current-buffer buf (and (not (memq major-mode '(sql-mode sql-interactive-mode sqlplus-mode))) ;; plsql-mode (not sqlplus-connect-string)))) nil) ("java" nil nil nil (lambda (buf) (with-current-buffer buf (not (or (eq major-mode 'java-mode))))) nil) ("rcirc" nil nil nil (lambda (buf) (with-current-buffer buf (not (eq major-mode 'rcirc-mode)))) rcirc-sort-buffers))) (defun rcirc-sort-name (buf) "Return server process and buffer name as a string." (with-current-buffer buf (downcase (concat (if rcirc-server-buffer (buffer-name rcirc-server-buffer) " ") " " (or (and rcirc-target (replace-regexp-in-string "^#+" "" rcirc-target)) ""))))) (defun rcirc-sort-buffers (a b) "Sort buffers A and B using `rcirc-sort-name'." (string< (rcirc-sort-name a) (rcirc-sort-name b))) ;;; elpoint, ept (add-to-list 'auto-mode-alist '("\\.ept\\'" . ept-mode)) ;;; Apache (define-generic-mode 'htaccess-mode '(?#) '( ;; core "AcceptPathInfo" "AccessFileName" "AddDefaultCharset" "AddOutputFilterByType" "AllowEncodedSlashes" "AllowOverride" "AuthName" "AuthType" "CGIMapExtension" "ContentDigest" "DefaultType" "DocumentRoot" "EnableMMAP" "EnableSendfile" "ErrorDocument" "ErrorLog" "FileETag" "ForceType" "HostnameLookups" "IdentityCheck" "Include" "KeepAlive" "KeepAliveTimeout" "LimitInternalRecursion" "LimitRequestBody" "LimitRequestFields" "LimitRequestFieldSize" "LimitRequestLine" "LimitXMLRequestBody" "LogLevel" "MaxKeepAliveRequests" "NameVirtualHost" "Options" "Require" "RLimitCPU" "RLimitMEM" "RLimitNPROC" "Satisfy" "ScriptInterpreterSource" "ServerAdmin" "ServerAlias" "ServerName" "ServerPath" "ServerRoot" "ServerSignature" "ServerTokens" "SetHandler" "SetInputFilter" "SetOutputFilter" "TimeOut" "UseCanonicalName" ;; .htaccess tutorial "AddHandler" "AuthUserFile" "AuthGroupFile" ;; mod_rewrite "RewriteBase" "RewriteCond" "RewriteEngine" "RewriteLock" "RewriteLog" "RewriteLogLevel" "RewriteMap" "RewriteOptions" "RewriteRule" ;; mod_alias "Alias" "AliasMatch" "Redirect" "RedirectMatch" "RedirectPermanent" "RedirectTemp" "ScriptAlias" "ScriptAliasMatch") '(("%{\\([A-Z_]+\\)}" 1 font-lock-variable-name-face) ("\\b[0-9][0-9][0-9]\\b" . font-lock-constant-face) ("\\[.*\\]" . font-lock-type-face)) '(".htaccess\\'") nil "Generic mode for Apache .htaccess files.") ;;; ASCII table (autoload 'ascii-table "ascii-table" nil t) ;;; INCR (autoload 'incr-dwim "incr" nil t) ;;; svn (autoload 'svn-status "psvn" nil t) ;;; XML (defun print-xml-tree (node-list element attribute &optional depth) "Walk DOCUMENT, printing ATTRIBUTE of each ELEMENT. Indent by DEPTH, if required" (setq depth (or depth 0)) (when (listp node-list) (dolist (node node-list) (when (listp node) (when (string= (xml-node-name node) element) (insert (make-string (* 2 depth) ?\ ) (xml-get-attribute node attribute) "\n")) (print-xml-tree (xml-node-children node) element attribute (+ depth 2)))))) ;; Example use: ;; (print-xml-tree (xml-parse-file "~/Desktop/Produktionsstruktur.xml") "AdClass" 'name) ;; (defun scout-tree () ;; (interactive) ;; (save-excursion ;; (let ((here (point)) ;; (indent 0) ;; (ids nil) ;; (path nil)) ;; (search-backward "<view") ;; (while (re-search-forward "^\\( *\\)<outline_text\\b.*\\blabel=\"\\([^\"]*\\)" here t) ;; (if (> (length (match-string 1)) indent) ;; (setq indent (length (match-string 1)) ;; ids (cons (match-string 2) ids)) ;; (when (= (length (match-string 1)) indent) ;; (setcar ids (match-string 2))))) ;; (dolist (id ids) ;; (goto-char (point-min)) ;; (when (re-search-forward (concat "<text id=\"" id "\" [^>]*>\\([^<]*\\)")) ;; (setq path (cons (match-string 1) path)))) ;; (message (mapconcat 'identity path " - "))))) ;;; Java ;; coworkers use TAB to indent code (add-hook 'java-mode-hook (lambda () (setq c-basic-offset 2 tab-width 8 indent-tabs-mode t))) ;;; sql (autoload 'sqlplus "sqlplus" nil t) (autoload 'sqlplus-mode "sqlplus" nil t) ;; (dolist (item '(("\\.sqp\\'" . sqlplus-mode) ;; ("\\.sql\\'" . sqlplus-mode))) ;; (add-to-list 'auto-mode-alist item)) ;; (autoload 'plsql-mode "plsql" nil t) ;; (dolist (item '(("\\.pls\\'" . plsql-mode) ("\\.pkg\\'" . plsql-mode) ;; ("\\.pks\\'" . plsql-mode) ("\\.pkb\\'" . plsql-mode) ;; ("\\.prc\\'" . plsql-mode) ("\\.fnc\\'" . plsql-mode) ;; ("\\.trg\\'" . plsql-mode) ("\\.vw\\'" . plsql-mode))) ;; ("\\.sql\\'" . plsql-mode) ;; (add-to-list 'auto-mode-alist item)) ;; (global-set-key (kbd "C-c q") 'sqlplus) (add-hook 'sqlplus-mode-hook (lambda () (local-set-key (kbd "C-z") 'bury-buffer) (set-process-coding-system (get-process (sqlplus-get-process-name sqlplus-connect-string)) 'latin-1 'latin-1))) ;; (add-hook 'plsql-mode-hook ;; (lambda () ;; (setq indent-tabs-mode nil) ;; (local-set-key (kbd "<C-return>") 'sqlplus-send-current))) ;; (add-hook 'sql-mode-hook (lambda () ;; (setq c-basic-offset 3 ;; tab-width 3 ;; indent-tabs-mode nil) ;; (local-set-key (kbd "C-c w") 'sql-copy-word))) ;; (defun sql-copy-word () ;; "Copy current word to the end of the buffer." ;; (interactive) ;; (save-excursion ;; (let ((sym (symbol-at-point))) ;; (goto-char (point-max)) ;; (insert sym ", ")))) (global-set-key (kbd "C-c q") 'sql-oracle) (setq sql-user "pista" sql-password "pista" sql-database "PISTA_11") ;; (setq sql-user "ci" sql-password "cipw" sql-database "BSICRM.VD_5164") ;; (setenv "NLS_LANG" "AMERICAN_AMERICA.UTF8") ;; (add-to-list 'process-coding-system-alist '("SQL" . utf-8));; no effect? (setq sql-input-ring-file-name "~/.sql_history" sql-product 'oracle comint-input-ring-size 500) (add-to-list 'auto-mode-alist '("\\.pls\\'" . sql-mode)) (add-to-list 'auto-mode-alist '("\\.pkb\\'" . sql-mode)) (add-to-list 'auto-mode-alist '("\\.pkg\\'" . sql-mode)) (define-skeleton ors-uc "Insert ORS_UTIL.GET_USER_CODE(UID, LANGUAGE_ID)." nil "substr(ors_util.get_user_code(" _ ", 246), 0, 30) \"code\"") (define-abbrev-table 'sql-mode-abbrev-table nil) (define-abbrev sql-mode-abbrev-table "orsuc" "" 'ors-uc) (add-hook 'sql-mode-hook (lambda () (setq indent-tabs-mode nil) (abbrev-mode 1) (local-set-key (kbd "C-z") 'sql-oracle) (local-set-key (kbd "C-c n") 'my-insert-next-key) (local-set-key (kbd "C-c C-c") 'sql-send-modified-paragraph) (local-set-key (kbd "C-c C-d") 'sql-oracle-describe) (local-set-key (kbd "<C-return>") 'sql-send-modified-paragraph))) (add-hook 'sql-interactive-mode-hook (lambda () (local-set-key (kbd "C-z") 'bury-buffer) (abbrev-mode 1) (set-process-coding-system (get-buffer-process sql-buffer) 'latin-1 'latin-1))) (add-hook 'sql-interactive-mode-hook 'my-sql-set-buffer) (defun my-sql-quote (start end) (interactive "r") (setq end (copy-marker end)) (goto-char end) (insert "'") (goto-char start) (save-excursion (while (re-search-forward "[0-9][0-9]+" end t) (replace-match "?"))) (save-excursion (while (search-forward "'" end t) (replace-match "''"))) (save-excursion (while (search-forward "\n" end t) (replace-match "'\n||' "))) (insert "'")) (defun my-sql-quote-for-java (start end) (interactive "r") (setq end (copy-marker end)) (goto-char end) (insert "\"") (set-mark (point)) (goto-char start) (save-excursion (while (search-forward "\n" end t) (replace-match " \" +\n\""))) (insert "\"") (forward-char -1) (untabify start end)) (defun my-code-quote-for-java (start end) (interactive "r") (setq end (copy-marker end)) (goto-char end) (insert "\"") (goto-char start) (save-excursion (while (search-forward "\"" end t) (replace-match "\\\\\""))) (save-excursion (while (search-forward "\n" end t) (replace-match "\\\\n\" +\n\""))) (insert "\"") (untabify start end)) (defun my-sql-set-buffer () "Sets the SQLi buffer for all unconnected SQL buffers. Called from `sql-interactive-mode-hook'." (let ((new-buffer (current-buffer))) (dolist (buf (buffer-list)) (with-current-buffer buf (unless (buffer-live-p sql-buffer) (setq sql-buffer new-buffer) (run-hooks 'sql-set-sqli-hook)))))) (defcustom sql-replacements '(("#W#" . "")) "Replacements to do." :type 'alist) (defun sql-send-modified-paragraph (reset) "Send paragraph and replace all variables using `sql-replacments'. If the optional argument RESET is given, reset `sql-replacments' to nil and ask for all the replacements again." (interactive "P") (when reset (setq sql-replacements nil)) (unless sql-buffer (sql-oracle) (sit-for 3)) (let ((str (buffer-substring-no-properties (save-excursion (backward-paragraph) (point)) (save-excursion (forward-paragraph) (point))))) (with-temp-buffer (insert str) (goto-char (point-min)) (while (re-search-forward "\\(:[a-zA-Z0-9_.]+\\|\\(#\\w+#\\)\\|\\(@@[a-zA-Z0-9_.]+@@\\)\\|<eval>.*</eval>\\|\\?\\)" nil t) (let* ((key (match-string 0)) (val (cdr (assoc key sql-replacements)))) (when (not val) (setq val (read-string (format "Replacement for %s: " key)) sql-replacements (cons (cons key val) sql-replacements))) (replace-match val))) (setq str (buffer-string))) (save-excursion (pop-to-buffer sql-buffer) (goto-char (point-max)) (recenter -1)) (sql-send-string str))) (defun sql-oracle-describe (word) "Describe object at point." (interactive (list (let ((sym (symbol-at-point))) (if sym (symbol-name sym) (read-string "Object name: "))))) (sql-send-string (concat "DESC " word))) (defun sql-replacement-delete (key) "Remove KEY from `sql-replacements'." (interactive (list (completing-read (if sql-replacements (concat "Key (" (car (car sql-replacements)) "): ") (concat "Key: ")) sql-replacements))) (when (string= key "") (setq key (car (car sql-replacements)))) (setq sql-replacements (delete (assoc key sql-replacements) sql-replacements))) (defun sql-generate-uc (id type num &rest data) "Generate INSERT statements for ORS_UC and ORS_UCL." (interactive "nFirst Id: \nnType: \nnHow many: ") (dotimes (i num) (insert "INSERT INTO ORS_UC (UC_UID, PARTITION_UID, CODE_TYPE, ACTIVE, PROTECTED, PARENT_UID)\n" "VALUES (" (number-to-string (+ id i)) ", 0, " (number-to-string type) ", 1, 0, 0);\n" "\n" "INSERT INTO ORS_UCL (UC_UID, LANGUAGE_UID, CODE_NAME)\n" "VALUES (" (number-to-string (+ id i)) ", 1303, '" (or (car data) "") "');\n" "\n") (setq data (cdr data)))) ;; (sql-generate-uc 999701 999700 3 "Test" "Foo") (defun sql-generate-uc-region (id type start end) "Generate INSERT statements for ORS_UC and ORS_UCL. Use the region as input, one line per UC." (interactive "nFirst Id: \nnType: \nr") (let ((data (split-string (buffer-substring start end) "\n" t))) (delete-region start end) (apply 'sql-generate-uc id type (length data) data))) (defun sql-generate-person-region (id company nr start end) "Generate INSERT statements for the persons in the region. Each line consists of a lastname, a tab, and a firstname." (interactive "nFirst Id: \nsCompany Name: \nsCompany Nr: \nr") (let ((data (buffer-substring start end))) (delete-region start end) (dolist (person (split-string data "\n" t)) (destructuring-bind (lastname firstname) (split-string person "\t") (insert "-- " firstname " " lastname "\n" "\n" "INSERT INTO ORS_PERSON(PERSON_NR, FUNCTION_TYPE_UID, PERSON_TYPE, INTERN, DISPLAY_NAME, COMPANY_NR,\n" " FIRST_NAME, LAST_NAME, ACTIVE, LANGUAGE_UID, NO_MAILING, SALUTATION_UID, CIVIL_STATUS_UID, NATIONALITY_UID)\n" "VALUES(" (number-to-string id) ", 0, 1, 0, '" lastname ", " firstname " (" company ")', " nr ",\n" " '" firstname "', '" lastname "', 1, 1303, 0, 0, 0, 0);\n" "\n" "INSERT INTO ORS_PERSON_ADDRESS(PERSON_NR, TYPE_UID, ADDRESS_NR, COMP_TYPE_UID)\n" "VALUES(" (number-to-string id) ", 2469, 999500, 2315);\n" "\n") (incf id))))) ;; (let ((start (point))) (insert "foo\nbar\n") (sql-generate-uc-region 999601 999600 start (point))) (defun my-highest-key () "Find highest PK in buffer" (save-excursion (goto-char (point-min)) (let ((max 0) n) (while (re-search-forward "\\bvalues\\s-*(\\([0-9]+\\)" nil t) (setq n (string-to-number (match-string 1))) (when (> n max) (setq max n))) max))) (defun my-insert-next-key () "Insert highest PK + 1" (interactive) (insert (number-to-string (1+ (my-highest-key))))) ;;; session management, optional (when (require 'session nil t) (add-hook 'after-init-hook 'session-initialize) (add-to-list 'session-globals-exclude 'org-mark-ring) (add-to-list 'session-locals-include 'buffer-undo-list)) ;;; css mode (autoload 'css-mode "css-mode" nil t) (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode)) ;;; dired mode (require 'dired-x) (setq dired-recursive-deletes 'top dired-recursive-copies 'top dired-dwim-target t dired-guess-shell-alist-user '(("\\.pdf$" "start"))) (defface dired-pdf-face '((t (:foreground "firebrick"))) "PDF files") (add-hook 'dired-mode-hook (lambda () (local-set-key (kbd "M-<down>") (lambda () (interactive) (dired-do-shell-command "start" nil (dired-get-marked-files t current-prefix-arg)))) (font-lock-add-keywords nil '(("^ .*\\.pdf$" (".+" (dired-move-to-filename) nil (0 'dired-pdf-face))))))) (add-hook 'sgml-mode-hook (lambda () (local-set-key (kbd "C-c t") 'sgml-tag))) (setq sentence-end-double-space nil) (dolist (hook '(emacs-lisp-mode-hook lisp-mode-hook rcirc-mode change-log-mode texinfo-mode-hook)) (add-hook hook (lambda () (eldoc-mode 1) (set (make-local-variable 'sentence-end-double-space) t)))) (defun highlight-fixme () (font-lock-add-keywords nil'(("\\<\\(FIXME!?\\)" 1 font-lock-warning-face prepend)))) (defface whitespace '((t (:background "hotpink"))) "Whitespace.") (defun highlight-whitespace () (font-lock-add-keywords nil'(("\t" . 'whitespace)))) (add-hook 'find-file-hook 'highlight-fixme t) (setq change-log-default-name "ChangeLog" user-full-name "Alex Schroeder" user-mail-address "alex@gnu.org") ;; (global-set-key (kbd "M-SPC") 'just-one-space) (global-set-key (kbd "C-v") 'goto-line) (global-set-key (kbd "C-x v x") 'vc-version-other-window) (defun url-escape (str) "URL-escape STR." (interactive "sURL-escape: ") (message "%s" (url-hexify-string str))) ;;; overlays (defun list-overlays-at (&optional pos) "Describe overlays at POS or point." (interactive) (setq pos (or pos (point))) (let ((overlays (overlays-at pos)) (obuf (current-buffer)) (buf (get-buffer-create "*Overlays*")) (props '(priority window category face mouse-face display help-echo modification-hooks insert-in-front-hooks insert-behind-hooks invisible intangible isearch-open-invisible isearch-open-invisible-temporary before-string after-string evaporate local-map keymap field)) start end text) (if (not overlays) (message "None.") (set-buffer buf) (erase-buffer) (dolist (o overlays) (setq start (overlay-start o) end (overlay-end o) text (with-current-buffer obuf (buffer-substring start end))) (when (> (- end start) 13) (setq text (concat (substring text 1 10) "..."))) (insert (format "From %d to %d: \"%s\":\n" start end text)) (dolist (p props) (when (overlay-get o p) (insert (format " %15S: %S\n" p (overlay-get o p)))))) (pop-to-buffer buf)))) ;;; hippie-expand and/or dabbrev-expand (global-set-key (kbd "C-<tab>") 'hippie-expand) (setq hippie-expand-try-functions-list '(try-expand-all-abbrevs try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-lisp-symbol-partially try-complete-lisp-symbol try-complete-file-name-partially try-complete-file-name)) ;;; shell (setq shell-file-name "C:/Programme/cygwin/bin/bash.exe") ;;; eshell (global-set-key (kbd "C-z") 'eshell) (setq eshell-save-history-on-exit t) (add-hook 'eshell-mode-hook (lambda () (local-set-key (kbd "C-z") 'bury-buffer) (local-set-key (kbd "C-a") 'eshell-bol) (local-set-key (kbd "<up>") 'previous-line) (local-set-key (kbd "<down>") 'next-line))) (defalias 'eshell/emacs 'find-file) (defun eshell/dired () (dired (eshell/pwd))) ;;; perl (setq cperl-hairy t cperl-electric-parens 'null) (add-to-list 'auto-mode-alist '("\\.pl\\'" . cperl-mode)) (add-to-list 'auto-mode-alist '("\\.t\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-hook 'cperl-mode-hook (lambda () (local-set-key (kbd "C-h f") 'cperl-perldoc))) ;;; rcirc, write such as not to require rcirc at startup (autoload 'rcirc "rcirc" t) (setq rcirc-prompt "%n> "; list nick rcirc-fill-prefix " " rcirc-nick-prefix-chars "~&@%+!" rcirc-fill-column 65; side-by-side on my laptop rcirc-default-nick "kensanata" rcirc-log-flag t rcirc-log-directory "~/IRC Logs" rcirc-keywords '("ken" "kens" "kensa" "kensanatas" "kensanta" "alex") rcirc-server-alist '(("irc.freenode.net" :channels ("#rcirc" "#wiki" "#oddmuse" "#epfarms" "#emacs" "#sql" "#eclipse-de" "#osgi" "#eclipse-scout" "#eclipse-hudson" "#emacswiki")) ;; ("irc.sorcery.net" :channels ("#StargazersWorld")) ;; ("irc.magicstar.net" :channels ("#rpgnet")) ("irc.perl.org" :channels ("#perlde" "#oddmuse"))) ;; ("ircnet.eversible.com" :channels ("#drsrm")) ;; ("irc.ch.euirc.net" :channels ("#tanelorn")) ;; irc.de.euirc.net ;; ("irc.otherworlders.org" :channels ("#enworld" "#pathfinder")) ;; "#scheme" "#nethack" "#atom" "#microformats" "#barcamp" ;; "#emacs-fu" "#haskell" "#openfire" "##jabber" "#tentacle" ;; "#openbsd" "#hcoop" "#scrum" "#eclipse" rcirc-decode-coding-system 'undecided rcirc-ignore-list '("consolers" "jordanb" "dustpuppy" "rudybot" "AL-76") rcirc-activity-string "" frame-title-format '("%b " rcirc-activity-string) rcirc-authinfo (let ((file "~/.rcirc-authinfo")) (when (file-readable-p file) (with-temp-buffer (insert-file-contents-literally file) (read (current-buffer)))))) ;; (defadvice rcirc-handler-JOIN (after rcirc-handler-JOIN-emacs-ops activate) ;; "Automatically join #emacs-ops if we join #emacs." ;; (when (and (string= (car args) "#emacs") ;; (not (assoc "#emacs" (with-rcirc-server-buffer ;; rcirc-buffer-alist)))) ;; (rcirc-send-string process (concat "JOIN " "#emacs-ops")))) ;; (defun rcirc-handler-ctcp-LAG (process target sender args) ;; (rcirc-send-string process ;; (concat "NOTICE " ;; (rcirc-user-nick sender) ;; " :\C-aLAG you first.\C-a"))) (eval-after-load 'rcirc '(defun-rcirc-command whois (nick) "Request information from server about NICK." (interactive (list (let ((completion-ignore-case t)) (completing-read "Whois: " (with-rcirc-server-buffer rcirc-nick-table))))) (rcirc-send-string process (concat "WHOIS " nick)))) (defun rcirc-unfill () (interactive) (save-excursion (goto-char rcirc-prompt-end-marker) (while (re-search-forward "\\s-+" nil t) (replace-match " ")))) (defun rcirc-only () (interactive) (let (channels) (dolist (buf (buffer-list)) (with-current-buffer buf (when (and (eq major-mode 'rcirc-mode) rcirc-target) (setq channels (cons buf channels))))) (delete-other-windows) (let ((win (selected-window)) (size (/ (window-height) (length channels)))) (dolist (buf channels) (split-window-vertically (- (window-height) size)) (window--display-buffer-2 buf (selected-window))) (delete-window win))) (balance-windows)) ;; (eval-after-load 'rcirc ;; '(add-to-list 'rcirc-markup-text-functions 'rcirc-smileys)) ;; (defvar rcirc-smileys '((":)" . "\u263A") ;; ("<3" . "\u2665")) ;; "Alist containing string replacements for rcirc messages.") ;; (defvar rcirc-smiley-regexp ;; (regexp-opt (mapcar 'car rcirc-smileys)) ;; "Regular expression matching the keys in rcirc-smileys.") ;; (defun rcirc-smileys (&rest ignore) ;; "Use Unicode smileys in the buffer." ;; (goto-char (point-min)) ;; (while (re-search-forward rcirc-smiley-regexp nil t) ;; (replace-match (cdr (assoc (match-string 0) rcirc-smileys))))) (global-set-key (kbd "C-c e") 'rcirc) (eval-after-load 'rcirc '(require 'rcirc-color nil t)) (eval-after-load 'rcirc '(require 'rcirc-controls nil t)) (eval-after-load 'rcirc '(require 'rcirc-notify nil t)) (eval-after-load 'rcirc '(require 'rcirc-pounce nil t)) (eval-after-load 'rcirc '(require 'rcirc-groups nil t)) ;; Windows doesn't like "*foo*" filenames (eval-after-load 'rcirc '(defun rcirc-generate-new-buffer-name (process target) "Return a buffer name based on PROCESS and TARGET. This is used for the initial name given to IRC buffers." (substring-no-properties (if target (concat target "@" (process-name process)) (process-name process))))) (eval-after-load 'rcirc '(defun-rcirc-command encoding (arg) "Change the encoding coding system `rcirc-encode-coding-system' for the current buffer only." (interactive) (if (string= arg "") (rcirc-print process (rcirc-nick process) "NOTICE" target (symbol-name rcirc-encode-coding-system)) (setq rcirc-encode-coding-system (intern-soft arg))))) (add-hook 'rcirc-mode-hook (lambda () (rcirc-track-minor-mode 1) (abbrev-mode 1) (local-set-key (kbd "M-q") 'rcirc-unfill))) (defadvice my-invisible-preference (after rcirc-connect activate) "When connecting to a server, set the user mode to +i (invisible)." (let ((process ad-return-value) (nick (or nick rcirc-default-nick))) (rcirc-send-string process (concat "MODE " nick " +i")))) ;; rcirc occur (eval-after-load 'rcirc '(defun-rcirc-command occur (regexp) "Run `multi-occur' for all buffers in `rcirc-mode'." (interactive "sList lines matching regexp: ") (multi-occur (let (result) (dolist (buf (buffer-list)) (with-current-buffer buf (when (eq major-mode 'rcirc-mode) (setq result (cons buf result))))) result) regexp))) ;; define rcirc faces (defface rcirc-nick-in-message '((t (:background "lemon chiffon"))) "My nick when mentioned by others.") (defface rcirc-my-nick '((t (:foreground "purple"))) "My own nick for rcirc.") (defface rcirc-track-nick '((t (:inherit rcirc-my-nick))) "The face used indicate activity directed at you.") (defface rcirc-nick-in-message-full-line '((t ())) "The face used indicate activity directed at you.") (defface rcirc-prompt '((t (:foreground "orchid"))) "My prompt for rcirc.") ;; invisible (defadvice my-invisible-preference (after rcirc-connect activate) "When connecting to a server, set the user mode to +i (invisible)." (let ((process ad-return-value) (nick (or nick rcirc-default-nick))) (rcirc-send-string process (concat "MODE " nick " +i")))) ;; rcirc /reconnect (eval-after-load 'rcirc '(defun-rcirc-command reconnect (arg) "Reconnect the server process." (interactive "i") (unless process (error "There's no process for this target")) (let* ((server (car (process-contact process))) (port (process-contact process :service)) (nick (rcirc-nick process)) channels query-buffers) (dolist (buf (buffer-list)) (with-current-buffer buf (when (eq process (rcirc-buffer-process)) (remove-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook) (if (rcirc-channel-p rcirc-target) (setq channels (cons rcirc-target channels)) (setq query-buffers (cons buf query-buffers)))))) (delete-process process) (rcirc-connect server port nick rcirc-default-nick user-full-name channels)))) ;; rcirc /sv (eval-after-load 'rcirc '(defun-rcirc-command sv (arg) "Boast about rcirc." (interactive "i") (let ((str (concat "I use rcirc on " (replace-regexp-in-string "\n" "" (emacs-version))))) (rcirc-send-message process target str)))) ;; rcirc /all (eval-after-load 'rcirc '(defun-rcirc-command all (input) "Run the arguments as a command for all connections. Example use: /all away food or /all quit zzzz." (interactive "s") (let (process-list) ;; Using a list is inefficient. Rebuilding a list ourselves is ;; important, because `rcirc-process-list' will only return ;; undeleted processes. (dolist (buf (buffer-list)) (with-current-buffer buf (when (eq major-mode 'rcirc-mode) (add-to-list 'process-list rcirc-process)))) (let ((buffers (mapcar 'process-buffer process-list))) (dolist (buf buffers) (message "Sending %s to %s" input (buffer-name buf)) (with-current-buffer buf (goto-char (point-max)) (insert "/" input) (rcirc-send-input))))))) ;; rcirc /op (eval-after-load 'rcirc '(defun-rcirc-command op (input) "Op myself on the current channel." (interactive "s") (rcirc-send-message process "chanserv" (concat "op " target)))) ;; rcirc /deop (eval-after-load 'rcirc '(defun-rcirc-command deop (input) "Deop myself on the current channel." (interactive "s") (rcirc-send-message process "chanserv" (concat "deop " target)))) ;; rcirc /mute (eval-after-load 'rcirc '(defun-rcirc-command mute (input) "Mute nick" (interactive "s") (rcirc-send-string process (format "MODE %s +q %s!*@*" target input)))) ;; rcirc /unmute (eval-after-load 'rcirc '(defun-rcirc-command unmute (input) "Mute nick" (interactive "s") (rcirc-send-string process (format "MODE %s -q %s!*@*" target input)))) ;; rcirc /ban (eval-after-load 'rcirc '(defun-rcirc-command ban (input) "Mute nick" (interactive "s") (rcirc-send-string process (format "MODE %s +b %s!*@*" target input)))) ;; rcirc /unban (eval-after-load 'rcirc '(defun-rcirc-command unban (input) "Mute nick" (interactive "s") (rcirc-send-string process (format "MODE %s -b %s!*@*" target input)))) ;; rcirc /kickban (eval-after-load 'rcirc '(defun-rcirc-command kickban (input) "Mute nick" (interactive "s") (rcirc-send-string process (format "MODE %s +b %s!*@*" target input)) (rcirc-send-string process (format "KICK %s %s kickban!" target input)))) ;; other (defun irc-version-summary () "Run this after you've sent a /CTCP #test VERSION." (interactive) (save-excursion (let ((agents)) (while (re-search-forward "CTCP VERSION \\([a-z]\\([^- \n:/]+\\|[^- \n:/]*[-/][^- \n:/0-9]+\\)\\)" nil t) (let* ((key (replace-regexp-in-string "-" "" (downcase (match-string-no-properties 1)))) (cell (or (assoc key agents) (car (setq agents (cons (cons key 0) agents)))))) (setcdr cell (1+ (cdr cell))))) (setq agents (sort agents (lambda (a b) (> (cdr a) (cdr b))))) (pop-to-buffer (get-buffer-create "*IRC Clients*")) (erase-buffer) (dolist (item agents) (insert (format "%4d %s\n" (cdr item) (car item)))) (insert "----\n" (format "%4d total\n" (apply '+ (mapcar 'cdr agents))))))) ;;; debugging hashmaps (defun describe-hash (variable &optional buffer) "Display the full documentation of VARIABLE (a symbol). Returns the documentation as a string, also. If VARIABLE has a buffer-local value in BUFFER (default to the current buffer), it is displayed along with the global value." (interactive (let ((v (variable-at-point)) (enable-recursive-minibuffers t) val) (setq val (completing-read (if (and (symbolp v) (hash-table-p (symbol-value v))) (format "Describe hash-map (default %s): " v) "Describe hash-map: ") obarray (lambda (atom) (and (boundp atom) (hash-table-p (symbol-value atom)))) t nil nil (if (hash-table-p v) (symbol-name v)))) (list (if (equal val "") v (intern val))))) (with-output-to-temp-buffer (help-buffer) (maphash (lambda (key value) (pp key) (princ " => ") (pp value) (terpri)) (symbol-value variable)))) ;;; text (add-hook 'text-mode-hook 'turn-on-auto-fill) ;;; oddmuse (autoload 'oddmuse-edit "Edit a page on an Oddmuse wiki." t) (autoload 'oddmuse-post "Post the current buffer to an Oddmuse wiki." t) (autoload 'oddmuse-mode "Yadda yadda." t) (setq oddmuse-wikis '(("TestWiki" . "http://www.emacswiki.org/cgi-bin/test") ("EmacsWiki" . "http://www.emacswiki.org/cgi-bin/emacs") ("CommunityWiki" . "http://www.communitywiki.org/cw") ("OddmuseWiki" . "http://www.oddmuse.org/cgi-bin/oddmuse") ("Alex" . "http://www.emacswiki.org/cgi-bin/alex"))) (add-hook 'text-mode-hook (lambda () (local-set-key (kbd "C-c =") 'oddmuse-section) (local-set-key (kbd "C-c -") 'oddmuse-subsection))) (defun oddmuse-section () (interactive) (oddmuse-header ?=)) (defun oddmuse-subsection () (interactive) (oddmuse-header ?-)) (defun oddmuse-header (char) (let ((n (- (line-end-position 0) (line-beginning-position 0)))) (beginning-of-line) (insert (make-string n char)))) (require 'goto-addr) (define-generic-mode 'alex-oddmuse-mode nil; comments nil; keywords `(("^=[^=\n]+=+$" . 'info-title-1) ("^==[^=\n]+=+$" . 'info-title-2) ("^===[^=\n]+=+$" . 'info-title-3) ("^====[^=\n]+=+$" . 'info-title-4) ("^[ \t].*$" . 'fixed-pitch) ("\\[\\[.*?\\]\\]" . 'link) ("\\[.*\\]" . 'link) (,goto-address-url-regexp . 'link) ("\\*\\*.*?\\*\\*" . 'bold) ("\\*.*?\\*" . 'bold) ("//.*?//" . 'italic) ("/.*?/" . 'italic) ("__.*?__" . 'italic) ("_.*?_" . 'underline)); font-lock list '(".oddmuse\\'"); auto-mode-alist '((lambda () (require 'info) (require 'goto-addr))); function-list "Major mode for editing Oddmuse wiki files. The particular markup mix is specific to my preferences.") (define-generic-mode 'campaign-wiki-mode nil; comments nil; keywords '(("^=[^=\n]+" . 'info-title-1) ("^==[^=\n]+" . 'info-title-2) ("^===[^=\n]+" . 'info-title-3) ("^====+[^=\n]+" . 'info-title-4) ("\\[\\[.*?\\]\\]" . 'link) ("\\[.*\\]" . 'link) ("\\[b\\].*?\\[/b\\]" . 'bold) ("\\[i\\].*?\\[/i\\]" . 'italic) ("\\*\\*.*?\\*\\*" . 'bold) ("\\*.*?\\*" . 'bold) ("\\_<//.*?//" . 'italic) ("\\_</.*?/" . 'italic) ("__.*?__" . 'italic) ("_.*?_" . 'underline) ("|+=?" . font-lock-string-face) ("\\\\\\\\[ \t]+" . font-lock-warning-face)); font-lock list '(".campaign\\'"); auto-mode-alist '((lambda () (require 'info) (require 'goto-addr) (local-set-key (kbd "C-c =") 'oddmuse-section) (local-set-key (kbd "C-c -") 'oddmuse-subsection))); function-list "Campaign Wiki stuff including Creole Markup and BBCode.") (defun creole-table (start end columns transposed) "Convert region into a table. The region must contain one cell content per line, cells by columns first." (interactive "r\nnHow many columns? \nP") (let* ((cells (split-string (buffer-substring start end) " *\n *" t)) (rows (/ (length cells) columns))) (unless (= 0 (mod (length cells) columns)) (error "Cannot fit %d cells into %d columns" (length cells) columns)) (unless cells (error "No cells in the region")) (dotimes (row rows) (let (result) (if transposed (progn (dotimes (col columns) (setq result (cons (nth (+ (* col rows) row) cells) result))) (nreverse result)) (setq result cells) (setq cells (nthcdr columns cells)) (setcdr (nthcdr (1- columns) result) nil)) (let ((sep (if (= row 0) "|= " "| "))) (insert sep (mapconcat 'identity result (concat " " sep)) " |\n"))))) (delete-region start end)) ;;; isearch & occur (defun isearch-occur () "Invoke `occur' from within isearch." (interactive) (let ((case-fold-search isearch-case-fold-search)) (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))) (define-key isearch-mode-map (kbd "C-o") 'isearch-occur) (defun isearch-highlight-phrase () "Invoke `highligh-phrase' from within isearch." (interactive) (let ((case-fold-search isearch-case-fold-search)) (highlight-phrase (if isearch-regexp isearch-string (regexp-quote isearch-string))))) (define-key isearch-mode-map (kbd "C-h") 'isearch-highlight-phrase) ;;; org ;; (add-to-list 'load-path "~/elisp/org-4.31") (require 'org-install nil t) (setq org-CUA-compatible t) (define-key global-map "\C-cl" 'org-store-link) (add-hook 'org-mode-hook 'my-org-init) (defun my-org-init () (require 'typopunct) (typopunct-change-language 'english) (typopunct-mode 1)) (setq org-export-html-style "<style type='text/css'> body { font-family: Garamond, Cochin, 'Bookman Old Style', serif; font-size: 12pt; line-height: 14pt; margin: 5em; } h2 { margin-top: 2em; } h2 + p { margin: 1.5em 2em; font-style: italic; } .license { font-size: 7pt; line-height: 8pt; } .license ol { padding-left: 0; list-style-position: inside; } br.page { page-break-before: always; } </style>") ;;; ediff (setq ediff-window-setup-function 'ediff-setup-windows-plain) ;; Calendar (setq calendar-week-start-day 1 calendar-day-name-array ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag" "Samstag"] calendar-month-name-array ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August" "September" "Oktober" "November" "Dezember"]) ;;; Working with the edic and kanjidic files (defun find-region-translation (start end) "Find the region in the EDICT file." (interactive "r") (let ((str (buffer-substring-no-properties start end)) (conf (current-window-configuration))) (if (= (length str) 1) (find-file "/Users/alex/Documents/Japan/kanjidic") (find-file "/Users/alex/Documents/apan/edict")) (goto-char (point-min)) (when (occur str) (set-window-configuration conf) (switch-to-buffer "*Occur*") (local-set-key (kbd "q") 'bury-buffer)))) (global-set-key (kbd "C-c j") 'find-region-translation) ;;; UCS/Unicode (defun unicode-data-convert () (interactive) (catch 'done (while t (let* ((attributes (split-string (buffer-substring (line-beginning-position) (line-end-position)) ";")) (char (decode-char 'ucs (string-to-number (nth 0 attributes) 16)))) (delete-region (line-beginning-position) (line-end-position)) (insert (format "%c\tu%s\t%5d\t%s\t%s" (if (numberp char) char 32) (nth 0 attributes) (string-to-number (nth 0 attributes) 16) (nth 1 attributes) (nth 10 attributes))) (when (> (forward-line 1) 0) (throw 'done t)))))) ;;; man using Cygwin seems to fail because no fgets is available. ;;; Use woman instead. (defalias 'man 'woman) (defalias 'eshell/man 'woman) (setq woman-manpath '("c:/cygwin/usr/man" "c:/cygwin/usr/share/man" "c:/cygwin/usr/local/man")) ;;; aspell using Cygwin (setq ispell-dictionary-alist '((nil "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "--dict-dir=/lib/aspell" "--master=english") nil iso-8859-1) ("english" "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "--dict-dir=/lib/aspell" "--master=english") nil iso-8859-1) ("swiss" "[a-zA-Z\304\326\334\344\366\337\374]" "[^a-zA-Z\304\326\334\344\366\337\374]" "[']" t ("-C" "--dict-dir=/lib/aspell" "--master=swiss") "~latin1" iso-8859-1))) ;;; EmacsClient (require 'server) (when (and (= emacs-major-version 23) (= emacs-minor-version 1) (equal window-system 'w32)) (defun server-ensure-safe-dir (dir) "Noop" t)) ; Suppress error "directory ; ~/.emacs.d/server is unsafe" ; on windows. (server-start 1) ;;; Identica Mode (when (require 'netrc nil t) (autoload 'identica-mode "identica-mode" nil t) (let ((identica (netrc-machine (netrc-parse "~/.netrc") "identi.ca" t))) (setq identica-username (netrc-get identica "login") identica-password (netrc-get identica "password")))) ;;; automatic additions (put 'narrow-to-region 'disabled nil) (put 'not-modified 'disabled t) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(canlock-password "f0e77d033338878513c7e4935cfac5eaa0da285c") '(inhibit-startup-screen t)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) (defun reverse-chars-in-region (start end) "Reverse the region character by character without reversing lines. Use `reverse-region' to reverse the lines in the region." (interactive "r") (let ((str (buffer-substring start end))) (delete-region start end) (dolist (line (split-string str "\n")) (let ((chars (mapcar (lambda (c) (or (matching-paren c) c)) (reverse (append line nil))))) (when chars (apply 'insert chars)) (newline)))))