undent | ️ Dedent and format multiline strings | Code Quality library
kandi X-RAY | undent Summary
kandi X-RAY | undent Summary
Undent turns multiline source code strings -- which may be indented, bookended with whitespace, or contain newlines injected to avoid long lines -- into beautiful, human-readable strings. To accomplish this, undent().
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Removes indentation from a string
- Splits text into paragraphs
- Remove empty lines from s
- Unwrap a paragraph
- Combine multiple paragraphs into a single line
- Get the indentation of a line
undent Key Features
undent Examples and Code Snippets
Community Discussions
Trending Discussions on undent
QUESTION
I'm trying to write an emacs LISP function to un-indent the region
(rigidly). I can pass prefix arguments to indent-code-rigidly
or
indent-rigidly
or indent-region and they all work fine, but I don't
want to always have to pass a negative prefix argument to shift things
left.
My current code is as below but it seems to do nothing:
...ANSWER
Answered 2017-Feb-11 at 01:04There are a number of problems with your function, including some vary fundamental elisp requirements. Highly recommend reading the Emacs Lisp Reference Manual (bundled with emacs). If you are new to programming and lisp, you may also find An Introduction to Emacs Lisp useful (also bundled with Emacs).
A few things to read about which will probably help
Read the section on the command loop from the elisp reference. In particular, look at the node which describes how to define a new command and the use of 'interactive', which you will need if you want to bind your function to a key or call it with M-x.
Read the section on variables from the lisp reference and understand variable scope (local v global). Look at using 'let' rather than 'setq' and what the difference is.
Read the section on 'positions' in the elisp reference. In particular, look at 'save-excursion' and 'save-restriction'. Understanding how to define and use the region is also important.
It isn't clear if your writing this function just as a learning exercise or not. However, just in case you are doing it because it is something you need to do rather than just something to learn elisp, be sure to go through the Emacs manual and index. What you appear to need is a common and fairly well supported requirement. It can get a little complicated if programming modes are involved (as opposed to plain text). However, with emacs, if what you need seems like something which would be a common requirement, you can be fairly confident it is already there - you just need to find it (which can be a challenge at first).
A common convention is for functions/commands to be defined which act 'in reverse' when supplied with a negative or universal argument. Any command which has this ability can also be called as a function in elisp code with the argument necessary to get that behaviour, so understanding the inter-play between commands, functions and calling conventions is important.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install undent
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page