From 58769965a640417d9a33bba3bd08a253cef8df13 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Sat, 1 Feb 2014 23:04:12 -0500 Subject: [PATCH] First blood --- .gitignore | 5 + emacsclient-activities | 24 ++++ init.el | 245 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 274 insertions(+) create mode 100644 .gitignore create mode 100755 emacsclient-activities create mode 100644 init.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65de021 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +auto-save-list +autosaves +sessions +backup +eshell diff --git a/emacsclient-activities b/emacsclient-activities new file mode 100755 index 0000000..8d55d41 --- /dev/null +++ b/emacsclient-activities @@ -0,0 +1,24 @@ +#!/bin/zsh + +function laststatus { return $? } + +kde-current-activity () { + qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.CurrentActivity +} + +emacsclient -n -s "$(kde-current-activity)" -a '/usr/bin/emacs' $@ + +# emacsclient -s "$(kde-current-activity)" -a false -e 'server-name' >/dev/null + +# if laststatus; then +# echo Server for current activity is running +# local exists=$(emacsclient -s "$(kde-current-activity)" -a "echo nil" -e '(select-X-frame)') +# if [[ $exists == "t" ]]; then +# emacsclient -s "$(kde-current-activity)" -n $@; +# else +# emacsclient -s "$(kde-current-activity)" -c -n $@; +# fi +# else +# echo Server is not running +# /usr/bin/emacs --daemon="$(kde-current-activity)" && emacsclient -s "$(kde-current-activity)" -c -n $@ +# fi diff --git a/init.el b/init.el new file mode 100644 index 0000000..732c04c --- /dev/null +++ b/init.el @@ -0,0 +1,245 @@ +(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. + '(TeX-newline-function (quote reindent-then-newline-and-indent)) + '(auto-save-file-name-transforms (quote ((".*" "~/.emacs.d/autosaves/\\1" t)))) + '(backup-directory-alist (quote ((".*" . "~/.emacs.d/backup/")))) + '(case-fold-search t) + '(current-language-environment "English") + '(default-input-method "rfc1345") + '(flyspell-duplicate-distance 0) + '(flyspell-mark-duplications-flag t) + '(font-latex-fontify-sectioning (quote color)) + '(global-font-lock-mode t nil (font-lock)) + '(inhibit-startup-screen t) + '(safe-local-variable-values (quote ((bookmark-default-file . "./emacs.bmk")))) + '(show-paren-mode t) + '(transient-mark-mode t) + '(truncate-partial-width-windows nil)) + +(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. + '(default ((t (:background "DarkSlateGrey" :foreground "Wheat" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 80 :width normal :foundry "xos4" :family "terminus")))) + '(bold ((t (:weight semi-bold)))) + '(cursor ((t (:background "orchid")))) + '(fixed-pitch ((t (:family "Bitstream Vera Sans Mono")))) + '(italic ((((supports :underline t)) nil))) + '(menu ((t (:inverse-video t)))) + '(mouse ((t (:background "orchid")))) + '(tooltip ((t (:inherit default :background "lightyellow" :foreground "black" :foundry "xos4" :family "terminus")))) + '(variable-pitch ((t (:family "default"))))) + +(setq-default display-buffer-reuse-frames t) + +(setq c-basic-offset 4) +(setq indent-tabs-mode nil) + +(setq-default abbrev-mode t) +(read-abbrev-file "~/.abbrev_defs") +(setq save-abbrevs t) + +;; fix compilation window eating up my work window +(setq compilation-scroll-output t + compilation-window-height 12) + +(tool-bar-mode 0) +(scroll-bar-mode -1) +(setq-default show-trailing-whitespace t) +(setq search-whitespace-regexp "[ \t\r\n]+") +(setq flyspell-use-meta-tab nil) + +(setq redisplay-dont-pause t + scroll-margin 1 + scroll-step 1 + scroll-conservatively 10000 + scroll-preserve-screen-position 1) + +(defun delete-word (arg) + "Delete characters forward until encountering the end of a word. + With argument, do this that many times." + (interactive "p") + (delete-region (point) (progn (forward-word arg) (point)))) + +(defun backward-delete-word (arg) + "Delete characters backward until encountering the end of a word. + With argument, do this that many times." + (interactive "p") + (delete-word (- arg))) + +(require 'mic-paren) ; loading +(paren-activate) ; activating + +(global-set-key (kbd "C-'") 'backward-delete-char) +(global-set-key (kbd "M-'") 'backward-kill-word) + +(global-set-key (kbd "C-M-") 'backward-kill-sexp) +(global-set-key (kbd "") 'TeX-complete-symbol) + +(setq mouse-autoselect-window nil) +(mouse-wheel-mode t) +(load "auctex.el" nil t t) +(setq TeX-auto-save t + TeX-parse-self t + TeX-insert-braces nil) +(setq-default TeX-master nil) +(setq font-latex-fontify-script nil) +(setq LaTeX-equation-label "e_") +(setq LaTeX-section-label "s_") +(load "~/bibsnarf.el" nil t t) +(require 'reftex) + +(fset 'insert-matching-paren + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([92 108 101 102 116 40 92 114 105 103 104 116 41 C-left left] 0 "%d")) arg))) +(fset 'insert-matching-sqbraces + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([92 108 101 102 116 91 92 114 105 103 104 116 93 C-left left] 0 "%d")) arg))) +(fset 'insert-matching-braces + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([92 108 101 102 116 92 123 92 114 105 103 104 116 92 125 C-left left] 0 "%d")) arg))) +(fset 'insert-matching-abs + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([92 108 101 102 116 124 92 114 105 103 104 116 124 C-left left] 0 "%d")) arg))) +(fset 'insert-matching-bcs + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([123 125 left] 0 "%d")) arg))) +(fset 'insert-superscript + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([94 123] 0 "%d")) arg))) +(fset 'insert-subscript + (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote (["_" 123] 0 "%d")) arg))) +(global-set-key (kbd "C-^") 'insert-superscript) +(global-set-key (kbd "C-_") 'insert-subscript) + + +;; KDE stuff +;; + +(add-to-list 'load-path "~/kde-emacs") + +(load "qml-mode.el" nil t t); +(require 'kde-emacs) +;;(setq kde-full-name "Jacopo De Simoi") +;;(setq kde-email "wilderkde@gmail.com") + +(setq frame-title-format + '("emacs %S: " (buffer-file-name "%f" + (dired-directory dired-directory "%b")))) + + +;; Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs.d/. +;; create the autosave dir if necessary, since emacs won't. +(make-directory "~/.emacs.d/autosaves/" t) +(make-directory "~/.emacs.d/backup/" t) + +;;(load "skype.el" nil t t) +;; +(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) +(add-hook 'text-mode-hook 'flyspell-mode) +(require 'linum) +(add-hook 'LaTeX-mode-hook 'linum-mode) +;; Let us see how it goes with this. +(add-hook 'LaTeX-mode-hook 'subword-mode) +(add-hook 'LaTeX-mode-hook (lambda () (modify-syntax-entry ?\\ "w" LaTeX-mode-syntax-table))) + +;; this should really be called in the hook +(setq subword-forward-regexp "\\W*\\(\\([\\\\[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") +(setq subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([\\\\[:upper:]]+\\W*\\)\\|\\W\\w+\\)") + + +(setq default-fill-column 120) +(add-to-list 'load-path "~/tmp" "~/tmp/expand-region.el") + +(setq mouse-yank-at-point t) +(blink-cursor-mode 0) +(global-hl-line-mode t) +(setq focus-follows-mouse nil) + +(require 'pomodoro) +(require 'key-chord) +(key-chord-mode 1) + + +;; kde activity stuff -- move to other file when stabilized +(defun kde-current-activity () + "Returns the current KDE activity" + (substring (shell-command-to-string "qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.CurrentActivity") 0 -1) +) + +(defun X-window-id-belongs-to-activity (window-id activity) + (= (shell-command (concat "xprop -id " window-id " | grep _KDE_NET_WM_ACTIVITIES | grep " activity ">/dev/null")) 0) +) + +(defun select-frame-on-activity (activity) + (setq framelist (frame-list)) + (setq done nil) + (while (and framelist (not done)) + (setq cur (car framelist)) + (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) + (if cur-id (if (X-window-id-belongs-to-activity cur-id activity) (progn; +(setq done 't) (select-frame cur)) )) + (setq framelist (cdr framelist))) + done +) + +(defun select-X-frame () + (setq framelist (frame-list)) + (setq done nil) + (while (and framelist (not done)) + (setq cur (car framelist)) + (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) + (if cur-id (progn; + (setq done 't) (raise-frame cur))) + (setq framelist (cdr framelist))) + done +) + +(defun select-frame-on-current-activity () + (select-frame-on-activity (kde-current-activity)) +) + +;; stop using the arrow keys +;; mark the date 30/1/2014 +(global-unset-key [left]) +(global-unset-key [up]) +(global-unset-key [right]) +(global-unset-key [down]) + +;;Remove insanely irritating key-binding +(global-unset-key (kbd "C-z")) + +(require 'visible-mark) +(visible-mark-mode t) +(global-visible-mark-mode t) + +(delete 'Git vc-handled-backends) +(require 'magit) + +(require 'iy-go-to-char) +;; (key-chord-define-global "hjdd" 'iy-go-to-char-backward) +;; (key-chord-define-global "jk" 'iy-go-to-char) + +(defun smart-line-beginning () + "Move point to the beginning of text on the current line; if that is already +the current position of point, then move it to the beginning of the line." + (interactive) + (let ((pt (point))) + (beginning-of-line-text) + (when (eq pt (point)) + (beginning-of-line)))) + +(global-set-key (kbd "C-a") 'smart-line-beginning) +(global-set-key (kbd "M-m") 'iy-go-to-char) + +(defun emacs-session-filename (session-id) + "Construct a filename to save the session in based on SESSION-ID. +If the directory ~/.emacs.d exists, we make a filename in there, otherwise +a file in the home directory." + (let ((basename (concat "sessions/session." session-id)) + (emacs-dir user-emacs-directory)) + (expand-file-name (if (file-directory-p emacs-dir) + (concat emacs-dir basename) + (concat "~/.emacs-" basename))))) + +(setq server-name (kde-current-activity)) +(server-start) +(menu-bar-mode -99)