all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: emacs-orgmode@gnu.org
Cc: Bastien <bzg@gnu.org>, Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: (Feature Request) have org-edit-special work inside non-environment LaTeX blocks, i.e. \( \) and \[ \]
Date: Tue, 26 May 2020 13:01:14 -0400	[thread overview]
Message-ID: <m2h7w2bpgl.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <BDF96401-83EB-4F79-BD8A-BADC0262FE06@getmailspring.com>


Timothy <tecosaur@gmail.com> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> 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


  parent reply	other threads:[~2020-05-26 17:02 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  1:31 (Feature Request) have org-edit-special work inside non-environment LaTeX blocks, i.e. \( \) and \[ \] Timothy
2020-05-19  7:47 ` Nicolas Goaziou
2020-05-19  9:27   ` Timothy
2020-05-19  9:39     ` Nicolas Goaziou
2020-05-19  9:45       ` Timothy
2020-05-19 13:27         ` Nicolas Goaziou
2020-05-19 13:32           ` Timothy
2020-05-19 14:09             ` Nicolas Goaziou
2020-05-19 14:12               ` Timothy
2020-05-19 14:28                 ` Nicolas Goaziou
2020-05-19 14:33                   ` Timothy
2020-05-23  9:10 ` Bastien
2020-05-23  9:20   ` tecosaur
2020-05-23  9:34     ` Bastien
2020-05-24 15:07   ` TEC
2020-05-24 15:38     ` TEC
2020-05-24 15:43       ` Timothy
2020-05-24 19:33         ` Nicolas Goaziou
2020-05-25  1:33           ` TEC
2020-05-25  7:11             ` Nicolas Goaziou
2020-05-25  9:28           ` TEC
2020-05-25  9:41             ` Nicolas Goaziou
2020-05-25  9:42               ` TEC
2020-05-25  9:55                 ` TEC
2020-05-25 10:09                   ` Nicolas Goaziou
2020-05-25 10:09                     ` TEC
2020-05-25 10:23                       ` Nicolas Goaziou
2020-05-25 10:24                         ` TEC
2020-05-25 10:32                           ` Nicolas Goaziou
2020-05-25 10:33                             ` TEC
2020-05-25 10:05                 ` TEC
2020-05-25 10:20                   ` Nicolas Goaziou
2020-05-25 10:21                     ` TEC
2020-05-25 11:27                       ` Nicolas Goaziou
2020-05-25 13:22                         ` Timothy
2020-05-25 14:08                           ` TEC
2020-05-26  7:56                             ` Nicolas Goaziou
2020-05-26  8:39                               ` Timothy
2020-05-26  9:11                                 ` Nicolas Goaziou
2020-05-26  9:23                                   ` TEC
2020-05-26 13:56                                     ` TEC
2020-05-26 21:13                                       ` Nicolas Goaziou
2020-05-26 17:01                                 ` John Kitchin [this message]
2020-05-25 18:58                           ` Nicolas Goaziou
2020-05-26  4:48                             ` TEC
2020-05-25 10:11                 ` Nicolas Goaziou
2020-05-25 10:17                   ` TEC
  -- strict thread matches above, loose matches on Subject: below --
2020-05-18  6:44 Timothy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2h7w2bpgl.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.