From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean Perry Newsgroups: gmane.emacs.bugs Subject: bug#12428: 23.4; Add padding for rendering of the line numbers by linum-mode Date: Wed, 12 Sep 2012 12:57:08 PDT Message-ID: <62162.1347479828@speakeasy.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_----------=_1347479828310991" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347480507 16747 80.91.229.3 (12 Sep 2012 20:08:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2012 20:08:27 +0000 (UTC) To: 12428@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 12 22:08:30 2012 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 1TBtEY-0004pV-By for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 22:08:26 +0200 Original-Received: from localhost ([::1]:36860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBtEU-0000YQ-EH for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 16:08:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBtER-0000YE-9E for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 16:08:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBtEN-0005P6-38 for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 16:08:19 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBtEM-0005Ox-Vb for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 16:08:15 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TBtF8-0003ON-4P for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 16:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Perry Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Sep 2012 20:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12428 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.134748052713013 (code B ref -1); Wed, 12 Sep 2012 20:09:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Sep 2012 20:08:47 +0000 Original-Received: from localhost ([127.0.0.1]:57796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBtEs-0003Np-AA for submit@debbugs.gnu.org; Wed, 12 Sep 2012 16:08:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44595) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBt4W-00038p-Ei for submit@debbugs.gnu.org; Wed, 12 Sep 2012 15:58:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBt3k-00024s-6J for submit@debbugs.gnu.org; Wed, 12 Sep 2012 15:57:17 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:41865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBt3k-00024n-3C for submit@debbugs.gnu.org; Wed, 12 Sep 2012 15:57:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBt3g-0005mM-1q for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 15:57:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBt3e-00023i-KC for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 15:57:11 -0400 Original-Received: from asbnvacz-mailrelay01.megapath.net ([207.145.128.243]:41868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBt3e-00023U-GL for bug-gnu-emacs@gnu.org; Wed, 12 Sep 2012 15:57:10 -0400 Original-Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net [69.17.117.53]) by asbnvacz-mailrelay01.megapath.net (Postfix) with ESMTP id AE3D0A704C3 for ; Wed, 12 Sep 2012 15:57:08 -0400 (EDT) Original-Received: (qmail 21377 invoked from network); 12 Sep 2012 19:57:08 -0000 Original-Received: by simscan 1.4.0 ppid: 31476, pid: 17990, t: 0.0202s scanners: clamav: 0.88.2/m:52/d:13495 Original-Received: from unknown (HELO wmail4.sea5.speakeasy.net) ([69.17.117.160]) (envelope-sender ) by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 12 Sep 2012 19:57:08 -0000 Original-Received: from wmail.speakeasy.net (localhost [127.0.0.1]) by wmail4.sea5.speakeasy.net (Postfix) with ESMTP id 28C4BBF93 for ; Wed, 12 Sep 2012 12:57:08 -0700 (PDT) X-Mailer: AtMail - 143.127.2.4 - shaleh@speakeasy.net X-Origin: 143.127.2.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Wed, 12 Sep 2012 16:08:44 -0400 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 (newer, 2) 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:64211 Archived-At: This is a multi-part message in MIME format. --_----------=_1347479828310991 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" I was experiencing the issue discussed here at StackOverflow http://stackoverflow.com/questions/4920210/what-causes-this-graphical-error= -in-emacs-with-linum-mode-on-os-x. The suggestions boil down to a few choices * stop using dynamic format and explicitly set a format like "%7d ". Note the trailing space. * specify a function to return the format which will include the trailing space * edit the source to ensure a space is added when the line number is finally rendered. I dislike all three choices. Choice 1 will usually eat too much room on the left. That is why dynamic was created in the first place. The format handler routine option in Choice 2 is inefficient to implement since the user will need to basically reimplement the dynamic logic and this is called for every line in the file. If you follow some of the links = on StackOverflow there are several solutions to this and similar problems that all reproduce the dynamic logic. I finally chose to implement a variation of option 3 which is attached as a patch. Basically it lets the user specify a padding value to added when the line is rendered. The patch is small, easy for a user to implement and efficient in execution. It certainly seems easier than the solutions involving defadvice and the dynamic format logic. For now I have a fork of linum in my .emacs.d/site-lisp. My patch to linum is attached. Feel free to change the name of the customization variable or improve the help text. Sean --_----------=_1347479828310991 Content-Disposition: inline; filename="linum.patch" Content-Transfer-Encoding: base64 Content-Type: application/octet-stream; name="linum.patch" LS0tIGxpbnVtLmVsCTIwMTItMDktMTIgMTI6MTY6MjAuMDAwMDAwMDAwIC0w NzAwCisrKyBsaW51bS5zcGVycnkuZWwJMjAxMi0wOS0xMiAxMjoxNzo1OC4w MDAwMDAwMDAgLTA3MDAKQEAgLTUzLDYgKzUzLDEyIEBAIFNlZSBhbHNvIGBs aW51bS1iZWZvcmUtbnVtYmVyaW5nLWhvb2snLiIKICAgOmdyb3VwICdsaW51 bQogICA6dHlwZSAnc2V4cCkKIAorKGRlZmN1c3RvbSBsaW51bS1tYXJnaW4t cGFkZGluZyAwCisgICJQYWRkaW5nIGFkZGVkIHRvIHRoZSBsZWZ0IG1hcmdp biB3aGVuIGRpc3BsYXlpbmcgdGhlIGxpbmUgbnVtYmVycy4KK1Nob3VsZCBi ZSBhIHBvc2l0aXZlIGludGVnZXIuIEEgdmFsdWUgYmV0d2VlbiAxIGFuZCA1 IGlzIHByb2JhYmx5IHN1ZmZpY2llbnQuIgorICA6Z3JvdXAgJ2xpbnVtCisg IDp0eXBlICdpbnRlZ2VyKQorCiAoZGVmZmFjZSBsaW51bQogICAnKCh0IDpp bmhlcml0IChzaGFkb3cgZGVmYXVsdCkpKQogICAiRmFjZSBmb3IgZGlzcGxh eWluZyBsaW5lIG51bWJlcnMgaW4gdGhlIGRpc3BsYXkgbWFyZ2luLiIKQEAg LTE1Nyw3ICsxNjMsNyBAQCBhbmQgeW91IGhhdmUgdG8gc2Nyb2xsIG9yIHBy ZXNzIFxcW3JlY2VuCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAo cHVzaCBvIGxpbnVtLW92ZXJsYXlzKSkKICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAoc2V0cSBsaW51bS1hdmFpbGFibGUgKGRlbHEgbyBsaW51bS1h dmFpbGFibGUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICh0aHJv dyAndmlzaXRlZCB0KSkpKSkpCi0gICAgICAgIChzZXRxIHdpZHRoIChtYXgg d2lkdGggKGxlbmd0aCBzdHIpKSkKKyAgICAgICAgKHNldHEgd2lkdGggKG1h eCB3aWR0aCAoKyAobGVuZ3RoIHN0cikgbGludW0tbWFyZ2luLXBhZGRpbmcp KSkKICAgICAgICAgKHVubGVzcyB2aXNpdGVkCiAgICAgICAgICAgKGxldCAo KG92IChpZiAobnVsbCBsaW51bS1hdmFpbGFibGUpCiAgICAgICAgICAgICAg ICAgICAgICAgICAobWFrZS1vdmVybGF5IChwb2ludCkgKHBvaW50KSkK --_----------=_1347479828310991--