From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iCKIHU6Uy14CJAAA0tVLHw (envelope-from ) for ; Mon, 25 May 2020 09:47:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id qEloGU6Uy154AwAAB5/wlQ (envelope-from ) for ; Mon, 25 May 2020 09:47:58 +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 EE78A94014C for ; Mon, 25 May 2020 09:47:57 +0000 (UTC) Received: from localhost ([::1]:49478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd9i8-0000uI-A7 for larch@yhetil.org; Mon, 25 May 2020 05:47:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd9hV-0000tV-GQ for emacs-orgmode@gnu.org; Mon, 25 May 2020 05:47:17 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:39554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jd9hU-0000T2-BI; Mon, 25 May 2020 05:47:17 -0400 Received: by mail-pj1-x1031.google.com with SMTP id n15so8332487pjt.4; Mon, 25 May 2020 02:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:references:user-agent:in-reply-to :message-id:mime-version; bh=BOZm9Z8Bd8vFMvJHHaJhdPSPqc8EAUt1xDVwYVnmFVg=; b=R+vDyp5J6Q3rAohkqpTPxS9mESEVtSqONZVFzyfrwdSxElJQvNdyEZ9ZU4S+RpLwAm Bwo6CiE4wZ6MYuGY6srtCvmgt6BgXFshHCAnTc8RlUJxh374yayP76suqR7A43EwqYT+ e083kubewoLvR+PQebq26vW+qWe5WSNRDaqqA4zHBELzkpNhIbl4cpNuWDARN3poRy+f DpSeAcGrVQav6MoGCXFVfNybJmw6yuqFuwpqcQp5lwMQhFhnGQj1vyu7/QuXM5uGVIzn 1SwYgq4xHDoDjM769OFiZaD2Qi07eEwbVaUeyIVK9XI061678OMXKZaWVITGTb6pIcen T45Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:references:user-agent :in-reply-to:message-id:mime-version; bh=BOZm9Z8Bd8vFMvJHHaJhdPSPqc8EAUt1xDVwYVnmFVg=; b=ShcHSlNPsw0TRKPeujME19mDPd5/i6eON495xUqeVdESfu8WoY1ak4tYCKURr6pxdW VfcF/Qem0MaoHoLbIcDOGZ5lhw3Fr1HibwTg9HHnUNGc3XuAeYh62B69E94DbLWnagbz FVZ9outLeJCAvsF6dbO3rCRXU9TJBFdTJwbE4P816jhilu9/fCrI/qkSFmDyhxje0qK+ l1jaPvcy/XIL6UtKC6fJSiH8hwfj5OxKwcf0C3eAPM20YVhqc602iI9Dca3LzU+VY4Mw VsDPf733x7f7mp3tPN74e8JB4ePHC6iqzPHcU5PvHww9E3XcJ6gPg1KnxzK2FsjsqINt cwVA== X-Gm-Message-State: AOAM532KOugBmNi4yDdjXEs6F0z4wQycSwTwq3zif/lP+k19n97+Igkc 9iUND2Vg7OBjjRsZsvSsZROhqQ97WBQ= X-Google-Smtp-Source: ABdhPJxcPMf7vwYfg/K8FswxsPwX4E9tzg4gYTUMh88H+A8FrO9IaHXId+DAaKZGs8Yk2PQRur5AHw== X-Received: by 2002:a17:90a:17ed:: with SMTP id q100mr18215222pja.80.1590400034454; Mon, 25 May 2020 02:47:14 -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 e13sm12908832pfm.103.2020.05.25.02.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 02:47:13 -0700 (PDT) From: TEC To: Nicolas Goaziou Subject: Re: (Feature Request) have org-edit-special work inside non-environment LaTeX blocks, i.e. \( \) and \[ \] Date: Mon, 25 May 2020 17:42:30 +0800 References: <87zh9xxrww.fsf@gmail.com> <4274FCF8-5304-4B55-9586-0C718DA388D3@getmailspring.com> <87r1v9ceml.fsf@nicolasgoaziou.fr> <871rn8gy40.fsf@gmail.com> <87ftbobbct.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.4.6; emacs 26.3 In-reply-to: <87ftbobbct.fsf@nicolasgoaziou.fr> Message-ID: <87zh9wfish.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=tecosaur@gmail.com; helo=mail-pj1-x1031.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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, HTML_MESSAGE=0.001, MPART_ALT_DIFF_COUNT=1.112, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: Bastien , "emacs-orgmode@gnu.org" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=R+vDyp5J; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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-Spam-Score: 0.09 X-TUID: lxSk+836Wp7y --=-=-= Content-Type: text/plain; format=flowed Nicolas Goaziou writes: > The equivalent code will prevent a user from changing, deleting > the LaTeX markers, or writing past them : this is not the > purpose of the functionality. That's most helpful, thanks :) I'l have a look at that now, in the mean time here's what I hope will be the penultimate version of this patch :D --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Extend-org-edit-special-to-editing-LaTeX-fragments.patch >From 748c20d65df9cd0ae9f9f80c2bb5ee87aea101e4 Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 24 May 2020 23:35:33 +0800 Subject: [PATCH] Extend org-edit-special to editing LaTeX-fragments Defines a new function, `org-edit-latex-fragment' which is hooked into `org-edit-special', modifying `org-src--contents-area-modified' to recognise the element type. --- lisp/org-src.el | 29 +++++++++++++++++++++++++++-- lisp/org.el | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index c9eef744e..d41879c09 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -360,8 +360,13 @@ where BEG and END are buffer positions and CONTENTS is a string." ((eq type 'inline-src-block) (let ((beg (progn (goto-char (org-element-property :begin datum)) (search-forward "{" (line-end-position) t))) - (end (progn (goto-char (org-element-property :end datum)) - (search-backward "}" (line-beginning-position) t)))) + (end (org-with-point-at (org-element-property :end datum) + (skip-chars-backward " \t") + (point)))) + (list beg end (buffer-substring-no-properties beg end)))) + ((eq type 'latex-fragment) + (let ((beg (org-element-property :begin datum)) + (end (org-element-property :end datum))) (list beg end (buffer-substring-no-properties beg end)))) ((org-element-property :contents-begin datum) (let ((beg (org-element-property :contents-begin datum)) @@ -959,6 +964,26 @@ Throw an error when not at such a table." (table-recognize) t)) +(defun org-edit-latex-fragment () + "Edit LaTeX fragment at point." + (interactive) + (let ((context (org-element-context))) + (unless (and (eq (org-element-type context) 'latex-fragment) + (org-src--on-datum-p context)) + (user-error "Not on a LaTeX fragment")) + (org-src--edit-element + context + (org-src--construct-edit-buffer-name (buffer-name) "LaTeX fragment") + (org-src-get-lang-mode "latex") + (lambda () ; trim content + (goto-char (point-min)) + (skip-chars-forward " \t") + (delete-region (point-min) (point)) + (goto-char (point-max)) + (skip-chars-backward " \t") + (delete-region (point) (point-max)))) + t)) + (defun org-edit-latex-environment () "Edit LaTeX environment at point. \\ diff --git a/lisp/org.el b/lisp/org.el index dcd446745..2f5b89231 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17340,6 +17340,7 @@ Otherwise, return a user error." (pcase (org-element-type context) (`footnote-reference (org-edit-footnote-reference)) (`inline-src-block (org-edit-inline-src-code)) + (`latex-fragment (org-edit-latex-fragment)) (`timestamp (if (eq 'inactive (org-element-property :type context)) (call-interactively #'org-time-stamp-inactive) (call-interactively #'org-time-stamp))) -- 2.26.2 --=-=-= Content-Type: multipart/related; boundary="==-=-=" --==-=-= Content-Type: text/html

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> The equivalent code will prevent a user from changing, deleting the
> LaTeX markers, or writing past them : this is not the purpose of the
> functionality.

That’s most helpful, thanks :)

I’l have a look at that now, in the mean time here’s what I hope will be the
penultimate version of this patch :D

<#part type=“text/x-patch” filename=“home/tec.emacs.d/.local/straight/repos/org-mode/0001-Extend-org-edit-special-to-editing-LaTeX-fragments.patch” disposition=attachment>
<#/part>

--==-=-=-- --=-=-=--