Anonymous avatar Anonymous committed a25db56

More changes

Comments (0)

Files changed (26)

 projectile-bookmarks.eld
 projectile.cache
 tramp
+*.elc
 ;; It keeps track of achievements you've already achieved.
 ;; Do not edit it manually, otherwise you'll spoil yourself the fun!
 
+(amode-set-achievement-data-plist "VISIT_FILE" (list :level 0))
+(amode-set-achievement-data-plist "SAVE_BUFFER" (list :level 0))
+(amode-set-achievement-data-plist "NO_ARROWS" (list :level 1 :data 7))
 (amode-set-achievement-data-plist "EVIL_MODE" (list :level 3))
-(amode-set-achievement-data-plist "NO_ARROWS" (list :level 1 :data 7))
 (amode-set-achievement-data-plist "CHEATING_BASTARD" (list :level 1))
 (amode-set-achievement-data-plist "TUTORIAL" (list :level 1))

files/allout-config.el

+(use-package allout
+  :commands allout-mode
+  :config
+  (progn
+    (defun my-allout-init ()
+      (unbind-key "M-k" allout-mode-map))
+
+    (add-hook 'allout-mode-hook 'my-allout-init)
+    ;; redefine this to make it work with smartparens
+    (defun allout-pre-command-business ()
+      "Outline `pre-command-hook' function for outline buffers.
+
+Among other things, implements special behavior when the cursor is on the
+topic bullet character.
+
+When the cursor is on the bullet character, self-insert
+characters are reinterpreted as the corresponding
+control-character in the `allout-mode-map-value'.  The
+`allout-mode' `post-command-hook' insures that the cursor which
+has moved as a result of such reinterpretation is positioned on
+the bullet character of the destination topic.
+
+The upshot is that you can get easy, single (ie, unmodified) key
+outline maneuvering operations by positioning the cursor on the bullet
+char.  When in this mode you can use regular cursor-positioning
+command/keystrokes to relocate the cursor off of a bullet character to
+return to regular interpretation of self-insert characters."
+
+      (if (not (allout-mode-p))
+          nil
+        (setq allout-command-counter (1+ allout-command-counter))
+        (setq allout-this-command-hid-text nil)
+        ;; Do hot-spot navigation.
+        (if (and (memq this-command '(sp--self-insert-command self-insert-command))
+                 (eq (point)(allout-current-bullet-pos)))
+            (allout-hotspot-key-handler))))))

files/allout.el

-(use-package allout
-  :commands allout-mode
-  :config
-  (progn
-    (defun my-allout-init ()
-      (unbind-key "M-k" allout-mode-map))
-
-    (add-hook 'allout-mode-hook 'my-allout-init)
-    ;; redefine this to make it work with smartparens
-    (defun allout-pre-command-business ()
-      "Outline `pre-command-hook' function for outline buffers.
-
-Among other things, implements special behavior when the cursor is on the
-topic bullet character.
-
-When the cursor is on the bullet character, self-insert
-characters are reinterpreted as the corresponding
-control-character in the `allout-mode-map-value'.  The
-`allout-mode' `post-command-hook' insures that the cursor which
-has moved as a result of such reinterpretation is positioned on
-the bullet character of the destination topic.
-
-The upshot is that you can get easy, single (ie, unmodified) key
-outline maneuvering operations by positioning the cursor on the bullet
-char.  When in this mode you can use regular cursor-positioning
-command/keystrokes to relocate the cursor off of a bullet character to
-return to regular interpretation of self-insert characters."
-
-      (if (not (allout-mode-p))
-          nil
-        (setq allout-command-counter (1+ allout-command-counter))
-        (setq allout-this-command-hid-text nil)
-        ;; Do hot-spot navigation.
-        (if (and (memq this-command '(sp--self-insert-command self-insert-command))
-                 (eq (point)(allout-current-bullet-pos)))
-            (allout-hotspot-key-handler))))))

files/diminish.el

 (require 'diminish)
-(diminish 'undo-tree-mode)
+(eval-after-load "undo-tree-mode"
+  '(diminish 'undo-tree-mode))
 (diminish 'visual-line-mode)
 (diminish 'smartparens-mode)
 (eval-after-load "eldoc"

files/dired-setup.el

 ;; see commentary in dired-defs.el
 (use-package dired
   :bind (("C-x d"  . my-dired-files)
-         ("M-<f2>" . my-find-dired))
+         ("M-<f2>" . my-find-dired)
+         ("C-x C-j" . dired-jump))
   :init
   (progn
     (defun my-dired-files (&optional arg)

files/ido-config.el

+(use-package ido
+  :defer t
+  :bind (("M-." . ido-goto-symbol) ;; was Find tag
+         )
+  :config
+  (progn
+    (use-package flx-ido
+      :defer t)
+
+    ;; Display ido results vertically, rather than horizontally
+    (setq ido-decorations (quote ("\n-> " "" "\n   " "\n   ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")))
+    (defun ido-disable-line-trucation () (set (make-local-variable 'truncate-lines) nil))
+    (add-hook 'ido-minibuffer-setup-hook 'ido-disable-line-trucation)
+
+    ;; see: http://emacswiki.org/emacs/InteractivelyDoThings#toc25
+    (defun ido-smart-select-text ()
+      "Select the current completed item.  Do NOT descend into directories."
+      (interactive)
+      (when (and (or (not ido-require-match)
+                     (if (memq ido-require-match
+                               '(confirm confirm-after-completion))
+                         (if (or (eq ido-cur-item 'dir)
+                                 (eq last-command this-command))
+                             t
+                           (setq ido-show-confirm-message t)
+                           nil))
+                     (ido-existing-item-p))
+                 (not ido-incomplete-regexp))
+        (when ido-current-directory
+          (setq ido-exit 'takeprompt)
+          (unless (and ido-text (= 0 (length ido-text)))
+            (let ((match (ido-name (car ido-matches))))
+              (throw 'ido
+                     (setq ido-selected
+                           (if match
+                               (replace-regexp-in-string "/\\'" "" match)
+                             ido-text)
+                           ido-text ido-selected
+                           ido-final-text ido-text)))))
+        (exit-minibuffer)))
+
+    (defun my-ido-keys ()
+      (bind-key "C-<tab>" 'ido-smart-select-text ido-file-dir-completion-map))
+
+    (add-hook 'ido-setup-hook 'my-ido-keys)
+
+    ;; ido and imenu integration
+    (defun ido-goto-symbol (&optional symbol-list)
+      "Refresh imenu and jump to a place in the buffer using Ido."
+      (interactive)
+      (unless (featurep 'imenu)
+        (require 'imenu nil t))
+      (cond
+       ((not symbol-list)
+        (let ((ido-mode ido-mode)
+              (ido-enable-flex-matching
+               (if (boundp 'ido-enable-flex-matching)
+                   ido-enable-flex-matching t))
+              name-and-pos symbol-names position)
+          (unless ido-mode
+            (ido-mode 1)
+            (setq ido-enable-flex-matching t))
+          (while (progn
+                   (imenu--cleanup)
+                   (setq imenu--index-alist nil)
+                   (ido-goto-symbol (imenu--make-index-alist))
+                   (setq selected-symbol
+                         (ido-completing-read "Symbol? " symbol-names))
+                   (string= (car imenu--rescan-item) selected-symbol)))
+          (unless (and (boundp 'mark-active) mark-active)
+            (push-mark nil t nil))
+          (setq position (cdr (assoc selected-symbol name-and-pos)))
+          (cond
+           ((overlayp position)
+            (goto-char (overlay-start position)))
+           (t
+            (goto-char position)))))
+       ((listp symbol-list)
+        (dolist (symbol symbol-list)
+          (let (name position)
+            (cond
+             ((and (listp symbol) (imenu--subalist-p symbol))
+              (ido-goto-symbol symbol))
+             ((listp symbol)
+              (setq name (car symbol))
+              (setq position (cdr symbol)))
+             ((stringp symbol)
+              (setq name symbol)
+              (setq position
+                    (get-text-property 1 'org-imenu-marker symbol))))
+            (unless (or (null position) (null name)
+                        (string= (car imenu--rescan-item) name))
+              (setq word-under-cursor (thing-at-point 'symbol))
+              (setq fix-the-order (not (null (member word-under-cursor symbol-names))))
+              (add-to-list 'symbol-names name)
+              (when fix-the-order
+                (delete word-under-cursor symbol-names)
+                (add-to-list 'symbol-names word-under-cursor))
+              (add-to-list 'name-and-pos (cons name position))))))))
+
+    ;; sort ido filelist by mtime instead of alphabetically
+    (defun ido-sort-mtime ()
+      (setq ido-temp-list
+            (sort ido-temp-list
+                  (lambda (a b)
+                    (time-less-p
+                     (sixth (file-attributes (concat ido-current-directory b)))
+                     (sixth (file-attributes (concat ido-current-directory a)))))))
+      (ido-to-end  ;; move . files to end (again)
+       (--select (char-equal (string-to-char it) ?.) ido-temp-list))
+      (when ido-show-dot-for-dired
+        (setq ido-temp-list
+              (cons "." (--remove (equal it ".") ido-temp-list)))))
+
+    (add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
+    (add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)))

files/ido.el

-(use-package ido
-  :bind (("M-." . ido-goto-symbol) ;; was Find tag
-         )
-  :config
-  (progn
-    (require 'flx-ido)
-
-    ;; Display ido results vertically, rather than horizontally
-    (setq ido-decorations (quote ("\n-> " "" "\n   " "\n   ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]")))
-    (defun ido-disable-line-trucation () (set (make-local-variable 'truncate-lines) nil))
-    (add-hook 'ido-minibuffer-setup-hook 'ido-disable-line-trucation)
-
-    ;; see: http://emacswiki.org/emacs/InteractivelyDoThings#toc25
-    (defun ido-smart-select-text ()
-      "Select the current completed item.  Do NOT descend into directories."
-      (interactive)
-      (when (and (or (not ido-require-match)
-                     (if (memq ido-require-match
-                               '(confirm confirm-after-completion))
-                         (if (or (eq ido-cur-item 'dir)
-                                 (eq last-command this-command))
-                             t
-                           (setq ido-show-confirm-message t)
-                           nil))
-                     (ido-existing-item-p))
-                 (not ido-incomplete-regexp))
-        (when ido-current-directory
-          (setq ido-exit 'takeprompt)
-          (unless (and ido-text (= 0 (length ido-text)))
-            (let ((match (ido-name (car ido-matches))))
-              (throw 'ido
-                     (setq ido-selected
-                           (if match
-                               (replace-regexp-in-string "/\\'" "" match)
-                             ido-text)
-                           ido-text ido-selected
-                           ido-final-text ido-text)))))
-        (exit-minibuffer)))
-
-    (defun my-ido-keys ()
-      (bind-key "C-<tab>" 'ido-smart-select-text ido-file-dir-completion-map))
-
-    (add-hook 'ido-setup-hook 'my-ido-keys)
-
-    ;; ido and imenu integration
-    (defun ido-goto-symbol (&optional symbol-list)
-      "Refresh imenu and jump to a place in the buffer using Ido."
-      (interactive)
-      (unless (featurep 'imenu)
-        (require 'imenu nil t))
-      (cond
-       ((not symbol-list)
-        (let ((ido-mode ido-mode)
-              (ido-enable-flex-matching
-               (if (boundp 'ido-enable-flex-matching)
-                   ido-enable-flex-matching t))
-              name-and-pos symbol-names position)
-          (unless ido-mode
-            (ido-mode 1)
-            (setq ido-enable-flex-matching t))
-          (while (progn
-                   (imenu--cleanup)
-                   (setq imenu--index-alist nil)
-                   (ido-goto-symbol (imenu--make-index-alist))
-                   (setq selected-symbol
-                         (ido-completing-read "Symbol? " symbol-names))
-                   (string= (car imenu--rescan-item) selected-symbol)))
-          (unless (and (boundp 'mark-active) mark-active)
-            (push-mark nil t nil))
-          (setq position (cdr (assoc selected-symbol name-and-pos)))
-          (cond
-           ((overlayp position)
-            (goto-char (overlay-start position)))
-           (t
-            (goto-char position)))))
-       ((listp symbol-list)
-        (dolist (symbol symbol-list)
-          (let (name position)
-            (cond
-             ((and (listp symbol) (imenu--subalist-p symbol))
-              (ido-goto-symbol symbol))
-             ((listp symbol)
-              (setq name (car symbol))
-              (setq position (cdr symbol)))
-             ((stringp symbol)
-              (setq name symbol)
-              (setq position
-                    (get-text-property 1 'org-imenu-marker symbol))))
-            (unless (or (null position) (null name)
-                        (string= (car imenu--rescan-item) name))
-              (setq word-under-cursor (thing-at-point 'symbol))
-              (setq fix-the-order (not (null (member word-under-cursor symbol-names))))
-              (add-to-list 'symbol-names name)
-              (when fix-the-order
-                (delete word-under-cursor symbol-names)
-                (add-to-list 'symbol-names word-under-cursor))
-              (add-to-list 'name-and-pos (cons name position))))))))
-
-    ;; sort ido filelist by mtime instead of alphabetically
-    (defun ido-sort-mtime ()
-      (setq ido-temp-list
-            (sort ido-temp-list
-                  (lambda (a b)
-                    (time-less-p
-                     (sixth (file-attributes (concat ido-current-directory b)))
-                     (sixth (file-attributes (concat ido-current-directory a)))))))
-      (ido-to-end  ;; move . files to end (again)
-       (--select (char-equal (string-to-char it) ?.) ido-temp-list))
-      (when ido-show-dot-for-dired
-        (setq ido-temp-list
-              (cons "." (--remove (equal it ".") ido-temp-list)))))
-
-    (add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
-    (add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)))

files/isearch-config.el

+(use-package "isearch"
+  :bind (("C-s" . isearch-forward-regexp)
+         ("C-r" . isearch-backward-regexp))
+  :config
+  (progn
+    (use-package flex-isearch
+      :defer t
+      :load-path "~/.emacs.d/vendor/flex-isearch/"
+      :config
+      (progn
+        (defadvice isearch-forward-regexp (around flex-isearch activate)
+          (when (and flex-isearch-mode
+                     (equal (ad-get-arg 0) '(16)))
+            (flex-isearch-activate)
+            (ad-set-arg 0 '(4)))
+          ad-do-it)
+
+        (defadvice isearch-backward-regexp (around flex-isearch activate)
+          (when (and flex-isearch-mode
+                     (equal (ad-get-arg 0) '(16)))
+            (flex-isearch-activate)
+            (ad-set-arg 0 '(4)))
+          ad-do-it)))
+
+    (defun my-isearch-forward ()
+      "Repeat the forward search.
+
+If called from backward search, immediately jump to the following
+occurance instead of jumping to the end of current one."
+      (interactive)
+      (when (not isearch-forward)
+        (isearch-repeat 'forward))
+      (isearch-repeat 'forward))
+
+    (defun my-isearch-backward ()
+      "Repeat the backward search.
+
+If called from forward search, immediately jump to the previous
+occurance instead of jumping to the beginning of current one."
+      (interactive)
+      (when (and isearch-forward
+                 (/= (point) isearch-other-end))
+        (isearch-repeat 'backward))
+      (isearch-repeat 'backward))
+
+    (defun my-isearch-forward-to-beginning ()
+      "Repeat the forward search and place the point before the
+matched text."
+      (interactive)
+      (when (not isearch-forward)
+        (isearch-repeat 'forward))
+      (isearch-repeat 'forward)
+      (goto-char isearch-other-end))
+
+    (defun my-isearch-kill-match ()
+      "Kill the text last matched by isearch."
+      (interactive)
+      (isearch-exit)
+      (kill-region (point) isearch-other-end))
+
+    (defun my-isearch-zap-to-match ()
+      "Kill the region between the point of origin of isearch and the
+closest portion of the isearch match string.  The behaviour is
+meant to be analogous to zap-to-char.  The deleted region does
+not include the isearch word.  This is meant to be bound only in
+isearch mode."
+      (interactive)
+      (let* ((isearch-bounds (list isearch-other-end (point)))
+             (ismin (apply 'min isearch-bounds))
+             (ismax (apply 'max isearch-bounds))
+             (beg isearch-opoint))
+        (cond
+         ((< beg ismin)
+          (goto-char ismin)
+          (kill-region beg ismin))
+         ((> beg ismax)
+          (goto-char beg)
+          (kill-region ismax beg))
+         (t
+          (error "Internal error in isearch kill function.")))
+        (isearch-exit)))
+
+    (defun my-isearch-exit-other-end ()
+      "Exit isearch, but at the other end of the search string.
+This is useful when followed by an immediate kill."
+      (interactive)
+      (isearch-exit)
+      (goto-char isearch-other-end))
+
+    (defun my-isearch-yank-symbol ()
+      "Pull next symbol from buffer into search string."
+      (interactive)
+      (isearch-yank-internal (lambda () (sp-forward-symbol) (point))))
+
+    (defun my-isearch-exit ()
+      "Exit search normally.
+
+If in dired buffer, find file under cursor.  If it is a
+directory, go right back into search."
+      (interactive)
+      (isearch-exit)
+      (if (eq major-mode 'dired-mode)
+          ;; we're assuming no files are marked
+          (let ((d (car (dired-get-marked-files))))
+            (dired-find-file)
+            (when (file-directory-p d)
+              (dired-isearch-filenames)))))
+
+    ;; keybindings
+    (bind-key "<f6>" 'replace-regexp)
+
+    (bind-key "C-v" 'my-isearch-forward-to-beginning isearch-mode-map)
+    (bind-key "C-r" 'my-isearch-backward             isearch-mode-map)
+    (bind-key "C-s" 'my-isearch-forward              isearch-mode-map)
+    (bind-key "C-2" 'my-isearch-kill-match           isearch-mode-map)
+    (bind-key "C-3" 'my-isearch-exit-other-end       isearch-mode-map)
+    (bind-key "C-w" 'my-isearch-yank-symbol          isearch-mode-map)
+    (bind-key "C-M-w" 'isearch-yank-word-or-char     isearch-mode-map)
+    (bind-key "M-z" 'my-isearch-zap-to-match         isearch-mode-map)
+    (bind-key "<f2>" 'isearch-occur                  isearch-mode-map)
+    (bind-key "\r" 'my-isearch-exit                  isearch-mode-map)
+
+    (bind-key "C-S-s" 'flex-isearch-forward)
+    (bind-key "C-S-r" 'flex-isearch-backward)))

files/isearch.el

-(use-package "isearch"
-  :bind (("C-s" . isearch-forward-regexp)
-         ("C-r" . isearch-backward-regexp))
-  :config
-  (progn
-    (use-package flex-isearch
-      :load-path "~/.emacs.d/vendor/flex-isearch/"
-      :config
-      (progn
-        (defadvice isearch-forward-regexp (around flex-isearch activate)
-          (when (and flex-isearch-mode
-                     (equal (ad-get-arg 0) '(16)))
-            (flex-isearch-activate)
-            (ad-set-arg 0 '(4)))
-          ad-do-it)
-
-        (defadvice isearch-backward-regexp (around flex-isearch activate)
-          (when (and flex-isearch-mode
-                     (equal (ad-get-arg 0) '(16)))
-            (flex-isearch-activate)
-            (ad-set-arg 0 '(4)))
-          ad-do-it)))
-
-    (defun my-isearch-forward ()
-      "Repeat the forward search.
-
-If called from backward search, immediately jump to the following
-occurance instead of jumping to the end of current one."
-      (interactive)
-      (when (not isearch-forward)
-        (isearch-repeat 'forward))
-      (isearch-repeat 'forward))
-
-    (defun my-isearch-backward ()
-      "Repeat the backward search.
-
-If called from forward search, immediately jump to the previous
-occurance instead of jumping to the beginning of current one."
-      (interactive)
-      (when (and isearch-forward
-                 (/= (point) isearch-other-end))
-        (isearch-repeat 'backward))
-      (isearch-repeat 'backward))
-
-    (defun my-isearch-forward-to-beginning ()
-      "Repeat the forward search and place the point before the
-matched text."
-      (interactive)
-      (when (not isearch-forward)
-        (isearch-repeat 'forward))
-      (isearch-repeat 'forward)
-      (goto-char isearch-other-end))
-
-    (defun my-isearch-kill-match ()
-      "Kill the text last matched by isearch."
-      (interactive)
-      (isearch-exit)
-      (kill-region (point) isearch-other-end))
-
-    (defun my-isearch-zap-to-match ()
-      "Kill the region between the point of origin of isearch and the
-closest portion of the isearch match string.  The behaviour is
-meant to be analogous to zap-to-char.  The deleted region does
-not include the isearch word.  This is meant to be bound only in
-isearch mode."
-      (interactive)
-      (let* ((isearch-bounds (list isearch-other-end (point)))
-             (ismin (apply 'min isearch-bounds))
-             (ismax (apply 'max isearch-bounds))
-             (beg isearch-opoint))
-        (cond
-         ((< beg ismin)
-          (goto-char ismin)
-          (kill-region beg ismin))
-         ((> beg ismax)
-          (goto-char beg)
-          (kill-region ismax beg))
-         (t
-          (error "Internal error in isearch kill function.")))
-        (isearch-exit)))
-
-    (defun my-isearch-exit-other-end ()
-      "Exit isearch, but at the other end of the search string.
-This is useful when followed by an immediate kill."
-      (interactive)
-      (isearch-exit)
-      (goto-char isearch-other-end))
-
-    (defun my-isearch-yank-symbol ()
-      "Pull next symbol from buffer into search string."
-      (interactive)
-      (isearch-yank-internal (lambda () (sp-forward-symbol) (point))))
-
-    (defun my-isearch-exit ()
-      "Exit search normally.
-
-If in dired buffer, find file under cursor.  If it is a
-directory, go right back into search."
-      (interactive)
-      (isearch-exit)
-      (if (eq major-mode 'dired-mode)
-          ;; we're assuming no files are marked
-          (let ((d (car (dired-get-marked-files))))
-            (dired-find-file)
-            (when (file-directory-p d)
-              (dired-isearch-filenames)))))
-
-    ;; keybindings
-    (bind-key "<f6>" 'replace-regexp)
-
-    (bind-key "C-v" 'my-isearch-forward-to-beginning isearch-mode-map)
-    (bind-key "C-r" 'my-isearch-backward             isearch-mode-map)
-    (bind-key "C-s" 'my-isearch-forward              isearch-mode-map)
-    (bind-key "C-2" 'my-isearch-kill-match           isearch-mode-map)
-    (bind-key "C-3" 'my-isearch-exit-other-end       isearch-mode-map)
-    (bind-key "C-w" 'my-isearch-yank-symbol          isearch-mode-map)
-    (bind-key "C-M-w" 'isearch-yank-word-or-char     isearch-mode-map)
-    (bind-key "M-z" 'my-isearch-zap-to-match         isearch-mode-map)
-    (bind-key "<f2>" 'isearch-occur                  isearch-mode-map)
-    (bind-key "\r" 'my-isearch-exit                  isearch-mode-map)
-
-    (bind-key "C-S-s" 'flex-isearch-forward)
-    (bind-key "C-S-r" 'flex-isearch-backward)))

files/ispell-config.el

+(use-package ispell
+  :bind (("<f10>" . ispell-word)
+         ("C-<f10>" . flyspell-mode)))

files/ispell.el

-(use-package ispell
-  :bind (("<f10>" . ispell-word)
-         ("C-<f10>" . flyspell-mode)))
 
 (bind-key "H-u" 'universal-argument)
 (bind-key "H-u" 'universal-argument-more universal-argument-map)
-(dotimes (i 10)
-  (bind-key (format "H-%d" i) 'digit-argument))
+(bind-key "H-0" 'digit-argument)
+(bind-key "H-1" 'digit-argument)
+(bind-key "H-2" 'digit-argument)
+(bind-key "H-3" 'digit-argument)
+(bind-key "H-4" 'digit-argument)
+(bind-key "H-5" 'digit-argument)
+(bind-key "H-6" 'digit-argument)
+(bind-key "H-7" 'digit-argument)
+(bind-key "H-8" 'digit-argument)
+(bind-key "H-9" 'digit-argument)
 (bind-key "H--" 'negative-argument)
 
 (defvar ctl-c-s-map)
     `(progn
        (defun ,fname ()
          (interactive)
-         (beginning-of-buffer)
+         (goto-char (point-min))
          ,@forms)
        (add-hook ',mode-hook (lambda () (define-key ,mode-map [remap beginning-of-buffer] ',fname))))))
 
     `(progn
        (defun ,fname ()
          (interactive)
-         (end-of-buffer)
+         (goto-char (point-max))
          ,@forms)
        (add-hook ',mode-hook (lambda () (define-key ,mode-map [remap end-of-buffer] ',fname))))))
 

files/markdown-config.el

+(use-package markdown-mode
+  :mode ("\\.md$" . gfm-mode)
+  :config
+  (progn
+    (defun my-markdown-init ()
+      (modify-syntax-entry ?\" "$\""))
+    (add-hook 'gfm-mode-hook 'my-markdown-init)
+
+    (defun -repeat (n x)
+      "Return a list with X repeated N times.
+Returns nil if N is less than 1."
+      (let (ret)
+        (--dotimes n (!cons x ret))
+        ret))
+
+    (defun my-markdown-toc ()
+      "Generate table of content from # to ####### headers."
+      (interactive)
+      (let ((n 'nil)
+            (last-m nil)
+            (toc ""))
+        (save-excursion
+          (while (re-search-forward "^\\(#+\\) \\(.*\\)" nil t)
+            (if (equal last-m (match-string 1))
+                (progn
+                  (setcar n (1+ (car n))))
+              (if (< (length last-m) (length (match-string 1)))
+                  (!cons 1 n)
+                (!cdr n)
+                (setcar n (1+ (car n))))
+              (setq last-m (match-string 1)))
+            (setq toc (concat
+                       toc
+                       (apply #'concat (-repeat (* 4 (1- (length (match-string 1)))) " "))
+                       (int-to-string (car n))
+                       ". ["
+                       (match-string 2)
+                       "]"
+                       "(#"
+                       (replace-regexp-in-string " " "-" (downcase (match-string 2)))
+                       ")
+"
+                       ))))
+        (insert toc)))
+
+    (defun my-markdown-generate-anchors ()
+      "Add anchors above each header.  If an anchor is present,
+delete it and re-insert new one."
+      (interactive)
+      (let (m)
+        (while (re-search-forward "^\\(#+\\) \\(.*\\)" nil t)
+          (setq m (match-string 2))
+          (beginning-of-line)
+          (previous-line)
+          (if (looking-at "<a")
+              (delete-region (point) (line-end-position))
+            (newline))
+          (insert (concat
+                   "<a name=\""
+                   (replace-regexp-in-string " " "-" (downcase m))
+                   "\" />"))
+          (next-line 2))))))

files/markdown.el

-(use-package markdown-mode
-  :mode ("\\.md$" . gfm-mode)
-  :config
-  (progn
-    (defun my-markdown-init ()
-      (modify-syntax-entry ?\" "$\""))
-    (add-hook 'gfm-mode-hook 'my-markdown-init)
-
-    (defun -repeat (n x)
-      "Return a list with X repeated N times.
-Returns nil if N is less than 1."
-      (let (ret)
-        (--dotimes n (!cons x ret))
-        ret))
-
-    (defun my-markdown-toc ()
-      "Generate table of content from # to ####### headers."
-      (interactive)
-      (let ((n 'nil)
-            (last-m nil)
-            (toc ""))
-        (save-excursion
-          (while (re-search-forward "^\\(#+\\) \\(.*\\)" nil t)
-            (if (equal last-m (match-string 1))
-                (progn
-                  (setcar n (1+ (car n))))
-              (if (< (length last-m) (length (match-string 1)))
-                  (!cons 1 n)
-                (!cdr n)
-                (setcar n (1+ (car n))))
-              (setq last-m (match-string 1)))
-            (setq toc (concat
-                       toc
-                       (apply #'concat (-repeat (* 4 (1- (length (match-string 1)))) " "))
-                       (int-to-string (car n))
-                       ". ["
-                       (match-string 2)
-                       "]"
-                       "(#"
-                       (replace-regexp-in-string " " "-" (downcase (match-string 2)))
-                       ")
-"
-                       ))))
-        (insert toc)))
-
-    (defun my-markdown-generate-anchors ()
-      "Add anchors above each header.  If an anchor is present,
-delete it and re-insert new one."
-      (interactive)
-      (let (m)
-        (while (re-search-forward "^\\(#+\\) \\(.*\\)" nil t)
-          (setq m (match-string 2))
-          (beginning-of-line)
-          (previous-line)
-          (if (looking-at "<a")
-              (delete-region (point) (line-end-position))
-            (newline))
-          (insert (concat
-                   "<a name=\""
-                   (replace-regexp-in-string " " "-" (downcase m))
-                   "\" />"))
-          (next-line 2))))))

files/multi-web-mode-config.el

 (use-package multi-web-mode
+  :defer t
   :config
   (progn
     (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
     (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))))
 
 (use-package sgml-mode
+  :defer t
   :config
   (progn
     (defun my-html-mode-setup ()

files/org-mode-config.el

+(use-package org
+  :mode ("\\.org\\'" . org-mode)
+  ;; The following lines are always needed.  Choose your own keys.
+  :bind  (("C-c l" . org-store-link)
+          ("<f12>" . org-agenda)
+          ("C-c C-x C-o" . org-clock-out))
+  :config
+  (progn
+    (bind-key "TAB" 'smart-tab org-mode-map)
+    (bind-key "C-e" 'my-end-of-code-or-line org-mode-map)
+    (bind-key "C-a" 'my-back-to-indentation-or-beginning org-mode-map)
+    (bind-key "C-c C-x r" 'org-clock-remove-overlays org-mode-map)
+
+    (require 'org-table)
+    ;; org/orgtbl bindings
+    (defvar my-org-table-map)
+    (define-prefix-command 'my-org-table-map)
+    (bind-key "C-c t" 'my-org-table-map org-mode-map)
+    (bind-key "C-c t" 'my-org-table-map orgtbl-mode-map)
+    (defvar my-org-table-insert-map)
+    (define-prefix-command 'my-org-table-insert-map)
+    (bind-key "C-c t i" 'my-org-table-insert-map org-mode-map)
+    (bind-key "C-c t i" 'my-org-table-insert-map orgtbl-mode-map)
+    (bind-key "C-c t i i" 'orgtbl-insert-radio-table orgtbl-mode-map)
+    (defvar my-org-table-delete-map)
+    (define-prefix-command 'my-org-table-delete-map)
+    (bind-key "C-c t d" 'my-org-table-delete-map org-mode-map)
+    (bind-key "C-c t d" 'my-org-table-delete-map orgtbl-mode-map)
+
+    (let ((bindings '(("C-c t i c" org-table-insert-column)
+                      ("C-c t i r" org-table-insert-row)
+                      ("C-c t d c" org-table-delete-column)
+                      ("C-c t d r" org-table-kill-row)))
+          (n 1000))
+      (dolist (b bindings)
+        (define-key org-mode-map (kbd (car b)) (cadr b))
+        (org-defkey orgtbl-mode-map (kbd (car b)) (orgtbl-make-binding (cadr b) n (kbd (car b))))
+        (setq n (1+ n))))
+
+    (defun my-org-select-cell ()
+      "Select the cell in org table the point is in."
+      (interactive)
+      (let ((b (save-excursion
+                 (re-search-forward "|")
+                 (backward-char 1)
+                 (skip-chars-backward " ")
+                 (point)))
+            (e (save-excursion
+                 (re-search-backward "|")
+                 (forward-char 1)
+                 (skip-chars-forward " ")
+                 (point))))
+        (push-mark b t t)
+        (goto-char e)))
+    (bind-key "C-c t" 'my-org-select-cell org-mode-map)
+
+    (defun my-markdown-to-org-link (b e)
+      (interactive "r")
+      (goto-char b)
+      (sp-down-sexp)
+      (let ((desc (sp-get (sp--next-thing-selection 0)
+                    (buffer-substring-no-properties :beg :end)))
+            (link (progn
+                    (sp-beginning-of-sexp 2)
+                    (sp-get (sp--next-thing-selection 0)
+                      (buffer-substring-no-properties :beg :end)))))
+        (delete-region b e)
+        (insert (format "[[%s][%s]]" link desc))))
+
+    (load "files/org-clock")
+    (load "files/org-project")
+
+    (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
+
+    ;; Enable modules
+    (setq org-modules (quote (org-bbdb
+                              org-bibtex
+                              org-crypt
+                              org-gnus
+                              org-id
+                              org-info
+                              org-jsinfo
+                              org-habit
+                              org-inlinetask
+                              org-irc
+                              org-mew
+                              org-mhe
+                              org-protocol
+                              org-rmail
+                              org-vm
+                              org-wl
+                              org-w3m)))
+
+    ;; position the habit graph on the agenda to the right of the default
+    (setq org-habit-graph-column 50)
+
+;;;;;;;;;;;;;;;;;;;;; CAPTURE
+    (setq org-directory "~/org")
+    (setq org-default-notes-file "~/org/refile.org")
+
+    ;; I use C-M-r to start capture mode
+    (bind-key "C-M-r" 'org-capture)
+
+    ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
+    (setq org-capture-templates
+          (quote (("t" "todo" entry (file "~/org/refile.org")
+                   "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
+                  ("s" "someday" entry (file "~/org/refile.org")
+                   "* SOMEDAY %?\n%U\n%a\n" :clock-in t :clock-resume t)
+                  ("n" "note" entry (file "~/org/refile.org")
+                   "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
+                  ("j" "Journal" entry (file+datetree "~/org/diary.org")
+                   "* %?\n%U\n" :clock-in t :clock-resume t))))
+
+    ;; Remove empty LOGBOOK drawers on clock out
+    (defun bh/remove-empty-drawer-on-clock-out ()
+      (interactive)
+      (save-excursion
+        (beginning-of-line 0)
+        (org-remove-empty-drawer-at "LOGBOOK" (point))))
+
+    (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
+
+;;;;;;;;;;;;;;;;; REFILING
+    ;; Targets include this file and any file contributing to the agenda - up to 9 levels deep
+    (setq org-refile-targets (quote ((nil :maxlevel . 9)
+                                     (org-agenda-files :maxlevel . 9))))
+
+    ;; Use full outline paths for refile targets - we file directly with IDO
+    (setq org-refile-use-outline-path t)
+
+    ;; Targets complete directly with IDO
+    (setq org-outline-path-complete-in-steps nil)
+
+    ;; Allow refile to create parent tasks with confirmation
+    (setq org-refile-allow-creating-parent-nodes (quote confirm))
+
+    ;; Use IDO for both buffer and file completion and ido-everywhere to t
+    (setq org-completion-use-ido t)
+
+;;;; Refile settings
+    ;; Exclude DONE state tasks from refile targets
+    (defun bh/verify-refile-target ()
+      "Exclude todo keywords with a done state from refile targets"
+      (not (member (nth 2 (org-heading-components)) org-done-keywords)))
+
+    (setq org-refile-target-verify-function 'bh/verify-refile-target)
+
+    (setq org-log-done 'time)
+    (setq org-log-done 'note)
+
+    ;; english locale
+    (setq system-time-locale "C")
+    (setq org-completion-use-ido t)
+
+    ;; support selecting with shift+arrows
+    (setq org-support-shift-select t)
+
+    ;; fast state selection
+    (setq org-use-fast-todo-selection t)
+
+    (setq org-agenda-files (quote ("~/org/")))
+
+    ;; TODO KEYWORDS SETTINGS
+    (setq org-todo-keywords
+          '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
+            (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)")
+            (sequence "SOMEDAY(S)" "|")))
+
+    (setq org-todo-keyword-faces
+          (quote (("TODO" :foreground "IndianRed1" :weight bold)
+                  ("NEXT" :foreground "RoyalBlue" :weight bold)
+                  ("DONE" :foreground "LimeGreen" :weight bold)
+                  ("WAITING" :foreground "orange" :weight bold)
+                  ("HOLD" :foreground "orange" :weight bold)
+                  ("CANCELLED" :foreground "LimeGreen" :weight bold)
+                  ("SOMEDAY" :foreground "pink" :weight bold))))
+
+    (setq org-todo-state-tags-triggers
+          (quote (("CANCELLED" ("CANCELLED" . t))
+                  ("WAITING" ("WAITING" . t))
+                  ("HOLD" ("WAITING" . t) ("HOLD" . t))
+                  (done ("WAITING") ("HOLD"))
+                  ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
+                  ("SOMEDAY" ("WAITING") ("CANCELLED") ("HOLD"))
+                  ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
+                  ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
+
+    ;; Tags shortcuts
+    (setq org-tag-alist (quote ((:startgroup)
+                                ("@errand" . ?e)
+                                ("@school" . ?o)
+                                ("@home" . ?H)
+                                (:endgroup)
+                                ("READING" . ?r)
+                                ("LATIN" . ?l))))
+
+    ;; Allow setting single tags without the menu
+    (setq org-fast-tag-selection-single-key (quote expert))
+
+    ;; Archiving settings
+    (setq org-archive-mark-done nil)
+    (setq org-archive-location "%s_archive::* Archived Tasks")
+
+    (defun bh/skip-non-archivable-tasks ()
+      "Skip trees that are not available for archiving"
+      (save-restriction
+        (widen)
+        (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
+          ;; Consider only tasks with done todo headings as archivable candidates
+          (if (member (org-get-todo-state) org-done-keywords)
+              (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
+                     (daynr (string-to-int (format-time-string "%d" (current-time))))
+                     (a-month-ago (* 60 60 24 (+ daynr 1)))
+                     (last-month (format-time-string "%Y-%m-" (time-subtract (current-time) (seconds-to-time a-month-ago))))
+                     (this-month (format-time-string "%Y-%m-" (current-time)))
+                     (subtree-is-current (save-excursion
+                                           (forward-line 1)
+                                           (and (< (point) subtree-end)
+                                                (re-search-forward (concat last-month "\\|" this-month) subtree-end t)))))
+                (if subtree-is-current
+                    next-headline ; Has a date in this month or last month, skip it
+                  nil))  ; available to archive
+            (or next-headline (point-max))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;; AGENDA VIEW
+    ;; Compact the block agenda view
+    ;; (setq org-agenda-compact-blocks t)
+
+    ;; Custom agenda command definitions
+    (setq org-agenda-custom-commands
+          (quote (("N" "Notes" tags "NOTE"
+                   ((org-agenda-overriding-header "Notes")
+                    (org-tags-match-list-sublevels t)))
+                  ("h" "Habits" tags-todo "STYLE=\"habit\""
+                   ((org-agenda-overriding-header "Habits")
+                    (org-agenda-sorting-strategy
+                     '(todo-state-down effort-up category-keep))))
+                  (" " "Agenda"
+                   ((agenda "" nil)
+                    (tags "REFILE"
+                          ((org-agenda-overriding-header "Tasks to Refile")
+                           (org-tags-match-list-sublevels nil)))
+                    (tags-todo "-CANCELLED/!"
+                               ((org-agenda-overriding-header "Stuck Projects")
+                                (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
+                    (tags-todo "-WAITING-CANCELLED/!NEXT"
+                               ((org-agenda-overriding-header "Next Tasks")
+                                (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
+                                (org-agenda-todo-ignore-scheduled t)
+                                (org-agenda-todo-ignore-deadlines t)
+                                (org-agenda-todo-ignore-with-date t)
+                                (org-tags-match-list-sublevels t)
+                                (org-agenda-sorting-strategy
+                                 '(todo-state-down effort-up category-keep))))
+                    (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING-SOMEDAY"
+                               ((org-agenda-overriding-header "Tasks")
+                                (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
+                                (org-agenda-todo-ignore-scheduled t)
+                                (org-agenda-todo-ignore-deadlines t)
+                                (org-agenda-todo-ignore-with-date t)
+                                (org-agenda-sorting-strategy
+                                 '(category-keep))))
+                    (tags-todo "-HOLD-CANCELLED/!"
+                               ((org-agenda-overriding-header "Projects")
+                                (org-agenda-skip-function 'bh/skip-non-projects)
+                                (org-agenda-sorting-strategy
+                                 '(category-keep))))
+                    (tags-todo "-CANCELLED+WAITING/!"
+                               ((org-agenda-overriding-header "Waiting and Postponed Tasks")
+                                (org-agenda-skip-function 'bh/skip-stuck-projects)
+                                (org-tags-match-list-sublevels nil)
+                                (org-agenda-todo-ignore-scheduled 'future)
+                                (org-agenda-todo-ignore-deadlines 'future)))
+                    (tags "-REFILE/"
+                          ((org-agenda-overriding-header "Tasks to Archive")
+                           (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
+                           (org-tags-match-list-sublevels nil))))
+                   nil)
+                  ("r" "Tasks to Refile" tags "REFILE"
+                   ((org-agenda-overriding-header "Tasks to Refile")
+                    (org-tags-match-list-sublevels nil)))
+                  ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
+                   ((org-agenda-overriding-header "Stuck Projects")
+                    (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
+                  ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
+                   ((org-agenda-overriding-header "Next Tasks")
+                    (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
+                    (org-agenda-todo-ignore-scheduled t)
+                    (org-agenda-todo-ignore-deadlines t)
+                    (org-agenda-todo-ignore-with-date t)
+                    (org-tags-match-list-sublevels t)
+                    (org-agenda-sorting-strategy
+                     '(todo-state-down effort-up category-keep))))
+                  ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
+                   ((org-agenda-overriding-header "Tasks")
+                    (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
+                    (org-agenda-sorting-strategy
+                     '(category-keep))))
+                  ("S" "Someday" todo "SOMEDAY"
+                   ((org-agenda-overriding-header "Someday")
+                    (org-tags-match-list-sublevels nil)))
+                  ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
+                   ((org-agenda-overriding-header "Projects")
+                    (org-agenda-skip-function 'bh/skip-non-projects)
+                    (org-agenda-sorting-strategy
+                     '(category-keep))))
+                  ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
+                   ((org-agenda-overriding-header "Waiting and Postponed tasks"))
+                   (org-tags-match-list-sublevels nil))
+                  ("A" "Tasks to Archive" tags "-REFILE/"
+                   ((org-agenda-overriding-header "Tasks to Archive")
+                    (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
+                    (org-tags-match-list-sublevels nil))))))))

files/org-mode.el

-(use-package org
-  :mode ("\\.org\\'" . org-mode)
-  ;; The following lines are always needed.  Choose your own keys.
-  :bind  (("C-c l" . org-store-link)
-          ("<f12>" . org-agenda)
-          ("C-c C-x C-o" . org-clock-out))
-  :config
-  (progn
-    (bind-key "TAB" 'smart-tab org-mode-map)
-    (bind-key "C-e" 'my-end-of-code-or-line org-mode-map)
-    (bind-key "C-a" 'my-back-to-indentation-or-beginning org-mode-map)
-    (bind-key "C-c C-x r" 'org-clock-remove-overlays org-mode-map)
-
-    (require 'org-table)
-    ;; org/orgtbl bindings
-    (defvar my-org-table-map)
-    (define-prefix-command 'my-org-table-map)
-    (bind-key "C-c t" 'my-org-table-map org-mode-map)
-    (bind-key "C-c t" 'my-org-table-map orgtbl-mode-map)
-    (defvar my-org-table-insert-map)
-    (define-prefix-command 'my-org-table-insert-map)
-    (bind-key "C-c t i" 'my-org-table-insert-map org-mode-map)
-    (bind-key "C-c t i" 'my-org-table-insert-map orgtbl-mode-map)
-    (bind-key "C-c t i i" 'orgtbl-insert-radio-table orgtbl-mode-map)
-    (defvar my-org-table-delete-map)
-    (define-prefix-command 'my-org-table-delete-map)
-    (bind-key "C-c t d" 'my-org-table-delete-map org-mode-map)
-    (bind-key "C-c t d" 'my-org-table-delete-map orgtbl-mode-map)
-
-    (let ((bindings '(("C-c t i c" org-table-insert-column)
-                      ("C-c t i r" org-table-insert-row)
-                      ("C-c t d c" org-table-delete-column)
-                      ("C-c t d r" org-table-kill-row)))
-          (n 1000))
-      (dolist (b bindings)
-        (define-key org-mode-map (kbd (car b)) (cadr b))
-        (org-defkey orgtbl-mode-map (kbd (car b)) (orgtbl-make-binding (cadr b) n (kbd (car b))))
-        (setq n (1+ n))))
-
-    (defun my-org-select-cell ()
-      "Select the cell in org table the point is in."
-      (interactive)
-      (let ((b (save-excursion
-                 (re-search-forward "|")
-                 (backward-char 1)
-                 (skip-chars-backward " ")
-                 (point)))
-            (e (save-excursion
-                 (re-search-backward "|")
-                 (forward-char 1)
-                 (skip-chars-forward " ")
-                 (point))))
-        (push-mark b t t)
-        (goto-char e)))
-    (bind-key "C-c t" 'my-org-select-cell org-mode-map)
-
-    (defun my-markdown-to-org-link (b e)
-      (interactive "r")
-      (goto-char b)
-      (sp-down-sexp)
-      (let ((desc (sp-get (sp--next-thing-selection 0)
-                    (buffer-substring-no-properties :beg :end)))
-            (link (progn
-                    (sp-beginning-of-sexp 2)
-                    (sp-get (sp--next-thing-selection 0)
-                      (buffer-substring-no-properties :beg :end)))))
-        (delete-region b e)
-        (insert (format "[[%s][%s]]" link desc))))
-
-    (load "files/org-clock")
-    (load "files/org-project")
-
-    (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
-
-    ;; Enable modules
-    (setq org-modules (quote (org-bbdb
-                              org-bibtex
-                              org-crypt
-                              org-gnus
-                              org-id
-                              org-info
-                              org-jsinfo
-                              org-habit
-                              org-inlinetask
-                              org-irc
-                              org-mew
-                              org-mhe
-                              org-protocol
-                              org-rmail
-                              org-vm
-                              org-wl
-                              org-w3m)))
-
-    ;; position the habit graph on the agenda to the right of the default
-    (setq org-habit-graph-column 50)
-
-;;;;;;;;;;;;;;;;;;;;; CAPTURE
-    (setq org-directory "~/org")
-    (setq org-default-notes-file "~/org/refile.org")
-
-    ;; I use C-M-r to start capture mode
-    (bind-key "C-M-r" 'org-capture)
-
-    ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, and org-protocol
-    (setq org-capture-templates
-          (quote (("t" "todo" entry (file "~/org/refile.org")
-                   "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
-                  ("s" "someday" entry (file "~/org/refile.org")
-                   "* SOMEDAY %?\n%U\n%a\n" :clock-in t :clock-resume t)
-                  ("n" "note" entry (file "~/org/refile.org")
-                   "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
-                  ("j" "Journal" entry (file+datetree "~/org/diary.org")
-                   "* %?\n%U\n" :clock-in t :clock-resume t))))
-
-    ;; Remove empty LOGBOOK drawers on clock out
-    (defun bh/remove-empty-drawer-on-clock-out ()
-      (interactive)
-      (save-excursion
-        (beginning-of-line 0)
-        (org-remove-empty-drawer-at "LOGBOOK" (point))))
-
-    (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
-
-;;;;;;;;;;;;;;;;; REFILING
-    ;; Targets include this file and any file contributing to the agenda - up to 9 levels deep
-    (setq org-refile-targets (quote ((nil :maxlevel . 9)
-                                     (org-agenda-files :maxlevel . 9))))
-
-    ;; Use full outline paths for refile targets - we file directly with IDO
-    (setq org-refile-use-outline-path t)
-
-    ;; Targets complete directly with IDO
-    (setq org-outline-path-complete-in-steps nil)
-
-    ;; Allow refile to create parent tasks with confirmation
-    (setq org-refile-allow-creating-parent-nodes (quote confirm))
-
-    ;; Use IDO for both buffer and file completion and ido-everywhere to t
-    (setq org-completion-use-ido t)
-
-;;;; Refile settings
-    ;; Exclude DONE state tasks from refile targets
-    (defun bh/verify-refile-target ()
-      "Exclude todo keywords with a done state from refile targets"
-      (not (member (nth 2 (org-heading-components)) org-done-keywords)))
-
-    (setq org-refile-target-verify-function 'bh/verify-refile-target)
-
-    (setq org-log-done 'time)
-    (setq org-log-done 'note)
-
-    ;; english locale
-    (setq system-time-locale "C")
-    (setq org-completion-use-ido t)
-
-    ;; support selecting with shift+arrows
-    (setq org-support-shift-select t)
-
-    ;; fast state selection
-    (setq org-use-fast-todo-selection t)
-
-    (setq org-agenda-files (quote ("~/org/")))
-
-    ;; TODO KEYWORDS SETTINGS
-    (setq org-todo-keywords
-          '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
-            (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)")
-            (sequence "SOMEDAY(S)" "|")))
-
-    (setq org-todo-keyword-faces
-          (quote (("TODO" :foreground "IndianRed1" :weight bold)
-                  ("NEXT" :foreground "RoyalBlue" :weight bold)
-                  ("DONE" :foreground "LimeGreen" :weight bold)
-                  ("WAITING" :foreground "orange" :weight bold)
-                  ("HOLD" :foreground "orange" :weight bold)
-                  ("CANCELLED" :foreground "LimeGreen" :weight bold)
-                  ("SOMEDAY" :foreground "pink" :weight bold))))
-
-    (setq org-todo-state-tags-triggers
-          (quote (("CANCELLED" ("CANCELLED" . t))
-                  ("WAITING" ("WAITING" . t))
-                  ("HOLD" ("WAITING" . t) ("HOLD" . t))
-                  (done ("WAITING") ("HOLD"))
-                  ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
-                  ("SOMEDAY" ("WAITING") ("CANCELLED") ("HOLD"))
-                  ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
-                  ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
-
-    ;; Tags shortcuts
-    (setq org-tag-alist (quote ((:startgroup)
-                                ("@errand" . ?e)
-                                ("@school" . ?o)
-                                ("@home" . ?H)
-                                (:endgroup)
-                                ("READING" . ?r)
-                                ("LATIN" . ?l))))
-
-    ;; Allow setting single tags without the menu
-    (setq org-fast-tag-selection-single-key (quote expert))
-
-    ;; Archiving settings
-    (setq org-archive-mark-done nil)
-    (setq org-archive-location "%s_archive::* Archived Tasks")
-
-    (defun bh/skip-non-archivable-tasks ()
-      "Skip trees that are not available for archiving"
-      (save-restriction
-        (widen)
-        (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
-          ;; Consider only tasks with done todo headings as archivable candidates
-          (if (member (org-get-todo-state) org-done-keywords)
-              (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
-                     (daynr (string-to-int (format-time-string "%d" (current-time))))
-                     (a-month-ago (* 60 60 24 (+ daynr 1)))
-                     (last-month (format-time-string "%Y-%m-" (time-subtract (current-time) (seconds-to-time a-month-ago))))
-                     (this-month (format-time-string "%Y-%m-" (current-time)))
-                     (subtree-is-current (save-excursion
-                                           (forward-line 1)
-                                           (and (< (point) subtree-end)
-                                                (re-search-forward (concat last-month "\\|" this-month) subtree-end t)))))
-                (if subtree-is-current
-                    next-headline ; Has a date in this month or last month, skip it
-                  nil))  ; available to archive
-            (or next-headline (point-max))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;; AGENDA VIEW
-    ;; Compact the block agenda view
-    ;; (setq org-agenda-compact-blocks t)
-
-    ;; Custom agenda command definitions
-    (setq org-agenda-custom-commands
-          (quote (("N" "Notes" tags "NOTE"
-                   ((org-agenda-overriding-header "Notes")
-                    (org-tags-match-list-sublevels t)))
-                  ("h" "Habits" tags-todo "STYLE=\"habit\""
-                   ((org-agenda-overriding-header "Habits")
-                    (org-agenda-sorting-strategy
-                     '(todo-state-down effort-up category-keep))))
-                  (" " "Agenda"
-                   ((agenda "" nil)
-                    (tags "REFILE"
-                          ((org-agenda-overriding-header "Tasks to Refile")
-                           (org-tags-match-list-sublevels nil)))
-                    (tags-todo "-CANCELLED/!"
-                               ((org-agenda-overriding-header "Stuck Projects")
-                                (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
-                    (tags-todo "-WAITING-CANCELLED/!NEXT"
-                               ((org-agenda-overriding-header "Next Tasks")
-                                (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
-                                (org-agenda-todo-ignore-scheduled t)
-                                (org-agenda-todo-ignore-deadlines t)
-                                (org-agenda-todo-ignore-with-date t)
-                                (org-tags-match-list-sublevels t)
-                                (org-agenda-sorting-strategy
-                                 '(todo-state-down effort-up category-keep))))
-                    (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING-SOMEDAY"
-                               ((org-agenda-overriding-header "Tasks")
-                                (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
-                                (org-agenda-todo-ignore-scheduled t)
-                                (org-agenda-todo-ignore-deadlines t)
-                                (org-agenda-todo-ignore-with-date t)
-                                (org-agenda-sorting-strategy
-                                 '(category-keep))))
-                    (tags-todo "-HOLD-CANCELLED/!"
-                               ((org-agenda-overriding-header "Projects")
-                                (org-agenda-skip-function 'bh/skip-non-projects)
-                                (org-agenda-sorting-strategy
-                                 '(category-keep))))
-                    (tags-todo "-CANCELLED+WAITING/!"
-                               ((org-agenda-overriding-header "Waiting and Postponed Tasks")
-                                (org-agenda-skip-function 'bh/skip-stuck-projects)
-                                (org-tags-match-list-sublevels nil)
-                                (org-agenda-todo-ignore-scheduled 'future)
-                                (org-agenda-todo-ignore-deadlines 'future)))
-                    (tags "-REFILE/"
-                          ((org-agenda-overriding-header "Tasks to Archive")
-                           (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
-                           (org-tags-match-list-sublevels nil))))
-                   nil)
-                  ("r" "Tasks to Refile" tags "REFILE"
-                   ((org-agenda-overriding-header "Tasks to Refile")
-                    (org-tags-match-list-sublevels nil)))
-                  ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
-                   ((org-agenda-overriding-header "Stuck Projects")
-                    (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
-                  ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
-                   ((org-agenda-overriding-header "Next Tasks")
-                    (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
-                    (org-agenda-todo-ignore-scheduled t)
-                    (org-agenda-todo-ignore-deadlines t)
-                    (org-agenda-todo-ignore-with-date t)
-                    (org-tags-match-list-sublevels t)
-                    (org-agenda-sorting-strategy
-                     '(todo-state-down effort-up category-keep))))
-                  ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
-                   ((org-agenda-overriding-header "Tasks")
-                    (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
-                    (org-agenda-sorting-strategy
-                     '(category-keep))))
-                  ("S" "Someday" todo "SOMEDAY"
-                   ((org-agenda-overriding-header "Someday")
-                    (org-tags-match-list-sublevels nil)))
-                  ("p" "Projects" tags-todo "-HOLD-CANCELLED/!"
-                   ((org-agenda-overriding-header "Projects")
-                    (org-agenda-skip-function 'bh/skip-non-projects)
-                    (org-agenda-sorting-strategy
-                     '(category-keep))))
-                  ("w" "Waiting Tasks" tags-todo "-CANCELLED+WAITING/!"
-                   ((org-agenda-overriding-header "Waiting and Postponed tasks"))
-                   (org-tags-match-list-sublevels nil))
-                  ("A" "Tasks to Archive" tags "-REFILE/"
-                   ((org-agenda-overriding-header "Tasks to Archive")
-                    (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
-                    (org-tags-match-list-sublevels nil))))))))
   :bind ("C-<f5>" . revbufs))
 
 (use-package smartparens
+  :defer t
   :init
   (progn
     (load "~/.emacs.d/files/smartparens")))
 
 (use-package smex
+  :defer t
   :init
   (progn
     (bind-key "M-x" 'beautify-smex)
 
 (use-package yasnippet
   :diminish yas-minor-mode
-  :commands (yas-minor-mode yas-expand)
+  :commands (yas-minor-mode
+             yas-expand)
+  :init
+  (progn
+    (autoload 'yas/hippie-try-expand "yasnippet"))
   :config
   (progn
     (require 'dropdown-list)
       (define-key yas-minor-mode-map [(tab)] nil)
       (define-key yas-minor-mode-map (kbd "TAB") nil))
 
-    ;; Replace yasnippets's TAB
-    (add-hook 'yas-minor-mode-hook 'my-yas-startup) ; was yas/expand
-    ))
+    ;; Replace yasnippets's TAB, was yas/expand
+    (add-hook 'yas-minor-mode-hook 'my-yas-startup)))
 (tooltip-mode -1)
 
 ;; maximize window at startup
-(defun maximize-frame ()
-  "Maximizes the active frame in Windows"
-  (interactive)
-  ;; Send a `WM_SYSCOMMAND' message to the active frame with the
-  ;; `SC_MAXIMIZE' parameter.
-  (when (eq system-type 'windows-nt)
-    (w32-send-sys-command 61488)))
-(add-hook 'window-setup-hook 'maximize-frame t)
-
-;; add load paths
-(add-to-list 'load-path "~/.emacs.d")
-(add-to-list 'load-path "~/.emacs.d/vendor")
-(add-to-list 'load-path "~/.emacs.d/site-lisp")
-(mapc (apply-partially 'add-to-list 'load-path) (f-directories "~/.emacs.d/vendor"))
+;; (defun maximize-frame ()
+;;   "Maximizes the active frame in Windows"
+;;   (interactive)
+;;   ;; Send a `WM_SYSCOMMAND' message to the active frame with the
+;;   ;; `SC_MAXIMIZE' parameter.
+;;   (when (eq system-type 'windows-nt)
+;;     (w32-send-sys-command 61488)))
+;; (add-hook 'window-setup-hook 'maximize-frame t)
 
 ;; add repos
 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                          ("marmalade" . "http://marmalade-repo.org/packages/")
                          ("melpa" . "http://melpa.milkbox.net/packages/")))
-(require 'autoinstall)
 (package-initialize)
+(load "~/.emacs.d/autoinstall")
 
-(require 'use-package)
 (require 'parenface)
 (require 'uniquify)
 (require 'dash)
 (require 'f)
 (require 's)
 
+;; add load paths
+(add-to-list 'load-path "~/.emacs.d/")
+(mapc (apply-partially 'add-to-list 'load-path) (f-directories "~/.emacs.d/vendor"))
+
+(require 'use-package)
+
 ;; autoloads
 (autoload 'calc-same-interface "calc" nil t)
 (autoload 'zap-up-to-char "misc"
   "Kill up to, but not including ARGth occurrence of CHAR." t)
 
 ;; load site lisp
-(mapc 'load (f-files "~/.emacs.d/site-lisp/"))
+(load "site-lisp/advices")
+(load "site-lisp/defuns-buffer")
+(load "site-lisp/defuns-edit")
+(load "site-lisp/defuns-macros")
+(load "site-lisp/defuns")
+(load "site-lisp/emacs-lisp-mode")
+(load "site-lisp/macros")
+(load "site-lisp/vendor")
+
+;; load keys
+(load "files/keys")
 
 ;; load settings
 (load "files/global")
 
 ;; load config files
 (load "files/ack")
-(load "files/allout")
+(load "files/allout-config")
 (load "files/auto-complete")
 (load "files/dired-setup")
 (load "files/eshell-mode")
 (load "files/haskell")
 (load "files/ibuffer-config")
-(load "files/ido")
-(load "files/isearch")
-(load "files/ispell")
+(load "files/ido-config")
+(load "files/isearch-config")
+(load "files/ispell-config")
 (load "files/latex-mode-config")
-(load "files/markdown")
+(load "files/markdown-config")
 (load "files/multi-web-mode-config")
-(load "files/org-mode")
+(load "files/org-mode-config")
 (load "files/recentf-config")
 (load "files/tramp")
 (load "files/vendor")
 ;; diminish useless modeline clutter
 (load "files/diminish")
 
-;; load keys
-(load "files/keys")
-
 ;; Customize
 (setq custom-file "~/.emacs.d/files/emacs-custom.el")
 (load custom-file)
 
 ;; Reload theme -- hackish
-(load "~/.emacs.d/themes/my-tango-dark-theme")
+;; (load "~/.emacs.d/themes/my-tango-dark-theme")
 
 ;; autoopen files
 (find-file "~/.emacs.d/init.el")

site-lisp/anki-to-tex.el

-(use-package anki-to-tex
-  :commands (my-dictionary-format
-             my-format-synonyms)
-  :config
-  (progn
-    (defun my-dictionary-format ()
-      (interactive)
-      (fix-reset-after-each
-       (replace-regexp "" "")
-       (replace-regexp "" "")
-       (replace-string "E'" "\\`E")
-       (replace-regexp "~" "\\\\mytilde{}")
-       (replace-regexp "intransitive" "$\\\\iota$")
-       (replace-regexp "transitive" "$\\\\tau$")
-       (replace-regexp "reflexive" "$\\\\rho$")
-       (replace-regexp "auxiliary" "$\\\\alpha$")
-       (replace-regexp "impersonal" "$\\\\mu$")
-       (replace-regexp "<div><div>" "<div>")
-       (replace-regexp "</div></div>" "</div>")
-       (replace-regexp "&nbsp;" " ")
-       (replace-regexp "&lt;" "<")
-       (replace-regexp "&gt;" ">")
-       (replace-string "< " "$<$ ")
-       (replace-regexp "^<div>" "")
-       (replace-regexp "\t</div>" "\t")
-       (replace-regexp "<br />" "")
-       (replace-regexp "(<i>" "<i>(")
-       (replace-regexp "</i>)" ")</i>")
-       (replace-regexp "<i>\\(.*?\\)</i>" "\\\\emph{\\1}")
-       (replace-regexp "\\([^{]\\)(syn: \\(.*?\\))" "\\1\\\\emph{(syn: \\2)}")
-       (replace-regexp "(syn: \\(.*?\\))" "{\\\\footnotesize ($\\\\sigma\\\\!\\\\!:\\\\!$ \\1)}")
-       (replace-regexp "\\.\\.\\." "\\\\dots ")
-       ;; remove all the divs in front of first tab
-       (with-lines
-         (goto-char (point-min))
-         (save-excursion
-           (save-restriction
-             (narrow-to-region (point) (save-excursion (re-search-forward "\t" nil t)))
-             (replace-string "<div>" "")
-             (replace-string "</div>" ""))))
-       (while (re-search-forward "\t.*?<div>" nil t)
-         (beginning-of-line)
-         (re-search-forward "\t" nil t)
-         (unless (looking-at "<div>")
-           (insert "<div>")
-           (re-search-forward "<div>" nil t)
-           (backward-char 5)
-           (insert "</div>"))
-         (end-of-line)
-         (unless (looking-back "</div>")
-           (insert "</div>")))
-       (while (re-search-forward "\t<div>" nil t)
-         (backward-delete-char 5)
-         (insert "
+(defun my-dictionary-format ()
+  (interactive)
+  (fix-reset-after-each
+    (replace-regexp "" "")
+    (replace-regexp "" "")
+    (replace-string "E'" "\\`E")
+    (replace-regexp "~" "\\\\mytilde{}")
+    (replace-regexp "intransitive" "$\\\\iota$")
+    (replace-regexp "transitive" "$\\\\tau$")
+    (replace-regexp "reflexive" "$\\\\rho$")
+    (replace-regexp "auxiliary" "$\\\\alpha$")
+    (replace-regexp "impersonal" "$\\\\mu$")
+    (replace-regexp "<div><div>" "<div>")
+    (replace-regexp "</div></div>" "</div>")
+    (replace-regexp "&nbsp;" " ")
+    (replace-regexp "&lt;" "<")
+    (replace-regexp "&gt;" ">")
+    (replace-string "< " "$<$ ")
+    (replace-regexp "^<div>" "")
+    (replace-regexp "\t</div>" "\t")
+    (replace-regexp "<br />" "")
+    (replace-regexp "(<i>" "<i>(")
+    (replace-regexp "</i>)" ")</i>")
+    (replace-regexp "<i>\\(.*?\\)</i>" "\\\\emph{\\1}")
+    (replace-regexp "\\([^{]\\)(syn: \\(.*?\\))" "\\1\\\\emph{(syn: \\2)}")
+    (replace-regexp "(syn: \\(.*?\\))" "{\\\\footnotesize ($\\\\sigma\\\\!\\\\!:\\\\!$ \\1)}")
+    (replace-regexp "\\.\\.\\." "\\\\dots ")
+    ;; remove all the divs in front of first tab
+    (with-lines
+      (goto-char (point-min))
+      (save-excursion
+        (save-restriction
+          (narrow-to-region (point) (save-excursion (re-search-forward "\t" nil t)))
+          (replace-string "<div>" "")
+          (replace-string "</div>" ""))))
+    (while (re-search-forward "\t.*?<div>" nil t)
+      (beginning-of-line)
+      (re-search-forward "\t" nil t)
+      (unless (looking-at "<div>")
+        (insert "<div>")
+        (re-search-forward "<div>" nil t)
+        (backward-char 5)
+        (insert "</div>"))
+      (end-of-line)
+      (unless (looking-back "</div>")
+        (insert "</div>")))
+    (while (re-search-forward "\t<div>" nil t)
+      (backward-delete-char 5)
+      (insert "
 \\begin{enumerate}
 \\item ")
-         (end-of-line)
-         (backward-delete-char 6)
-         (insert "
+      (end-of-line)
+      (backward-delete-char 6)
+      (insert "
 \\end{enumerate}"))
-       (replace-regexp "^\\(.*?\\)\t" "{\\\\bfseries \\1} ")
-       (replace-regexp "</div><div>" "
+    (replace-regexp "^\\(.*?\\)\t" "{\\\\bfseries \\1} ")
+    (replace-regexp "</div><div>" "
 \\\\item ")
-       ;; what is this??
-       (while (re-search-forward "\\\\item \\[" nil t)
-         (backward-delete-char 7)
-         (when (looking-back "^")
-           (backward-delete-char 1))
-         (insert "[")
-         (save-excursion
-           (save-restriction
-             (narrow-to-region (point) (save-excursion (re-search-forward "\\]" nil t)))
-             (goto-char (point-min))
-             (replace-regexp "
+    ;; what is this??
+    (while (re-search-forward "\\\\item \\[" nil t)
+      (backward-delete-char 7)
+      (when (looking-back "^")
+        (backward-delete-char 1))
+      (insert "[")
+      (save-excursion
+        (save-restriction
+          (narrow-to-region (point) (save-excursion (re-search-forward "\\]" nil t)))
+          (goto-char (point-min))
+          (replace-regexp "
 \\\\item " "; "))))
-       (while (re-search-forward "\\[" nil t)
-         (save-excursion
-           (save-restriction
-             (narrow-to-region (point) (1- (save-excursion (re-search-forward "\\]" nil t))))
-             (goto-char (point-min))
-             (insert "{\\footnotesize ")
-             (if (re-search-forward "= " nil t)
-                 (progn
-                   (backward-delete-char 2)
-                   (insert "\\emph{")
-                   (goto-char (point-max))
-                   (insert ";}}"))
-               (goto-char (point-max))
-               (insert ";}")))))
-       (replace-regexp "\\[\\(.*?\\)\\]" "\\\\emph{\\1}")
-       (let ((case-fold-search nil)) (replace-string "\\Bf" "\\bf"))
-       (my-dictionary-fix-quotes)
-       (replace-regexp "$" "
+    (while (re-search-forward "\\[" nil t)
+      (save-excursion
+        (save-restriction
+          (narrow-to-region (point) (1- (save-excursion (re-search-forward "\\]" nil t))))
+          (goto-char (point-min))
+          (insert "{\\footnotesize ")
+          (if (re-search-forward "= " nil t)
+              (progn
+                (backward-delete-char 2)
+                (insert "\\emph{")
+                (goto-char (point-max))
+                (insert ";}}"))
+            (goto-char (point-max))
+            (insert ";}")))))
+    (replace-regexp "\\[\\(.*?\\)\\]" "\\\\emph{\\1}")
+    (let ((case-fold-search nil)) (replace-string "\\Bf" "\\bf"))
+    (my-dictionary-fix-quotes)
+    (replace-regexp "$" "
 ")
-       (my-dictionary-remove-single-item-list)
-       (replace-string "enumerate" "enumerate*")))
+    (my-dictionary-remove-single-item-list)
+    (replace-string "enumerate" "enumerate*")))
 
-    (defun my-dictionary-fix-quotes ()
-      (let ((single 0)
-            (double 0))
-        (fix-reset-after-each
-         (replace-regexp "\\(\\W\\)'\\(\\w\\)" "\\1`\\2")
-         ;; (while (re-search-forward "[^a-z]'[^a-z]" nil t)
-         ;;   (backward-char 1)
-         ;;   (backward-delete-char 1)
-         ;;   (if (= (mod double 2) 0)
-         ;;       (insert "`")
-         ;;     (insert "'"))
-         ;;   (setq single (1+ single)))
-         (while (re-search-forward "\"" nil t)
-           (backward-delete-char 1)
-           (if (= (mod double 2) 0)
-               (insert "``")
-             (insert "''"))
-           (setq double (1+ double))))))
-
-    (defun my-dictionary-remove-single-item-list ()
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\begin{enumerate}" nil t)
-        (save-excursion
-          (save-restriction
-            (narrow-to-region (match-beginning 0) (save-excursion (re-search-forward "\\\\end{enumerate}" nil t)))
-            (goto-char (point-min))
-            (when (= 1 (count-matches "^\\\\item"))
-              (kill-line 2)
-              (delete-char 6)
-              (end-of-line)
-              (delete-region (point) (point-max))))
-          (beginning-of-line)
-          (backward-delete-char 2)
-          (insert " "))))
-
-    (defun my-format-synonyms ()
-      (interactive)
-      (goto-char (point-min))
-      (re-search-forward "Synonyms" nil t)
-      (my-kill-entire-line)
-      (while (re-search-forward "(\\([0-9]+\\))" nil t)
-        (save-excursion
-          (let ((text (buffer-substring-no-properties (point) (point-at-eol))))
-            (goto-char (point-min))
-            (goto-line (string-to-int (match-string 1)))
-            (end-of-line)
-            (insert " (syn:" text ")")))
-        (my-kill-entire-line))
-      (goto-char (point-min))
-      (replace-regexp "\n\\'" "")
-      (clipboard-kill-region (point-min) (point-max)))))
+(provide 'anki-to-tex)

site-lisp/defuns-edit.el

 (require 'thingatpt)
 
+(declare-function org-table-p "org")
+(declare-function org-beginning-of-line "org")
+(declare-function org-end-of-line "org")
+(declare-function cua--rectangle-top "cua-base")
+(declare-function cua--rectangle-bot "cua-base")
+(declare-function cua-resize-rectangle-right "cua-base")
+
 (defun my-kill-whitespace (&optional forward)
   "Kill all the whitespace characters backwards until hitting
 non-whitespace character.  With prefix argument, kill in the
         (indent-according-to-mode))
     (end-of-line)
     (open-line (prefix-numeric-value arg))
-    (next-line 1)
+    (forward-line 1)
     (indent-according-to-mode)))
 
 (defun forward-line-and-indent (arg)
 (defun move-line (n)
   "Move the current line up or down by N lines."
   (interactive "p")
-  (setq col (current-column))
-  (beginning-of-line) (setq start (point))
-  (end-of-line) (forward-char) (setq end (point))
-  (let ((line-text (delete-and-extract-region start end)))
-    (forward-line n)
-    (insert line-text)
-    (forward-line -1)
-    (forward-char col)))
+  (let ((col) (current-column) start end)
+    (beginning-of-line) (setq start (point))
+    (end-of-line) (forward-char) (setq end (point))
+    (let ((line-text (delete-and-extract-region start end)))
+      (forward-line n)
+      (insert line-text)
+      (forward-line -1)
+      (forward-char col))))
 
 (defun move-line-up (n)
   "Move the current line up by N lines."
 
 (defun my-back-to-indentation ()
   (if visual-line-mode
-      (flet ((beginning-of-line (arg) (beginning-of-visual-line arg)))
+      (cl-flet ((beginning-of-line (arg) (beginning-of-visual-line arg)))
         (back-to-indentation))
     (back-to-indentation)))
 
 Comments are recognized in any mode that sets syntax-ppss
 properly."
   (interactive "p")
-  (flet ((end-of-line-lov () (if visual-line-mode
-                                 (end-of-visual-line arg)
-                               (move-end-of-line arg)))
-         (beg-of-line-lov () (if visual-line-mode
-                                 (beginning-of-visual-line arg)
-                               (move-beginning-of-line arg))))
+  (cl-flet ((end-of-line-lov () (if visual-line-mode
+                                    (end-of-visual-line arg)
+                                  (move-end-of-line arg)))
+            (beg-of-line-lov () (if visual-line-mode
+                                    (beginning-of-visual-line arg)
+                                  (move-beginning-of-line arg))))
     (cond
      ((and (functionp'org-table-p)
            (org-table-p))

site-lisp/defuns-macros.el

 (defmacro fix-reset-after-each (&rest forms)
   (declare (indent 0))
   `(progn
-     ,@(apply 'append (mapcar (lambda (form) (list '(beginning-of-buffer) form)) forms))))
+     ,@(apply 'append (mapcar (lambda (form) (list '(goto-char (point-min)) form)) forms))))
 
 (defvar my-macro-names
   '(

site-lisp/emacs-lisp-mode.el

 (use-package lisp-mode
+  :defer t
   :init
   (progn
     (defun my-emacs-lisp-init ()
                    (eq (following-char) ?\)))
           (newline)
           (indent-according-to-mode)
-          (previous-line))))
+          (forward-line -1)
+          (indent-according-to-mode))))
 
     (defun my-describe-thing-in-buffer ()
       "Display the full documentation of FUNCTION (a symbol) in the help buffer."

site-lisp/latextohtml.el

 ;; e segnati il contenuto della nota. A fine capitolo cicla le note e metti
 ;; <P><SUP><A HREF="#note_from_$N" NAME="#note_to_$N">$N</A></SUP> Testo della nota</P>
 
-(use-package latextohtml
-  :commands (gen-footnotes
-             gen-html
-             fix-basic
-             fix-quotes
-             fix-quotes-italian
-             fix-italian
-             fix-quot-to-quotes
-             fix-html
-             fix-html-fimfic
-             fix-prepare-diff)
-  :config
-  (progn
-    (defun gen-footnotes-internal (n)
-      "n - currently processed footnote"
-      (when (search-forward "\\footnote" nil t)
-        (let* ((x (point)) (fn (number-to-string n)))
-          (forward-sexp)
-          (let* ((y (point)) (str (buffer-substring-no-properties (+ x 1) (- y 1))))
-            (progn (message str)
-                   (delete-region (- x 9) y)
-                   (insert (concat
-                            "<sup><a href=\"#note_to_"
-                            fn
-                            "\" name=\"note_from_"
-                            fn
-                            "\" >["
-                            fn
-                            "]</a></sup>"))
-                   (end-of-buffer)
-                   (insert (concat "
+(defun gen-footnotes-internal (n)
+  "n - currently processed footnote"
+  (when (search-forward "\\footnote" nil t)
+    (let* ((x (point)) (fn (number-to-string n)))
+      (forward-sexp)
+      (let* ((y (point)) (str (buffer-substring-no-properties (+ x 1) (- y 1))))
+        (progn (message str)
+               (delete-region (- x 9) y)
+               (insert (concat
+                        "<sup><a href=\"#note_to_"
+                        fn
+                        "\" name=\"note_from_"
+                        fn
+                        "\" >["
+                        fn
+                        "]</a></sup>"))
+               (end-of-buffer)
+               (insert (concat "
 
 <p><sup><a href=\"#note_from_"
-                                   fn
-                                   "\" name=\"note_to_"
-                                   fn
-                                   "\" >["
-                                   fn
-                                   "]</a></sup> "
-                                   str
-                                   "</p>"))
+                               fn
+                               "\" name=\"note_to_"
+                               fn
+                               "\" >["
+                               fn
+                               "]</a></sup> "
+                               str
+                               "</p>"))
                                         ;(pop-global-mark)
-                   (beginning-of-buffer)
-                   (gen-footnotes-internal (+ n 1)))))))
+               (goto-char (point-min))
+               (gen-footnotes-internal (+ n 1)))))))
 
-    (defun gen-footnotes ()
-      (interactive)
-      (beginning-of-buffer)
-      (gen-footnotes-internal 1))
+(defun gen-footnotes ()
+  (interactive)
+  (goto-char (point-min))
+  (gen-footnotes-internal 1))
 
-    (defun print-frontmatter ()
-      (beginning-of-buffer)
-      (insert "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
+(defun print-frontmatter ()
+  (goto-char (point-min))
+  (insert "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
 <html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"it\" xml:lang=\"it\">
 <head>
 <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />
 </head>
 <body>"))
 
-    (defun print-backmatter ()
-      (end-of-buffer)
-      (insert "
+(defun print-backmatter ()
+  (end-of-buffer)
+  (insert "
 
 </body>
 </html>"))
 
 
-    (defun gen-html ()
-      (interactive)
-      (let* ((bn (buffer-name)) (bfn (buffer-file-name)) (nbfn (when (string-match ".tex" bfn)
-                                                                 (message (replace-match ".html" nil nil bfn)))))
-        (progn (find-file nbfn)
-               (erase-buffer)
-               (insert-buffer-substring bn)))
-      (end-of-buffer)
-      (insert "<hr>
+(defun gen-html ()
+  (interactive)
+  (let* ((bn (buffer-name)) (bfn (buffer-file-name)) (nbfn (when (string-match ".tex" bfn)
+                                                             (message (replace-match ".html" nil nil bfn)))))
+    (progn (find-file nbfn)
+           (erase-buffer)
+           (insert-buffer-substring bn)))
+  (end-of-buffer)
+  (insert "<hr>
 ")
-      (beginning-of-buffer)
-      (gen-footnotes)
-      (beginning-of-buffer)
-      (replace-regexp "\"<" "&laquo;")
-      (beginning-of-buffer)
-      (replace-regexp "\">" "&raquo;")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\dk{``A}" "&ldquo;A")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\dk{\"<A}" "&ldquo;A")
-      (beginning-of-buffer)
-      (replace-regexp "``" "&ldquo;")
-      (beginning-of-buffer)
-      (replace-regexp "''" "&rdquo;")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\textasciitilde{}" "~")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\textgreater{}" "&gt;")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\-" "")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\fussy " "")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\sloppy " "")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\newline" "<br>")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\vspace{\\(.*?\\)}" "<div style=\"height: \\1\" ></div>")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\emph{\\(.*?\\)}" "<em>\\1</em>")
-      (beginning-of-buffer)
-      (replace-regexp "{\\\\bf \\(.*?\\)}" "<strong>\\1</strong>")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\Scene" "<div class=\"scene\" ></div>")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\dots" "&hellip;")
-      (beginning-of-buffer)
-      (replace-regexp "---" " &mdash; ")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\%" "%")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\#" "#")
-      (beginning-of-buffer) ; add newlines around begin
-      (replace-regexp "\\(\\\\begin{.*?}\\)" "
+  (goto-char (point-min))
+  (gen-footnotes)
+  (goto-char (point-min))
+  (replace-regexp "\"<" "&laquo;")
+  (goto-char (point-min))
+  (replace-regexp "\">" "&raquo;")
+  (goto-char (point-min))
+  (replace-regexp "\\\\dk{``A}" "&ldquo;A")
+  (goto-char (point-min))
+  (replace-regexp "\\\\dk{\"<A}" "&ldquo;A")
+  (goto-char (point-min))
+  (replace-regexp "``" "&ldquo;")
+  (goto-char (point-min))
+  (replace-regexp "''" "&rdquo;")
+  (goto-char (point-min))
+  (replace-regexp "\\\\textasciitilde{}" "~")
+  (goto-char (point-min))
+  (replace-regexp "\\\\textgreater{}" "&gt;")
+  (goto-char (point-min))
+  (replace-regexp "\\\\-" "")
+  (goto-char (point-min))
+  (replace-regexp "\\\\fussy " "")
+  (goto-char (point-min))
+  (replace-regexp "\\\\sloppy " "")
+  (goto-char (point-min))
+  (replace-regexp "\\\\newline" "<br>")
+  (goto-char (point-min))
+  (replace-regexp "\\\\vspace{\\(.*?\\)}" "<div style=\"height: \\1\" ></div>")
+  (goto-char (point-min))
+  (replace-regexp "\\\\emph{\\(.*?\\)}" "<em>\\1</em>")
+  (goto-char (point-min))
+  (replace-regexp "{\\\\bf \\(.*?\\)}" "<strong>\\1</strong>")
+  (goto-char (point-min))
+  (replace-regexp "\\\\Scene" "<div class=\"scene\" ></div>")
+  (goto-char (point-min))
+  (replace-regexp "\\\\dots" "&hellip;")
+  (goto-char (point-min))
+  (replace-regexp "---" " &mdash; ")
+  (goto-char (point-min))
+  (replace-regexp "\\\\%" "%")
+  (goto-char (point-min))
+  (replace-regexp "\\\\#" "#")
+  (goto-char (point-min)) ; add newlines around begin
+  (replace-regexp "\\(\\\\begin{.*?}\\)" "
 \\1
 ")
-      (beginning-of-buffer) ; add newlines around end
-      (replace-regexp "\\(\\\\end{.*?}\\)" "
+  (goto-char (point-min)) ; add newlines around end
+  (replace-regexp "\\(\\\\end{.*?}\\)" "
 \\1
 ")
-      (beginning-of-buffer) ; remove excessive newlines
-      (replace-regexp "
+  (goto-char (point-min)) ; remove excessive newlines
+  (replace-regexp "
 
 
 +" "
 
 ")
-      (beginning-of-buffer) ; add <p> tags
-      (replace-regexp "\\(^[^<\\
+  (goto-char (point-min)) ; add <p> tags
+  (replace-regexp "\\(^[^<\\
 ].*?\\)
 
 " "<p>\\1</p>
 
 ")
-      (beginning-of-buffer) ; change begin .letter and .terminal and .song into <blockquote>
-      (replace-regexp "\\\\begin{\\(\\(letter\\|terminal\\|song\\)\\)}" "<blockquote class=\"\\1\" >")
-      (beginning-of-buffer) ; change end .letter and .terminal .song into </blockquote>
-      (replace-regexp "\\\\end{\\(\\(letter\\|terminal\\|song\\)\\)}" "</blockquote>")
-      (beginning-of-buffer) ; memoryOrb style
-      (replace-regexp "\\\\begin{memoryOrb}" "<div class=\"memoryOrb\" >
+  (goto-char (point-min)) ; change begin .letter and .terminal and .song into <blockquote>
+  (replace-regexp "\\\\begin{\\(\\(letter\\|terminal\\|song\\)\\)}" "<blockquote class=\"\\1\" >")
+  (goto-char (point-min)) ; change end .letter and .terminal .song into </blockquote>
+  (replace-regexp "\\\\end{\\(\\(letter\\|terminal\\|song\\)\\)}" "</blockquote>")
+  (goto-char (point-min)) ; memoryOrb style
+  (replace-regexp "\\\\begin{memoryOrb}" "<div class=\"memoryOrb\" >
 <div class=\"memoryOrbOpen\" >(* * *)</div>")
-      (beginning-of-buffer)
-      (replace-regexp "\\\\end{memoryOrb}" "<div class=\"memoryOrbClose\" >(* * *)</div>
+  (goto-char (point-min))
+  (replace-regexp "\\\\end{memoryOrb}" "<div class=\"memoryOrbClose\" >(* * *)</div>
 </div>")
-      (beginning-of-buffer)
-      (replace-regexp "<blockquote class=\"song\" >" "<blockquote class=\"song\" >
+  (goto-char (point-min))
+  (replace-regexp "<blockquote class=\"song\" >" "<blockquote class=\"song\" >