;; Added by Package.el. This must come before configurations of ;; installed packages. Don't delete this line. If you don't want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (package-initialize) (unless (and (setq dwim-emacs-workspace (expand-file-name "~/workspace/emacs/")) (file-exists-p dwim-emacs-workspace)) (error "Could not find workspace directory (tried '%s'). Set/change the shell environment variable DWIM_WORKSPACE if you want to use something else." dwim-emacs-workspace)) ;;(setq dwim-sbcl-binary (expand-file-name "~/workspace/sbcl/run-sbcl.sh")) (add-to-list 'load-path (expand-file-name "~/common-lisp/hu.dwim.environment/emacs/")) (require 'dwim-init) (require 'dwim-key-bindings) (global-set-key [backtab] (lambda () (interactive) (insert " "))) (global-set-key (kbd "M-b") 'redo) (global-set-key (kbd "C-b") 'undo-only) (global-set-key (kbd "C-,") 'dwim-clipboard-kill-ring-save) (global-set-key (kbd "C-.") 'dwim-clipboard-yank) (global-set-key (kbd "C-<") 'dwim-clipboard-kill-region) (global-set-key (kbd "C-í") 'dwim-clipboard-kill-region) (global-set-key [(control insert)] 'dwim-clipboard-kill-region) (dwim-define-lisp-key (kbd "C->") 'dwim-paste-clipboard-at-last-change) (dwim-define-lisp-key (kbd "C-M-,") 'dwim-copy-sexp-at-point) (dwim-define-lisp-key (kbd "C-M-.") 'dwim-replace-sexp-at-point-with-clipboard) (global-set-key (kbd "C-p") 'kill-this-buffer) (define-key dired-mode-map (kbd "C-p") 'kill-this-buffer) (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/smartparens/"))) (require 'smartparens-config) (add-hook 'nix-mode-hook 'smartparens-mode) (add-hook 'c-mode-hook 'smartparens-mode) (add-hook 'python-mode-hook 'smartparens-mode) (add-hook 'go-mode-hook 'smartparens-mode) (defun attila/smartparens-mode-hook () (cl-flet ((redef (key function) (define-key smartparens-mode-map key function))) (redef (kbd "M-") 'sp-backward-sexp) (redef (kbd "M-") 'sp-forward-sexp) (redef (kbd "M-") 'sp-down-sexp) (redef (kbd "M-") 'sp-backward-up-sexp))) (add-hook 'smartparens-enabled-hook 'attila/smartparens-mode-hook) ;;; coq and proofgeneral (add-to-list 'load-path (expand-file-name "/media/store/work/coq/tools/")) (setq auto-mode-alist (cons '("\\.v$" . coq-mode) auto-mode-alist)) (autoload 'coq-mode "coq" "Major mode for editing Coq vernacular." t) (eval-after-load 'coq-mode (progn (setq coq-compiler "/media/store/work/coq/bin/coqc") (setq coq-prog-name "/media/store/work/coq/bin/coqtop"))) (ignore-errors (load-file "/media/store/work/ProofGeneral/generic/proof-site.el")) ;(eval-after-load 'proofgeneral ; (progn ; (define-key proof-mode-map [(control c) return] 'proof-goto-point))) ;;; ;;; edit-server (for e.g. the chrome edit-in-emacs plugin) ;;; (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/emacs_chrome/servers"))) (require 'edit-server) (edit-server-start) ;; ;; to deal with the stupid new gmail compose code that uses html internally even in plain text mode ;; (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/edit-server-htmlize"))) ;; (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) ;; (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) ;; (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) ;; (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) ;; ;; KLUDGE ideally the above installed autoloads should be enough, but ;; ;; we cannot install the local load path early enough for ;; ;; customizations, so we cannot use customization for setting ;; ;; EDIT-SERVER-HTMLIZE-URL-REGEXP. ;; (require 'edit-server-htmlize) ;; (setq edit-server-htmlize-url-regexp ;; "^\\(mail\\.google\\.com/mail/\\|groups\\.google\\.com/forum/\\)") (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/expand-region"))) (require 'expand-region) (global-set-key (kbd "C-@") 'er/expand-region) ;;; backups (pushnew '(".*/notes/.*" . ".backups") backup-directory-alist) ;;; email integration (setq message-signature 'attila/message-signature) (setq mu4e-compose-signature 'attila/message-signature) (setq message-signature-insert-empty-line nil) (defun attila/message-signature () (let ((default-directory "~/")) ; so that it also works when the cwd is some ssh:// link (shell-command-to-string "~/bin/update-signature") (with-temp-buffer (insert-file-contents "~/.signature") (buffer-string)))) (defun attila/message-insert-signature () (interactive) (save-excursion (message-goto-signature) (unless (eql (point) (buffer-end 1)) (previous-line) (move-beginning-of-line nil) (kill-region (point) (buffer-end 1))) (message-insert-signature)) (message-goto-signature)) (when (memq 'mu4e features) (message "WARNING: mu4e is already loaded when we try to load our own") (sit-for 2)) (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/mu/mu4e/"))) (require 'mu4e) (global-set-key [(super m)] 'mu4e) (global-set-key [(control c) (control w)] 'attila/message-insert-signature) (global-set-key [(super n)] (defun attila/open-note () (interactive) (ido-file-internal ido-default-file-method nil "~/notes/"))) (define-key message-mode-map [(control c) (control w)] 'attila/message-insert-signature) (define-key message-mode-map [(control c) tab] 'completion-help-at-point) ;; mu4e-compose-mode-map (add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime) (add-hook 'mu4e-compose-mode-hook 'mml-secure-message-sign-pgpmime) (setq mu4e-maildir "~/Maildir") ;; FIXME this may save unencrypted drafts... check it! (setq mu4e-drafts-folder "/[Gmail].Drafts") (setq mu4e-sent-folder "/[Gmail].Sent Mail") (setq mu4e-trash-folder "/[Gmail].Trash") (setq mu4e-sent-messages-behavior 'delete) (setq mu4e-get-mail-command "offlineimap -q") (setq message-kill-buffer-on-exit t) (setq mu4e-view-show-images t mu4e-view-image-max-width 800) (setq mu4e-attachment-dir "~/Desktop") (setq mu4e-maildir-shortcuts '( ("/INBOX" . ?i) ("/[Gmail].Sent Mail" . ?s) ("/[Gmail].Trash" . ?t) ("/[Gmail].All Mail" . ?a))) (setq user-mail-address "attila.lendvai@gmail.com" user-full-name "Attila Lendvai") (setq message-send-mail-function 'smtpmail-send-it smtpmail-stream-type 'starttls smtpmail-default-smtp-server "smtp.gmail.com" smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-service 587) ;;; gpg pgp integration, open encrypted files (require 'epa-file) (epa-file-enable) (defun attila/kill-gpg-buffers () ;; automatically delete *.gpg buffers that has been displayed longer than 60 seconds ago ;; install with: (run-with-idle-timer 60 t 'attila/kill-gpg-buffers) (interactive) (let ((buffers-killed 0)) ;; (message "Looking for .gpg buffers among '%s' buffers" (length (buffer-list))) (dolist (buffer (copy-list (buffer-list))) (with-current-buffer buffer ;; (message "Looking at '%s' buffers" (buffer-name buffer)) (when (and (string-match ".*\.gpg$" (buffer-name)) buffer-file-name (> (buffer-size) 0) ;; unless it's currently focused and displayed ;; https://emacs.stackexchange.com/questions/2959/how-to-know-my-buffers-visible-focused-status ;; no, it's unsafe (not (eq buffer (window-buffer (selected-window)))) ) (let* ((current-time (current-time)) (last-displayed-time (or buffer-display-time (progn (display-buffer (current-buffer)) buffer-display-time))) (last-modified-time (if (numberp (visited-file-modtime)) (list 0 0) (visited-file-modtime))) (last-activity-time (if (time-less-p last-displayed-time last-modified-time) last-modified-time last-displayed-time)) (time-since-last-activity (time-to-seconds (time-subtract current-time last-activity-time)))) ;; (message "'%s': last-displayed-time '%s', last-modified-time '%s', last-activity-time '%s', time-since-last-activity '%s'" ;; (buffer-name buffer) last-displayed-time last-modified-time last-activity-time time-since-last-activity) (if (> time-since-last-activity 90) (progn (message "Auto-killing .gpg buffer '%s' because it was last active %s seconds ago" (buffer-name buffer) time-since-last-activity) (when (buffer-modified-p buffer) (save-buffer) (message "Autosaved .gpg buffer '%s'" (buffer-name buffer))) (kill-buffer buffer) (incf buffers-killed)) (progn ;; (message "Not killing .gpg buffer '%s' yet, it was active %s seconds ago" (buffer-name buffer) time-since-last-activity) )))))) (unless (zerop buffers-killed) (message "%s .gpg buffers have been killed (and potentially autosaved)" buffers-killed)))) ;; TODO maybe use run-with-idle-timer ? (run-with-timer 15 15 'attila/kill-gpg-buffers) ;; (cancel-function-timers 'attila/kill-gpg-buffers) (global-set-key [(control next)] 'end-of-buffer) (global-set-key [(control prior)] 'beginning-of-buffer) (require 'bbdb-loaddefs "~/workspace/emacs/bbdb/lisp/bbdb-loaddefs.el") (global-set-key [(super b)] 'bbdb) (require 'bbdb) (require 'bbdb-mua) (add-hook 'gnus-startup-hook (lambda () (define-key gnus-summary-mode-map (kbd "C-o") 'other-window) (require 'bbdb) (bbdb-initialize 'gnus) (setq bbdb-complete-name-allow-cycling t bbdb-always-add-addresses t bbdb/mail-auto-create-p t) (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus))) ;; press * v to export a bbdb search result view ;; https://github.com/tohojo/bbdb-vcard ;;(add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/bbdb-vcard/"))) ;;(require 'bbdb-vcard) ;; (defun attila/delete-bbdb-xfields (field-name) ;; (bbdb-with-db-buffer ;; (dolist (record bbdb-records) ;; (bbdb-record-set-xfield record field-name nil) ;; (bbdb-change-record record)) ;; (bbdb-save))) ;;(setf minibuffer-message-timeout 0) ;;(setq tramp-default-proxies-alist '(("ebr42.otm.gov.hu" "" "/ssh:%u@armageddon.intranet.netvisor.hu#2222:"))) ;; KLUDGE to deal with the 'hyperspect' debian package (let ((buffer (find-buffer-visiting "/usr/share/doc/hyperspec/Data/Map_Sym.txt"))) (when buffer (kill-buffer buffer))) ;;(setq browse-url-firefox-program "/usr/local/bin/Icecat32") ;;(setq browse-url-firefox-program "firefox") (setq browse-url-browser-function 'browse-url-generic) (setq browse-url-generic-program "chromium") ;; http://random-state.net/log/3512630740.html (setq font-lock-verbose nil) ;; (add-hook 'slime-load-hook (lambda () (setq slime-protocol-version 'ignore))) ;(ignore-errors ; (let ((dir "/media/store/work/")) ; (when (file-exists-p dir) ; (dolist (entry (dwim/build-sbcl-lisp-implementation-entries/from-installed-binaries dir)) ; (pushnew entry slime-lisp-implementations :test 'equal))))) ;(add-hook 'bbdb-initialize-hook (lambda () ; (setq bbdb-user-mail-names ; (regexp-opt '("attila.lendvai@gmail.com"))))) ;; TODO promote to shared settings? (global-set-key [(control meta ?,)] 'dwim-copy-word-at-point) (global-set-key [(control meta ?.)] 'dwim-replace-word-at-point-with-clipboard) (defun ati-c-setup () (setq c-default-style "linux" c-basic-offset 4) (modify-syntax-entry ?_ "w" c-mode-syntax-table) ; _ should not be a word separator (pushnew '(statement-case-intro . 0) c-offsets-alist) (pushnew '(substatement-open . 0) c-offsets-alist) (cl-flet ((redef (key function) (define-key c-mode-map key function) (define-key c++-mode-map key function))) (redef [(control ?d)] 'dwim-duplicate-line-at-point) (redef (kbd "[") (lambda () (interactive) (insert "("))) (redef (kbd "]") (lambda () (interactive) (insert ")"))) (redef (kbd "\(") (lambda () (interactive) (insert "["))) (redef (kbd "\)") (lambda () (interactive) (insert "]"))))) (add-hook 'c-mode-hook 'ati-c-setup) ;(add-hook 'lisp-mode-hook (lambda () ; (setf slime-default-lisp 'sbcl-perec-development-image))) ;; (add-to-list 'load-path (expand-file-name "~/workspace/environment/emacs-addons/icicles/")) ;; (require 'icicles) ;; (icy-mode) ;; (unless icicle-fuzzy-completion-flag ;; (icicle-toggle-fuzzy-completion)) ;; (add-hook 'ido-define-mode-map-hook ;; (lambda () ;; (cl-flet ((redef (key function) ;; (define-key ido-completion-map key function))) ;; (redef (kbd "M-p") 'previous-history-element) ;; (redef (kbd "") 'previous-history-element) ;; (redef (kbd "M-n") 'next-history-element) ;; (redef (kbd "") 'next-history-element)))) (dwim-redefine-ido-key (kbd "C-b") (lookup-key global-map (kbd "C-b"))) (dwim-redefine-ido-key (kbd "M-b") (lookup-key global-map (kbd "M-b"))) ;; ;; ;; lua ;; ;; (autoload 'lua-mode "lua-mode" "Lua editing mode." t) (add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode)) (add-to-list 'interpreter-mode-alist '("lua" . lua-mode)) (defun* dwim-define-lua-key (key binding &key (repl t) (buffers t)) (when buffers (define-key lua-mode-map key binding)) ;; it's a goddamn plain commint-mode, no repl map... ;;(when repl ;; (define-key slime-repl-mode-map key binding)) ) (defun attila/lua-mode-hook () (dwim-define-lua-key (kbd "[") (lambda () (interactive) (insert "("))) (dwim-define-lua-key (kbd "]") (lambda () (interactive) (insert ")"))) (dwim-define-lua-key (kbd "\(") (lambda () (interactive) (insert "["))) (dwim-define-lua-key (kbd "\)") (lambda () (interactive) (insert "]"))) (dwim-define-lua-key (kbd "C-c C-c") (lambda () (interactive) (save-excursion (let ((start (progn (lua-beginning-of-proc) (point))) (end (progn (lua-end-of-proc) (point))) (original-repl-buffer-size (buffer-size lua-process-buffer)) (lua-always-show nil)) (slime-flash-region start end) (lua-send-region start end) (when (> (- (buffer-size lua-process-buffer) original-repl-buffer-size) 10) (display-buffer lua-process-buffer)))))) (dwim-define-lua-key (kbd "C-/") (lambda () (interactive) (or (and lua-process (comint-check-proc lua-process-buffer)) (lua-start-process lua-default-application)) (dwim-switch-between-target-buffer-and-last-buffer lua-process-buffer) (goto-char (1+ (buffer-size lua-process-buffer))))) (setq lua-default-application "/home/alendvai/workspace/lua-5.2.0/src/lua ") (setq lua-default-application "/usr/bin/env") (setq lua-default-command-switches '("LUA_PATH=/home/alendvai/workspace/luasocket2-hg/install/share/lua/5.2/?.lua" "LUA_CPATH=/home/alendvai/workspace/luasocket2-hg/install/lib/lua/5.2/?.so" "/home/alendvai/workspace/lua-5.2.0/src/lua" "-i"))) (add-hook 'lua-mode-hook 'attila/lua-mode-hook) ;; ;; ;; python ;; ;; (defun attila/python-mode-hook () (modify-syntax-entry ?_ "w" python-mode-syntax-table) ; _ should not be a word separator (cl-flet ((redef (key function) (define-key python-mode-map key function))) (redef (kbd "RET") 'newline-and-indent) (redef (kbd "[") (lambda () (interactive) (insert "("))) (redef (kbd "]") (lambda () (interactive) (insert ")"))) (redef (kbd "\(") (lambda () (interactive) (insert "["))) (redef (kbd "\)") (lambda () (interactive) (insert "]"))) (redef (kbd "M-") 'sp-backward-sexp) (redef (kbd "M-") 'sp-forward-sexp) (redef (kbd "M-") 'sp-down-sexp) (redef (kbd "M-") 'sp-backward-up-sexp))) (add-hook 'python-mode-hook 'attila/python-mode-hook) ;;(load (expand-file-name (concat dwim-common-lisp-workspace "/hu.dwim.environment/emacs/nxhtml/autostart.el"))) (setq enable-local-variables t) (defun unfill-paragraph () "Takes a multi-line paragraph and makes it into a single line of text." (interactive) (let ((fill-column (point-max))) (fill-paragraph nil))) (global-set-key "\M-Q" 'unfill-paragraph) ;; ;; ;; comint-mode ;; ;; ;; an alternative is #ansi-mode: You should generally stay in char mode (bound to C-c C-k) and occasionally switch to line mode (bound to C-c C-j) for editing command output. (define-key comint-mode-map (kbd "M-p") 'comint-previous-matching-input-from-input) (define-key comint-mode-map (kbd "M-n") 'comint-next-matching-input-from-input) ;; from https://emacs.stackexchange.com/a/2897/5312 (setq comint-prompt-read-only t) (defun attila/comint-preoutput-turn-buffer-read-only (text) (propertize text 'read-only t)) (add-hook 'comint-preoutput-filter-functions 'attila/comint-preoutput-turn-buffer-read-only) ;; go-mode (add-to-list 'load-path (expand-file-name (concat dwim-emacs-workspace "/go-mode.el"))) (require 'go-mode-autoloads) ;; org-mode redefines at least one of these, so write it over (add-hook 'org-mode-hook (defun attila/org-mode-hook () (print "attila/org-mode-hook running...") (dwim-copy-keymap-entry/global-to-local (kbd "C-,")) (dwim-copy-keymap-entry/global-to-local (kbd "C-.")) (dwim-copy-keymap-entry/global-to-local [(control tab)]) (dwim-copy-keymap-entry/global-to-local [(control e)]))) (pushnew '(ecl ("/opt/ecl/bin/ecl")) slime-lisp-implementations :test 'equal) ;; #maru stuff, temporarily here (add-to-list 'load-path (expand-file-name "~/workspace/llvm-project/llvm/utils/emacs/")) (require 'llvm-mode) (pushnew `(sbcl-maru-development ,(lambda () (dwim/build-sbcl-lisp-implementation-entry/image "maru_development"))) slime-lisp-implementations :test 'equal) (setq whitespace-global-modes (remove 'asm-mode whitespace-global-modes)) (defun maru-lisp-mode-hook () ;; otherwise it gets confused in maru files (100% CPU) (modify-syntax-entry ?| "w" lisp-mode-syntax-table) (let ((overrides '((list-do 2) (array-do 2) (environment-do 1) (times-do 1) (string-do 2) (if-at-expand if) (when-at-expand when) (awhen when) (aif if) (types-do 1) (define-emit 1) (define-operand 2) (define-method 3) (define-selector 1) (define-primitive-function 2) (gc/protect 1) (gc/let 1) (gc/let* 1) (for 1) (make 1) (safety 1) (verbosity 1) (make/opaque 1) (eval-in-module 1) (with-instance-accessors 2) (while 1) (until while) (if 2)))) (dolist (el overrides) (put (first el) 'common-lisp-indent-function (if (symbolp (second el)) (get (second el) 'common-lisp-indent-function) (second el))))) (font-lock-add-keywords 'lisp-mode `(("\\((safe[ \n]*.*\\)" 1 'font-lock-logger-expression-face t) ("\\((debug.*)\\)" 0 'font-lock-logger-expression-face t) ("\\((k/assert.*)\\)" 0 'font-lock-logger-expression-face t) ("\\((gc/debug[ \n].*)\\)" 0 'font-lock-logger-expression-face t) (,(concatenate 'string "[(']\\(" (regexp-opt '("put" "get" "set" "incr" "decr" "return" "if-at-expand" "when-at-expand" "eval-at-expand") t) "\\|with.*?-lock.*?\\|recurse.*?\\)[ \n()]") 1 font-lock-builtin-face t) (,(concatenate 'string "([ \n]*" (regexp-opt '("gc/let*") t) "[ \n()]") 1 font-lock-keyword-face)))) (add-hook 'lisp-mode-hook 'maru-lisp-mode-hook) (setq slime-default-lisp 'sbcl-hu.dwim-development) ;;(setq slime-default-lisp 'sbcl-maru-development)