;; .emacs ;;; uncomment this line to disable loading of "default.el" at startup ;; (setq inhibit-default-init t) ;;; enable debugging ; (setq debug-on-error t) ;; Turn off mouse interface early in startup to avoid momentary display (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; reenable the menu bar in X, also disable ^Z, set some colors, etc (when window-system (set-background-color "black") (set-foreground-color "cyan") (menu-bar-mode -1) (tool-bar-mode -1) (global-unset-key "\C-z") ; iconify-or-deiconify-frame (C-x C-z) (setq use-dialog-box nil) ; disable dialog boxes (load "server") (unless (server-running-p) (server-start)) (when (< emacs-major-version 25) (setq x-select-enable-clipboard nil) (setq x-select-enable-primary nil) ;; use shift-ins to insert selection instead of kill-ring (global-set-key [(shift insert)] (lambda () (interactive) (insert (x-get-selection-value)))) ) (when (>= emacs-major-version 25) (setq select-enable-clipboard nil) (setq select-enable-primary nil) ;; use shift-ins to insert selection instead of kill-ring (global-set-key [(shift insert)] (lambda () (interactive) (insert (get-selection-value)))) ) ) (setq inhibit-startup-message t) (defun disable-enriched-text () "See http://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00211.html" (eval-after-load "enriched" '(defun enriched-decode-display-prop (start end &optional param) (list start end))) ) (add-to-list 'load-path "~/.emacs.d/elisp") (when (= emacs-major-version 23) (load-library "package-emacs23.el") (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) (setq erc-buffer-switch-mode 'erc-iswitchb) (iswitchb-mode 1) ) (when (= emacs-major-version 24) ;fix package.el bug in emacs24 (defadvice package-compute-transaction (before package-compute-transaction-reverse (package-list requirements) activate compile) "reverse the requirements" (setq requirements (reverse requirements)) (print requirements)) (when (< emacs-minor-version 4) (setq erc-buffer-switch-mode 'erc-iswitchb) (iswitchb-mode 1) ) (when (>= emacs-minor-version 4) (setq erc-buffer-switch-mode 'erc-switch-to-buffer) (icomplete-mode 1) ) ) (when (< emacs-major-version 25) (disable-enriched-text) ) (when (>= emacs-major-version 25) (setq erc-buffer-switch-mode 'erc-switch-to-buffer) (icomplete-mode 1) (when (< emacs-minor-version 2) (disable-enriched-text) ) ) ;; mac stuff (when (eq system-type 'darwin) (setq mac-option-modifier 'super) (setq mac-command-modifier 'meta) (global-set-key [kp-delete] 'delete-char) ;; sets fn-delete to be right-delete ) ;; put backup/autosave files into ~/.emacs.d (defvar backup-dir (expand-file-name "~/.emacs.d/backups/")) (defvar autosave-dir (expand-file-name "~/.emacs.d/autosaves/")) (setq backup-directory-alist (list (cons ".*" backup-dir))) (setq auto-save-list-file-prefix autosave-dir) (setq auto-save-file-name-transforms `((".*" ,autosave-dir t))) ;;store tramp backup files locally (setq tramp-backup-directory-alist backup-directory-alist) ;; turn on font-lock mode (when (fboundp 'global-font-lock-mode) (global-font-lock-mode t)) ;; disable tansient mark mode (setq transient-mark-mode nil) ;; default to better frame titles (setq frame-title-format (concat "%b - emacs@" system-name)) ;; enable smooth scrolling ;(require 'smooth-scroll) ;(smooth-scroll-mode t) ;; scroll one line at a time (less "jumpy" than defaults) (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time (setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse (setq scroll-conservatively 1000) ;; keyboard scroll one line at a time (setq auto-window-vscroll nil) ;; make movement move by entire lines, not wrapped partial lines (setq line-move-visual nil) ;; make gnu-tls more secure (default is 256 bits) (setq gnutls-min-prime-bits 1024) ; add shortcut to shrink the current window (global-set-key (kbd "C-x ,") 'shrink-window) ; add shortcut to describe-char (global-set-key (kbd "C-x 8 d") 'describe-char) (global-set-key (kbd "C-x 8 s") (lambda () (interactive) (insert "?"))) ;; disable prompt echo in shell-mode (defun my-shell-turn-echo-off () (setq comint-process-echoes t)) (add-hook 'shell-mode-hook 'my-shell-turn-echo-off) ; add command to toggle between last buffer and bind it (require 'toggle-buffer) (global-set-key (kbd "C-x SPC") 'joc-toggle-buffer) ; add command to unfill paragraph (defun remove-hard-wrap-paragraph () "Replace line endings into single spaces on the current paragraph." (interactive) (let ((fill-column 90002000)) (fill-paragraph nil))) (global-set-key (kbd "M-Q") 'remove-hard-wrap-paragraph) ;;(global-set-key (kbd "C-l") 'recenter) ;; enable C-r search in minibuffers ;(require 'minibuf-isearch) ;; rebind search keys to include regexp by default (global-set-key (kbd "C-s") 'isearch-forward-regexp) (global-set-key (kbd "C-r") 'isearch-backward-regexp) (global-set-key (kbd "C-M-s") 'isearch-forward) (global-set-key (kbd "C-M-r") 'isearch-backward) (global-set-key (kbd "M-r") 'replace-regexp) ; save/restore minibuffer history (require 'savehist) (savehist-mode t) ;; word count function (defun wc (&optional start end) "Prints number of lines, words and characters in region or whole buffer." (interactive) (let ((n 0) (start (if mark-active (region-beginning) (point-min))) (end (if mark-active (region-end) (point-max)))) (save-excursion (goto-char start) (while (< (point) end) (if (forward-word 1) (setq n (1+ n))))) (message "%3d %3d %3d" (count-lines start end) n (- end start)))) ;; offby1's crude but effective method for searching all buffers (defun search-all-buffers (regexp) (interactive "sRegexp: ") (multi-occur-in-matching-buffers "." regexp t)) (global-set-key [f7] 'search-all-buffers) ;; disable line-wrap character so copy/paste of urls works slightly better ; broken in emacs 23+ ; (set-display-table-slot standard-display-table 'wrap ?\0) ;; enable webjump-plus (require 'webjump-plus) (global-set-key (kbd "C-c j") 'webjump) (setq webjump-sites (append '( ("Pop's Site" . "www.joebob-and-son.foo/") ) webjump-plus-sites webjump-sample-sites)) ; move to previous window (defun select-previous-window () "Switch to the previous window" (interactive) (select-window (previous-window))) (global-set-key (kbd "C-x p") 'select-previous-window) ; enable all deactivated-by-default commands (setq disabled-command-function nil) ;; define forward-pipe and bind keys (defun forward-pipe (arg) "Move point to the next position that is the end of a pipe. With prefix argument ARG, do it ARG times if positive, or move backwards ARG times if negative." (interactive "p") (if (natnump arg) (re-search-forward "|+" nil 'move arg) (while (< arg 0) (if (re-search-backward "|+" nil 'move) (skip-syntax-backward "c_")) (setq arg (1+ arg))))) (global-set-key (kbd "M-F") 'forward-pipe) (global-set-key (kbd "M-B") (lambda () (interactive) (forward-pipe -1))) (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. '(apropos-do-all t) '(babel-preferred-to-language "English") '(browse-url-browser-function (quote browse-url-generic)) '(browse-url-generic-program "~/bin/remotecopy") '(browse-url-text-browser "lynx") '(erc-accidental-paste-threshold-seconds nil) '(erc-auto-discard-away t) '(erc-auto-query (quote window-noselect)) '(erc-autoaway-idle-method (quote irc)) '(erc-autoaway-mode t) '(erc-dcc-get-default-directory "~/dl") '(erc-email-userid "Sketch") '(erc-fill-mode t) '(erc-fool-highlight-type (quote all)) '(erc-fools (quote ("stoned" "pifon1" "docmur" "echelon"))) '(erc-ignore-list (quote ("*!*@unaffiliated/stoned/bot/nugs"))) '(erc-input-line-position nil) '(erc-interpret-mirc-color nil) '(erc-join-buffer (quote window-noselect)) '(erc-keywords (quote (("http" default)))) '(erc-lurker-hide-list (quote ("JOIN" "PART" "QUIT"))) '(erc-lurker-threshold-time 43200) '(erc-modules (quote (autoaway button completion fill irccontrols match move-to-prompt netsplit readonly ring scrolltobottom stamp spelling track truncate tweet))) '(erc-notify-list (quote ("SiR^" "nephthys"))) '(erc-notify-mode t) '(erc-notify-signon-hook (quote (erc-notify-signon))) '(erc-paranoid t) '(erc-prompt-for-password nil) '(erc-server-auto-reconnect nil) '(erc-server-reconnect-attempts 5) '(erc-server-send-ping-timeout 240) '(erc-stamp-mode t) '(erc-timestamp-format-right "[%H:%M]") '(erc-timestamp-intangible t) '(erc-timestamp-right-column 71) '(erc-track-switch-direction (quote importance)) '(erc-truncate-mode t) '(erc-try-new-nick-p nil) '(erc-whowas-on-nosuchnick t) '(google-translate-default-source-language "auto") '(google-translate-default-target-language "en") '(inhibit-startup-screen t) '(initial-scratch-message nil) '(mouse-yank-at-point t) '(muse-project-alist (quote (("WikiPlanner" ("~/.emacs.d/plans" :default "index" :major-mode planner-mode :visit-link planner-visit-link))))) '(package-selected-packages (quote (rpm-spec-mode no-emoji engine-mode ipcalc znc yasnippet w3m url-shortener tramp-term salt-mode phi-search-mc mc-extras kill-ring-search jinja2-mode google-translate google-contacts f esxml erc-tweet erc-colorize dictionary dash-functional company bitly babel apache-mode))) '(uniquify-after-kill-buffer-p t) '(uniquify-buffer-name-style (quote forward) nil (uniquify)) '(znc-detatch-on-kill 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. '(erc-direct-msg-face ((t (:foreground "cyan" :weight bold)))) '(erc-fool-face ((t (:foreground "color-20")))) '(erc-input-face ((t (:foreground "cyan")))) '(erc-my-nick-face ((t (:foreground "cyan" :weight bold)))) '(erc-nick-default-face ((t (:box (:line-width 2 :color "blue" :style pressed-button) :weight bold)))) '(erc-nick-msg-face ((t (:foreground "SlateBlue" :weight bold)))) '(erc-notice-face ((t (:foreground "blue" :weight bold)))) '(erc-timestamp-face ((t (:foreground "green")))) '(gnus-summary-normal-read ((t (:foreground "blue"))))) (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" "324" "329" "332" "333" "353" "477")) ;; still shipping emacs 22? thanks apple. this wraps pretty much the rest of the config, since 22 has no packages it's missing tons of stuff. (when (>= emacs-major-version 23) (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize) ;; add google translate (require 'google-translate) (require 'google-translate-default-ui) (global-set-key (kbd "C-c t") 'google-translate-at-point) (global-set-key (kbd "C-c T") 'google-translate-query-translate) ;(require 'google-translate-smooth-ui) ;(global-set-key (kbd "C-c t") 'google-translate-smooth-translate) ;; erc stuff (require 'erc) (require 'erc-tweet) (require 'znc) ;;(require 'erc-youtube) ;;(add-to-list 'erc-modules 'youtube) (erc-update-modules) (load-library "~/.emacs.d/erc-bar.el") (load-library "~/.emacs.d/erc-flip.el") (load-library "~/.emacs.d/erc-misc-commands.el") (load-library "~/.emacs.d/erc-rank-stalkers.el") (load-library "~/.emacs.d/erc-ignore.el") ;;(load-library "~/.emacs.d/erc-fill.el") ;;(load-library "~/.emacs.d/erc-highlight-nicknames.el") ;;(erc-highlight-nicknames-enable) ;;(load-library "~/.emacs.d/planner-start.el") (eval-after-load 'erc '(progn (define-key erc-mode-map (kbd "C-c h") 'erc-toggle-hidden-lines) (define-key erc-mode-map (kbd "C-c C-c") nil))) ; add shortcuts key to make erc buffer switching easier (add-hook 'erc-mode-hook (lambda () (local-set-key (kbd "C-c SPC") 'erc-track-switch-buffer) (local-set-key (kbd "C-c b") erc-buffer-switch-mode))) ;; w3m stuff '(w3m-use-tab nil) '(w3m-cookie-accept-bad-cookies (quote ask)) '(w3m-cookie-accept-domains (quote ("reddit.com" "www.reddit.com"))) (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t) (global-set-key (kbd "C-x m") 'browse-url-at-point) (setq browse-url-browser-function 'w3m-browse-url browse-url-new-window-flag t) ;; end w3m stuff (require 'multiple-cursors) (global-set-key (kbd "M-s m m") 'mc/edit-lines) (global-set-key (kbd "M-s m n") 'mc/mark-next-like-this) (global-set-key (kbd "M-s m p") 'mc/mark-previous-like-this) (global-set-key (kbd "M-s m a") 'mc/mark-all-like-this) (require 'dictionary) (global-set-key (kbd "C-c d") 'dictionary-lookup-definition) ;; verify CA certs (setq tls-checktrust t) (setq tls-program '("openssl s_client -connect %h:%p -CAfile /etc/ssl/certs/ca-bundle.crt -no_ssl2 -ign_eof")) ;; kill ring search (autoload 'kill-ring-search "kill-ring-search" "Search the kill ring in the minibuffer." (interactive)) (global-set-key (kbd "M-C-y") 'kill-ring-search) ;;enable tramp-term (require 'tramp-term) ) ;;end of emacs23+ stuff ;; store passwords and local config in non-version controlled files (load-library "~/.emacs.d/passwords.el") (load-library "~/.emacs.d/local.el")