emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode ecfee1c 1/2: Disable buffer-read-only if pos


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode ecfee1c 1/2: Disable buffer-read-only if possible
Date: Thu, 22 Jul 2021 04:57:18 -0400 (EDT)

branch: elpa/markdown-mode
commit ecfee1ce78a98519352c7d9704ec4a80a047b3ef
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>

    Disable buffer-read-only if possible
---
 CHANGES.md             |  2 ++
 markdown-mode.el       |  3 +++
 tests/markdown-test.el | 10 +++++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 890ae1b..90b95d6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -32,6 +32,7 @@
     -   Add ability to resize inline image display 
(`markdown-toggle-inline-images`) without Imagemagick installed in the computer 
(emulating Org Mode)
     -   Support including braces around the language specification in GFM code 
blocks
     -   Improve `markdown-insert-{bold,italic}` when region starts with 
spaces[GH-613][]
+    -   Disable buffer-read-only if possible when markdown-mode is called 
[GH-622][]
 
 *   Bug fixes:
     -   Fix issue with `nil` being returned from 
`markdown-imenu-create-nested-index` [GH-578][]
@@ -74,6 +75,7 @@
   [gh-590]: https://github.com/jrblevin/markdown-mode/pull/590
   [gh-598]: https://github.com/jrblevin/markdown-mode/pull/598
   [gh-613]: https://github.com/jrblevin/markdown-mode/issues/613
+  [gh-622]: https://github.com/jrblevin/markdown-mode/issues/622
   [gh-625]: https://github.com/jrblevin/markdown-mode/issues/625
 
 # Markdown Mode 2.4
diff --git a/markdown-mode.el b/markdown-mode.el
index c5e4b17..0c77a40 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -9610,6 +9610,9 @@ rows and columns and the column alignment."
 ;;;###autoload
 (define-derived-mode markdown-mode text-mode "Markdown"
   "Major mode for editing Markdown files."
+  (when buffer-read-only
+    (when (or (not (buffer-file-name)) (file-writable-p (buffer-file-name)))
+      (setq-local buffer-read-only nil)))
   ;; Natural Markdown tab width
   (setq tab-width 4)
   ;; Comments
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 8416f88..f45d919 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -6768,6 +6768,14 @@ foo(bar=None)
     (markdown-test-string-gfm-view test-string
       (funcall test-func))))
 
+(ert-deftest test-markdown-view-mode/buffer-read-only ()
+  "Test disable buffer-read-only."
+  (markdown-test-string "foo"
+    (markdown-view-mode)
+    (should buffer-read-only)
+    (markdown-mode)
+    (should-not buffer-read-only)))
+
 ;;; Tests for electric pair
 
 (ert-deftest test-markdown-electric-pair-mode ()
@@ -6934,7 +6942,7 @@ title: asdasdasd
 "))))
 
 (ert-deftest test-markdown-table/disable-table-align ()
-  "Test table navigation."
+  "Test disable table alignment."
   (let ((input "| 12345 | 6 |
 | 7 | 8 |"))
     (markdown-test-string input



reply via email to

[Prev in Thread] Current Thread [Next in Thread]