From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: Suggestion for hl-line.el Date: Fri, 16 May 2003 12:07:13 +0200 Organization: CWI, Amsterdam Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <200305071446.h47EkSJw014780@rum.cs.yale.edu> <200305081448.h48EmnZd019230@rum.cs.yale.edu> <200305151550.h4FFokqA023107@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1053082039 23621 80.91.224.249 (16 May 2003 10:47:19 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 16 May 2003 10:47:19 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri May 16 12:47:17 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Gck8-00068h-00 for ; Fri, 16 May 2003 12:47:16 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19GcsS-00035D-00 for ; Fri, 16 May 2003 12:55:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19GcHc-0003vF-03 for emacs-devel@quimby.gnus.org; Fri, 16 May 2003 06:17:48 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19GcGd-0003Vt-00 for emacs-devel@gnu.org; Fri, 16 May 2003 06:16:47 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19GcCx-0001bs-00 for emacs-devel@gnu.org; Fri, 16 May 2003 06:13:00 -0400 Original-Received: from hera.cwi.nl ([192.16.191.8]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19Gc7P-0000GU-00 for emacs-devel@gnu.org; Fri, 16 May 2003 06:07:15 -0400 Original-Received: from occarina.pna.cwi.nl (occarina.pna.cwi.nl [192.16.184.200]) by hera.cwi.nl with ESMTP id MAA02702 for ; Fri, 16 May 2003 12:07:14 +0200 (MEST) Original-Received: (from lute@localhost) by occarina.pna.cwi.nl (8.12.8/8.12.5) id h4GA7EHi027694; Fri, 16 May 2003 12:07:14 +0200 X-Authentication-Warning: occarina.pna.cwi.nl: lute set sender to Lute.Kamstra@cwi.nl using -f Original-To: "Stefan Monnier" In-Reply-To: <200305151550.h4FFokqA023107@rum.cs.yale.edu> (Stefan Monnier's message of "Thu, 15 May 2003 11:50:46 -0400") User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (gnu/linux) Original-Lines: 58 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13920 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13920 "Stefan Monnier" writes: >> I committed this change. If you like, you could take a look and see >> how bad I messed up. (I'd appreciate it.) > > Since you asked for it ;-) I love to learn. :-) > - Use present tense in the ChangeLog message (I've just changed it). Got it. Err... Get it. > - Replace (1+ (line-end-position)) with (line-beginning-position 2) > (I know this was already in the code before, but I just noticed it). Committed. > - I hate code duplication so I'd have kept a single highlight and a single > unhighlight function. Basically, I'd have aimed for something like: > > (define-minor-mode global-hl-line-mode > "foo" > (setq-default hl-line-mode global-hl-line-mode) > (if global-hl-line-mode > (progn > (add-hook 'pre-command-hook #'hl-line-unhighlight) > (add-hook 'post-command-hook #'hl-line-highlight)) > (global-hl-line-unhighlight) > (remove-hook 'pre-command-hook #'hl-line-unhighlight) > (remove-hook 'post-command-hook #'hl-line-highlight))) I planned to do this originally, but could not get it to work nicely. If the global and local mode share an overlay, then the global mode would make any local mode non-sticky. Icky. If the global and local mode share the (un)highlighting functions, they have to use the same overlay, as the (un)highlighting functions cannot tell for which mode they are working. Maybe I'm missing something? > - Ideally, doing M-x global-hl-line-mode and then M-x hl-line-mode > should give you hl-line in all buffers except the current one. > > Merging the global and local mode may not be as simple as I make it > out to be, tho, especially w.r.t. the hl-line-overlay Indeed. I think it is best (more predictable, consistent behavior) to let the global and local mode be completely independent. > (which I wouldn't `make-variable-buffer-local' but would rather > `make-local-variable' in hl-line-mode). I thought a bit about this. Both options would work similarly. I figured that using make-variable-buffer-local would make it (automatically) clear that hl-line-overlay would be used buffer-locally only. Why do you prefer make-local-variable? Lute.