Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
83a5aac5
Commit
83a5aac5
authored
Sep 08, 2009
by
Stefan Monnier
Browse files
(with-silent-modifications): New macro.
parent
3b814ebc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
etc/NEWS
etc/NEWS
+2
-0
lisp/ChangeLog
lisp/ChangeLog
+4
-0
lisp/subr.el
lisp/subr.el
+23
-0
No files found.
etc/NEWS
View file @
83a5aac5
...
...
@@ -200,6 +200,8 @@ functions and variables.
* Lisp changes in Emacs 23.2
** New macro with-silent-modifications to tweak text properties without
affecting the buffer's modification state.
** All the default-FOO variables that hold the default value of the FOO
variable, are now declared obsolete.
...
...
lisp/ChangeLog
View file @
83a5aac5
2009-09-08 Stefan Monnier <monnier@iro.umontreal.ca>
* subr.el (with-silent-modifications): New macro.
2009-09-07 Juanma Barranquero <lekktu@gmail.com>
* files.el (top-level): Require `cl' when compiling.
...
...
lisp/subr.el
View file @
83a5aac5
...
...
@@ -2749,6 +2749,29 @@ See also `with-temp-file' and `with-output-to-string'."
(
and
(
buffer-name
,
temp-buffer
)
(
kill-buffer
,
temp-buffer
)))))))
(
defmacro
with-silent-modifications
(
&rest
body
)
"Execute BODY, pretending it does not modifies the buffer.
If BODY performs real modifications to the buffer's text, other
than cosmetic ones, undo data may become corrupted.
Typically used around modifications of text-properties which do not really
affect the buffer's content."
(
declare
(
debug
t
)
(
indent
0
))
(
let
((
modified
(
make-symbol
"modified"
)))
`
(
let*
((
,
modified
(
buffer-modified-p
))
(
buffer-undo-list
t
)
(
inhibit-read-only
t
)
(
inhibit-modification-hooks
t
)
deactivate-mark
;; Avoid setting and removing file locks and checking
;; buffer's uptodate-ness w.r.t the underlying file.
buffer-file-name
buffer-file-truename
)
(
unwind-protect
(
progn
,@
body
)
(
unless
,
modified
(
restore-buffer-modified-p
nil
))))))
(
defmacro
with-output-to-string
(
&rest
body
)
"Execute BODY, return the text it sent to `standard-output', as a string."
(
declare
(
indent
0
)
(
debug
t
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment