[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/osm f830a5a54f 3/4: Improve error handling
From: |
ELPA Syncer |
Subject: |
[elpa] externals/osm f830a5a54f 3/4: Improve error handling |
Date: |
Fri, 11 Mar 2022 07:57:43 -0500 (EST) |
branch: externals/osm
commit f830a5a54f9a7510f3785fc33a57f7cf98cf7933
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve error handling
---
osm.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/osm.el b/osm.el
index d51d6a6cb5..7e8b4728dc 100644
--- a/osm.el
+++ b/osm.el
@@ -608,13 +608,20 @@ Should be at least 7 days according to the server usage
policies."
mwheel-scroll-left-function #'osm--zoom-out-wheel
mwheel-scroll-right-function #'osm--zoom-in-wheel
bookmark-make-record-function #'osm--make-bookmark)
- (add-hook 'change-major-mode-hook #'osm--barf-unsupported nil 'local)
- (add-hook 'write-contents-functions #'osm--barf-unsupported nil 'local)
+ (add-hook 'change-major-mode-hook #'osm--barf-change-mode nil 'local)
+ (add-hook 'write-contents-functions #'osm--barf-write nil 'local)
(add-hook 'window-size-change-functions #'osm--resize nil 'local))
-(defun osm--barf-unsupported ()
- "Barf for unsupported operation."
- (error "Operation is not supported"))
+(defun osm--barf-write ()
+ "Barf for write operation."
+ (set-buffer-modified-p nil)
+ (setq buffer-read-only t)
+ (set-visited-file-name nil)
+ (error "Writing the buffer to a file is not supported"))
+
+(defun osm--barf-change-mode ()
+ "Barf for change mode operation."
+ (error "Changing the major mode is not supported"))
(defun osm--barf-unless-osm ()
"Barf if not an `osm-mode' buffer."