]> git.earman.xyz Git - emacsinit.git/commitdiff
Cleanup, addition of openwith, various defuns from whattheemacsd.com
authorrearman <rearman@r717.net>
Wed, 16 Nov 2022 19:35:36 +0000 (14:35 -0500)
committerrearman <rearman@r717.net>
Wed, 16 Nov 2022 19:35:36 +0000 (14:35 -0500)
editing-defuns.el
init.el

index 83a118c78d70e2df2348ae5df2352f070a9ad768..290da105b79a6f429a9bb06d41a79df873375468 100644 (file)
@@ -54,3 +54,68 @@ Can't go prev line first, edge case of beginning of buffer."
   "Bring up work-eqs.el for editing."
   (interactive)
   (find-file work-eqns))
+
+(defun toggle-window-split ()
+  "If two windows are open, toggle their split layout between vert. and horiz.
+Stolen from http://whattheemacsd.com"
+  (interactive)
+  (if (= (count-windows) 2)
+      (let* ((this-win-buffer (window-buffer))
+            (next-win-buffer (window-buffer (next-window)))
+            (this-win-edges (window-edges (selected-window)))
+            (next-win-edges (window-edges (next-window)))
+            (this-win-2nd (not (and (<= (car this-win-edges)
+                                        (car next-win-edges))
+                                    (<= (cadr this-win-edges)
+                                        (cadr next-win-edges)))))
+            (splitter
+             (if (= (car this-win-edges)
+                    (car (window-edges (next-window))))
+                 'split-window-horizontally
+               'split-window-vertically)))
+       (delete-other-windows)
+       (let ((first-win (selected-window)))
+         (funcall splitter)
+         (if this-win-2nd (other-window 1))
+         (set-window-buffer (selected-window) this-win-buffer)
+         (set-window-buffer (next-window) next-win-buffer)
+         (select-window first-win)
+         (if this-win-2nd (other-window 1))))))
+
+(defun rotate-windows ()
+  "Rotate your windows.
+Stolen from http://whattheemacsd.com"
+  (interactive)
+  (cond ((not (> (count-windows)1))
+        (message "You can't rotate a single window!"))
+       (t
+        (setq i 1)
+        (setq numWindows (count-windows))
+        (while  (< i numWindows)
+          (let* (
+                 (w1 (elt (window-list) i))
+                 (w2 (elt (window-list) (+ (% i numWindows) 1)))
+
+                 (b1 (window-buffer w1))
+                 (b2 (window-buffer w2))
+
+                 (s1 (window-start w1))
+                 (s2 (window-start w2))
+                 )
+            (set-window-buffer w1  b2)
+            (set-window-buffer w2 b1)
+            (set-window-start w1 s2)
+            (set-window-start w2 s1)
+            (setq i (1+ i)))))))
+
+(defadvice magit-status (around magit-fullscreen activate)
+  (window-configuration-to-register :magit-fullscreen)
+  ad-do-it
+  (delete-other-windows))
+
+(defun magit-quit-session ()
+  "Restores the previous window configuration and kills the magit buffer.
+Stolen from http://whattheemacsd.com"
+  (interactive)
+  (kill-buffer)
+  (jump-to-register :magit-fullscreen))
diff --git a/init.el b/init.el
index 8915efab174b335c8e4bcc03c5a7baf206e8c31b..d684b701e85908f269664be0c8f08a5140ec95f2 100644 (file)
--- a/init.el
+++ b/init.el
@@ -8,8 +8,8 @@
           (setq delete-by-moving-to-trash t))
   nil)
 
-(load-file work-eqns)
-(load-file editing-defuns)
+(load work-eqns)
+(load editing-defuns)
 
 ;; PACKAGES
 ;; NEW STRAIGHT.EL CONFIG
 
 (use-package gnuplot-mode)
 
+(use-package openwith
+  :config
+  (openwith-mode t)
+  (setq openwith-associations '(("\\.pdf\\'" "sumatrapdf" (file))
+                               ("\\.xlsx\\'" "excel" (file))
+                               ("\\.doc\\'" "word" (file))
+                               ("\\.docx\\'" "word" (file)))))
+
 ;; OPTIONS
 (recentf-mode t)
 (fringe-mode 1)
 (menu-bar-mode -1)
 (tool-bar-mode -1)
 (auto-fill-mode t)
-(show-paren-mode t)
 (column-number-mode t)
 (set-scroll-bar-mode 'left)
 (global-hl-line-mode t)
 
 ;; HOOKS
 (add-hook 'before-save-hook 'whitespace-cleanup)
+(add-hook 'dired-mode-hook 'dired-hide-details-mode t)
 
 ;; SETQ AND DEFAULTS
 (setq default-directory "~/"
       inhibit-startup-message t
       initial-scratch-message nil
+      server-client-instructions nil
       require-final-newline t
       use-short-answers t
       mode-line-compact t
       auto-save-default nil
       show-paren-delay 0
       show-paren-style 'mixed
+      global-hl-line-sticky-flag t
       confirm-nonexistent-file-or-buffer nil
-      ido-enable-flex-matching t
-      ido-create-new-buffer 'always
       org-M-RET-may-split-line nil
       org-startup-folded t
       org-startup-indented t
+      org-catch-invisible-edits 'show
       mouse-autoselect-window t)
 
 (setq-default indicate-empty-lines t
-             show-trailing-whitespace t
+             fill-column 80
              read-file-name-completion-ignore-case t
              read-buffer-completion-ignore-case t
+             dired-hide-details-mode t
              cursor-type 'bar
              cursor-in-non-selected-windows nil)
 
 (global-set-key (kbd "C-c ei") 'edit-init)
 (global-set-key (kbd "C-c ew") 'edit-work-eqs)
 (global-set-key (kbd "C-c r") 'recentf-open-files)
+(global-set-key (kbd "C-c s") 'rotate-windows)
+(global-set-key (kbd "C-c t") 'toggle-window-split)
 ;; OVERRIDES
 (global-set-key (kbd "M-j") 'backward-join-line)
 (global-set-key (kbd "M-J") 'join-line)
 (global-set-key (kbd "C-x ,") 'previous-buffer)
 (global-set-key (kbd "M-%") 'replace-regexp)
 (global-set-key (kbd "C-M-%") 'query-replace-regexp)
+;; MODE SPECIFIC
+(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)
 
 (custom-set-variables
  ;; custom-set-variables was added by Custom.