unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* linum.el: problem (bug ?) fix and improvement
@ 2011-05-07 14:50 Toru TSUNEYOSHI
  2011-05-12 13:58 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Toru TSUNEYOSHI @ 2011-05-07 14:50 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2049 bytes --]

Hello.

I sometimes use linum-mode, then I meet a problem.
It is displaying a wrong line number when there is an invisible line.
(I don't know the problem is a bug clearly, but it is trouble to me.)

    Example:
    ====================================================================
      In buffer (linum-mode is enabled).

        1 abc
        2 def
        3 ghi
        4 jkl

      Make the 2nd line ("def\n") invisible (by `facemenu-set-invisible').

        1 abc
        2 ghi                   <= wrong
        4 jkl
    ====================================================================

I fixed the problem.

    the attached file: "linum-mode.el.1.diff"
                       (based on Emacs 23.3.)

(If the following additional improvement is unnecessary, please ignore.)

Additionally, I improved about invisible buffer string.

    the attached file: "linum-mode.el.2.diff"
                       (including the above bug fix.)

  (1) Indicating invisible line(s) by an underlined line number
      when the following line(s) is/are invisible.

    ====================================================================
        _1_ abc                 <= underline
         3  ghi
         4  jkl
    ====================================================================

  (2) Indicating partial invisible string by a `strike-through' line
      number when the line has partial invisible string.

    ====================================================================
        _1_ abc
         3  ghi
         4  jkl

      Make the 3rd line ("hi") invisible partially.

        _1_ abc
        -3- g                   <= strike-through
         4  jkl

      Make the 1st line ("ab") invisible partially.

        -_1_- c                 <= underline and strike-through
         -3-  g
          4   jkl
    ====================================================================

  For the additional improvement,
check the new variable `linum-indicate-invis',
and eval the following, please.

    (setq linum-indicate-invis t)

[-- Attachment #2: linum.el.1.diff --]
[-- Type: text/x-patch, Size: 2768 bytes --]

--- linum.el.orig	2011-01-09 02:45:14.000000000 +0900
+++ linum.el	2011-05-06 21:24:13.338622400 +0900
@@ -146,26 +146,38 @@
     ;; Create an overlay (or reuse an existing one) for each
     ;; line visible in this window, if necessary.
     (while (and (not (eobp)) (<= (point) limit))
-      (let* ((str (if fmt
-                      (propertize (format fmt line) 'face 'linum)
-                    (funcall linum-format line)))
-             (visited (catch 'visited
-                        (dolist (o (overlays-in (point) (point)))
-                          (when (equal-including-properties
-				 (overlay-get o 'linum-str) str)
-                            (unless (memq o linum-overlays)
-                              (push o linum-overlays))
-                            (setq linum-available (delq o linum-available))
-                            (throw 'visited t))))))
-        (setq width (max width (length str)))
-        (unless visited
-          (let ((ov (if (null linum-available)
-                        (make-overlay (point) (point))
-                      (move-overlay (pop linum-available) (point) (point)))))
-            (push ov linum-overlays)
-            (overlay-put ov 'before-string
-                         (propertize " " 'display `((margin left-margin) ,str)))
-            (overlay-put ov 'linum-str str))))
+      (unless (and (invisible-p (point))
+		   (catch 'invisible-p
+		     (save-excursion
+		       (let* ((inhibit-field-text-motion t)
+			      (eol (line-end-position)))
+			 (while (not (eolp))
+			   (goto-char
+			    (next-single-char-property-change
+			     (point) 'invisible nil eol))
+			   (unless (invisible-p (point))
+			     (throw 'invisible-p nil)))
+			 t))))	  ; current line is invisible entirely ?
+	(let* ((str (if fmt
+			(propertize (format fmt line) 'face 'linum)
+		      (funcall linum-format line)))
+	       (visited (catch 'visited
+			  (dolist (o (overlays-in (point) (point)))
+			    (when (equal-including-properties
+				   (overlay-get o 'linum-str) str)
+			      (unless (memq o linum-overlays)
+				(push o linum-overlays))
+			      (setq linum-available (delq o linum-available))
+			      (throw 'visited t))))))
+	  (setq width (max width (length str)))
+	  (unless visited
+	    (let ((ov (if (null linum-available)
+			  (make-overlay (point) (point))
+			(move-overlay (pop linum-available) (point) (point)))))
+	      (push ov linum-overlays)
+	      (overlay-put ov 'before-string
+			   (propertize " " 'display `((margin left-margin) ,str)))
+	      (overlay-put ov 'linum-str str)))))
       ;; Text may contain those nasty intangible properties, but that
       ;; shouldn't prevent us from counting those lines.
       (let ((inhibit-point-motion-hooks t))

[-- Attachment #3: linum.el.2.diff --]
[-- Type: text/x-patch, Size: 10826 bytes --]

--- linum.el.orig	2011-01-09 02:45:14.000000000 +0900
+++ linum.el	2011-05-07 23:06:51.062956400 +0900
@@ -58,6 +58,39 @@
   "Face for displaying line numbers in the display margin."
   :group 'linum)
 
+(defface linum-partial-text-invis
+  '((t (:inherit linum :strike-through t)))
+  "Face for displaying line numbers in the display margin.
+It is used only for a line which has the partial (not entire) invisible text."
+  :group 'linum)
+
+(defface linum-following-line-invis
+  '((t (:inherit linum :underline t)))
+  "Face for displaying line numbers in the display margin.
+It is used only for a line which has the following invisible line(s)."
+  :group 'linum)
+
+(defface linum-partial-text-and-following-line-invis
+  ;;'((t (:inherit (linum-partial-text-invis linum-following-line-invis)))) ; NG
+  '((t (:inherit linum :strike-through t :underline t)))
+  "Face for displaying line numbers in the display margin.
+It is used only for a line which has the partial (not entire) invisible text
+and the following invisible line(s)."
+  :group 'linum)
+
+(defcustom linum-indicate-invis nil
+  "Whether to indicate invisibility by line number's face.
+
+A value of nil means don't indicate.
+A value of `partial-text' means do only for the partial text.
+A value of `following-line' means do only for the following line.
+A value of t means do both for the partial text and for the following line."
+  :type '(choice (const :tag "Don't indicate" nil)
+		 (const :tag "Only for partial text" partial-text)
+		 (const :tag "Only for the following line" following-line)
+		 (const :tag "Both for partial text and for the following line" t))
+  :group 'linum)
+
 (defcustom linum-eager t
   "Whether line numbers should be updated after each command.
 The conservative setting `nil' might miss some buffer changes,
@@ -133,51 +166,200 @@
 
 (defun linum-update-window (win)
   "Update line numbers for the portion visible in window WIN."
-  (goto-char (window-start win))
+  (goto-char (1- (window-end win t)))
+  (let ((inhibit-point-motion-hooks t))
+    (forward-line 0))
   (let ((line (line-number-at-pos))
-        (limit (window-end win t))
+        (limit (window-start win))
         (fmt (cond ((stringp linum-format) linum-format)
                    ((eq linum-format 'dynamic)
                     (let ((w (length (number-to-string
                                       (count-lines (point-min) (point-max))))))
                       (concat "%" (number-to-string w) "d")))))
-        (width 0))
+        (width 0)
+	(shortage 0)
+	bol-invis eol eol-invis invis orig-invis old-invis
+	(invis-list '((nil			       . 0)
+		      (partial-text		       . 1)
+		      (following-line		       . 2)
+		      (partial-text-and-following-line . 3)   ; (+ 1 2)
+		      (whole-line		       . 6))) ; (+ 2 4), it may hide `following-line'
+	(face-list `((nil . linum)
+		     (partial-text
+		      . ,(if (memq linum-indicate-invis '(t partial-text))
+			     'linum-partial-text-invis
+			   'linum))
+		     (following-line
+		      . ,(if (memq linum-indicate-invis '(t following-line))
+			     'linum-following-line-invis
+			   'linum))
+		     (partial-text-and-following-line
+		      . ,(or (cdr (assq linum-indicate-invis
+					'((nil		  . linum)
+					  (t		  . linum-partial-text-and-following-line-invis)
+					  (partial-text	  . linum-partial-text-invis)
+					  (following-line . linum-following-line-invis))))
+			     'linum))
+		     ;;(whole-line . nil)
+		     )))
     (run-hooks 'linum-before-numbering-hook)
     ;; Create an overlay (or reuse an existing one) for each
     ;; line visible in this window, if necessary.
-    (while (and (not (eobp)) (<= (point) limit))
-      (let* ((str (if fmt
-                      (propertize (format fmt line) 'face 'linum)
-                    (funcall linum-format line)))
-             (visited (catch 'visited
-                        (dolist (o (overlays-in (point) (point)))
-                          (when (equal-including-properties
-				 (overlay-get o 'linum-str) str)
-                            (unless (memq o linum-overlays)
-                              (push o linum-overlays))
-                            (setq linum-available (delq o linum-available))
-                            (throw 'visited t))))))
-        (setq width (max width (length str)))
-        (unless visited
-          (let ((ov (if (null linum-available)
-                        (make-overlay (point) (point))
-                      (move-overlay (pop linum-available) (point) (point)))))
-            (push ov linum-overlays)
-            (overlay-put ov 'before-string
-                         (propertize " " 'display `((margin left-margin) ,str)))
-            (overlay-put ov 'linum-str str))))
+    (while (and (zerop shortage) (<= limit (point)))
+      (let ((inhibit-point-motion-hooks t))
+	(setq bol-invis (invisible-p (point))
+	      eol (line-end-position)
+	      eol-invis (invisible-p eol)
+
+              ;; | bol-invis | (mol-invis) | eol-invis | -> | invis                           |
+              ;; |-----------+-------------+-----------+----+---------------------------------|
+              ;; | t         | t           | t         |    | whole-line                      |
+              ;; | t         | t           | nil       |    | partial-text                    |
+              ;; | t         | nil         | t         |    | partial-text-and-following-line |
+              ;; | t         | nil         | nil       |    | partial-text                    |
+              ;; | nil       | t           | t         |    | partial-text-and-following-line |
+              ;; | nil       | t           | nil       |    | partial-text                    |
+              ;; | nil       | nil         | t         |    | following-line                  |
+              ;; | nil       | nil         | nil       |    | nil                             |
+
+	      invis (cond (bol-invis
+			   ;; middle of line is invisible ?
+			   (cond ((catch 'invisible-p
+				    (while t
+				      (goto-char
+				       (next-single-char-property-change
+					(point) 'invisible nil eol))
+				      (cond ((eolp)
+					     (throw 'invisible-p t))
+					    ((not (invisible-p (point)))
+					     (throw 'invisible-p nil)))))
+				  (cond (eol-invis
+					 'whole-line)
+					(t
+					 'partial-text)))
+				 (t
+				  (cond (eol-invis
+					 'partial-text-and-following-line)
+					(t
+					 'partial-text)))))
+			  (t
+			   ;; middle of line is invisible ?
+			   (cond ((catch 'invisible-p
+				    (while t
+				      (goto-char
+				       (next-single-char-property-change
+					(point) 'invisible nil eol))
+				      (cond ((eolp)
+					     (throw 'invisible-p nil))
+					    ((invisible-p (point))
+					     (throw 'invisible-p t)))))
+				  (cond (eol-invis
+					 'partial-text-and-following-line)
+					(t
+					 'partial-text)))
+				 (t
+				  (cond (eol-invis
+					 'following-line)
+					(t
+					 nil))))))
+	      orig-invis invis
+	      ;; consider the following line invisibility
+	      invis (car (rassq (logior (cdr (assq invis invis-list))
+					(cdr (assq old-invis invis-list)))
+				invis-list)))
+	(forward-line 0))
+      (unless (eq invis 'whole-line)
+	(let* ((str (if fmt
+			(propertize (format fmt line)
+				    'face (cdr (assq invis face-list)))
+		      (funcall linum-format line)))
+	       (visited (catch 'visited
+			  (dolist (o (overlays-in (point) (point)))
+			    (when (equal-including-properties
+				   (overlay-get o 'linum-str) str)
+			      (unless (memq o linum-overlays)
+				(push o linum-overlays))
+			      (setq linum-available (delq o linum-available))
+			      (throw 'visited t))))))
+	  (setq width (max width (length str)))
+	  (unless visited
+	    (let ((ov (if (null linum-available)
+			  (make-overlay (point) (point))
+			(move-overlay (pop linum-available) (point) (point)))))
+	      (push ov linum-overlays)
+	      (overlay-put ov 'before-string
+			   (propertize " " 'display `((margin left-margin) ,str)))
+	      (overlay-put ov 'linum-str str)
+	      (overlay-put ov 'linum-invis orig-invis)))))
+      (setq old-invis (if (eq invis 'whole-line) 'following-line nil))
       ;; Text may contain those nasty intangible properties, but that
       ;; shouldn't prevent us from counting those lines.
       (let ((inhibit-point-motion-hooks t))
-        (forward-line))
-      (setq line (1+ line)))
+	(setq shortage (forward-line -1)))
+      (setq line (1- line)))
     (set-window-margins win width (cdr (window-margins win)))))
 
 (defun linum-after-change (beg end len)
   ;; update overlays on deletions, and after newlines are inserted
   (when (or (= beg end)
             (= end (point-max))
-            (string-match-p "\n" (buffer-substring-no-properties beg end)))
+            (string-match-p "\n" (buffer-substring-no-properties beg end))
+	    (if linum-indicate-invis
+		;; overlay property `linum-invis' value and current `invis' value are different ?
+		(save-excursion
+		  (let ((inhibit-point-motion-hooks t)
+			bol-invis eol eol-invis invis orig-invis)
+		    (goto-char beg)
+		    (forward-line 0)
+		    (setq orig-invis (catch 'linum-invis
+				       (dolist (o (overlays-in (point) (point)))
+					 (if (plist-member (overlay-properties o) 'linum-invis)
+					     (throw 'linum-invis (overlay-get o 'linum-invis))))
+				       'whole-line)
+			  bol-invis (invisible-p (point))
+			  eol (line-end-position)
+			  eol-invis (invisible-p eol)
+			  invis (cond (bol-invis
+				       ;; middle of line is invisible ?
+				       (cond ((catch 'invisible-p
+						(while t
+						  (goto-char
+						   (next-single-char-property-change
+						    (point) 'invisible nil eol))
+						  (cond ((eolp)
+							 (throw 'invisible-p t))
+							((not (invisible-p (point)))
+							 (throw 'invisible-p nil)))))
+					      (cond (eol-invis
+						     'whole-line)
+						    (t
+						     'partial-text)))
+					     (t
+					      (cond (eol-invis
+						     'partial-text-and-following-line)
+						    (t
+						     'partial-text)))))
+				      (t
+				       ;; middle of line is invisible ?
+				       (cond ((catch 'invisible-p
+						(while t
+						  (goto-char
+						   (next-single-char-property-change
+						    (point) 'invisible nil eol))
+						  (cond ((eolp)
+							 (throw 'invisible-p nil))
+							((invisible-p (point))
+							 (throw 'invisible-p t)))))
+					      (cond (eol-invis
+						     'partial-text-and-following-line)
+						    (t
+						     'partial-text)))
+					     (t
+					      (cond (eol-invis
+						     'following-line)
+						    (t
+						     nil)))))))
+		    (not (eq orig-invis invis))))))
     (linum-update-current)))
 
 (defun linum-after-scroll (win start)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-07 14:50 linum.el: problem (bug ?) fix and improvement Toru TSUNEYOSHI
@ 2011-05-12 13:58 ` Stefan Monnier
  2011-05-12 17:21   ` Eli Zaretskii
  2011-05-13 12:14   ` Toru TSUNEYOSHI
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-05-12 13:58 UTC (permalink / raw)
  To: Toru TSUNEYOSHI; +Cc: emacs-devel

> It is displaying a wrong line number when there is an invisible line.
> (I don't know the problem is a bug clearly, but it is trouble to me.)

>     Example:
>     ====================================================================
>       In buffer (linum-mode is enabled).

>         1 abc
>         2 def
>         3 ghi
>         4 jkl

>       Make the 2nd line ("def\n") invisible (by `facemenu-set-invisible').

>         1 abc
>         2 ghi                   <= wrong
>         4 jkl
>     ====================================================================

Actually, it's even more interesting:

the line number displayed in front of `ghi' is sometimes 2 and sometimes
3, changing "at random" while editing that line or when mouse-1 clicking
in that window.

IIUC the problem is that Emacs "displays" both margin properties: the
one from the `def' line and the one from the `ghi' line, and since
in reality both can't be displayed it ends up choosing one of the two
and depending on how the redisplay happens it picks one or the other.

What we'd like here is for the redisplay to ignore the margin property
placed on invisible text.  This boils down to making Emacs ignore
`before-string' properties placed at the beginning of invisible text.
I don't think it's always right to ignore them, tho.  Maybe a good way
to make it work is to rely on the stickiness of the `before-string'
property: by making it rear-sticky (i.e. making the overlay's
front-advance non-nil) we'd be stating explicitly that the property
belongs to the hidden text and should hence be hidden as well.

> I fixed the problem.

Alternatively we can let linum do the hard work, like your patch
does, of course.

> Additionally, I improved about invisible buffer string.

>     the attached file: "linum-mode.el.2.diff"
>                        (including the above bug fix.)

>   (1) Indicating invisible line(s) by an underlined line number
>       when the following line(s) is/are invisible.

>     ====================================================================
>         _1_ abc                 <= underline
>          3  ghi
>          4  jkl
>     ====================================================================

>   (2) Indicating partial invisible string by a `strike-through' line
>       number when the line has partial invisible string.

>     ====================================================================
>         _1_ abc
>          3  ghi
>          4  jkl

>       Make the 3rd line ("hi") invisible partially.

>         _1_ abc
>         -3- g                   <= strike-through
>          4  jkl

>       Make the 1st line ("ab") invisible partially.

>         -_1_- c                 <= underline and strike-through
>          -3-  g
>           4   jkl
>     ====================================================================

Could you describe the context in which you've needed such a thing?
The strike-through info seems to be redundant with the fact that the
next line number is not the immediate successor, and I wonder when you'd
be so interested in knowing if there's some hidden text on
a particular line.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-12 13:58 ` Stefan Monnier
@ 2011-05-12 17:21   ` Eli Zaretskii
  2011-05-12 19:43     ` Stefan Monnier
  2011-05-13 12:14   ` Toru TSUNEYOSHI
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2011-05-12 17:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: t_tuneyosi, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Thu, 12 May 2011 10:58:58 -0300
> Cc: emacs-devel@gnu.org
> 
> What we'd like here is for the redisplay to ignore the margin property
> placed on invisible text.

Are you sure?  Only part of a line could be invisible, in which case
it won't be easy to explain why we drop the before-string on the
floor.  I would be uneasy to make such radical changes on behalf of a
single use case.

> This boils down to making Emacs ignore
> `before-string' properties placed at the beginning of invisible text.
> I don't think it's always right to ignore them, tho.

There's explicit code to do it the way we do now:

	  /* If there are before-strings at the start of invisible
	     text, and the text is invisible because of a text
	     property, arrange to show before-strings because 20.x did
	     it that way.  (If the text is invisible because of an
	     overlay property instead of a text property, this is
	     already handled in the overlay code.)  */
	  if (NILP (overlay)
	      && get_overlay_strings (it, it->stop_charpos))
	    {
	      handled = HANDLED_RECOMPUTE_PROPS;
	      it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
	    }

Just undoing this would be regression from Emacs 20.x.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-12 17:21   ` Eli Zaretskii
@ 2011-05-12 19:43     ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-05-12 19:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: t_tuneyosi, emacs-devel

>> What we'd like here is for the redisplay to ignore the margin property
>> placed on invisible text.
> Are you sure?  Only part of a line could be invisible, in which case
> it won't be easy to explain why we drop the before-string on the
> floor.  I would be uneasy to make such radical changes on behalf of a
> single use case.

Good point, but that's easy to fix: put the overlay over the whole line
of text rather than one the empty string at its beginning.

>> This boils down to making Emacs ignore
>> `before-string' properties placed at the beginning of invisible text.
>> I don't think it's always right to ignore them, tho.

> There's explicit code to do it the way we do now:

> 	  /* If there are before-strings at the start of invisible
> 	     text, and the text is invisible because of a text
> 	     property, arrange to show before-strings because 20.x did
> 	     it that way.  (If the text is invisible because of an
> 	     overlay property instead of a text property, this is
> 	     already handled in the overlay code.)  */
> 	  if (NILP (overlay)
> 	      && get_overlay_strings (it, it->stop_charpos))
> 	    {
> 	      handled = HANDLED_RECOMPUTE_PROPS;
it-> stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
> 	    }

> Just undoing this would be regression from Emacs 20.x.

I know.  That's why I mention that maybe we should pay attention to the
stickiness so as to allow the Elisp code to choose which behavior
is desired.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-12 13:58 ` Stefan Monnier
  2011-05-12 17:21   ` Eli Zaretskii
@ 2011-05-13 12:14   ` Toru TSUNEYOSHI
  2011-05-13 14:15     ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Toru TSUNEYOSHI @ 2011-05-13 12:14 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: linum.el: problem (bug ?) fix and improvement
Date: Thu, 12 May 2011 10:58:58 -0300
Message-ID: <jwv4o50591y.fsf-monnier+emacs@gnu.org>

>> Additionally, I improved about invisible buffer string.
> 
>>     the attached file: "linum-mode.el.2.diff"
>>                        (including the above bug fix.)
> 
>>   (1) Indicating invisible line(s) by an underlined line number
>>       when the following line(s) is/are invisible.
> 
>>     ====================================================================
>>         _1_ abc                 <= underline
>>          3  ghi
>>          4  jkl
>>     ====================================================================
> 
>>   (2) Indicating partial invisible string by a `strike-through' line
>>       number when the line has partial invisible string.
> 
>>     ====================================================================
>>         _1_ abc
>>          3  ghi
>>          4  jkl
> 
>>       Make the 3rd line ("hi") invisible partially.
> 
>>         _1_ abc
>>         -3- g                   <= strike-through
>>          4  jkl
> 
>>       Make the 1st line ("ab") invisible partially.
> 
>>         -_1_- c                 <= underline and strike-through
>>          -3-  g
>>           4   jkl
>>     ====================================================================
> 
> Could you describe the context in which you've needed such a thing?
> The strike-through info seems to be redundant with the fact that the
> next line number is not the immediate successor, and I wonder when you'd
> be so interested in knowing if there's some hidden text on
> a particular line.
> 
> 
>         Stefan
> 

Thanks for your replying.

I have a case that I make unimportant text invisible temporarily, to
know only important information. However, I sometimes want to check the
unimportant (invisible) text. Then, the strike-through info tell me the
text place (by the line number).

    Example:
    ====================================================================
      In buffer (linum-mode is enabled).

        1 2000-01-01 abc
        2 2003-12-01 21:00:00 def
        3 2005-07-21 01:23:45 ghi
        4 2010-05-24 jkl
        5 2011-05-13 12:34:56 mno

      I want to know only the day and make the time invisible temporarily.

         1  2000-01-01 abc
        -2- 2003-12-01 def
        -3- 2005-07-21 ghi
         4  2010-05-24 jkl
        -5- 2011-05-13 mno

      (Now, I can know that 2nd, 3rd and 5th lines have the time by the
      strike-through info.)

      If I want to know the time of today, then I make the time visible.

         1  2000-01-01 abc
        -2- 2003-12-01 def
        -3- 2005-07-21 ghi
         4  2010-05-24 jkl
         5  2011-05-13 12:34:56 mno
      ====================================================================



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-13 12:14   ` Toru TSUNEYOSHI
@ 2011-05-13 14:15     ` Stefan Monnier
  2011-05-13 15:55       ` Toru TSUNEYOSHI
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-05-13 14:15 UTC (permalink / raw)
  To: Toru TSUNEYOSHI; +Cc: emacs-devel

> I have a case that I make unimportant text invisible temporarily, to
> know only important information.

Any reason why you don't use the ellipsis (see buffer-invisibility-spec)?


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-13 14:15     ` Stefan Monnier
@ 2011-05-13 15:55       ` Toru TSUNEYOSHI
  2011-05-13 16:26         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Toru TSUNEYOSHI @ 2011-05-13 15:55 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: linum.el: problem (bug ?) fix and improvement
Date: Fri, 13 May 2011 11:15:45 -0300
Message-ID: <jwv39ki7kml.fsf-monnier+emacs@gnu.org>

>> I have a case that I make unimportant text invisible temporarily, to
>> know only important information.
> 
> Any reason why you don't use the ellipsis (see buffer-invisibility-spec)?
> 
> 
>         Stefan
> 

I can't check the ellipsis easily, if `truncate-lines' is non-nil and
the ellipsis text is truncated.
(In this case, I must scroll the window horizontally many times.)

If linum-mode provides information about the invisible text, I can check
the information very easily, I think.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-13 15:55       ` Toru TSUNEYOSHI
@ 2011-05-13 16:26         ` Stefan Monnier
  2011-05-14  1:53           ` Toru TSUNEYOSHI
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-05-13 16:26 UTC (permalink / raw)
  To: Toru TSUNEYOSHI; +Cc: emacs-devel

>>> I have a case that I make unimportant text invisible temporarily, to
>>> know only important information.
>> Any reason why you don't use the ellipsis (see buffer-invisibility-spec)?
> I can't check the ellipsis easily, if `truncate-lines' is non-nil and
> the ellipsis text is truncated.

Indeed, that can be a problem.  Tho, if you make "foo\n" (as you seem to
do) invisible, the "..." will end up at the beginning of the line rather
than its end.  So it'll probably be too visible rather than not enough.

BTW, making "\nfoo" invisible instead of "foo\n" should circumvent the
current mis-numbering problem which your patch tries to circumvent.

> (In this case, I must scroll the window horizontally many times.)

C-e does the trick if you're on the right line.

> If linum-mode provides information about the invisible text, I can check
> the information very easily, I think.

I understand that it makes sense in your particular case, but it seems
too tightly linked to a particular use of invisible (and this particular
use of invisible is in turn tightly linked to linum in order to make it
bearable).  So I'm not convinced this belongs in linum.el as it stands.
OTOH maybe we could install a patch to linum.el that provides a hook
that you could use to add the same functionality.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linum.el: problem (bug ?) fix and improvement
  2011-05-13 16:26         ` Stefan Monnier
@ 2011-05-14  1:53           ` Toru TSUNEYOSHI
  0 siblings, 0 replies; 9+ messages in thread
From: Toru TSUNEYOSHI @ 2011-05-14  1:53 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: linum.el: problem (bug ?) fix and improvement
Date: Fri, 13 May 2011 13:26:04 -0300
Message-ID: <jwvfwoi60jb.fsf-monnier+emacs@gnu.org>

>>>> I have a case that I make unimportant text invisible temporarily, to
>>>> know only important information.
>>> Any reason why you don't use the ellipsis (see buffer-invisibility-spec)?
>> I can't check the ellipsis easily, if `truncate-lines' is non-nil and
>> the ellipsis text is truncated.
> 
> Indeed, that can be a problem.  Tho, if you make "foo\n" (as you seem to
> do) invisible, the "..." will end up at the beginning of the line rather
> than its end.  So it'll probably be too visible rather than not enough.
> 

Yes.
In that case, I would not use the ellipsis.

> BTW, making "\nfoo" invisible instead of "foo\n" should circumvent the
> current mis-numbering problem which your patch tries to circumvent.
> 

Sorry, I am a little tired of trying.

>> (In this case, I must scroll the window horizontally many times.)
> 
> C-e does the trick if you're on the right line.
> 

I see.
(Although, the ellipsis is not always at the end of a line.
So I must scroll ...)

However, I still wish to know the invisibility information at a glance.
Currently, it is useful to check the result by `hide-sublevels' or
`hide-body' on `outline-minor-mode'.

>> If linum-mode provides information about the invisible text, I can check
>> the information very easily, I think.
> 
> I understand that it makes sense in your particular case, but it seems
> too tightly linked to a particular use of invisible (and this particular
> use of invisible is in turn tightly linked to linum in order to make it
> bearable).  So I'm not convinced this belongs in linum.el as it stands.
> OTOH maybe we could install a patch to linum.el that provides a hook
> that you could use to add the same functionality.
> 
> 
>         Stefan
> 

That's right.
(I will use the function for my own solution.)

Thank you.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-05-14  1:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-07 14:50 linum.el: problem (bug ?) fix and improvement Toru TSUNEYOSHI
2011-05-12 13:58 ` Stefan Monnier
2011-05-12 17:21   ` Eli Zaretskii
2011-05-12 19:43     ` Stefan Monnier
2011-05-13 12:14   ` Toru TSUNEYOSHI
2011-05-13 14:15     ` Stefan Monnier
2011-05-13 15:55       ` Toru TSUNEYOSHI
2011-05-13 16:26         ` Stefan Monnier
2011-05-14  1:53           ` Toru TSUNEYOSHI

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).