From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: uu1101@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#17619: 24.3; js-indent-line mixes display position with character position Date: Wed, 28 May 2014 20:16:39 +0200 Message-ID: <86sint4vlk.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1401301174 24800 80.91.229.3 (28 May 2014 18:19:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 May 2014 18:19:34 +0000 (UTC) To: 17619@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 28 20:19:27 2014 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 1WpiRg-0000Ob-Ff for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 May 2014 20:19:24 +0200 Original-Received: from localhost ([::1]:44193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiRf-0006sD-TV for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 May 2014 14:19:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiRT-0006ns-Ha for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:19:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpiRK-00062H-7T for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:19:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiRK-00062C-4k for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WpiRJ-0002GP-Or for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: uu1101@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 May 2014 18:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17619 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.14013011248661 (code B ref -1); Wed, 28 May 2014 18:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 May 2014 18:18:44 +0000 Original-Received: from localhost ([127.0.0.1]:34824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WpiQw-0002FS-Ks for submit@debbugs.gnu.org; Wed, 28 May 2014 14:18:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55781) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WpiPm-0002Cf-TA for submit@debbugs.gnu.org; Wed, 28 May 2014 14:17:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpiPY-0005U8-JA for submit@debbugs.gnu.org; Wed, 28 May 2014 14:17:21 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiPY-0005U4-H1 for submit@debbugs.gnu.org; Wed, 28 May 2014 14:17:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiPP-0005Gm-Ga for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:17:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpiPE-0005ES-Mt for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:17:03 -0400 Original-Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:56149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpiPE-0005E4-H6 for bug-gnu-emacs@gnu.org; Wed, 28 May 2014 14:16:52 -0400 Original-Received: by mail-wi0-f169.google.com with SMTP id hi2so4010940wib.4 for ; Wed, 28 May 2014 11:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=tXUJK3IkjQTZiK2ULa3MKxshJOxstDVnqU+Pulvj0kE=; b=ZWZkKLu8WUV6DRU97oIdRlLZItqpzCowqyvHmEfM3dzQRJ/BRhmZJ1HmEiD0NxQO7x +yoorVGH+VwbkbkeTw8QlVnUD8L6ewbrnz7E+2bdiUbiFQr+UVGYJNXHOfyXfYzzrAiq eRn95GbxWyfuNga9Ud0NCy2ivf/Zntwr5C3nXig5GbN4/prxE8j6UEK9VFAHbRMhbV2O 4bNObiiZj4tddbSq6117Xhi/f+fLtQEPA1odE/UfChwDuzNIEwbrIx13iVsB9WlkC/ma JlDUwMDDekbLsLV+Vjb+kGS43/2g/cLmjy47Y4Y3sTiLdp5ZBFzKcMYnYUT/g556vw/1 fpxQ== X-Received: by 10.180.106.1 with SMTP id gq1mr51607542wib.45.1401301010943; Wed, 28 May 2014 11:16:50 -0700 (PDT) Original-Received: from amclap (f053115024.adsl.alicedsl.de. [78.53.115.24]) by mx.google.com with ESMTPSA id ej4sm8472431wib.4.2014.05.28.11.16.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 May 2014 11:16:50 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Wed, 28 May 2014 14:18:37 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:89636 Archived-At: `js-indent-line' mixes up display column with character count. This results in incorrect indentation when both differ. For example, I am using the following snippet to ``prettify'' function keywords, resulting in the characters 'function' being displayed as a single 'f': -- >8 -- (font-lock-add-keywords 'js-mode `(("\\(function *\\)(" (0 (progn (compose-region (match-beginning 1) (match-end 1) "\u0192") nil))))) -- >8 -- The current implementation of `js-indent-line' is the following: -- >8 -- (defun js-indent-line () "Indent the current line as JavaScript." (interactive) (save-restriction (widen) (let* ((parse-status (save-excursion (syntax-ppss (point-at-bol)))) (offset (- (current-column) (current-indentation)))) (indent-line-to (js--proper-indentation parse-status)) (when (> offset 0) (forward-char offset))))) -- >8 -- Please, notice how `current-column', which returns the _display_ position is used to calculate the offset, but then the result is used with `forward-char' which expects a character offset instead. I am using the following modification to work-around the issue, although it is not correct either: it mixes character count with display offset returned by `current-indentation'. It fixes the issue with my font-lock customization. -- >8 -- (defun js-indent-line () "Indent the current line as JavaScript." (interactive) (save-restriction (widen) (let* ((parse-status (save-excursion (syntax-ppss (point-at-bol)))) (current-char-position (save-excursion (let ((final (point))) (beginning-of-line) (- final (point))))) (offset (- current-char-position (current-indentation)))) (indent-line-to (js--proper-indentation parse-status)) (when (> offset 0) (forward-char offset))))) -- >8 -- Best regards, Urbano Ustero.