Gnus development mailing list
 help / color / mirror / Atom feed
* patch: gnus-art,sum -- No save, if Edit didn't modify buffer
@ 1997-11-25 10:32 jari.aalto
  1997-11-25 16:06 ` Hrvoje Niksic
  0 siblings, 1 reply; 5+ messages in thread
From: jari.aalto @ 1997-11-25 10:32 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 398 bytes --]



    Hi,

    - Whwn I edit buffer and I decide that was a mistake, I press
      C-c C-c to end the edit. 
    - Gnus however writes the buffer back whether the buffer was
      modified or not.

    The following patch writes the buffer only if buffer was modified.
    gnus-sum patch's + marks are mostly due to changed indentation,
    the changes are in the the `when' statement.

    jari



[-- Attachment #2: log --]
[-- Type: text/plain, Size: 440 bytes --]

Tue Nov 25 11:50:16 1997  Jari Aalto  <jari.aalto@poboxes.com>

	* gnus-art.el (gnus-article-edit-article): When going edit mode,
	clear the buffer modified flag.
	(gnus-article-edit-exit): Added modified-flag
	which keeps the modified state of the edit buffer

	* gnus-sum.el (gnus-summary-edit-article-done): Added
	`buffer-modified-p' test. Article is not written back to disk
	if buffer is unmodified. Now uses `when' instead of `if'



[-- Attachment #3: gnus-art.diff --]
[-- Type: application/octet-stream, Size: 1215 bytes --]

Prereq: 1.1

===================================================================
RCS file: RCS/gnus-art.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 1.1	1997/11/25 09:48:19
+++ 1.2	1997/11/25 10:25:34
@@ -2531,6 +2531,7 @@
     (gnus-configure-windows 'edit-article)
     (setq gnus-article-edit-done-function exit-func)
     (setq gnus-prev-winconf winconf)
+    (set-buffer-modified-p nil)
     (gnus-message 6 "C-c C-c to end edits")))
 
 (defun gnus-article-edit-done (&optional arg)
@@ -2552,12 +2553,19 @@
   "Exit the article editing without updating."
   (interactive)
   ;; We remove all text props from the article buffer.
-  (let ((buf (format "%s" (buffer-string)))
+  (let ((modified-flag (buffer-modified-p))
+	(buf (format "%s" (buffer-string)))
 	(curbuf (current-buffer))
 	(p (point))
 	(window-start (window-start)))
     (erase-buffer)
     (insert buf)
+    
+    ;;  Was the buffer modified before we cleared the properties?
+    ;;  --> preserve previous state.
+    (when (null modified-flag)
+      (set-buffer-modified-p nil))
+
     (let ((winconf gnus-prev-winconf))
       (gnus-article-mode)
       ;; The cache and backlog have to be flushed somewhat.

[-- Attachment #4: gnus-sum.diff --]
[-- Type: application/octet-stream, Size: 4028 bytes --]

Prereq: 1.1

===================================================================
RCS file: RCS/gnus-sum.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 1.1	1997/11/25 10:21:19
+++ 1.2	1997/11/25 10:25:09
@@ -7241,55 +7241,56 @@
   "Make edits to the current article permanent."
   (interactive)
   ;; Replace the article.
-  (if (and (not read-only)
-	   (not (gnus-request-replace-article
-		 (cdr gnus-article-current) (car gnus-article-current)
-		 (current-buffer))))
-      (error "Couldn't replace article")
-    ;; Update the summary buffer.
-    (if (and references
-	     (equal (message-tokenize-header references " ")
-		    (message-tokenize-header
-		     (or (message-fetch-field "references") "") " ")))
-	;; We only have to update this line.
-	(save-excursion
-	  (save-restriction
-	    (message-narrow-to-head)
-	    (let ((head (buffer-string))
-		  header)
-	      (nnheader-temp-write nil
-		(insert (format "211 %d Article retrieved.\n"
-				(cdr gnus-article-current)))
-		(insert head)
-		(insert ".\n")
-		(let ((nntp-server-buffer (current-buffer)))
-		  (setq header (car (gnus-get-newsgroup-headers
-				     (save-excursion
-				       (set-buffer gnus-summary-buffer)
-				       gnus-newsgroup-dependencies)
-				     t))))
-		(save-excursion
-		  (set-buffer gnus-summary-buffer)
-		  (gnus-data-set-header
-		   (gnus-data-find (cdr gnus-article-current))
-		   header)
-		  (gnus-summary-update-article-line
-		   (cdr gnus-article-current) header))))))
-      ;; Update threads.
-      (set-buffer (or buffer gnus-summary-buffer))
-      (gnus-summary-update-article (cdr gnus-article-current)))
-    ;; Prettify the article buffer again.
-    (unless no-highlight
+  (when (buffer-modified-p)		;Changed ?
+    (if (and (not read-only)
+	     (not (gnus-request-replace-article
+		   (cdr gnus-article-current) (car gnus-article-current)
+		   (current-buffer))))
+	(error "Couldn't replace article")))
+  ;; Update the summary buffer.
+  (if (and references
+	   (equal (message-tokenize-header references " ")
+		  (message-tokenize-header
+		   (or (message-fetch-field "references") "") " ")))
+      ;; We only have to update this line.
       (save-excursion
-	(set-buffer gnus-article-buffer)
-	(run-hooks 'gnus-article-display-hook)
-	(set-buffer gnus-original-article-buffer)
-	(gnus-request-article
-	 (cdr gnus-article-current)
-	 (car gnus-article-current) (current-buffer))))
-    ;; Prettify the summary buffer line.
-    (when (gnus-visual-p 'summary-highlight 'highlight)
-      (run-hooks 'gnus-visual-mark-article-hook))))
+	(save-restriction
+	  (message-narrow-to-head)
+	  (let ((head (buffer-string))
+		header)
+	    (nnheader-temp-write nil
+	      (insert (format "211 %d Article retrieved.\n"
+			      (cdr gnus-article-current)))
+	      (insert head)
+	      (insert ".\n")
+	      (let ((nntp-server-buffer (current-buffer)))
+		(setq header (car (gnus-get-newsgroup-headers
+				   (save-excursion
+				     (set-buffer gnus-summary-buffer)
+				     gnus-newsgroup-dependencies)
+				   t))))
+	      (save-excursion
+		(set-buffer gnus-summary-buffer)
+		(gnus-data-set-header
+		 (gnus-data-find (cdr gnus-article-current))
+		 header)
+		(gnus-summary-update-article-line
+		 (cdr gnus-article-current) header))))))
+    ;; Update threads.
+    (set-buffer (or buffer gnus-summary-buffer))
+    (gnus-summary-update-article (cdr gnus-article-current)))
+  ;; Prettify the article buffer again.
+  (unless no-highlight
+    (save-excursion
+      (set-buffer gnus-article-buffer)
+      (run-hooks 'gnus-article-display-hook)
+      (set-buffer gnus-original-article-buffer)
+      (gnus-request-article
+       (cdr gnus-article-current)
+       (car gnus-article-current) (current-buffer))))
+  ;; Prettify the summary buffer line.
+  (when (gnus-visual-p 'summary-highlight 'highlight)
+    (run-hooks 'gnus-visual-mark-article-hook)))
 
 (defun gnus-summary-edit-wash (key)
   "Perform editing command in the article buffer."

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1997-11-26 17:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-25 10:32 patch: gnus-art,sum -- No save, if Edit didn't modify buffer jari.aalto
1997-11-25 16:06 ` Hrvoje Niksic
1997-11-25 19:11   ` jari.aalto
1997-11-26  4:13     ` Hrvoje Niksic
1997-11-26 17:42       ` Wes Hardaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).