write function ive wanted for a long time
[dot-emacs] / my-init.org
index 1c98c882a264559deba457bd13a86f0f627618ca..107249901db55d0d9498c08fcc7cd541fb943bd7 100644 (file)
@@ -574,9 +574,20 @@ I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
 ;; main hook for my auto save
 (add-hook 'auto-save-hook 'my-auto-save)
 ;; additional hook to try to deal with emacs not auto-saving when a buffer isn't active
-(add-hook 'window-configuration-change-hook 'my-auto-save)
+(add-hook 'window-configuration-change-hook 'my-auto-save-win)
 
-(defun my-auto-save ()
+;; this function from mu4e really does not like buffer saving
+(advice-add 'message-send-and-exit :before 'my-as-off)
+(advice-add 'message-send-and-exit :after 'my-as-on)
+
+;; avoid window config hook saving too much, it can
+;; get into loops in some random situations
+(setq my-auto-save-last nil)
+(defun my-auto-save-win ()
+  (unless (eq (current-buffer) my-auto-save-last)
+  (my-auto-save (current-buffer))))
+
+(defun my-auto-save (&optional last)
   (when (and
          my-as
          (buffer-file-name)
@@ -584,6 +595,7 @@ I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
          (not (string= (buffer-file-name) "*draft*"))
          (buffer-modified-p)
          (not (org-src-edit-buffer-p)))
+    (setq my-auto-save-last last)
     (let (message-log-max)
       ;; a bit of a hack to partially suppress the constant saving in the echo area
       (with-temp-message ""
@@ -2268,9 +2280,8 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 ;; this starter kit setting is probably good
 (if window-system (setq frame-title-format '(buffer-file-name "%f" ("%b"))))
 
-(set-terminal-coding-system 'utf-8)
-(set-keyboard-coding-system 'utf-8)
-(prefer-coding-system 'utf-8)
+
+;;(prefer-coding-system 'utf-8-unix)
 
 ;; remove ugly 3d box feature
 (set-face-attribute 'mode-line nil :box nil)
@@ -3649,6 +3660,8 @@ commands to change: select other window: C-x o.
 #+end_src
 
 ** named commands
+*** gdb
+gdb-many-windows
 *** tramp sudo
 /ssh:host|sudo:host:
 when in the same session, you can then do:
@@ -5280,8 +5293,9 @@ join lines
 #+end_src
 *** M-/
 *** C-M-/]
-copy-variable
+copy-buffer-file-name
 #+begin_src emacs-lisp
+;; haven't bound this atm, todo, maybe someday?
 (defun copy-variable (variable)
   (interactive
    (let ((v (variable-at-point))
@@ -5300,7 +5314,17 @@ copy-variable
      (list (if (equal val "")
               v (intern val)))))
   (kill-new (symbol-value variable)))
-(global-set-key (kbd "C-M-/") 'copy-variable)
+
+(defun copy-buffer-file-name ()
+  (interactive)
+  (kill-new
+   (cond
+    ((derived-mode-p 'mu4e-view-mode) (mu4e-message-field-at-point :path))
+    (t buffer-file-name))
+   ))
+
+(global-set-key (kbd "C-M-/") 'copy-buffer-file-name)
+
 
 #+end_src
 *** C-S-/