Function: gnus-summary-edit-article-done

gnus-summary-edit-article-done is an interactive and byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-summary-edit-article-done &optional REFERENCES READ-ONLY BUFFER NO-HIGHLIGHT)

Documentation

Make edits to the current article permanent.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-summary-edit-article-done (&optional references read-only buffer
						 no-highlight)
  "Make edits to the current article permanent."
  (interactive nil gnus-summary-mode)
  (save-excursion
    ;; The buffer restriction contains the entire article if it exists.
    (when (article-goto-body)
      (let ((lines (count-lines (point) (point-max)))
	    (length (- (point-max) (point)))
	    (case-fold-search t)
	    (body (point-marker)))
	(goto-char (point-min))
	(when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
	  (delete-region (match-beginning 1) (match-end 1))
	  (insert (number-to-string length)))
	(goto-char (point-min))
	(when (re-search-forward
	       "^x-content-length:[ \t]\\([0-9]+\\)" body t)
	  (delete-region (match-beginning 1) (match-end 1))
	  (insert (number-to-string length)))
	(goto-char (point-min))
	(when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
	  (delete-region (match-beginning 1) (match-end 1))
	  (insert (number-to-string lines))))))
  ;; Replace the article.
  (let ((buf (current-buffer))
	(article (cdr gnus-article-current))
	replace-result)
    (with-temp-buffer
      (insert-buffer-substring buf)
      (if (and (not read-only)
	       (not (setq replace-result
			  (gnus-request-replace-article
			   article (car gnus-article-current)
			   (current-buffer) t))))
	  (error "Couldn't replace article")
	;; If we got a number back, then that's the new article number
	;; for this article.  Otherwise, the article number didn't change.
	(when (numberp replace-result)
	  (with-current-buffer gnus-summary-buffer
	    (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
	    (gnus-summary-limit gnus-newsgroup-limit)
	    (setq article replace-result)
	    (gnus-summary-goto-subject article t)))
	;; 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
		(nnheader-ms-strip-cr)
		(message-narrow-to-head)
		(let ((head (buffer-substring-no-properties
			     (point-min) (point-max)))
		      header)
		  (with-temp-buffer
		    (insert (format "211 %d Article retrieved.\n" article))
		    (insert head)
		    (insert ".\n")
		    (let ((nntp-server-buffer (current-buffer)))
		      (setq header (car (gnus-get-newsgroup-headers nil t))))
		    (with-current-buffer gnus-summary-buffer
		      (setf (gnus-data-header (gnus-data-find article)) header)
		      (gnus-summary-update-article-line article header)
		      (if (gnus-summary-goto-subject article nil t)
			  (gnus-summary-update-secondary-mark article)))))))
	  ;; Update threads.
	  (set-buffer (or buffer gnus-summary-buffer))
	  (gnus-summary-update-article article)
	  (if (gnus-summary-goto-subject article nil t)
	      (gnus-summary-update-secondary-mark article)))
	;; Prettify the article buffer again.
	(unless no-highlight
	  (with-current-buffer gnus-article-buffer
	    ;;!!! Fix this -- article should be rehighlighted.
	    ;;(gnus-run-hooks 'gnus-article-display-hook)
	    (set-buffer gnus-original-article-buffer)
	    (gnus-request-article
	     article (car gnus-article-current) (current-buffer))))
	;; Prettify the summary buffer line.
	(when (gnus-visual-p 'summary-highlight 'highlight)
	  (gnus-run-hooks 'gnus-visual-mark-article-hook))))))