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

* Re: patch: gnus-art,sum -- No save, if Edit didn't modify buffer
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Hrvoje Niksic @ 1997-11-25 16:06 UTC (permalink / raw)


<jari.aalto@poboxes.com> writes:

>     - 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.

Why don't you use `C-c C-k' when you decide you don't want to edit
stuff?  Just curious.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Unspeakable horrors from outer space paralyze the living and
resurrect the dead!


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

* Re: patch: gnus-art,sum -- No save, if Edit didn't modify buffer
  1997-11-25 16:06 ` Hrvoje Niksic
@ 1997-11-25 19:11   ` jari.aalto
  1997-11-26  4:13     ` Hrvoje Niksic
  0 siblings, 1 reply; 5+ messages in thread
From: jari.aalto @ 1997-11-25 19:11 UTC (permalink / raw)


|  97-11-25 Hrvoje Niksic <hniksic@srce.hr> list.ding
| 
| >     - 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.
| 
| Why don't you use `C-c C-k' when you decide you don't want to edit
| stuff?  Just curious.

For me the obvious selection was first to press C-c C-c t quit the
edit mode as in any other MUA (Like my old RMAIL). The Edit mode was
usually a key "mishit"(is that the word?): I really didn't want to
edit message, but press "E" to mark article expired. I have swapped
the keys now, but caps lock still suprises me from time to time.

When C-c C-c always saved a message; even unmodified one, I decided, that it 
would be more logical if it did nothing when user pressed C-c C-c
while visiting unmodified message. 

Actually after the patch, the code does update 
Gnus internal states, but there is no save any more. I left the
Gnus internal structure update untounched, because I wasn't sure If
that could be bypassed safely too.

jari


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

* Re: patch: gnus-art,sum -- No save, if Edit didn't modify buffer
  1997-11-25 19:11   ` jari.aalto
@ 1997-11-26  4:13     ` Hrvoje Niksic
  1997-11-26 17:42       ` Wes Hardaker
  0 siblings, 1 reply; 5+ messages in thread
From: Hrvoje Niksic @ 1997-11-26  4:13 UTC (permalink / raw)


<jari.aalto@poboxes.com> writes:

> | Why don't you use `C-c C-k' when you decide you don't want to edit
> | stuff?  Just curious.
> 
> For me the obvious selection was first to press C-c C-c t quit the
> edit mode as in any other MUA (Like my old RMAIL).

This selection is all but obvious in the Emacs tradition.  `C-c C-c'
sends the message (or does any other associated action) in all the
Emacs mailers I know of.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
ED WILL NOT CORRUPT YOUR PRECIOUS BODILY FLUIDS!!


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

* Re: patch: gnus-art,sum -- No save, if Edit didn't modify buffer
  1997-11-26  4:13     ` Hrvoje Niksic
@ 1997-11-26 17:42       ` Wes Hardaker
  0 siblings, 0 replies; 5+ messages in thread
From: Wes Hardaker @ 1997-11-26 17:42 UTC (permalink / raw)
  Cc: ding

>>>>> On 26 Nov 1997 05:13:14 +0100, Hrvoje Niksic <hniksic@srce.hr> said:

Hrvoje> This selection is all but obvious in the Emacs tradition.
Hrvoje> `C-c C-c' sends the message (or does any other associated
Hrvoje> action) in all the Emacs mailers I know of.

Of course, this can be a problem.  Ever tried to mail a quick note to
someone using /bin/mail?  I do this a whopping twice a year, and every
single time I do end up hitting C-c C-c to send it.  Opps.

-- 
"Ninjas aren't dangerous.  They're more afraid of you than you are of them."


^ 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).