emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Timothy <tecosaur@gmail.com>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Have C-c C-c recognise #+plot lines
Date: Tue, 27 Apr 2021 01:17:37 +0800	[thread overview]
Message-ID: <87im4955jj.fsf@gmail.com> (raw)
In-Reply-To: <87lf9555q8.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 82 bytes --]


... I didn't regenerate the patch after amending the commit.

:big sigh: Take 4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-Enable-plotting-with-C-c-C-c.patch --]
[-- Type: text/x-patch, Size: 3030 bytes --]

From 4e5fcb4726711ff356656cb6fccf6e341656443d Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Tue, 27 Apr 2021 00:05:37 +0800
Subject: [PATCH] org: Enable plotting with C-c C-c

* lisp/org.el (org-ctrl-c-ctrl-c): When at a table, check if the current
line starts with "#+plot", and if so call `org-plot/gnuplot'.
As I think 4-deep nested if statements are bad for readability, I
refactored the nested if statements to use `cond' while I was at it.
---
 lisp/org.el | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 3f9c9a284..94ef9660d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17693,24 +17693,29 @@ (defun org-ctrl-c-ctrl-c (&optional arg)
 	 ;; send the table if necessary.  If the table has
 	 ;; a `table.el' type, just give up.  At a table row or cell,
 	 ;; maybe recalculate line but always align table.
-	 (if (eq (org-element-property :type context) 'table.el)
-	     (message "%s" (substitute-command-keys "\\<org-mode-map>\
-Use `\\[org-edit-special]' to edit table.el tables"))
-	   (if (or (eq type 'table)
-		   ;; Check if point is at a TBLFM line.
-		   (and (eq type 'table-row)
-			(= (point) (org-element-property :end context))))
-	       (save-excursion
-		 (if (org-at-TBLFM-p)
-		     (progn (require 'org-table)
-			    (org-table-calc-current-TBLFM))
-		   (goto-char (org-element-property :contents-begin context))
-		   (org-call-with-arg 'org-table-recalculate (or arg t))
-		   (orgtbl-send-table 'maybe)))
-	     (org-table-maybe-eval-formula)
-	     (cond (arg (call-interactively #'org-table-recalculate))
-		   ((org-table-maybe-recalculate-line))
-		   (t (org-table-align))))))
+         (cond
+          ((and (< (point) (org-element-property :post-affiliated context))
+                (org-match-line "[ \t]*#\\+plot:"))
+           (org-plot/gnuplot))
+          ((eq (org-element-property :type context) 'table.el)
+           (message "%s" (substitute-command-keys "\\<org-mode-map>\
+Use `\\[org-edit-special]' to edit table.el tables")))
+          ((or (eq type 'table)
+               ;; Check if point is at a TBLFM line.
+               (and (eq type 'table-row)
+                    (= (point) (org-element-property :end context))))
+           (save-excursion
+             (if (org-at-TBLFM-p)
+                 (progn (require 'org-table)
+                        (org-table-calc-current-TBLFM))
+               (goto-char (org-element-property :contents-begin context))
+               (org-call-with-arg 'org-table-recalculate (or arg t))
+               (orgtbl-send-table 'maybe))))
+          (t
+           (org-table-maybe-eval-formula)
+           (cond (arg (call-interactively #'org-table-recalculate))
+                 ((org-table-maybe-recalculate-line))
+                 (t (org-table-align))))))
 	((or `timestamp (and `planning (guard (org-at-timestamp-p 'lax))))
 	 (org-timestamp-change 0 'day))
 	((and `nil (guard (org-at-heading-p)))
-- 
2.31.1


[-- Attachment #3: Type: text/plain, Size: 31 bytes --]


Sorry for the noise,

Timothy

  reply	other threads:[~2021-04-26 17:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 11:58 org-plot/gnuplot: question and feature suggestions Eric S Fraga
2021-03-25 12:18 ` Eric S Fraga
2021-03-25 12:31 ` Timothy
2021-03-25 14:02   ` Eric S Fraga
2021-04-26 16:24 ` [PATCH] Have C-c C-c recognise #+plot lines Timothy
2021-04-26 17:01   ` Nicolas Goaziou
     [not found] ` <88f6c54a01f345d785492c4d5b3b82d3@VI1PR0102MB3327.eurprd01.prod.exchangelabs.com>
2021-04-26 17:05   ` Eric S Fraga
2021-04-26 17:11     ` Timothy
2021-04-26 17:13       ` Timothy
2021-04-26 17:17         ` Timothy [this message]
2021-04-28 18:04           ` Timothy
2021-04-29 11:23             ` Eric S Fraga
2021-04-30  8:17             ` Eric S Fraga
2021-04-30  8:22               ` Bastien
2021-04-30  8:52                 ` Timothy
2021-04-30 10:55                   ` Eric S Fraga
2021-04-30 12:24                     ` Bastien
2021-04-30 10:59                   ` Eric S Fraga
2021-04-30 12:16                     ` Timothy
2021-04-30 12:20                       ` Eric S Fraga
2021-05-01  6:56               ` Bastien
2021-05-01  8:40                 ` Eric S Fraga
2021-05-01  8:52                   ` Bastien
2021-04-30  7:06           ` Timothy
2021-04-30  7:14             ` Bastien
     [not found]     ` <cd035f196ec74353b613018fd4ff86eb@VI1PR0102MB3327.eurprd01.prod.exchangelabs.com>
2021-04-26 21:32       ` Eric S Fraga
2021-04-26 21:33       ` Eric S Fraga
2021-04-27  5:18         ` Bastien

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87im4955jj.fsf@gmail.com \
    --to=tecosaur@gmail.com \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).