From fc4cda07a9afbbb545dcc6cd835ca697f6ef2a1b Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Sun, 10 Jan 2021 15:00:47 +0100 Subject: [PATCH] emacs: use lexical-bindings in all libraries Doing so causes many new compile warnings. Some of these warnings concern genuine changes in behavior that have to be addressed right away. Many other warnings are due to unused variables. Nothing has changed here, except that the byte-compiler can now detect these pre-existing and harmless issues. We delay addressing these issues so that we can focus on the important ones here. A third group of warnings concern arguments that are not actually used inside the function but which cannot be removed because the functions signature is dictated by some outside convention. Silencing these warning is also delayed until subsequent commits. --- emacs/coolj.el | 2 +- emacs/make-deps.el | 2 +- emacs/notmuch-address.el | 2 +- emacs/notmuch-compat.el | 2 +- emacs/notmuch-crypto.el | 2 +- emacs/notmuch-draft.el | 2 +- emacs/notmuch-hello.el | 2 +- emacs/notmuch-jump.el | 2 +- emacs/notmuch-lib.el | 2 +- emacs/notmuch-maildir-fcc.el | 2 +- emacs/notmuch-message.el | 2 +- emacs/notmuch-mua.el | 7 ++++++- emacs/notmuch-parser.el | 2 +- emacs/notmuch-print.el | 2 +- emacs/notmuch-query.el | 2 +- emacs/notmuch-show.el | 6 +++++- emacs/notmuch-tag.el | 18 ++++++++++-------- emacs/notmuch-tree.el | 2 +- emacs/notmuch-wash.el | 2 +- emacs/notmuch.el | 2 +- emacs/rstdoc.el | 2 +- 21 files changed, 39 insertions(+), 28 deletions(-) diff --git a/emacs/coolj.el b/emacs/coolj.el index b3e314f0..d820525b 100644 --- a/emacs/coolj.el +++ b/emacs/coolj.el @@ -1,4 +1,4 @@ -;;; coolj.el --- automatically wrap long lines -*- coding:utf-8 -*- +;;; coolj.el --- automatically wrap long lines -*- lexical-binding: t; coding: utf-8 -*- ;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc. diff --git a/emacs/make-deps.el b/emacs/make-deps.el index a7699fb1..8c9e0a27 100644 --- a/emacs/make-deps.el +++ b/emacs/make-deps.el @@ -1,4 +1,4 @@ -;;; make-deps.el --- compute make dependencies for Elisp sources +;;; make-deps.el --- compute make dependencies for Elisp sources -*- lexical-binding: t -*- ;; ;; Copyright © Austin Clements ;; diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index bf29c3a0..6b117458 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -1,4 +1,4 @@ -;;; notmuch-address.el --- address completion with notmuch +;;; notmuch-address.el --- address completion with notmuch -*- lexical-binding: t -*- ;; ;; Copyright © David Edmondson ;; diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el index c4e07780..ad134dfe 100644 --- a/emacs/notmuch-compat.el +++ b/emacs/notmuch-compat.el @@ -1,4 +1,4 @@ -;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs +;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs -*- lexical-binding: t -*- ;; ;; The functions in this file are copied from more modern versions of ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017 diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index 6d2d35a5..ee5231e5 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -1,4 +1,4 @@ -;;; notmuch-crypto.el --- functions for handling display of cryptographic metadata +;;; notmuch-crypto.el --- functions for handling display of cryptographic metadata -*- lexical-binding: t -*- ;; ;; Copyright © Jameson Rollins ;; diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el index 9ce9e736..8af04598 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -1,4 +1,4 @@ -;;; notmuch-draft.el --- functions for postponing and editing drafts +;;; notmuch-draft.el --- functions for postponing and editing drafts -*- lexical-binding: t -*- ;; ;; Copyright © Mark Walters ;; Copyright © David Bremner diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 28ffedd9..586a2848 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -1,4 +1,4 @@ -;;; notmuch-hello.el --- welcome to notmuch, a frontend +;;; notmuch-hello.el --- welcome to notmuch, a frontend -*- lexical-binding: t -*- ;; ;; Copyright © David Edmondson ;; diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index 7a27b6b3..5dcec970 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -1,4 +1,4 @@ -;;; notmuch-jump.el --- User-friendly shortcut keys +;;; notmuch-jump.el --- User-friendly shortcut keys -*- lexical-binding: t -*- ;; ;; Copyright © Austin Clements ;; diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 0b698d59..7595bbe1 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -1,4 +1,4 @@ -;;; notmuch-lib.el --- common variables, functions and function declarations +;;; notmuch-lib.el --- common variables, functions and function declarations -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el index 5de03cc2..e880653c 100644 --- a/emacs/notmuch-maildir-fcc.el +++ b/emacs/notmuch-maildir-fcc.el @@ -1,4 +1,4 @@ -;;; notmuch-maildir-fcc.el --- inserting using a fcc handler +;;; notmuch-maildir-fcc.el --- inserting using a fcc handler -*- lexical-binding: t -*- ;; Copyright © Jesse Rosenthal ;; diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index c2242070..f0e9ffcc 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -1,4 +1,4 @@ -;;; notmuch-message.el --- message-mode functions specific to notmuch +;;; notmuch-message.el --- message-mode functions specific to notmuch -*- lexical-binding: t -*- ;; ;; Copyright © Jesse Rosenthal ;; diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 6fe5f6d0..d50fdb26 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -1,4 +1,4 @@ -;;; notmuch-mua.el --- emacs style mail-user-agent +;;; notmuch-mua.el --- emacs style mail-user-agent -*- lexical-binding: t -*- ;; ;; Copyright © David Edmondson ;; @@ -38,6 +38,11 @@ (declare-function notmuch-draft-postpone "notmuch-draft" ()) (declare-function notmuch-draft-save "notmuch-draft" ()) +(defvar notmuch-show-indent-multipart) +(defvar notmuch-show-insert-header-p-function) +(defvar notmuch-show-max-text-part-size) +(defvar notmuch-show-insert-text/plain-hook) + ;;; Options (defcustom notmuch-mua-send-hook nil diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el index 4a437016..b8c3fd2c 100644 --- a/emacs/notmuch-parser.el +++ b/emacs/notmuch-parser.el @@ -1,4 +1,4 @@ -;;; notmuch-parser.el --- streaming S-expression parser +;;; notmuch-parser.el --- streaming S-expression parser -*- lexical-binding: t -*- ;; ;; Copyright © Austin Clements ;; diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el index d7b2fcce..8da9a091 100644 --- a/emacs/notmuch-print.el +++ b/emacs/notmuch-print.el @@ -1,4 +1,4 @@ -;;; notmuch-print.el --- printing messages from notmuch +;;; notmuch-print.el --- printing messages from notmuch -*- lexical-binding: t -*- ;; ;; Copyright © David Edmondson ;; diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el index 72ddd2ce..ffce8814 100644 --- a/emacs/notmuch-query.el +++ b/emacs/notmuch-query.el @@ -1,4 +1,4 @@ -;;; notmuch-query.el --- provide an emacs api to query notmuch +;;; notmuch-query.el --- provide an emacs api to query notmuch -*- lexical-binding: t -*- ;; ;; Copyright © David Bremner ;; diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7dfbb327..72e21d94 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1,4 +1,4 @@ -;;; notmuch-show.el --- displaying notmuch forests +;;; notmuch-show.el --- displaying notmuch forests -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; Copyright © David Edmondson @@ -59,6 +59,10 @@ (declare-function notmuch-read-query "notmuch" (prompt)) (declare-function notmuch-draft-resume "notmuch-draft" (id)) +(defvar shr-blocked-images) +(defvar gnus-blocked-images) +(defvar shr-content-function) + ;;; Options (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index 817ea99f..fa376b02 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -1,4 +1,4 @@ -;;; notmuch-tag.el --- tag messages within emacs +;;; notmuch-tag.el --- tag messages within emacs -*- lexical-binding: t -*- ;; ;; Copyright © Damien Cassou ;; Copyright © Carl Worth @@ -295,22 +295,24 @@ This can be used with `notmuch-tag-format-image-data'." (and (eq (string-match key tag) 0) (= (match-end 0) (length tag))))))) -(defun notmuch-tag--do-format (tag formatted-tag formats) +(defun notmuch-tag--do-format (bare-tag tag formats) "Apply a tag-formats entry to TAG." (cond ((null formats) ;; - Tag not in `formats', - formatted-tag) ;; the format is the tag itself. + tag) ;; the format is the tag itself. ((null (cdr formats)) ;; - Tag was deliberately hidden, nil) ;; no format must be returned (t ;; Tag was found and has formats, we must apply all the ;; formats. TAG may be null so treat that as a special case. - (let ((bare-tag tag) - (tag (copy-sequence (or formatted-tag "")))) + (let ((return-tag (copy-sequence (or tag "")))) (dolist (format (cdr formats)) - (setq tag (eval format))) - (if (and (null formatted-tag) (equal tag "")) + (setq return-tag + (eval format + `((bare-tag . ,bare-tag) + (tag . ,return-tag))))) + (if (and (null tag) (equal return-tag "")) nil - tag))))) + return-tag))))) (defun notmuch-tag-format-tag (tags orig-tags tag) "Format TAG according to `notmuch-tag-formats'. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 713b00da..1ed34801 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1,4 +1,4 @@ -;;; notmuch-tree.el --- displaying notmuch forests +;;; notmuch-tree.el --- displaying notmuch forests -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; Copyright © David Edmondson diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index f371cc4c..70eff637 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -1,4 +1,4 @@ -;;; notmuch-wash.el --- cleaning up message bodies +;;; notmuch-wash.el --- cleaning up message bodies -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; Copyright © David Edmondson diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 6a09dd38..ba9488ca 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -1,4 +1,4 @@ -;;; notmuch.el --- run notmuch within emacs +;;; notmuch.el --- run notmuch within emacs -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el index 4221f142..c7c13015 100644 --- a/emacs/rstdoc.el +++ b/emacs/rstdoc.el @@ -1,4 +1,4 @@ -;;; rstdoc.el --- help generate documentation from docstrings -*-lexical-binding: t-*- +;;; rstdoc.el --- help generate documentation from docstrings -*- lexical-binding: t -*- ;; Copyright (C) 2018 David Bremner