Hot answers tagged

46 votes
Accepted

The old "how to fold XML" question

I found this SO post: https://stackoverflow.com/questions/944614/emacs-does-hideshow-work-with-xml-mode-sgml-mode (require 'hideshow) (require 'sgml-mode) (require 'nxml-mode) (add-to-list 'hs-...
user avatar
35 votes
Accepted

How to prettify/format an XML buffer?

Does the functionality already exist to reformat this buffer to be somewhat user-readable? Of course, and you have plenty of options. I'd probably feed it to an external program using: C-x h C-u M-| ...
user avatar
  • 5,412
30 votes

How to prettify/format an XML buffer?

The built-in sgml-mode has a command to do this: sgml-pretty-print. If you're in nxml-mode it looks like you need switch to sgml-mode first. You could write a command to temporarily switch to sgml-...
user avatar
  • 19.1k
13 votes

The old "how to fold XML" question

web-mode has element folding built in and bound to C-c C-f. But you will lose some of the features of using nxml-mode obviously.
user avatar
7 votes

How to prettify/format an XML buffer?

write this into your ~/.emacs.d/init.el: (require 'sgml-mode) (defun ninrod/reformat-xml () (interactive) (save-excursion (sgml-pretty-print (point-min) (point-max)) (indent-region (...
user avatar
  • 1,266
6 votes

How to prettify/format an XML buffer?

Mark your xml and do: M-x sgml-pretty-print Or just run the command without a marked region to prettify the whole buffer.
user avatar
  • 61
5 votes
Accepted

How pretty format XML in Windows?

Try the command sgml-pretty-print from sgml-mode. This operates on the region, so you could mark the buffer first: C-x h M-x sgml-pretty-print Or maybe define a command : (defun my-xml-pretty-print ...
user avatar
  • 19.1k
4 votes
Accepted

How to show XPath for current location in an XML hierarchy in the modeline?

Install nxml-mode and which-function-mode. Take the nxml-where function from here and add it to your .emacs file followed by: (defun xml-find-file-hook () (when (derived-mode-p 'nxml-mode) (...
user avatar
  • 201
3 votes

Multiple modes for one file

Two options I'm aware of: mmm-mode is a minor mode for Emacs that allows Multiple Major Modes to coexist in one buffer. It is well-suited to editing: Preprocessed code, such as server-side Ruby, ...
user avatar
  • 20.1k
3 votes

How do I use Emacs as a feedly.com client?

Did you test elfeed? Is not a client for feedly.com, but you can read your RSS feeds within Emacs anyway
user avatar
  • 2,564
3 votes
Accepted

How do I use Emacs as a feedly.com client?

The answer is that you can't use Emacs as a Feedly client, or at least not without regenerating a developer key every three months. I received the same information as the folks at Feednix. There are ...
user avatar
3 votes
Accepted

Keybinding/Function to Close Xml Tag

You can close an XML block in nXML-mode via C-c / To find such functions, have a look at the mode's description, accessible via C-h m when in nXML-mode. It says C-c / finishes the current element ...
user avatar
  • 794
3 votes

How to prettify/format an XML buffer?

In nxml-mode, C-x H will mark the whole buffer and TAB will indent the selection.
user avatar
3 votes

One key shortcut to jump two-ways between matching opening/closing tags in nxml mode?

If you use evil-mode, you can install https://github.com/redguardtoo/evil-matchit and press % If you prefer original Emacs, (autoload 'sgml-skip-tag-backward "sgml-mode" nil t) (autoload 'sgml-skip-...
user avatar
  • 4,581
3 votes

Open SVG files in XML mode

You'll probably like to either disable auto-image-file-mode or tweak image-file-name-extensions. BTW, if Emacs crashes or hangs for a particular SVG file, I suggest you M-x report-emacs-bug about it. ...
user avatar
  • 25.2k
2 votes
Accepted

Moving around within xml documents?

See nxml-mode, option nxml-sexp-element-flag, and movement commands such as nxml-forward-balanced-item, nxml-forward-element, and nxml-up-element. If you use library Icicles then you can use Icicles ...
user avatar
  • 69.1k
2 votes
Accepted

Insert json or XML blocks in org mode

Org babel "Supported languages" are languages that you can evaluate/execute directly from an orgmode code block. I don't think JSON and XML are executable languages anywhere, so you don't ...
user avatar
  • 20.1k
1 vote

Disable flycheck in XML files

You can add the xml checkers to flycheck-disabled-checkers. For instance, if you are using use-package in your init file: (use-package flycheck :ensure t :config (global-flycheck-mode) (with-...
user avatar
  • 2,248
1 vote

Android manifest - find launch activity name programmatically

You can use xml.el to handle XML data. The following function should provide you with the class names you are looking for: (require 'xml) (require 'seq) (defun activity-from-manifest (manifest) (...
user avatar
1 vote

Open SVG files in XML mode

I have a solution that does 2 things: Attempt to open any XML file in nXML mode, and this obviously needs to include SVG files. If such a file is an SVG file, then define C-c C-c to image-mode. For ...
user avatar
  • 173
1 vote

Adding XUL file syntax highlighting support?

I found the solution: (setq auto-mode-alist (append '((".*\\.xul\\'" . nxml-mode)) auto-mode-alist))
user avatar
  • 41
1 vote
Accepted

How do I edit an XML file in Emacs with tag autocompletion from a known XSD schema?

Turns out the hardest part has to be done outside Emacs. Install auto-complete and auto-complete-nxml from MELPA (easy). Note: don't use genrnc from MELPA 'cause it does not fit the bill... Ensure ...
user avatar
1 vote

how to fold xml file (or specifically build.xml)

You need to add this hook: (add-hook 'nxml-mode-hook 'hs-minor-mode) After that put this in your init.el file or somewhere it'll be loaded. (define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding)...
user avatar
  • 937

Only top scored, non community-wiki answers of a minimum length are eligible