all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* A debugging puzzle with XML
@ 2015-01-28 17:33 Marcin Borkowski
  2015-01-29 10:46 ` Nicolas Richard
  0 siblings, 1 reply; 3+ messages in thread
From: Marcin Borkowski @ 2015-01-28 17:33 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi there,

as we all know, everything is better with XML, so here's a puzzle for
all interested (I call it a puzzle and not a bug because I finally
solved it).

Download the xmlgen library (https://github.com/philjackson/xmlgen) and
execute this code:

(require 'xmlgen)
(with-temp-file "foo.xml"
  (insert (xmlgen '(hello (world (of (xml) "!")))))).

Visit file foo.xml, do this:

C-x h M-x sgml-pretty-print

and enjoy your beautifully formatted (and indented!) XML code.

Now rinse and repeat, but with one change:

(require 'xmlgen)
(with-temp-file "foo.xml"
  (insert (xmlgen '(hello (world (of (xml) "!")))))
  (sgml-pretty-print (point-min) (point-max)))

and answer this question: where have all the indents go?

;-D

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: A debugging puzzle with XML
  2015-01-28 17:33 A debugging puzzle with XML Marcin Borkowski
@ 2015-01-29 10:46 ` Nicolas Richard
  2015-01-29 11:07   ` Marcin Borkowski
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Richard @ 2015-01-29 10:46 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> (require 'xmlgen)
> (with-temp-file "foo.xml"
>   (insert (xmlgen '(hello (world (of (xml) "!")))))
>   (sgml-pretty-print (point-min) (point-max)))
>
> and answer this question: where have all the indents go?

Ok let's play the game (i.e. I didn't try) : My guess is that since
`with-temp-file' doesn't set the major mode (i.e. it will be
fundamental-mode), there are local variables which are not set as
sgml-pretty-print would expect.

-- 
Nicolas Richard



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

* Re: A debugging puzzle with XML
  2015-01-29 10:46 ` Nicolas Richard
@ 2015-01-29 11:07   ` Marcin Borkowski
  0 siblings, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2015-01-29 11:07 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list


On 2015-01-29, at 11:46, Nicolas Richard <theonewiththeevillook@yahoo.fr> wrote:

> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>> (require 'xmlgen)
>> (with-temp-file "foo.xml"
>>   (insert (xmlgen '(hello (world (of (xml) "!")))))
>>   (sgml-pretty-print (point-min) (point-max)))
>>
>> and answer this question: where have all the indents go?
>
> Ok let's play the game (i.e. I didn't try) : My guess is that since
> `with-temp-file' doesn't set the major mode (i.e. it will be
> fundamental-mode), there are local variables which are not set as
> sgml-pretty-print would expect.

Good catch!  To be more precise: sgml-pretty-print calls
reindent-then-newline-and-indent, which depends on the mode.

It took me almost half an hour of frustration...  I guess this is just
another step on the path to real Emacs expertise, which I hope to finish
within a two-digit number of years...  (That assuming that "finishing"
it is at all possible.)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

end of thread, other threads:[~2015-01-29 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-28 17:33 A debugging puzzle with XML Marcin Borkowski
2015-01-29 10:46 ` Nicolas Richard
2015-01-29 11:07   ` Marcin Borkowski

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.