Hot answers tagged

42

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-special-modes-alist '(nxml-mode "<!--\\|<[^/>]*[^/]>" "-->\\|</[^/>]*[^/]>" "<!-...


29

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-| xmllint --format - RET This program comes with libxml2. You could also use tidy. Here's a list of commandline xml formatting tools: https://stackoverflow.com/...


21

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-mode, run pretty-print, then switch back to nxml-mode. For example, here is a command that will pretty-print the region, optionally with auto-fill enabled: (...


12

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.


7

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 (point-min) (point-max)))) reload emacs, then just call M-x reformat-xml on the badly formatted xml buffer. source: https://davidcapello.com/blog/emacs/reformat-...


5

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 () (interactive) (unless (featurep 'sgml-mode) (require 'sgml-mode)) (sgml-pretty-print (point-min) (point-max)))


4

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) (which-function-mode t) (setq which-func-mode t) (add-hook 'which-func-functions 'nxml-where t t))) (add-hook 'find-file-hook 'xml-find-file-hook t)


3

Did you test elfeed? Is not a client for feedly.com, but you can read your RSS feeds within Emacs anyway


3

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 two possible alternate solutions, neither of which I've yet tested: Use rss2email and have it send the articles from your list of RSS feeds to an email account ...


3

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. Maybe there's not much Emacs's code can do about it (e.g. the problem is in the SVG rendering livbrary), but it might be a good reason to change the default ...


3

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-tag-forward "sgml-mode" nil t) (defun html-get-tag () (let ((b (line-beginning-position)) (e (line-end-position)) (looping t) (html-...


3

Mark your xml and do: M-x sgml-pretty-print Or just run the command without a marked region to prettify the whole buffer.


2

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 by inserting an end-tag.


2

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, Perl or PHP embedded in HTML Code generating code, such as HTML output by CGI scripts Embedded code, such as Javascript in HTML Literate programming: code ...


1

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-eval-after-load 'flycheck (setq-default flycheck-disabled-checkers '(xml-xmlstarlet xml-xmllint)))) will enable flycheck globally, but disable the (two ...


1

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) (seq-filter 'identity (mapcar (lambda (node) (let ((name (xml-get-attribute-or-nil node 'android:name))) ...


1

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 the first item, I use magic-mode-alist to select nxml-mode on some sequences at the beginning of the buffer: <?xml, some DOCTYPE line with XHTML, and <svg ...


1

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 search commands icicle-search-xml-element and icicle-search-xml-element-text-node for navigating among and within XML elements. (Non-nil option icicle-ignore-...


1

I found the solution: (setq auto-mode-alist (append '((".*\\.xul\\'" . nxml-mode)) auto-mode-alist))


1

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 that xsltproc is installed on the system (easy for Linux/Unix/OSX users). Add the following customization into the user's ~/.emacs file (easy): (require 'auto-...


1

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) If you now press C-c h it will fold the xml at the element where your cursor is.


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