Commit dcf5fa579794

Vincent Demeester <vincent@sbr.pm>
2017-07-02 14:15:22
Update some org clocking idle time *and* whitespace mode
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 331129d
Changed files (2)
.emacs.d/emacs.el
@@ -1,64 +1,3 @@
-(defun curr-dir-git-branch-string (pwd)
-  "Returns current git branch as a string, or the empty string if
-PWD is not in a git repo (or the git command is not found)."
-  (interactive)
-  (when (and (eshell-search-path "git")
-             (locate-dominating-file pwd ".git"))
-    (let ((git-output (shell-command-to-string (concat "cd " pwd " && git branch | grep '\\*' | sed -e 's/^\\* //'"))))
-      (if (> (length git-output) 0)
-          (concat " :" (substring git-output 0 -1))
-        "(no branch)"))))
-
-(defun pwd-replace-home (pwd)
-  "Replace home in PWD with tilde (~) character."
-  (interactive)
-  (let* ((home (expand-file-name (getenv "HOME")))
-         (home-len (length home)))
-    (if (and
-         (>= (length pwd) home-len)
-         (equal home (substring pwd 0 home-len)))
-        (concat "~" (substring pwd home-len))
-   pwd)))
-
-(defun pwd-shorten-dirs (pwd)
-  "Shorten all directory names in PWD except the last two."
-  (let ((p-lst (split-string pwd "/")))
-    (if (> (length p-lst) 2)
-        (concat
-         (mapconcat (lambda (elm) (if (zerop (length elm)) ""
-                                    (substring elm 0 1)))
-                    (butlast p-lst 2)
-                    "/")
-         "/"
-         (mapconcat (lambda (elm) elm)
-                    (last p-lst 2)
-                    "/"))
-   pwd)))  ;; Otherwise, we just return the PWD
-
-(defun split-directory-prompt (directory)
-  (if (string-match-p ".*/.*" directory)
-   (list (file-name-directory directory) (file-name-base directory))
-    (list "" directory)))
-
-(setq eshell-highlight-prompt nil)
-
-(require 'em-smart)
-(setq eshell-where-to-jump 'begin)
-(setq eshell-review-quick-commands nil)
-(setq eshell-smart-space-goes-to-end t)
-
-(defun ha/eshell-quit-or-delete-char (arg)
-  (interactive "p")
-  (if (and (eolp) (looking-back eshell-prompt-regexp))
-      (progn
-        (eshell-life-is-too-much) ; Why not? (eshell/exit)
-        (ignore-errors
-          (delete-window)))
-    (delete-forward-char arg)))
-
-(add-hook 'eshell-mode-hook (lambda ()
-   (define-key eshell-mode-map (kbd "C-d")
-                               'ha/eshell-quit-or-delete-char)))
 
 (defun my/edit-emacs-configuration ()
   (interactive)
@@ -768,6 +707,16 @@ PWD is not in a git repo (or the git command is not found)."
             (setq show-trailing-whitespace 't))
           )
 
+(setq  whitespace-line-column fill-column
+     whitespace-style
+     '(face indentation tabs tab-mark spaces space-mark newline newline-mark
+          trailing lines-tail)
+     whitespace-display-mappings
+     '((tab-mark ?\t [?› ?\t])
+     (newline-mark ?\n [?¬ ?\n])
+     (space-mark ?\ [?·] [?.])))
+(whitespace-mode +1)
+
 (use-package comment-dwim-2
   :ensure t
   :bind* (("C-M-/" . comment-dwim-2)))
@@ -1294,6 +1243,9 @@ This can be 0 for immediate, or a floating point value.")
 (setq org-clock-out-remove-zero-time-clocks 1)
 ;; Clock out when moving task to a done state
 (setq org-clock-out-when-done 1)
+;; If idle for more than 15 minutes, resolve the things by asking what to do
+;; with the clock time
+(setq org-clock-idle-time 15)
 
 (defadvice org-clock-in (after sacha activate)
   "Set this task's status to 'PROGRESS'."
@@ -2142,3 +2094,65 @@ that directory."
   (interactive)
   (message (format "Tangling emacs config"))
   (tangle-config-sync (substitute-env-in-file-name "$HOME/src/configs/emacs-config/.emacs.d/emacs.org")))
+
+(defun curr-dir-git-branch-string (pwd)
+  "Returns current git branch as a string, or the empty string if
+PWD is not in a git repo (or the git command is not found)."
+  (interactive)
+  (when (and (eshell-search-path "git")
+             (locate-dominating-file pwd ".git"))
+    (let ((git-output (shell-command-to-string (concat "cd " pwd " && git branch | grep '\\*' | sed -e 's/^\\* //'"))))
+      (if (> (length git-output) 0)
+          (concat " :" (substring git-output 0 -1))
+        "(no branch)"))))
+
+(defun pwd-replace-home (pwd)
+  "Replace home in PWD with tilde (~) character."
+  (interactive)
+  (let* ((home (expand-file-name (getenv "HOME")))
+         (home-len (length home)))
+    (if (and
+         (>= (length pwd) home-len)
+         (equal home (substring pwd 0 home-len)))
+        (concat "~" (substring pwd home-len))
+   pwd)))
+
+(defun pwd-shorten-dirs (pwd)
+  "Shorten all directory names in PWD except the last two."
+  (let ((p-lst (split-string pwd "/")))
+    (if (> (length p-lst) 2)
+        (concat
+         (mapconcat (lambda (elm) (if (zerop (length elm)) ""
+                                    (substring elm 0 1)))
+                    (butlast p-lst 2)
+                    "/")
+         "/"
+         (mapconcat (lambda (elm) elm)
+                    (last p-lst 2)
+                    "/"))
+   pwd)))  ;; Otherwise, we just return the PWD
+
+(defun split-directory-prompt (directory)
+  (if (string-match-p ".*/.*" directory)
+   (list (file-name-directory directory) (file-name-base directory))
+    (list "" directory)))
+
+(setq eshell-highlight-prompt nil)
+
+(require 'em-smart)
+(setq eshell-where-to-jump 'begin)
+(setq eshell-review-quick-commands nil)
+(setq eshell-smart-space-goes-to-end t)
+
+(defun ha/eshell-quit-or-delete-char (arg)
+  (interactive "p")
+  (if (and (eolp) (looking-back eshell-prompt-regexp))
+      (progn
+        (eshell-life-is-too-much) ; Why not? (eshell/exit)
+        (ignore-errors
+          (delete-window)))
+    (delete-forward-char arg)))
+
+(add-hook 'eshell-mode-hook (lambda ()
+   (define-key eshell-mode-map (kbd "C-d")
+                               'ha/eshell-quit-or-delete-char)))
.emacs.d/emacs.org
@@ -1084,15 +1084,15 @@
 
         (when (package-installed-p 'hydra)
           (defhydra hydra-window-size (:color red)
-    	"Windows size"
-    	("h" shrink-window-horizontally "shrink horizontal")
-    	("j" shrink-window "shrink vertical")
-    	("k" enlarge-window "enlarge vertical")
-    	("l" enlarge-window-horizontally "enlarge horizontal"))
+        "Windows size"
+        ("h" shrink-window-horizontally "shrink horizontal")
+        ("j" shrink-window "shrink vertical")
+        ("k" enlarge-window "enlarge vertical")
+        ("l" enlarge-window-horizontally "enlarge horizontal"))
           (defhydra hydra-window-frame (:color red)
-    	"Frame"
-    	("f" make-frame "new frame")
-    	("x" delete-frame "delete frame"))
+        "Frame"
+        ("f" make-frame "new frame")
+        ("x" delete-frame "delete frame"))
           (add-to-list 'aw-dispatch-alist '(?w hydra-window-size/body) t)
           (add-to-list 'aw-dispatch-alist '(?o hydra-window-scroll/body) t)
           (add-to-list 'aw-dispatch-alist '(?\; hydra-window-frame/body) t))
@@ -1391,6 +1391,21 @@
               )
   #+END_SRC
 
+  I like to see /invisible/ characters, like tab, etc… In `Emacs`, to
+  display those, it's called whitespace-mode.
+
+  #+BEGIN_SRC emacs-lisp
+    (setq  whitespace-line-column fill-column
+         whitespace-style
+         '(face indentation tabs tab-mark spaces space-mark newline newline-mark
+              trailing lines-tail)
+         whitespace-display-mappings
+         '((tab-mark ?\t [?› ?\t])
+         (newline-mark ?\n [?¬ ?\n])
+         (space-mark ?\ [?·] [?.])))
+    (whitespace-mode +1)
+  #+END_SRC
+
 ** TODO Selection
 
    One feature of IntelliJ that really rocks is the =C-w= shortcuts
@@ -2206,6 +2221,9 @@
      (setq org-clock-out-remove-zero-time-clocks 1)
      ;; Clock out when moving task to a done state
      (setq org-clock-out-when-done 1)
+     ;; If idle for more than 15 minutes, resolve the things by asking what to do
+     ;; with the clock time
+     (setq org-clock-idle-time 15)
    #+END_SRC
 
    We also want to set the state to =PROGRESS= when we are clocking