From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: [patch] vc-annotate-toggle-annotation-visibility, almost Date: Sun, 04 Nov 2007 02:29:15 +0100 Message-ID: <87zlxu4x3o.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1194139840 5170 80.91.229.12 (4 Nov 2007 01:30:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2007 01:30:40 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 04 02:30:43 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IoUK2-0001M9-02 for ged-emacs-devel@m.gmane.org; Sun, 04 Nov 2007 02:30:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoUJr-0008Oy-Bj for ged-emacs-devel@m.gmane.org; Sat, 03 Nov 2007 21:30:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IoUJm-0008Hz-3j for emacs-devel@gnu.org; Sat, 03 Nov 2007 21:30:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IoUJl-0008EQ-2a for emacs-devel@gnu.org; Sat, 03 Nov 2007 21:30:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoUJk-0008E7-Oj for emacs-devel@gnu.org; Sat, 03 Nov 2007 21:30:24 -0400 Original-Received: from ppp-39-35.21-151.libero.it ([151.21.35.39] helo=ambire.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IoUJj-0004R7-VL for emacs-devel@gnu.org; Sat, 03 Nov 2007 21:30:24 -0400 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1IoUId-0004Zg-CR for emacs-devel@gnu.org; Sun, 04 Nov 2007 02:29:15 +0100 X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82473 Archived-At: "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))