From unknown Mon Jun 23 04:09:25 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#17619 <17619@debbugs.gnu.org> To: bug#17619 <17619@debbugs.gnu.org> Subject: Status: 24.3; js-indent-line mixes display position with character position Reply-To: bug#17619 <17619@debbugs.gnu.org> Date: Mon, 23 Jun 2025 11:09:25 +0000 retitle 17619 24.3; js-indent-line mixes display position with character po= sition reassign 17619 emacs submitter 17619 uu1101@gmail.com severity 17619 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed May 28 14:18:43 2014 Received: (at submit) by debbugs.gnu.org; 28 May 2014 18:18:44 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_40, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,T_DKIM_INVALID autolearn=disabled version=3.3.2 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 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 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 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 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) 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) From: uu1101@gmail.com To: bug-gnu-emacs@gnu.org Subject: 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> MIME-Version: 1.0 Content-Type: text/plain 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: submit 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.8 (---) `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. From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 21:30:34 2014 Received: (at 17619) by debbugs.gnu.org; 1 Jun 2014 01:30:34 +0000 Received: from localhost ([127.0.0.1]:39269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WqubZ-00034L-Dv for submit@debbugs.gnu.org; Sat, 31 May 2014 21:30:33 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:5073) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WqubV-000344-PW for 17619@debbugs.gnu.org; Sat, 31 May 2014 21:30:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDTeHcQjSGReOegcWhCIBA6kZgWqBcYFbIQ X-IPAS-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDTeHcQjSGReOegcWhCIBA6kZgWqBcYFbIQ X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="65208159" Received: from 206-248-131-163.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 31 May 2014 21:30:24 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id E0831AE0BC; Sat, 31 May 2014 21:30:23 -0400 (EDT) From: Stefan Monnier To: uu1101@gmail.com Subject: Re: bug#17619: 24.3; js-indent-line mixes display position with character position Message-ID: References: <86sint4vlk.fsf@gmail.com> Date: Sat, 31 May 2014 21:30:23 -0400 In-Reply-To: <86sint4vlk.fsf@gmail.com> (uu's message of "Wed, 28 May 2014 20:16:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 17619 Cc: 17619@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > `js-indent-line' mixes up display column with character count. Indeed. > I am using the following modification to work-around the issue, although [..] > (offset (- current-char-position (current-indentation)))) This still mixes char counts and column counts. I used the patch below instead. Stefan === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-31 20:02:47 +0000 +++ lisp/ChangeLog 2014-06-01 01:27:03 +0000 @@ -1,3 +1,8 @@ +2014-06-01 Stefan Monnier + + * progmodes/js.el (js-indent-line): Don't mix columns and chars + (bug#17619). + 2014-05-31 Stefan Monnier * subr.el (set-transient-map): Don't wait for some "nested" === modified file 'lisp/progmodes/js.el' --- lisp/progmodes/js.el 2014-05-01 23:55:25 +0000 +++ lisp/progmodes/js.el 2014-06-01 01:29:02 +0000 @@ -1907,7 +1907,7 @@ (interactive) (let* ((parse-status (save-excursion (syntax-ppss (point-at-bol)))) - (offset (- (current-column) (current-indentation)))) + (offset (- (point) (save-excursion (back-to-indentation) (point))))) (indent-line-to (js--proper-indentation parse-status)) (when (> offset 0) (forward-char offset)))) From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 21:53:41 2014 Received: (at control) by debbugs.gnu.org; 1 Jun 2014 01:53:41 +0000 Received: from localhost ([127.0.0.1]:39288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wquxw-0003od-HI for submit@debbugs.gnu.org; Sat, 31 May 2014 21:53:40 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:51343) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wquxt-0003oM-VG for control@debbugs.gnu.org; Sat, 31 May 2014 21:53:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIImAQEEVjMLNBIUGA2IMNIZF48BFoQiAQOpGYFqgXGBWyE X-IPAS-Result: ArQGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIImAQEEVjMLNBIUGA2IMNIZF48BFoQiAQOpGYFqgXGBWyE X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="65209114" Received: from 206-248-131-163.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 31 May 2014 21:53:32 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id D6033AE0BC; Sat, 31 May 2014 21:53:31 -0400 (EDT) From: Stefan Monnier To: control@debbugs.gnu.org Subject: Re: bug#17619: 24.3; js-indent-line mixes display position with character position Message-ID: References: <86sint4vlk.fsf@gmail.com> Date: Sat, 31 May 2014 21:53:31 -0400 In-Reply-To: (Stefan Monnier's message of "Sat, 31 May 2014 21:30:23 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) close 17619 thanks From unknown Mon Jun 23 04:09:25 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 29 Jun 2014 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator