* [patch] vc-annotate-toggle-annotation-visibility, almost
@ 2007-11-04 1:29 Thien-Thi Nguyen
2007-11-04 3:13 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2007-11-04 1:29 UTC (permalink / raw)
To: emacs-devel
"almost" because i don't see any change w/ `redisplay'
in `vc-annotate-toggle-annotation-visibility'; use of
`force-mode-line-update' is suboptimal. still investigating.
* vc.el (vc-annotate-toggle-annotation-visibility): New command.
(vc-annotate-mode-map): Bind "V" to new command.
(vc-annotate-mode): Clear buffer-invisibility-spec.
(vc-annotate-get-time-set-line-props): New func.
(vc-annotate-display-autoscale, vc-annotate-difference): Use it.
("VC Annotate Display Menu"): Add entry for new command.
comments?
thi
__________________________________________________________
*** vc.el 30 Oct 2007 12:43:34 -0000 1.477
--- vc.el 4 Nov 2007 01:17:53 -0000
***************
*** 774,779 ****
--- 774,780 ----
(define-key m "N" 'vc-annotate-next-revision)
(define-key m "P" 'vc-annotate-prev-revision)
(define-key m "W" 'vc-annotate-working-revision)
+ (define-key m "V" 'vc-annotate-toggle-annotation-visibility)
m)
"Local keymap used for VC-Annotate mode.")
***************
*** 3132,3142 ****
--- 3133,3158 ----
You can use the mode-specific menu to alter the time-span of the used
colors. See variable `vc-annotate-menu-elements' for customizing the
menu items."
+ (setq buffer-invisibility-spec nil)
(set (make-local-variable 'truncate-lines) t)
(set (make-local-variable 'font-lock-defaults)
'(vc-annotate-font-lock-keywords t))
(view-mode 1))
+ (defun vc-annotate-toggle-annotation-visibility ()
+ "Toggle whether or not the annotation is visible."
+ (interactive)
+ (funcall (if (memq 'vc-annotate-annotation buffer-invisibility-spec)
+ 'remove-from-invisibility-spec
+ 'add-to-invisibility-spec)
+ 'vc-annotate-annotation)
+ (when (get-text-property (point) 'invisible)
+ (goto-char (next-single-property-change (point) 'invisible)))
+ ;; FIXME: `redisplay' is ineffectual. --ttn
+ ;; (let ((redisplay-dont-pause t))
+ ;; (redisplay t))
+ (force-mode-line-update t))
+
(defun vc-annotate-display-default (ratio)
"Display the output of \\[vc-annotate] using the default color range.
The color range is given by `vc-annotate-color-map', scaled by RATIO.
***************
*** 3151,3156 ****
--- 3167,3179 ----
;; Since entries should be sorted, we can just use the last one.
(caar (last color-map)))
+ (defun vc-annotate-get-time-set-line-props ()
+ (let ((bol (point))
+ (date (vc-call-backend vc-annotate-backend 'annotate-time))
+ (inhibit-read-only t))
+ (put-text-property bol (point) 'invisible 'vc-annotate-annotation)
+ date))
+
(defun vc-annotate-display-autoscale (&optional full)
"Highlight the output of \\[vc-annotate] using an autoscaled color map.
Autoscaling means that the map is scaled from the current time to the
***************
*** 3166,3172 ****
(save-excursion
(goto-char (point-min))
(while (not (eobp))
! (when (setq date (vc-call-backend vc-annotate-backend 'annotate-time))
(if (> date newest)
(setq newest date))
(if (< date oldest)
--- 3189,3195 ----
(save-excursion
(goto-char (point-min))
(while (not (eobp))
! (when (setq date (vc-annotate-get-time-set-line-props))
(if (> date newest)
(setq newest date))
(if (< date oldest)
***************
*** 3214,3219 ****
--- 3237,3243 ----
:style toggle :selected
(eq vc-annotate-display-mode 'fullscale)]
"--"
+ ["Toggle annotation visibility" vc-annotate-toggle-annotation-visibility]
["Annotate previous revision" vc-annotate-prev-revision]
["Annotate next revision" vc-annotate-next-revision]
["Annotate revision at line" vc-annotate-revision-at-line]
***************
*** 3478,3484 ****
This calls the backend function annotate-time, and returns the
difference in days between the time returned and the current time,
or OFFSET if present."
! (let ((next-time (vc-call-backend vc-annotate-backend 'annotate-time)))
(if next-time
(- (or offset
(vc-call-backend vc-annotate-backend 'annotate-current-time))
--- 3502,3508 ----
This calls the backend function annotate-time, and returns the
difference in days between the time returned and the current time,
or OFFSET if present."
! (let ((next-time (vc-annotate-get-time-set-line-props)))
(if next-time
(- (or offset
(vc-call-backend vc-annotate-backend 'annotate-current-time))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] vc-annotate-toggle-annotation-visibility, almost
2007-11-04 1:29 [patch] vc-annotate-toggle-annotation-visibility, almost Thien-Thi Nguyen
@ 2007-11-04 3:13 ` Stefan Monnier
2007-11-04 9:43 ` Thien-Thi Nguyen
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2007-11-04 3:13 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: emacs-devel
> "almost" because i don't see any change w/ `redisplay'
> in `vc-annotate-toggle-annotation-visibility'; use of
> `force-mode-line-update' is suboptimal. still investigating.
Use of force-mode-line-update doesn't seem particularly bad to me
(assuming it works).
> You can use the mode-specific menu to alter the time-span of the used
> colors. See variable `vc-annotate-menu-elements' for customizing the
> menu items."
> + (setq buffer-invisibility-spec nil)
> (set (make-local-variable 'truncate-lines) t)
> (set (make-local-variable 'font-lock-defaults)
> '(vc-annotate-font-lock-keywords t))
> (view-mode 1))
Why?
> + (when (get-text-property (point) 'invisible)
> + (goto-char (next-single-property-change (point) 'invisible)))
What is this for?
We could additionally put commands to print the (invisible) annotation
in the echo-area, and also add a `help-echo' property to the whole
buffer so as to get tooltips that display the (invisible) annotation.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] vc-annotate-toggle-annotation-visibility, almost
2007-11-04 3:13 ` Stefan Monnier
@ 2007-11-04 9:43 ` Thien-Thi Nguyen
0 siblings, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2007-11-04 9:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
() Stefan Monnier <monnier@iro.umontreal.ca>
() Sat, 03 Nov 2007 23:13:29 -0400
> "almost" because i don't see any change w/ `redisplay'
> in `vc-annotate-toggle-annotation-visibility'; use of
> `force-mode-line-update' is suboptimal. still investigating.
Use of force-mode-line-update doesn't seem particularly bad to me
(assuming it works).
prior to `redisplay' being available, i would agree. but not now.
that `redisplay' doesn't is bug that should be fixed, IMO.
> You can use the mode-specific menu to alter the time-span of the used
> colors. See variable `vc-annotate-menu-elements' for customizing the
> menu items."
> + (setq buffer-invisibility-spec nil)
> (set (make-local-variable 'truncate-lines) t)
> (set (make-local-variable 'font-lock-defaults)
> '(vc-annotate-font-lock-keywords t))
> (view-mode 1))
the default buffer-invisibility-spec value is `t', so when
vc-annotate-get-time-set-line-props sets the text property `invisible' to a
non-nil value, the result is that the buffer is initially displayed w/
invisible annotations. (you would need to toggle it once to see them.)
thanks for pointing this out. upon review, i think there is a better way:
;; Frob buffer-invisibility-spec so that if it is originally a naked t,
;; it will become a list, to avoid initial annotations being invisible.
(add-to-invisibility-spec 'foo)
(remove-from-invisibility-spec 'foo)
> + (when (get-text-property (point) 'invisible)
> + (goto-char (next-single-property-change (point) 'invisible)))
What is this for?
effect "edge-triggered intangible". however, it's not necessary (and
in fact somtimes leaves point one further than expected). removed.
We could additionally put commands to print the (invisible) annotation
in the echo-area, and also add a `help-echo' property to the whole
buffer so as to get tooltips that display the (invisible) annotation.
yes, but that's outside the scope of this patch.
thi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-04 9:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-04 1:29 [patch] vc-annotate-toggle-annotation-visibility, almost Thien-Thi Nguyen
2007-11-04 3:13 ` Stefan Monnier
2007-11-04 9:43 ` Thien-Thi Nguyen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).