diff --git a/why-this.el b/why-this.el index 287ee99921..19acb90f9f 100644 --- a/why-this.el +++ b/why-this.el @@ -36,6 +36,10 @@ (require 'timezone) (require 'color) +;; A very high-level request that would probably take too much work to +;; actualise, would be to figure out some way to integrate this into +;; VC. That way you can make use of this even if you don't use Git or Hg. + (defgroup why-this nil "Show why the current line contains this." :group 'tools @@ -64,6 +68,7 @@ the first argument is the command (which is a symbol): `:author' Name of the author. `:time' Time of change (local). `:desc' Single line description of change." + ;; Would it make sense to use a `cl-defstruct'? :type 'hook :options (list #'why-this-git #'why-this-hg) @@ -326,6 +331,7 @@ TIME-FORMAT is used to format data." (?t . (why-this-format-time time-format (plist-get data :time))) (?i . (plist-get data :desc))))) + ;; `format-spec' should make this simpler (replace-regexp-in-string "%." (lambda (str) @@ -342,7 +348,7 @@ TIME-FORMAT is used to format data." (defun why-this--overlay-bg-type (pos) "Return the background type for overlay at POS." (cond - ((and (use-region-p) + ((and (use-region-p) ;perhaps `region-active-p'? (>= pos (region-beginning)) (< pos (region-end))) 'region) @@ -364,6 +370,7 @@ TIME-FORMAT is used to format data." 'solaire-region-face 'region)) ('line + ;; Looks like a `cond' to me (if (bound-and-true-p hl-line-mode) (if (bound-and-true-p solaire-mode) 'solaire-hl-line-face @@ -382,12 +389,10 @@ TIME-FORMAT is used to format data." (while why-this--overlays (delete-overlay (pop why-this--overlays))) (when why-this-mode - (let* ((begin (line-number-at-pos (if (use-region-p) - (region-beginning) - (point)))) - (end (1+ (line-number-at-pos (if (use-region-p) - (region-end) - (point))))) + (let* ((line (line-number-at-pos (if (use-region-p) + (region-beginning) + (point)))) + (begin line) (end (1+ line)) (backend why-this--backend) (data (funcall backend 'line-data begin end))) (dolist (i (number-sequence 0 (- end begin 1))) @@ -446,6 +451,8 @@ TIME-FORMAT is used to format data." (region-end) (point)))))) (setq + ;; Perhaps this could be made more readble by using + ;; `thread-last' or the above let binding why-this--overlays (delq nil @@ -458,10 +465,10 @@ TIME-FORMAT is used to format data." (< line end) (eq line (overlay-get ov 'why-this-line))))) (progn - (let* ((ov-start (overlay-start ov)) - line-begin - line-end - column) + (let ((ov-start (overlay-start ov)) + line-begin + line-end + column) (save-excursion (goto-char ov-start) (setq line-begin (line-beginning-position)) @@ -537,6 +544,11 @@ Actually the supported backend is returned." (* (- (nth i b-color) (nth i a-color)) ratio))))) + ;; Note that RGB interpolation doesn't always behave the way you + ;; think it does. You'd have to convert it into some other color + ;; space like CIELAB to get perceptual mixing right (but even that + ;; is trying because it requires some kind of a white-reference + ;; point). (color-rgb-to-hex (funcall mix 0) (funcall mix 1) (funcall mix 2)