emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* proposal for improved integration of cdlatex
@ 2014-07-25 16:31 Federico Beffa
  2014-07-28 14:44 ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Federico Beffa @ 2014-07-25 16:31 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

when you enable org-cdlatex and insert a LaTeX environment by pressing
M-{, the new environment is inserted ignoring indentation. To correct
for that it is not enough to press TAB as TAB is locally bound to
cdlatex-tab and moves the cursor to the next "interesting" part of the
environment.

For this reason I would like to propose an improved default binding to
the org-cdlatex-mode-map M-{ as follows:

-----------------------------------------------------------------------------------
(defun org-cdlatex-environment-indent (&optional environment item)
  (interactive)
  (cdlatex-environment environment item)
  (save-excursion
    (org-mark-element)
    (org-indent-region (point) (mark))))

(org-defkey org-cdlatex-mode-map "\C-c{"
        'org-cdlatex-environment-indent)
-----------------------------------------------------------------------------------

Regards,
Fede

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-25 16:31 proposal for improved integration of cdlatex Federico Beffa
@ 2014-07-28 14:44 ` Bastien
  2014-07-29  7:24   ` Federico Beffa
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-07-28 14:44 UTC (permalink / raw)
  To: Federico Beffa; +Cc: emacs-orgmode

Hi Federico,

Federico Beffa <beffa@ieee.org> writes:

> (defun org-cdlatex-environment-indent (&optional environment item)
                                                   ^^^^^^^^^^^^^^^^

Why those parameters?

>   (interactive)
>   (cdlatex-environment environment item)
>   (save-excursion
>     (org-mark-element)
>     (org-indent-region (point) (mark))))
>
> (org-defkey org-cdlatex-mode-map "\C-c{"
>         'org-cdlatex-environment-indent)

I'm not sure it's worth it.  You can indent the element with M-h C-\
easily enough, no?

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-28 14:44 ` Bastien
@ 2014-07-29  7:24   ` Federico Beffa
  2014-07-29 14:28     ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Federico Beffa @ 2014-07-29  7:24 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi,

> Why those parameters?
>

the parameters are just in case you want to use this function
non-interactively in place of cdlatex-tab.

> I'm not sure it's worth it.  You can indent the element with M-h C-\
> easily enough, no?

Because typing one key combination is faster than typing 3 and there
are no disadvantages.

Regards,
Fede

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-29  7:24   ` Federico Beffa
@ 2014-07-29 14:28     ` Bastien
  2014-07-29 14:44       ` Federico Beffa
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-07-29 14:28 UTC (permalink / raw)
  To: Federico Beffa; +Cc: emacs-orgmode

Hi Federico,

Federico Beffa <beffa@ieee.org> writes:

> the parameters are just in case you want to use this function
> non-interactively in place of cdlatex-tab.

Is there a real use-case for non-interactive use?

>> I'm not sure it's worth it.  You can indent the element with M-h C-\
>> easily enough, no?
>
> Because typing one key combination is faster than typing 3 and there
> are no disadvantages.

Fair enough.  Please provide a patch against the master branch.
See http://orgmode.org/worg/org-contribute.html for details on
how to format the changelog entry properly.

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-29 14:28     ` Bastien
@ 2014-07-29 14:44       ` Federico Beffa
  2014-07-29 14:54         ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Federico Beffa @ 2014-07-29 14:44 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

>> the parameters are just in case you want to use this function
>> non-interactively in place of cdlatex-tab.
>
> Is there a real use-case for non-interactive use?

To be honest, I do not know. But, the original cdlatex-tab function
takes those parameters and I thought it would be a good idea to pass
on the same parameters, just in case someone uses them.

Regards,
Fede

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-29 14:44       ` Federico Beffa
@ 2014-07-29 14:54         ` Bastien
  2014-07-30 19:48           ` Federico Beffa
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-07-29 14:54 UTC (permalink / raw)
  To: Federico Beffa; +Cc: emacs-orgmode

Federico Beffa <beffa@ieee.org> writes:

> To be honest, I do not know. But, the original cdlatex-tab function
> takes those parameters and I thought it would be a good idea to pass
> on the same parameters, just in case someone uses them.

Ah okay, I didn't check that.  Please go ahead with the patch then,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-29 14:54         ` Bastien
@ 2014-07-30 19:48           ` Federico Beffa
  2014-07-30 20:25             ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Federico Beffa @ 2014-07-30 19:48 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

Please find attached the patch as discussed.

Regards,
Fede

On Tue, Jul 29, 2014 at 4:54 PM, Bastien <bzg@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> writes:
>
>> To be honest, I do not know. But, the original cdlatex-tab function
>> takes those parameters and I thought it would be a good idea to pass
>> on the same parameters, just in case someone uses them.
>
> Ah okay, I didn't check that.  Please go ahead with the patch then,
>
> --
>  Bastien

[-- Attachment #2: 0001-org.el-add-function-to-indent-environment-inserted-b.patch --]
[-- Type: application/octet-stream, Size: 1762 bytes --]

From f038de72cc8a5d2ba57ba797f7e69c41f5c823ec Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Wed, 30 Jul 2014 19:58:38 +0200
Subject: [PATCH] org.el: add function to indent environment inserted by
 cdlatex-enviroment

* lisp/org.el (org-cdlatex-environment-indent): TINYCHANGE new function `org-cdlatex-environment-indent' bound to "\C-c{" in `org-cdlatex-mode-map' to add a LaTeX environment and indent it.
---
 lisp/org.el |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 lisp/org.el

diff --git a/lisp/org.el b/lisp/org.el
old mode 100644
new mode 100755
index 0f7a4ef..8732840
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18405,7 +18405,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 (org-defkey org-cdlatex-mode-map "^" 'org-cdlatex-underscore-caret)
 (org-defkey org-cdlatex-mode-map "`" 'cdlatex-math-symbol)
 (org-defkey org-cdlatex-mode-map "'" 'org-cdlatex-math-modify)
-(org-defkey org-cdlatex-mode-map "\C-c{" 'cdlatex-environment)
+(org-defkey org-cdlatex-mode-map "\C-c{" 'org-cdlatex-environment-indent)
 
 (defvar org-cdlatex-texmathp-advice-is-done nil
   "Flag remembering if we have applied the advice to texmathp already.")
@@ -18483,6 +18483,13 @@ Revert to the normal definition outside of these fragments."
     (let (org-cdlatex-mode)
       (call-interactively (key-binding (vector last-input-event))))))
 
+(defun org-cdlatex-environment-indent (&optional environment item)
+  "Execute `cdlatex-environment' and indent the inserted environment."
+  (interactive)
+  (cdlatex-environment environment item)
+  (save-excursion
+    (org-mark-element)
+    (org-indent-region (point) (mark))))
 
 \f
 ;;;; LaTeX fragments
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-30 19:48           ` Federico Beffa
@ 2014-07-30 20:25             ` Nicolas Goaziou
  2014-07-31  9:12               ` Federico Beffa
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2014-07-30 20:25 UTC (permalink / raw)
  To: Federico Beffa; +Cc: Bastien, emacs-orgmode

Hello,

Federico Beffa <beffa@ieee.org> writes:

> +  (save-excursion
> +    (org-mark-element)
> +    (org-indent-region (point) (mark))))

The function shouldn't set the mark. The following should be enough:


  (let ((element (org-element-at-point)))
    (when element
      (org-indent-region (org-element-property :begin element)
                         (org-element-property :end element))))


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-07-30 20:25             ` Nicolas Goaziou
@ 2014-07-31  9:12               ` Federico Beffa
  0 siblings, 0 replies; 11+ messages in thread
From: Federico Beffa @ 2014-07-31  9:12 UTC (permalink / raw)
  To: Bastien, emacs-orgmode

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

Thanks for the suggestion. Please find attached the improved patch.

Regards,
Federico


On Wed, Jul 30, 2014 at 10:25 PM, Nicolas Goaziou
<mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Federico Beffa <beffa@ieee.org> writes:
>
>> +  (save-excursion
>> +    (org-mark-element)
>> +    (org-indent-region (point) (mark))))
>
> The function shouldn't set the mark. The following should be enough:
>
>
>   (let ((element (org-element-at-point)))
>     (when element
>       (org-indent-region (org-element-property :begin element)
>                          (org-element-property :end element))))
>
>
> Regards,
>
> --
> Nicolas Goaziou

[-- Attachment #2: 0001-org.el-add-function-to-indent-environment-inserted-b.patch --]
[-- Type: application/octet-stream, Size: 1870 bytes --]

From 2782cbad53e1f01a972adad1f2209c60cdc5a727 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Thu, 31 Jul 2014 11:08:44 +0200
Subject: [PATCH] org.el: add function to indent environment inserted by
 cdlatex-enviroment

* lisp/org.el (org-cdlatex-environment-indent): TINYCHANGE new function `org-cdlatex-environment-indent' bound to "\C-c{" in `org-cdlatex-mode-map' to add a LaTeX environment and indent it.
---
 lisp/org.el |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 lisp/org.el

diff --git a/lisp/org.el b/lisp/org.el
old mode 100644
new mode 100755
index 0f7a4ef..5d4b5f7
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18405,7 +18405,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
 (org-defkey org-cdlatex-mode-map "^" 'org-cdlatex-underscore-caret)
 (org-defkey org-cdlatex-mode-map "`" 'cdlatex-math-symbol)
 (org-defkey org-cdlatex-mode-map "'" 'org-cdlatex-math-modify)
-(org-defkey org-cdlatex-mode-map "\C-c{" 'cdlatex-environment)
+(org-defkey org-cdlatex-mode-map "\C-c{" 'org-cdlatex-environment-indent)
 
 (defvar org-cdlatex-texmathp-advice-is-done nil
   "Flag remembering if we have applied the advice to texmathp already.")
@@ -18483,6 +18483,14 @@ Revert to the normal definition outside of these fragments."
     (let (org-cdlatex-mode)
       (call-interactively (key-binding (vector last-input-event))))))
 
+(defun org-cdlatex-environment-indent (&optional environment item)
+  "Execute `cdlatex-environment' and indent the inserted environment."
+  (interactive)
+  (cdlatex-environment environment item)
+  (let ((element (org-element-at-point)))
+    (when element
+      (org-indent-region (org-element-property :begin element)
+                         (org-element-property :end element)))))
 
 \f
 ;;;; LaTeX fragments
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
@ 2014-08-08 16:23 Federico Beffa
  2014-08-09  7:54 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Federico Beffa @ 2014-08-08 16:23 UTC (permalink / raw)
  To: emacs-orgmode, Nicolas Goaziou, Bastien

Do you think it is now a reasonable implementation? Would it be a
suitable tiny change to `org-mode'?

Regards,
Federico

> Thanks for the suggestion. Please find attached the improved patch.
>
> Regards,
> Federico
>
>
> On Wed, Jul 30, 2014 at 10:25 PM, Nicolas Goaziou
> <mail@nicolasgoaziou.fr> wrote:
>> Hello,
>>
>> Federico Beffa <beffa@ieee.org> writes:
>>
>>> +  (save-excursion
>>> +    (org-mark-element)
>>> +    (org-indent-region (point) (mark))))
>>
>> The function shouldn't set the mark. The following should be enough:
>>
>>
>>   (let ((element (org-element-at-point)))
>>     (when element
>>       (org-indent-region (org-element-property :begin element)
>>                          (org-element-property :end element))))
>>
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: proposal for improved integration of cdlatex
  2014-08-08 16:23 Federico Beffa
@ 2014-08-09  7:54 ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2014-08-09  7:54 UTC (permalink / raw)
  To: Federico Beffa; +Cc: Bastien, emacs-orgmode

Hello,

Federico Beffa <beffa@ieee.org> writes:

> Do you think it is now a reasonable implementation? Would it be a
> suitable tiny change to `org-mode'?

Yes, applied. Thank you.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-08-09  7:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 16:31 proposal for improved integration of cdlatex Federico Beffa
2014-07-28 14:44 ` Bastien
2014-07-29  7:24   ` Federico Beffa
2014-07-29 14:28     ` Bastien
2014-07-29 14:44       ` Federico Beffa
2014-07-29 14:54         ` Bastien
2014-07-30 19:48           ` Federico Beffa
2014-07-30 20:25             ` Nicolas Goaziou
2014-07-31  9:12               ` Federico Beffa
  -- strict thread matches above, loose matches on Subject: below --
2014-08-08 16:23 Federico Beffa
2014-08-09  7:54 ` Nicolas Goaziou

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).