From 7d58378a49ceb08c9fc7fb025564564c43656d82 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 16 Jul 2017 13:07:57 -0400 Subject: [PATCH 1/3] Correct emacs25 byte-compile warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Byte compiling the file in emacs25 generated a number of warnings, most due the use of obsolete functions, one due to use of an obsolete library, and one due to a face being used as a variable. One of the warnings, about the use function `toggle-read-only', I wasn't sure how to solve because I wasn't sure what the function was exactly doing. Here are the compile warnings: post.el:275:1:Warning: cl package required at runtime In post-font-lock-syntactic-face-function: post.el:675:1:Warning: reference to free variable ‘post-signature-text-face’ In post-el-random-signature: post.el:868:13:Warning: Use ‘with-current-buffer’ rather than save-excursion+set-buffer post.el:855:20:Warning: ‘insert-file’ is for interactive use only; use ‘insert-file-contents’ instead. post.el:856:20:Warning: ‘beginning-of-buffer’ is for interactive use only; use ‘(goto-char (point-min))’ instead. In post-select-signature-from-file: post.el:882:4:Warning: ‘insert-file’ is for interactive use only; use ‘insert-file-contents’ instead. In post-select-signature-from-dir: post.el:926:18:Warning: ‘toggle-read-only’ is an obsolete function (as of 24.3); use ‘read-only-mode’ instead. In post-select-signature-select-sig-from-dir: post.el:941:17:Warning: ‘insert-file’ is for interactive use only; use ‘insert-file-contents’ instead. In post-mode: post.el:1123:9:Warning: ‘flet’ is an obsolete macro (as of 24.3); use either ‘cl-flet’ or ‘cl-letf’. post.el:1137:7:Warning: ‘not-modified’ is for interactive use only; use ‘set-buffer-modified-p’ instead. In header-references-length: post.el:1326:66:Warning: ‘interactive-p’ is an obsolete function (as of 23.2); use ‘called-interactively-p’ instead. --- post.el | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/post.el b/post.el index 06525a1..ab4fdd9 100644 --- a/post.el +++ b/post.el @@ -1,5 +1,5 @@ ;; post.el --- Use (X?)Emacs(client) as an external editor for mail and news. - + ;;; Authors: Eric Kidd , ;;; Dave Pearson , ;;; Rob Reid , @@ -272,7 +272,7 @@ ;;; ;;; Required Packages -(require 'cl) +(require 'cl-lib) (require 'derived) (require 'easymenu) @@ -321,7 +321,7 @@ ;; (fset 'post-finish 'gnuserv-kill-buffer-function)) ;; (t ;; (fset 'post-finish 'save-buffers-kill-emacs))) - + ;; If customize isn't available just use defvar instead. (unless (fboundp 'defgroup) (defmacro defgroup (&rest rest) nil) @@ -579,6 +579,9 @@ comment-region" "Face used for text that is part of a signature" :group 'post-faces) +(defvar post-signature-text-face 'post-signature-text-face + "Face name to use for text that is part of a signature") + (defface post-email-address-text-face '((((class color) (background light)) @@ -851,10 +854,10 @@ the signatures in `post-variable-signature-source' must be separated by `post-signature-sep-regexp'." (interactive) (let ((sig nil)) - (save-excursion - (set-buffer (generate-new-buffer "*Post-Select-Signature*")) - (insert-file post-variable-signature-source) - (beginning-of-buffer) + (with-current-buffer + (generate-new-buffer "*Post-Select-Signature*") + (insert-file-contents post-variable-signature-source) + (goto-char (point-min)) ;; we have 2 lists of marks since seperators are of arbitrary lenght (let ((marks-st (list (point-min))) (marks-end (list)) @@ -880,7 +883,7 @@ the signatures in `post-variable-signature-source' must be separated by (setq post-select-signature-last-buffer (current-buffer)) (setq post-select-signature-last-point (point)) (pop-to-buffer "*Post-Select-Signature*") - (insert-file post-variable-signature-source) + (insert-file-contents post-variable-signature-source) (use-local-map post-select-signature-mode-map)) (defun post-select-signature-select-sig-from-file () @@ -940,7 +943,7 @@ the signatures in `post-variable-signature-source' must be separated by (switch-to-buffer post-select-signature-last-buffer) (goto-char (post-kill-signature)) (insert "-- \n") - (insert-file (concat post-signature-directory sig-to-load)) + (insert-file-contents (concat post-signature-directory sig-to-load)) (message "Signature set to %s%s" post-signature-directory sig-to-load) (post-select-signature-quit))) @@ -975,7 +978,7 @@ the signatures in `post-variable-signature-source' must be separated by (defun post-body-says-attach-p () "Check if attach appears in the body." (post-goto-body) - + ;; Aargh it's annoying that how-many returns a string, ;; "13 occurences" instead of a number, 13. ;; As of Emacs 22 how-many returns an integer number. Consideration @@ -1110,7 +1113,7 @@ When you finish editing this message, type \\[post-save-current-buffer-and-exit] (if (boundp 'font-lock-defaults) (make-local-variable 'font-lock-defaults)) - (flet ((add-syntax-highlight (face regexps) + (cl-flet ((add-syntax-highlight (face regexps) (set face face) (nconc post-font-lock-keywords (loop for regexp in regexps @@ -1135,7 +1138,7 @@ When you finish editing this message, type \\[post-save-current-buffer-and-exit] ;; Kill quoted sig if so required. (cond (post-kill-quoted-sig (post-delete-quoted-signatures) - (not-modified))) + (set-buffer-modified-p nil))) ;; Remap signature selection functions according to whether the ;; signatures are stored in a file or directory. @@ -1160,7 +1163,7 @@ When you finish editing this message, type \\[post-save-current-buffer-and-exit] ;; Give the buffer a handy name. (if post-rename-buffer (setq post-buf (rename-buffer "*Composing*" t))) - + ;; If this is a news posting, check the length of the References field. (if (post-references-p) (header-check-references)) @@ -1322,7 +1325,7 @@ Optional argument SHOW Whether or not to display the length." (let* ((header "References") (refs (header-get-value header)) (len (+ (length header) (length refs) 2))) - (if (or (interactive-p) show) + (if (or (called-interactively-p "any") show) (message "References header is %d characters in length." len)) len)) From 4fd5c72453772312ba26c57340d8953104e30476 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 16 Jul 2017 15:22:17 -0400 Subject: [PATCH 2/3] Assure signature buffer always read-only-mode 1] Set the signature select buffer to read-only mode also in function `post-select-signature-from-file' 2] Replace use of the obsolete function `toggle-read-only' with function `read-only-mode' --- post.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/post.el b/post.el index ab4fdd9..f5da6c4 100644 --- a/post.el +++ b/post.el @@ -884,7 +884,8 @@ the signatures in `post-variable-signature-source' must be separated by (setq post-select-signature-last-point (point)) (pop-to-buffer "*Post-Select-Signature*") (insert-file-contents post-variable-signature-source) - (use-local-map post-select-signature-mode-map)) + (use-local-map post-select-signature-mode-map) + (read-only-mode t)) (defun post-select-signature-select-sig-from-file () "*Chooses the signature the cursor is in from `post-variable-signature-source'." @@ -927,7 +928,7 @@ the signatures in `post-variable-signature-source' must be separated by (kill-buffer "*Directory*") (pop-to-buffer "*Post-Select-Signature*") (use-local-map post-select-signature-mode-map) - (toggle-read-only t)) + (read-only-mode t)) (defun post-select-signature-select-sig-from-dir () "Set the signature in the calling buffer to the one under the cursor." From 30e58aec729bdd777d51e2811d4a148b7d5246f7 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 30 Jul 2017 16:39:12 -0400 Subject: [PATCH 3/3] evaluation of exit function needs to be made at runtime --- post.el | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/post.el b/post.el index f5da6c4..2e458c6 100644 --- a/post.el +++ b/post.el @@ -306,22 +306,6 @@ (defmacro string-read (prompt) `(read-string ,prompt nil nil nil t))) - ;; XEmacs gnuserv uses slightly different functions than the GNU Emacs - ;; server, and some people are still wasting time and CPU cycles by starting - ;; up a new emacs each time. - (fset 'post-finish (cond ((fboundp 'server-edit) - 'server-edit) - ((fboundp 'gnuserv-kill-buffer-function) - 'gnuserv-kill-buffer-function) - (t - 'save-buffers-kill-emacs))) -;; (cond ((fboundp 'server-edit) -;; (fset 'post-finish 'server-edit)) -;; ((fboundp 'gnuserv-kill-buffer-function) -;; (fset 'post-finish 'gnuserv-kill-buffer-function)) -;; (t -;; (fset 'post-finish 'save-buffers-kill-emacs))) - ;; If customize isn't available just use defvar instead. (unless (fboundp 'defgroup) (defmacro defgroup (&rest rest) nil) @@ -720,7 +704,14 @@ post-signature-text-face) (if post-backup-original (kill-buffer "*Original*")) - (post-finish) + (cond + ((fboundp 'server-edit) + (server-edit)) + ((fboundp 'gnuserv-kill-buffer-function) + (gnuserv-kill-buffer-function)) + (t + (save-buffers-kill-emacs))) + ;; Added by Rob Reid 10/13/1998 to prevent accumulating *Composing* buffers ;; when using (emacs|gnu)client. Helped by Eric Marsden's Eliza example in