[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 221/287: Be more careful with links. Issue #247
From: |
Matthew Fidler |
Subject: |
[elpa] 221/287: Be more careful with links. Issue #247 |
Date: |
Wed, 02 Jul 2014 14:46:10 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit 78eb28da4c95748f855f0acca7bc1f6645975a10
Author: Matthew L. Fidler <address@hidden>
Date: Thu Jun 26 08:36:45 2014 -0500
Be more careful with links. Issue #247
---
ergoemacs-macros.el | 41 +++++++++++++++++++++++++++++++++++++++++
ergoemacs-shortcuts.el | 19 ++++++++++---------
2 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/ergoemacs-macros.el b/ergoemacs-macros.el
index a1eeb88..89738af 100644
--- a/ergoemacs-macros.el
+++ b/ergoemacs-macros.el
@@ -389,6 +389,47 @@ It says that `adjoin' from `cl' may be called at runtime,
so use
`(pushnew ,x ,place ,@plist))
(t `(add-to-list ',place ,x ,(plist-get plist ':test)))))
+;;;###autoload
+(defmacro ergoemacs-save-buffer-state (&rest body)
+ "Eval BODY,
+then restore the buffer state under the assumption that no significant
+modification has been made in BODY. A change is considered
+significant if it affects the buffer text in any way that isn't
+completely restored again. Changes in text properties like `face' or
+`syntax-table' are considered insignificant. This macro allows text
+properties to be changed, even in a read-only buffer.
+
+This macro should be placed around all calculations which set
+\"insignificant\" text properties in a buffer, even when the buffer is
+known to be writeable. That way, these text properties remain set
+even if the user undoes the command which set them.
+
+This macro should ALWAYS be placed around \"temporary\" internal buffer
+changes \(like adding a newline to calculate a text-property then
+deleting it again\), so that the user never sees them on his
+`buffer-undo-list'.
+
+However, any user-visible changes to the buffer \(like auto-newlines\)
+must not be within a `ergoemacs-save-buffer-state', since the user then
+wouldn't be able to undo them.
+
+The return value is the value of the last form in BODY.
+
+This was stole/modified from `c-save-buffer-state'"
+ `(let* ((modified (buffer-modified-p)) (buffer-undo-list t)
+ (inhibit-read-only t) (inhibit-point-motion-hooks t)
+ before-change-functions after-change-functions
+ deactivate-mark
+ buffer-file-name buffer-file-truename ; Prevent primitives checking
+ ; for file modification
+ )
+ (unwind-protect
+ (progn ,@body)
+ (and (not modified)
+ (buffer-modified-p)
+ (set-buffer-modified-p nil)))))
+
+
(provide 'ergoemacs-macros)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ergoemacs-macros.el ends here
diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el
index 21036aa..8bb51cf 100644
--- a/ergoemacs-shortcuts.el
+++ b/ergoemacs-shortcuts.el
@@ -1743,10 +1743,11 @@ Setup C-c and C-x keys to be described properly.")
(when (and (previous-single-property-change (point) 'keymap)
(next-single-property-change (point) 'keymap))
;; (ergoemacs-debug "Put into text properties")
- (put-text-property
- (previous-single-property-change (point) 'keymap)
- (next-single-property-change (point) 'keymap)
- 'keymap override-text-map)))
+ (ergoemacs-save-buffer-state
+ (put-text-property
+ (or (previous-single-property-change (point) 'keymap
(current-buffer) (point-min)) (point-min))
+ (or (next-single-property-change (point) 'keymap
(current-buffer) (point-max)) (point-max))
+ 'keymap override-text-map))))
(setq tmp-overlay (make-overlay (max (- (point) 1) (point-min))
(min (+ (point) 1) (point-max))))
(overlay-put tmp-overlay 'keymap lookup)
@@ -1879,11 +1880,11 @@ The keymaps are:
(overlay-put found 'keymap override-text-map)
;; Overlay not found; change text property
;; (ergoemacs-debug "Put into text properties")
- (put-text-property
- (previous-single-property-change (point) 'keymap)
- (next-single-property-change (point) 'keymap)
- 'keymap
- override-text-map))
+ (ergoemacs-save-buffer-state
+ (put-text-property
+ (or (previous-single-property-change (point) 'keymap
(current-buffer) (point-min)) (point-min))
+ (or (next-single-property-change (point) 'keymap (current-buffer)
(point-max)) (point-max))
+ 'keymap override-text-map)))
;; (ergoemacs-debug-keymap 'override-text-map)
)))))
- [elpa] 211/287: Add send outlook files to emacs, (continued)
- [elpa] 211/287: Add send outlook files to emacs, Matthew Fidler, 2014/07/02
- [elpa] 213/287: Merge branch 'master' of github.com:ergoemacs/ergoemacs-mode, Matthew Fidler, 2014/07/02
- [elpa] 215/287: Merge pull request #245 from bmalehorn/programmer-dv, Matthew Fidler, 2014/07/02
- [elpa] 214/287: fix incorrect ergoemacs-layout-programmer-dv, Matthew Fidler, 2014/07/02
- [elpa] 212/287: modified ergoemacs-cut-all so it doesn't join previous cut., Matthew Fidler, 2014/07/02
- [elpa] 216/287: Drop FIXME, Matthew Fidler, 2014/07/02
- [elpa] 223/287: Remove archive-mode and ses-mode from menus. Issue #246., Matthew Fidler, 2014/07/02
- [elpa] 217/287: Fix image generation and autohotkey generation, Matthew Fidler, 2014/07/02
- [elpa] 220/287: Partial Fix for Issue #243, Matthew Fidler, 2014/07/02
- [elpa] 222/287: Merge branch 'master' of github.com:ergoemacs/ergoemacs-mode, Matthew Fidler, 2014/07/02
- [elpa] 221/287: Be more careful with links. Issue #247,
Matthew Fidler <=
- [elpa] 225/287: Added disabling to redo based on undo-tree-mode, Matthew Fidler, 2014/07/02
- [elpa] 218/287: Merge branch 'master' of github.com:ergoemacs/ergoemacs-mode, Matthew Fidler, 2014/07/02
- [elpa] 231/287: Change layout descriptions, Matthew Fidler, 2014/07/02
- [elpa] 229/287: Fix order of operations, Matthew Fidler, 2014/07/02
- [elpa] 226/287: Remove default redo keys; Possibly Fix Issue #242, Matthew Fidler, 2014/07/02
- [elpa] 224/287: Make undo-tree the default undo method and installed when ergoemacs-mode is installed. Issue #242, Matthew Fidler, 2014/07/02
- [elpa] 228/287: Add `cua-rect` require so that tests pass, Matthew Fidler, 2014/07/02
- [elpa] 219/287: `ergoemacs-select-text-in-quote' can now deal with escaped quote in string., Matthew Fidler, 2014/07/02
- [elpa] 233/287: Change the default option back, Matthew Fidler, 2014/07/02
- [elpa] 230/287: Fix `ergoemacs-beginning-of-line-or-what` and `ergoemacs-end-of-line-or-what`, Matthew Fidler, 2014/07/02