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 6DFzMYpLzV5wGgAA0tVLHw (envelope-from ) for ; Tue, 26 May 2020 17:02:02 +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 yDlTLYpLzV7RXQAAB5/wlQ (envelope-from ) for ; Tue, 26 May 2020 17:02:02 +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 117009402D1 for ; Tue, 26 May 2020 17:02:01 +0000 (UTC) Received: from localhost ([::1]:56008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdcxj-0002HB-Om for larch@yhetil.org; Tue, 26 May 2020 13:01:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdcx6-0002Fv-Qv for emacs-orgmode@gnu.org; Tue, 26 May 2020 13:01:20 -0400 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]:41047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdcx5-0006oD-HO; Tue, 26 May 2020 13:01:20 -0400 Received: by mail-qv1-xf36.google.com with SMTP id v15so9777267qvr.8; Tue, 26 May 2020 10:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:references:user-agent:from:to:cc:subject:in-reply-to :message-id:date:mime-version; bh=slfUsMAYsjqXGkl35wfyT68y6BLI6hRMVmCfM1G4zx4=; b=VG90I5d77u8ylUX1ZzS56hF52Si9EsvvPHNfcQA8zkjat9XWBQLICN7UQdAqAFdpQH f42zBYi5Jd04OGk3Mq5xNKozY8CqKj4qhxooyYTIPPxVqQGubng76Cx9Z29bSfqsWXwH Z526YUuXFxo3s3dDattVypj/UjxE92fRFgSlo8Th5E1ai7EQgByb0YfO4pPnvY6RXfF3 m39O17prm4g8DEtFGzOIYBk9tbIOfza/ZjFSx9UXbEaP6LyJQl369wL0zKWr5G8MuNZ6 AukPZTaPtRBe8t+ee82oYRn0DR8JA/o9WOJXkJLCQp5u6T664UKJUNOuAUHA0XVrEI+G E7Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=slfUsMAYsjqXGkl35wfyT68y6BLI6hRMVmCfM1G4zx4=; b=uAGE1YBBL1binhuCEYjKfvuajxLO7jx02aJoreyGDBMAddZmpr+KZdkc7xTdIq42y8 XzIskioJxfDrSkwzqk41da4Ckso9pOph6lE1bBbb1jwvIcqrnGTJKRwHiVNIRKjHBlWS hxXkVdwzMfgyTl/Zj4f2DDl2BZvwK0JPrUrDy7B1b2d9IeAsgo+k68cy3p7VurfDC/4N 9he4XXtSzJFJV0/b4tdRaFzowv9Y+KwWcn7YdQDQ5bxZSeBhESiZGPk+g05EUQxSEkzt BvwHBHKtWr5LBnofYr1yiGMStAght8IX8hE+aGGldDFVDGSphGKxMgZGh8bFPzC2mvGB taMA== X-Gm-Message-State: AOAM531HuMhBRCDhEaF614Tzm13ggRzlQLANtKGsM/cpjgeQiyKjmpV1 foyOWfFIRWfWwg5ZazhVJjL8OVhyC1U= X-Google-Smtp-Source: ABdhPJyyPr+uKSEGwQ5bAlgLcDLRMmTduK0C9FB0eDph5NDysqsoBRAaGUl7T1L0pNwC/txTce9SkQ== X-Received: by 2002:ad4:5684:: with SMTP id bc4mr21507840qvb.85.1590512477317; Tue, 26 May 2020 10:01:17 -0700 (PDT) Received: from Johns-MacBook-Air.local ([2601:547:901:1830:74ea:8f85:c5eb:4d44]) by smtp.gmail.com with ESMTPSA id c191sm146259qke.114.2020.05.26.10.01.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 May 2020 10:01:15 -0700 (PDT) References: <87wo4z6sec.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.3.6; emacs 26.3 From: John Kitchin To: emacs-orgmode@gnu.org Subject: Re: (Feature Request) have org-edit-special work inside non-environment LaTeX blocks, i.e. \( \) and \[ \] In-reply-to: Message-ID: Date: Tue, 26 May 2020 13:01:14 -0400 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=johnrkitchin@gmail.com; helo=mail-qv1-xf36.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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 , Nicolas Goaziou 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=VG90I5d7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=andrew.cmu.edu (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: 3qtJPzAE3DfN Timothy writes: > Nicolas Goaziou writes: > >> Thank you. It looks fine, I will only be nitpicking. > > Nitpick away :D > >>> +(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"))) Is this a case for the if-let* macro? Or is that too new a feature for org to use still? >> >> This is a fancy way to use a let-binding. I suggest to mimic what is >> done elsewhere, i.e., first bind `context', then check if we're at >> a LaTeX fragment, then bind the rest. > > I had a look at that, to me this was cleaner than using multiple let > bindings, like so > > (let ((context ...)) > (unless ... user error) > (let* ((contents ...) > (delim-length ...)) > ... > > vs. > > (let* ((context ...) > (_ (unless ... user error)) > (contents ...) > (delim-length ...)) > ... > > Personally I find the second one nicer. Thoughts? > >>> + ;; Grab the LaTeX fragment for propertization >> >> Missing full stop at the end of the comment. > > Fixed! > >> >>> + (contents (buffer-substring-no-properties >>> + (org-element-property :begin context) >>> + (- (org-element-property :end context) >>> + (org-element-property :post-blank context)))) >>> + (delim-length (if (string-match "\\$[^$]" (substring contents 0 2)) >> >> Use >> >> (string-match "\\`\\$[^$]" contents) >> >> instead. >> >> or, arguably better, >> >> (string-match (rx (seq string-start "$" (not (any "$")))) >> contents) >> >>> + 1 2))) >>> + ;; make the LaTeX deliminators read-only > > I've changed to (string-match-p "\\`\\$[^$]" contents), as this seems > like the idiomatic form, let me know if you're happy with this. > > I'm not actually sure what's going on with your second suggested form, > or why that may be better. If you'd mind explaining, that would be > appriciated :) > >> Missing initial capital and final full stop. > > Fixed! > >> You could factor out (length contents) so it is only called once. > > I'm not sure if this a big deal, but I shoved it in the let* for now, > let me know if that suffices. > >>> + (org-src--edit-element >>> + context >>> + (org-src--construct-edit-buffer-name (buffer-name) "LaTeX fragment") >>> + (org-src-get-lang-mode "latex") >>> + (lambda () >>> + ;; Blank lines break things, replace with a single newline >> >> See above. > > I'm not quite sure what I should see? I don't notice anything to factor > out here. > >> >>> + (while (re-search-forward "\n[ \t]*\n" nil t) (replace-match "\n")) >>> + ;; If within a table a newline would disrupt the structure, >> >> This comment is truncated. > > Added ", so remove newlines" > >> Don't leave parenthesis alone. > > Fixed! > >> Also, make sure your indentation is right, e.g., using M-q on the >> definition. > > I've applied auto-indent to `org-edit-latex-fragment' > >> You also need to add a proper commit message and use `git format-patch', >> and an entry in ORG-NEWS (probably in Miscellaneous part). > > I recall being asked to list modified/added functions, what else do I need? > >> Bonus points if you can add some tests in >> "testing/lisp/test-org-src.el". > > I'll have a look at that, but I'm not quite sure what to do. > >> Could you remind me if you signed the FSF papers already? > > They're done and dusted :) > > Regards, > > Timothy. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu