From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oHh0CTQ6iWDf5QAAgWs5BA (envelope-from ) for ; Wed, 28 Apr 2021 12:34:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id iHo5BTQ6iWClWwAA1q6Kng (envelope-from ) for ; Wed, 28 Apr 2021 10:34:28 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 93F1320E77 for ; Wed, 28 Apr 2021 12:34:27 +0200 (CEST) Received: from localhost ([::1]:42258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbhWU-0006gE-39 for larch@yhetil.org; Wed, 28 Apr 2021 06:34:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbhVX-0006LH-Si for emacs-orgmode@gnu.org; Wed, 28 Apr 2021 06:33:27 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:45595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbhVW-0005Lp-19 for emacs-orgmode@gnu.org; Wed, 28 Apr 2021 06:33:27 -0400 Received: by mail-pl1-x634.google.com with SMTP id p17so6666098plf.12 for ; Wed, 28 Apr 2021 03:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=gLTpaffGpnoJVIW83XQXHEeaNl7Jfa5eA6gP/cEA+fk=; b=om9oGCL5WaEXOtJRYS3rJt2ZXwauRcJ+gQAmKe/JhQUIG4d2wQ3JmGS8auwjztsqHL rDvM9o9QrDkcYaqiYFzmin9kNMfcUKiHazmKZfmpP90qZWCmbWKK5MMeKeMNy1Y8hGFl AB0R/2n0i72XHC/Wk04MmwrGcQqZydKIzohb+LEhYzyw53lsj62OEkf1W5fPOvsnn9D5 eGmFMlZOQWOQEDj2ElNx0RsBUOHfnXfdIIr96dyurbPqCejFg0+QaaNOx9eAa/mTvdnt JXjUeo0ZXux+AnQUN+3nAY1yIGCmokni3A6THeEotTOTMGcMqnMrLdZWa8NukKkHMjI6 Xg1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=gLTpaffGpnoJVIW83XQXHEeaNl7Jfa5eA6gP/cEA+fk=; b=h4mNl7OhyV3v3ajSqPEF2hmQ4vc3ftT/qDucG2QOKc7Lak7QtbZhxYfjKEwl6BEOfa x1M4jtYibRhsM1y87JiqgsgU7i+hMsYHTjuT8JCimmPMb9WVV0GTRae4sMLzAWMe0de9 mtcquceuKRNHQZxt3Q3WbRO5M51XDifHGBmeZVVTW2UahoyALR1Vhh2IgH5wM5pajUZE yvug7m5egPybK7B5Su/Afy5HVzsGTCBuejtg56pMzlmuq+Z7PZWY2g+++KeOnyXoWUPr t26vqsqBzMykEsA7hupmBwua/QdKZx3dXvDESwuPGl1c7cUzTW66AkQ81xhamlxpdUYa kOIA== X-Gm-Message-State: AOAM531Kv9adb5rtLQnJPrfn5unjUMfKVLnfcO5LvuKxTUytVsH+VIja VFJkBTGemupmrylRUlvme66IL5wRI40= X-Google-Smtp-Source: ABdhPJziyR9KhBN8Lfc6c5kz3fsUA9rf2dYswDMOQiFjczf7MzPiPWAJZ2ePL3BvR7dwC0Z0qaOzKg== X-Received: by 2002:a17:90a:fa0e:: with SMTP id cm14mr3278231pjb.59.1619606003236; Wed, 28 Apr 2021 03:33:23 -0700 (PDT) Received: from localhost (180-150-91-8.b4965b.per.nbn.aussiebb.net. [180.150.91.8]) by smtp.gmail.com with ESMTPSA id q19sm2129398pgv.38.2021.04.28.03.33.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 03:33:22 -0700 (PDT) User-agent: mu4e 1.4.15; emacs 28.0.50 From: Timothy To: org-mode-email Subject: [PATCH] fix point position shifting in some org-src instances Message-ID: <87r1iuhf69.fsf@gmail.com> Date: Wed, 28 Apr 2021 18:33:18 +0800 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619606067; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=gLTpaffGpnoJVIW83XQXHEeaNl7Jfa5eA6gP/cEA+fk=; b=f91iuR6j9Sb6g2g4Ej2snsVA1+8+/zgX9AB3ou0fuLCJ24Yr8f/DK9IWJmRfduzFP+R5x8 yZaxXGgQCHmsYBIQt8+RKb8yQOSumP6Y/3FwLwwO2kDd5ouu+HxjsRzCm2TAC5UDed5S8m 0q0niTzPMuQnAiyB2HCLkdOIXxuUK8H8KwJZfY3d7NfwdeXP3whphl4PXA1UxlcisZ5YIz CF15llkmPFho/3RTiyHdonppkX9/d9xjZtWkEbF0wgPWo/+zUURNjMviNXFED8kDYYXUH+ 7RRt6jj5sE5mS8HlHZ84LzfbQlqrHX09LYmL/RXxMgzQ4nKqbiv+jBjXHwb6CQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619606067; a=rsa-sha256; cv=none; b=EuFSO8NygYb/MYyTl2eTNeBeHKVOeTKHmm0m3fECMVXAEzjFuFslivblHG5vBTm0QufH6F cV/YtmPZtb7wZHrlS6R27Blhh/XsDuo+2mI6DxrehgjiADhQQjDY0d3Eq1Bqu+Ygk5Wc6e RvD+KjtXnJtOhqEonTgA5LVQyv2luGfwzYIFji/U4mc5/dtv1VK50t2Fp8vPgxA2kxOYUy omIgIxiXXb2vRyA7exwfIszKUHN9JZX9kc+MO5LzeakvAz2dnRuV87ZIu42UHPqZTjJ8SC OaOKoc8hmSuDQC24eDimZZdedGnLF6AK+upVnThMWqNV4X0QolAs0Vv4R2rFJg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=om9oGCL5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.15 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=om9oGCL5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 93F1320E77 X-Spam-Score: -3.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: ICnpF2oyLejt --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi All, I've noticed for a while that if you have a block with overlays/invisible characters that editing it with `org-edit-special' moves the point around. For example, with Org pretty entities enabled, and =E2=96=88 indicating the cursor, if I call org-edit-special on a LaTeX fragment like: \( \alpha +=E2=96=88\beta \) which is displayed as \( =CE=B1 +=E2=96=88=CE=B2 \) The point is moved on creation of the org-src buffer \( \alpha + \beta =E2=96=88\) Then if I move it back to after the "+", on calling `org-edit-src-exit' the point is moved to \(=E2=96=88 \alpha + \beta \) In the original buffer. This may seem quite minor, but if you're editing a lot of LaTeX fragments having the point constantly jumping around can be quite a pain. After investigating this, I tried shifting org-src--{goto-}coordinates to a point-based approach from a column-based approach, and it seems to have fixed the problem. I have tested a few other situations (e.g. LaTeX environments, example blocks, src blocks), and it seems to work well. -- Timothy --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-org-src-Use-point-instead-of-column-for-coords.patch Content-Transfer-Encoding: quoted-printable >From 8e8faf389d6d5c0769b5f95775ec7883820b10b3 Mon Sep 17 00:00:00 2001 From: TEC Date: Wed, 28 Apr 2021 18:17:00 +0800 Subject: [PATCH] org-src: Use point instead of column for coords MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/org-src.el (org-src--coordinates, org-src--goto-coordinates): Using a column-based approach fails to account for invisible regions or display overlays that change the number of columns: for example, showing a LaTeX \alpha as =CE=B1. In src edits which involve such structures, this causes the point to be shifted undesirably. By using a point-based approach this issue does not occur. --- lisp/org-src.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index cabedecb6..a694e5595 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -327,8 +327,7 @@ (defun org-src--coordinates (pos beg end) (cons (count-lines beg (line-beginning-position)) ;; Column is relative to the end of line to avoid problems of ;; comma escaping or colons appended in front of the line. - (- (current-column) - (progn (end-of-line) (current-column))))))) + (- (point) (min end (line-end-position))))))) =20 (defun org-src--goto-coordinates (coord beg end) "Move to coordinates COORD relatively to BEG and END. @@ -341,9 +340,9 @@ (defun org-src--goto-coordinates (coord beg end) (org-with-wide-buffer (goto-char beg) (forward-line (car coord)) - (end-of-line) - (org-move-to-column (max (+ (current-column) (cdr coord)) 0)) - (point))))) + (max (point) + (+ (min end (line-end-position)) + (cdr coord))))))) =20 (defun org-src--contents-area (datum) "Return contents boundaries of DATUM. --=20 2.31.1 --=-=-=--