From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#14170: 24.3; linum won't create all overlays after a folding Date: Sun, 14 Apr 2013 09:15:27 +0300 Message-ID: <83vc7p7i4g.fsf@gnu.org> References: <834nfbap2x.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1365920161 32354 80.91.229.3 (14 Apr 2013 06:16:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Apr 2013 06:16:01 +0000 (UTC) Cc: 14170@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 14 08:16:04 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1URGEO-0003Mz-0l for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Apr 2013 08:16:04 +0200 Original-Received: from localhost ([::1]:57056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URGEN-0004gl-Iz for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Apr 2013 02:16:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URGEJ-0004gU-1h for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 02:16:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URGEH-0004gl-Vk for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 02:15:58 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URGEH-0004gf-SG for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 02:15:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1URGID-000157-SK for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2013 02:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2013 06:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14170-submit@debbugs.gnu.org id=B14170.13659203804091 (code B ref 14170); Sun, 14 Apr 2013 06:20:01 +0000 Original-Received: (at 14170) by debbugs.gnu.org; 14 Apr 2013 06:19:40 +0000 Original-Received: from localhost ([127.0.0.1]:49613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URGHr-00013t-6s for submit@debbugs.gnu.org; Sun, 14 Apr 2013 02:19:39 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:57601) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1URGHo-00013g-Cg for 14170@debbugs.gnu.org; Sun, 14 Apr 2013 02:19:37 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0ML800H00EOH5K00@a-mtaout20.012.net.il> for 14170@debbugs.gnu.org; Sun, 14 Apr 2013 09:15:21 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0ML800G06EPLO6F0@a-mtaout20.012.net.il>; Sun, 14 Apr 2013 09:15:21 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73394 Archived-At: > From: Stefan Monnier > Cc: Glenn Morris , 14170@debbugs.gnu.org > Date: Sat, 13 Apr 2013 21:21:22 -0400 > > >> > nlinum works correctly. > >> This is the answer to most recent bug reports involving linum, as I > >> recall. Will nlinum replace linum at some point? > > Btw, if nlinum is our response to the problems in linum, then nlinum > > should be a bit more friendly to bidirectional text, and determine > > whether to put numbers on the left or right margin by looking at what > > current-bidi-paragraph-direction returns. (Yes, this means that if > > some paragraphs are L2R and others R2L, some numbers will be on the > > left, while others on the right.) > > Patches welcome Below. (There's a missing feature in bidi display that causes the numbers to be displayed backwards in R2L paragraphs; I will fix that later.) > but I don't think we need to worry a bout this w.r.t moving from > linum.el to nlinum.el since linum.el doesn't support R2L paragraphs > either. Well, I hope you allow me to worry about that ;-) === modified file 'packages/nlinum/nlinum.el' --- packages/nlinum/nlinum.el 2012-10-24 19:29:40 +0000 +++ packages/nlinum/nlinum.el 2013-04-14 06:09:13 +0000 @@ -35,7 +35,7 @@ ;;;###autoload (define-minor-mode nlinum-mode - "Toggle display of line numbers in the left margin (Linum mode). + "Toggle display of line numbers in the margin (Linum mode). With a prefix argument ARG, enable Linum mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. @@ -55,9 +55,21 @@ Linum mode is a buffer-local minor mode. (jit-lock-register #'nlinum--region t)) (nlinum--setup-windows)) +(defvar margin-side nil) (defun nlinum--setup-window () - (set-window-margins nil (if nlinum-mode nlinum--width) - (cdr (window-margins)))) + (cond ((eq bidi-paragraph-direction 'left-to-right) + (set-window-margins nil (if nlinum-mode nlinum--width) + (cdr (window-margins))) + (setq-local margin-side 'left)) + ((eq bidi-paragraph-direction 'right-to-left) + (set-window-margins nil (car (window-margins)) + (if nlinum-mode nlinum--width)) + (setq-local margin-side 'right)) + (t + (set-window-margins nil + (if nlinum-mode nlinum--width) + (if nlinum-mode nlinum--width)) + (setq-local margin-side nil)))) (defun nlinum--setup-windows () (dolist (win (get-buffer-window-list nil nil t)) @@ -157,7 +169,14 @@ Linum mode is a buffer-local minor mode. (and (not (eobp)) (< (point) limit) (let* ((ol (make-overlay (point) (1+ (point)))) (str (format fmt line)) - (width (string-width str))) + (width (string-width str)) + (side + (cond ((eq margin-side 'left) 'left-margin) + ((eq margin-side 'right) 'right-margin) + (t (if (eq (current-bidi-paragraph-direction) + 'right-to-left) + 'right-margin + 'left-margin))))) (when (< nlinum--width width) (setq nlinum--width width) (nlinum--new-width)) @@ -165,7 +184,7 @@ Linum mode is a buffer-local minor mode. (overlay-put ol 'evaporate t) (overlay-put ol 'before-string (propertize " " 'display - `((margin left-margin) + `((margin ,side) ,(propertize str 'face 'linum)))) ;; (setq nlinum--ol-counter (1- nlinum--ol-counter))