emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to font-lock diffs?
@ 2018-08-22  8:51 Marcin Borkowski
  2018-08-22 12:44 ` John Kitchin
  2018-08-22 12:52 ` Nick Dokos
  0 siblings, 2 replies; 6+ messages in thread
From: Marcin Borkowski @ 2018-08-22  8:51 UTC (permalink / raw)
  To: Org-Mode mailing list

Hi all,

I hoped this:

#+begin_src diff
  @@ -1,5 +1,5 @@
  -lorem
  +Lorem
   ipsum
   dolor
   sit
  -amet
  +amet.
#+end_src

would Just Work™, i.e., the diff would be font-locked like in
diff-mode.  Well, it is not.  How do I convince Org-mode to color my
diffs?

Best,

-- 
Marcin Borkowski
http://mbork.pl

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

* Re: How to font-lock diffs?
  2018-08-22  8:51 How to font-lock diffs? Marcin Borkowski
@ 2018-08-22 12:44 ` John Kitchin
  2018-08-22 12:52 ` Nick Dokos
  1 sibling, 0 replies; 6+ messages in thread
From: John Kitchin @ 2018-08-22 12:44 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

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

This does Just Work™ for me if I remove the two spaces at the front of each
line. I never use the indentation, so I am not sure what the interplay
there is.

John

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


On Wed, Aug 22, 2018 at 4:51 AM, Marcin Borkowski <mbork@mbork.pl> wrote:

> Hi all,
>
> I hoped this:
>
> #+begin_src diff
>   @@ -1,5 +1,5 @@
>   -lorem
>   +Lorem
>    ipsum
>    dolor
>    sit
>   -amet
>   +amet.
> #+end_src
>
> would Just Work™, i.e., the diff would be font-locked like in
> diff-mode.  Well, it is not.  How do I convince Org-mode to color my
> diffs?
>
> Best,
>
> --
> Marcin Borkowski
> http://mbork.pl
>
>

[-- Attachment #2: Type: text/html, Size: 1720 bytes --]

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

* Re: How to font-lock diffs?
  2018-08-22  8:51 How to font-lock diffs? Marcin Borkowski
  2018-08-22 12:44 ` John Kitchin
@ 2018-08-22 12:52 ` Nick Dokos
  2018-08-23 19:03   ` Marcin Borkowski
  1 sibling, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2018-08-22 12:52 UTC (permalink / raw)
  To: emacs-orgmode

Marcin Borkowski <mbork@mbork.pl> writes:

> Hi all,
>
> I hoped this:
>
> #+begin_src diff
>   @@ -1,5 +1,5 @@
>   -lorem
>   +Lorem
>    ipsum
>    dolor
>    sit
>   -amet
>   +amet.
> #+end_src
>
> would Just Work™, i.e., the diff would be font-locked like in
> diff-mode.  Well, it is not.  How do I convince Org-mode to color my
> diffs?
>

By somehow elimintating the indentation perhaps?

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler

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

* Re: How to font-lock diffs?
  2018-08-22 12:52 ` Nick Dokos
@ 2018-08-23 19:03   ` Marcin Borkowski
  2018-08-23 20:37     ` Leslie Watter
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2018-08-23 19:03 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode


On 2018-08-22, at 14:52, Nick Dokos <ndokos@gmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Hi all,
>>
>> I hoped this:
>>
>> #+begin_src diff
>>   @@ -1,5 +1,5 @@
>>   -lorem
>>   +Lorem
>>    ipsum
>>    dolor
>>    sit
>>   -amet
>>   +amet.
>> #+end_src
>>
>> would Just Work™, i.e., the diff would be font-locked like in
>> diff-mode.  Well, it is not.  How do I convince Org-mode to color my
>> diffs?
>>
>
> By somehow elimintating the indentation perhaps?

Thanks Nick (and John, in previous message).  This works indeed.

However, double C-c ' on the source block reintroduces the
indentation...

Still, I can live with it as-is.

Best,

-- 
Marcin Borkowski
http://mbork.pl

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

* Re: How to font-lock diffs?
  2018-08-23 19:03   ` Marcin Borkowski
@ 2018-08-23 20:37     ` Leslie Watter
  2018-08-23 22:25       ` Samuel Wales
  0 siblings, 1 reply; 6+ messages in thread
From: Leslie Watter @ 2018-08-23 20:37 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Nick Dokos, org-mode-email

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

Hi Marcin,

You can configure this behaviour of org-mode (setting the identation of
source blocks to 0) using the following code: (put it in your emacs config
file)

(setq org-edit-src-content-indentation 0)

Hope it helps.

Cheers,

LEslie


On Thu, Aug 23, 2018 at 4:05 PM Marcin Borkowski <mbork@mbork.pl> wrote:

>
> On 2018-08-22, at 14:52, Nick Dokos <ndokos@gmail.com> wrote:
>
> > Marcin Borkowski <mbork@mbork.pl> writes:
> >
> >> Hi all,
> >>
> >> I hoped this:
> >>
> >> #+begin_src diff
> >>   @@ -1,5 +1,5 @@
> >>   -lorem
> >>   +Lorem
> >>    ipsum
> >>    dolor
> >>    sit
> >>   -amet
> >>   +amet.
> >> #+end_src
> >>
> >> would Just Work™, i.e., the diff would be font-locked like in
> >> diff-mode.  Well, it is not.  How do I convince Org-mode to color my
> >> diffs?
> >>
> >
> > By somehow elimintating the indentation perhaps?
>
> Thanks Nick (and John, in previous message).  This works indeed.
>
> However, double C-c ' on the source block reintroduces the
> indentation...
>
> Still, I can live with it as-is.
>
> Best,
>
> --
> Marcin Borkowski
> http://mbork.pl
>
>

-- 
Leslie H. Watter

[-- Attachment #2: Type: text/html, Size: 2166 bytes --]

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

* Re: How to font-lock diffs?
  2018-08-23 20:37     ` Leslie Watter
@ 2018-08-23 22:25       ` Samuel Wales
  0 siblings, 0 replies; 6+ messages in thread
From: Samuel Wales @ 2018-08-23 22:25 UTC (permalink / raw)
  To: leslie; +Cc: Nick Dokos, org-mode-email

i ran into this type of thing years ago and wrote this summary in
comments to remind myself of the issues.  maybe it will be useful to
somebody.

;; when you edit a source or data block, org will by default
;; remove some leading whitespace and then add 2 spaces, so the
;; whole block in org is indented by 2.
;;
;; (the deleted rectangle seems to be the maximum amount of
;; whitespace common to all lines in each block.)
;;
;; initial tabs get converted to spaces, which breaks things.
;; example blocks get unindented during export incorrectly.
;; mistakes are possible.
;;
;; this as non-nil prevents all that.
;;
;; we EITHER unindent all and set this non-nil, OR put up with
;; stripping of leading whitespace from blocks.
;;
;; /i prefer t./ it is not possible in babel to indent without
;; having the special feature of removing the whitespace
;; rectangle.
;;
;; you can use -i to locally do t.  there isn't the reverse of
;; -i.  there are no long options.
;;
;; source blocks might actually work without indentation even
;; with the default value, but then when you edit it indents.
(setq org-src-preserve-indentation t)

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

end of thread, other threads:[~2018-08-23 22:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22  8:51 How to font-lock diffs? Marcin Borkowski
2018-08-22 12:44 ` John Kitchin
2018-08-22 12:52 ` Nick Dokos
2018-08-23 19:03   ` Marcin Borkowski
2018-08-23 20:37     ` Leslie Watter
2018-08-23 22:25       ` Samuel Wales

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