>From 3b5b2a942f14d6512a848cf6cafa4d8a7d5610de Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Mon, 11 Oct 2021 19:14:23 +0100 Subject: [PATCH] Fix byte-compilation warnings in nox builds * lisp/edmacro.el (edmacro-fix-menu-commands): Load mwheel to pacify undefined variable warnings in without-x builds. * lisp/mh-e/mh-compat.el: Declare image.el functions that are not preloaded in without-x builds. * lisp/mh-e/mh-utils.el (mh--with-image-load-path): New macro. (mh-logo-display): * lisp/mh-e/mh-tool-bar.el (mh-tool-bar-folder-buttons-init) (mh-tool-bar-letter-buttons-init): Use it to pacify byte-compilation warnings about image.el definitions not preloaded without-x. --- lisp/edmacro.el | 6 ++++++ lisp/mh-e/mh-compat.el | 4 ++++ lisp/mh-e/mh-tool-bar.el | 12 ++---------- lisp/mh-e/mh-utils.el | 37 ++++++++++++++++++++++++------------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/lisp/edmacro.el b/lisp/edmacro.el index e90b3a006e..a4eb574a4c 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -604,6 +604,12 @@ edmacro-sanitize-for-string (defun edmacro-fix-menu-commands (macro &optional noerror) (if (vectorp macro) (let (result) + ;; Not preloaded in without-x builds. + (require 'mwheel) + (defvar mouse-wheel-down-event) + (defvar mouse-wheel-left-event) + (defvar mouse-wheel-right-event) + (defvar mouse-wheel-up-event) ;; Make a list of the elements. (setq macro (append macro nil)) (dolist (ev macro) diff --git a/lisp/mh-e/mh-compat.el b/lisp/mh-e/mh-compat.el index 659c4354b1..37a12de075 100644 --- a/lisp/mh-e/mh-compat.el +++ b/lisp/mh-e/mh-compat.el @@ -89,9 +89,13 @@ 'mh-face-background (define-obsolete-function-alias 'mh-font-lock-add-keywords #'font-lock-add-keywords "29.1") +;; Not preloaded in without-x builds. +(declare-function image-load-path-for-library "image") (define-obsolete-function-alias 'mh-image-load-path-for-library #'image-load-path-for-library "29.1") +;; Not preloaded in without-x builds. +(declare-function image-search-load-path "image") (define-obsolete-function-alias 'mh-image-search-load-path #'image-search-load-path "29.1") diff --git a/lisp/mh-e/mh-tool-bar.el b/lisp/mh-e/mh-tool-bar.el index 805408cfc7..d199cdb872 100644 --- a/lisp/mh-e/mh-tool-bar.el +++ b/lisp/mh-e/mh-tool-bar.el @@ -213,11 +213,7 @@ mh-tool-bar-define ;; Tool bar initialization functions (defun mh-tool-bar-folder-buttons-init () (when (mh-buffer-exists-p 'mh-folder-mode) - (let* ((load-path (image-load-path-for-library "mh-e" - "mh-logo.xpm")) - (image-load-path (cons (car load-path) - (when (boundp 'image-load-path) - image-load-path)))) + (mh--with-image-load-path (setq mh-folder-tool-bar-map (let ((tool-bar-map (make-sparse-keymap))) ,@(nreverse folder-button-setter) @@ -236,11 +232,7 @@ mh-tool-bar-define tool-bar-map))))) (defun mh-tool-bar-letter-buttons-init () (when (mh-buffer-exists-p 'mh-letter-mode) - (let* ((load-path (image-load-path-for-library "mh-e" - "mh-logo.xpm")) - (image-load-path (cons (car load-path) - (when (boundp 'image-load-path) - image-load-path)))) + (mh--with-image-load-path (setq mh-letter-tool-bar-map (let ((tool-bar-map (make-sparse-keymap))) ,@(nreverse letter-button-setter) diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el index 93bc7f8d39..b64e6e49c1 100644 --- a/lisp/mh-e/mh-utils.el +++ b/lisp/mh-e/mh-utils.el @@ -119,24 +119,35 @@ mh-replace-string ;;; Logo Display +;;;###mh-autoload +(defmacro mh--with-image-load-path (&rest body) + "Load `image' and eval BODY with `image-load-path' set appropriately." + (declare (debug t) (indent 0)) + `(mh-do-in-gnu-emacs + ;; Not preloaded in without-x builds. + (require 'image) + (defvar image-load-path) + (declare-function image-load-path-for-library "image") + (let* ((load-path (image-load-path-for-library "mh-e" "mh-logo.xpm")) + (image-load-path (cons (car load-path) + (and (boundp 'image-load-path) + image-load-path)))) + ,@body))) + (defvar mh-logo-cache nil) ;;;###mh-autoload (defun mh-logo-display () "Modify mode line to display MH-E logo." - (mh-do-in-gnu-emacs - (let* ((load-path (image-load-path-for-library "mh-e" "mh-logo.xpm")) - (image-load-path (cons (car load-path) - (when (boundp 'image-load-path) - image-load-path)))) - (add-text-properties - 0 2 - `(display ,(or mh-logo-cache - (setq mh-logo-cache - (mh-funcall-if-exists - find-image '((:type xpm :ascent center - :file "mh-logo.xpm")))))) - (car mode-line-buffer-identification))))) + (mh--with-image-load-path + (add-text-properties + 0 2 + `(display ,(or mh-logo-cache + (setq mh-logo-cache + (mh-funcall-if-exists + find-image '(( :type xpm :ascent center + :file "mh-logo.xpm" )))))) + (car mode-line-buffer-identification)))) -- 2.33.0