From: Matthew Fidler <matthew.fidler@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 18014@debbugs.gnu.org
Subject: bug#18014: 24.3; Unused Lexical argument warning, when argument is used in a function...
Date: Mon, 14 Jul 2014 14:46:04 -0500 [thread overview]
Message-ID: <CAOmN8O4CKA+FGwv1S4AMz8Wb=jfDcAZAMB2w_BzErMPNGx7UGg@mail.gmail.com> (raw)
In-Reply-To: <83lhrv9an4.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 1407 bytes --]
Easy enough. Put these in a directory, say ~/emacs-bug-1801 and run the
following command:
emacs -Q --batch -L . --eval \
"(progn \
(setq byte-compile-error-on-warn t) \
(batch-byte-compile))" *.el
On Emacs 24.3 the following warning will occur:
In toplevel form:
bug.el:10:1:Warning: Unused lexical argument `key' *<<--- Incorrect; key is
a used lexical argument*
Wrote e:/EmacsPortable.App/Data/src/ergoemacs-mode/bug.elc
In toplevel form:
bug2.el:10:1:Warning: argument `_key' not left unused
*<<--- Correct; _key is a used lexical argument*Wrote
e:/EmacsPortable.App/Data/src/ergoemacs-mode/bug2.elc
Also on emacs 24.3, even though batch-byte-compile-error-on-warn is set to
t, it will ignore the errors, which is not what I expect when I set this
option.
On Emacs trunk (24.4) it will not ignore the error but cause the make to
fail.
Matt
Type the following
On Mon, Jul 14, 2014 at 11:18 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Mon, 14 Jul 2014 11:01:12 -0500
> > From: Matthew Fidler <matthew.fidler@gmail.com>
> > Cc: 18014@debbugs.gnu.org
> >
> > You probably downloaded the version with lexical binding disabled.
> >
> > Sorry, I should have linked to the version with lexical binding enabled.
>
> So how about posting a complete, self-contained recipe that could be
> used to reproduce the problem?
>
> TIA
>
[-- Attachment #1.2: Type: text/html, Size: 2237 bytes --]
[-- Attachment #2: bug.el --]
[-- Type: text/plain, Size: 7493 bytes --]
;;; -*- lexical-binding: t; byte-compile-error-on-warn: t -*-
(declare-function ergoemacs-translate-shifted "ergoemacs-translate.el")
(declare-function ergoemacs-pretty-key "ergoemacs-translate.el")
(declare-function ergoemacs-translation-install "ergoemacs-translate.el")
(defvar ergoemacs-translate-hash)
(defvar ergoemacs-shifted-assoc)
(defvar ergoemacs-translations)
(defvar ergoemacs-use-ergoemacs-key-descriptions)
(defun ergoemacs-translate (key)
"Translates KEY and returns a plist of the translations.
:shift-translated
S-a -> a
M-S-a -> M-a
C-S-a -> C-a
Anything without shift is nil.
All other translations are defined in `ergoemacs-translations'.
There are also :XXX-key and :XXX-pretty for actual key-strokes
and `ergoemacs-pretty-key' descriptions.
"
(let* ((ret (gethash key ergoemacs-translate-hash))
(orig-key key)
case-fold-search
only-key
shift-translated
(ergoemacs-use-ergoemacs-key-descriptions t)
shifted-key
unshifted-key)
(if ret ret
(unless (stringp key)
(setq key (key-description key)
orig-key key))
(cond
((string-match "\\(^<.+>$\\|SPC\\|DEL\\|ESC\\|RET\\|TAB\\)" key)
(setq only-key (replace-regexp-in-string "[CMS]-" "" key t))
(if (string-match "S-" key)
(setq shifted-key (replace-match "" t nil key))
(setq shifted-key (concat "S-" key))))
(t
(setq only-key (replace-regexp-in-string "^.*\\(.\\)$" "\\1" key t)
shifted-key (assoc only-key ergoemacs-shifted-assoc))
(when shifted-key
(setq shifted-key (cdr shifted-key)))))
(when (and (string-match "\\([A-Z]\\)$" key)
(not (string-match "\\<\\(SPC\\|DEL\\|ESC\\|RET\\|TAB\\)\\>" key)))
(setq key
(replace-match
(concat "S-" (downcase (match-string 1 key))) t t key)))
(when shifted-key
(setq unshifted-key only-key)
(unless (string-match "\\(^<.+>$\\|\\<SPC\\>\\|\\<DEL\\>\\|\\<ESC\\>\\|\\<RET\\>\\|\\<TAB\\>\\)" shifted-key)
(when (string-match "[A-Z]" shifted-key)
(setq shifted-key (concat "S-" (downcase shifted-key))))
(when (string-match "[A-Z]" unshifted-key)
(setq unshifted-key (concat "S-" (downcase unshifted-key))))))
(when (string-match "S-" key)
(setq shift-translated (replace-regexp-in-string "S-" "" key t)))
(if shift-translated
(progn
(setq ret (plist-put ret ':shift-translated (ergoemacs-translate-shifted shift-translated)))
(setq ret (plist-put ret ':shift-translated-key (read-kbd-macro (ergoemacs-translate-shifted shift-translated) t)))
(setq ret (plist-put ret ':shift-translated-pretty (ergoemacs-pretty-key shift-translated))))
(setq ret (plist-put ret ':shift-translated nil))
(setq ret (plist-put ret ':shift-translated-key nil))
(setq ret (plist-put ret ':shift-translated-pretty nil)))
(when shifted-key
(setq ret (plist-put ret ':shifted (ergoemacs-translate-shifted shifted-key)))
(setq ret (plist-put ret ':shifted-key (read-kbd-macro (ergoemacs-translate-shifted shifted-key) t)))
(setq ret (plist-put ret ':shifted-pretty (ergoemacs-pretty-key shifted-key))))
(when unshifted-key
(setq ret (plist-put ret ':unshifted (ergoemacs-translate-shifted unshifted-key)))
(setq ret (plist-put ret ':unshifted-key (read-kbd-macro (ergoemacs-translate-shifted unshifted-key) t)))
(setq ret (plist-put ret ':unshifted-pretty (ergoemacs-pretty-key unshifted-key))))
(setq ret (plist-put ret ':ctl (ergoemacs-translate-shifted
(concat "C-" unshifted-key))))
(setq ret (plist-put ret ':ctl-key (read-kbd-macro (plist-get ret ':ctl) t)))
(setq ret (plist-put ret ':ctl-pretty (ergoemacs-pretty-key (plist-get ret ':ctl))))
(setq ret (plist-put ret ':raw (ergoemacs-translate-shifted
(replace-regexp-in-string
"\\<[CSMS]-" "" key))))
(setq ret (plist-put ret ':raw-key (read-kbd-macro (plist-get ret ':raw) t)))
(setq ret (plist-put ret ':raw-pretty (ergoemacs-pretty-key
(plist-get ret ':raw))))
(if (assoc (plist-get ret ':raw) ergoemacs-shifted-assoc)
(progn
(setq ret (plist-put ret ':raw-shift
(ergoemacs-translate-shifted
(replace-regexp-in-string
"\\<[CSM]-" ""
(cdr (assoc (plist-get ret ':raw) ergoemacs-shifted-assoc))))))
(setq ret (plist-put ret ':raw-shift-key
(read-kbd-macro (plist-get ret ':raw-shift) t)))
(setq ret (plist-put ret ':raw-shift-pretty
(ergoemacs-pretty-key
(plist-get ret ':raw-shift)))))
(setq ret (plist-put ret ':raw-shift nil))
(setq ret (plist-put ret ':raw-shift-key nil))
(setq ret (plist-put ret ':raw-shift-pretty nil)))
(setq ret (plist-put ret ':alt (ergoemacs-translate-shifted
(concat "M-" unshifted-key))))
(setq ret (plist-put ret ':alt-key (read-kbd-macro (plist-get ret ':alt) t)))
(setq ret (plist-put ret ':alt-pretty (ergoemacs-pretty-key (plist-get ret ':alt))))
(when unshifted-key
(setq ret (plist-put ret ':alt-ctl (ergoemacs-translate-shifted
(concat "M-C-" unshifted-key))))
(setq ret (plist-put ret ':alt-ctl-key (read-kbd-macro (plist-get ret ':alt-ctl) t)))
(setq ret (plist-put ret ':alt-ctl-pretty (ergoemacs-pretty-key (plist-get ret ':alt-ctl)))))
(when shifted-key
(setq ret (plist-put ret ':ctl-shift (ergoemacs-translate-shifted
(concat "C-" shifted-key))))
(setq ret (plist-put ret ':ctl-shift-key (read-kbd-macro (plist-get ret ':ctl-shift) t)))
(setq ret (plist-put ret ':ctl-shift-pretty (ergoemacs-pretty-key (plist-get ret ':ctl-shift))))
(setq ret (plist-put ret ':alt-shift (ergoemacs-translate-shifted
(concat "M-" shifted-key))))
(setq ret (plist-put ret ':alt-shift-key (read-kbd-macro (plist-get ret ':alt-shift) t)))
(setq ret (plist-put ret ':alt-shift-pretty (ergoemacs-pretty-key (plist-get ret ':alt-shift))))
(setq ret (plist-put ret ':alt-ctl-shift (ergoemacs-translate-shifted
(concat "M-C-" shifted-key))))
(setq ret (plist-put ret ':alt-ctl-shift-key (read-kbd-macro (plist-get ret ':alt-ctl-shift) t)))
(setq ret (plist-put ret ':alt-ctl-shift-pretty (ergoemacs-pretty-key (plist-get ret ':alt-ctl-shift)))))
(maphash
(lambda(key plist)
(setq ret (ergoemacs-translation-install plist orig-key ret)))
ergoemacs-translations)
(puthash orig-key ret ergoemacs-translate-hash)
(puthash key ret ergoemacs-translate-hash)
ret)))
[-- Attachment #3: bug2.el --]
[-- Type: text/plain, Size: 7517 bytes --]
;;; -*- lexical-binding: t; byte-compile-error-on-warn: t -*-
(declare-function ergoemacs-translate-shifted "ergoemacs-translate.el")
(declare-function ergoemacs-pretty-key "ergoemacs-translate.el")
(declare-function ergoemacs-translation-install "ergoemacs-translate.el")
(defvar ergoemacs-translate-hash)
(defvar ergoemacs-shifted-assoc)
(defvar ergoemacs-translations)
(defvar ergoemacs-use-ergoemacs-key-descriptions)
(defun ergoemacs-translate (_key)
"Translates _KEY and returns a plist of the translations.
:shift-translated
S-a -> a
M-S-a -> M-a
C-S-a -> C-a
Anything without shift is nil.
All other translations are defined in `ergoemacs-translations'.
There are also :XXX-key and :XXX-pretty for actual key-strokes
and `ergoemacs-pretty-key' descriptions.
"
(let* ((ret (gethash _key ergoemacs-translate-hash))
(orig-key _key)
case-fold-search
only-key
shift-translated
(ergoemacs-use-ergoemacs-key-descriptions t)
shifted-key
unshifted-key)
(if ret ret
(unless (stringp _key)
(setq _key (key-description _key)
orig-key _key))
(cond
((string-match "\\(^<.+>$\\|SPC\\|DEL\\|ESC\\|RET\\|TAB\\)" _key)
(setq only-key (replace-regexp-in-string "[CMS]-" "" _key t))
(if (string-match "S-" _key)
(setq shifted-key (replace-match "" t nil _key))
(setq shifted-key (concat "S-" _key))))
(t
(setq only-key (replace-regexp-in-string "^.*\\(.\\)$" "\\1" _key t)
shifted-key (assoc only-key ergoemacs-shifted-assoc))
(when shifted-key
(setq shifted-key (cdr shifted-key)))))
(when (and (string-match "\\([A-Z]\\)$" _key)
(not (string-match "\\<\\(SPC\\|DEL\\|ESC\\|RET\\|TAB\\)\\>" _key)))
(setq _key
(replace-match
(concat "S-" (downcase (match-string 1 _key))) t t _key)))
(when shifted-key
(setq unshifted-key only-key)
(unless (string-match "\\(^<.+>$\\|\\<SPC\\>\\|\\<DEL\\>\\|\\<ESC\\>\\|\\<RET\\>\\|\\<TAB\\>\\)" shifted-key)
(when (string-match "[A-Z]" shifted-key)
(setq shifted-key (concat "S-" (downcase shifted-key))))
(when (string-match "[A-Z]" unshifted-key)
(setq unshifted-key (concat "S-" (downcase unshifted-key))))))
(when (string-match "S-" _key)
(setq shift-translated (replace-regexp-in-string "S-" "" _key t)))
(if shift-translated
(progn
(setq ret (plist-put ret ':shift-translated (ergoemacs-translate-shifted shift-translated)))
(setq ret (plist-put ret ':shift-translated-key (read-kbd-macro (ergoemacs-translate-shifted shift-translated) t)))
(setq ret (plist-put ret ':shift-translated-pretty (ergoemacs-pretty-key shift-translated))))
(setq ret (plist-put ret ':shift-translated nil))
(setq ret (plist-put ret ':shift-translated-key nil))
(setq ret (plist-put ret ':shift-translated-pretty nil)))
(when shifted-key
(setq ret (plist-put ret ':shifted (ergoemacs-translate-shifted shifted-key)))
(setq ret (plist-put ret ':shifted-key (read-kbd-macro (ergoemacs-translate-shifted shifted-key) t)))
(setq ret (plist-put ret ':shifted-pretty (ergoemacs-pretty-key shifted-key))))
(when unshifted-key
(setq ret (plist-put ret ':unshifted (ergoemacs-translate-shifted unshifted-key)))
(setq ret (plist-put ret ':unshifted-key (read-kbd-macro (ergoemacs-translate-shifted unshifted-key) t)))
(setq ret (plist-put ret ':unshifted-pretty (ergoemacs-pretty-key unshifted-key))))
(setq ret (plist-put ret ':ctl (ergoemacs-translate-shifted
(concat "C-" unshifted-key))))
(setq ret (plist-put ret ':ctl-key (read-kbd-macro (plist-get ret ':ctl) t)))
(setq ret (plist-put ret ':ctl-pretty (ergoemacs-pretty-key (plist-get ret ':ctl))))
(setq ret (plist-put ret ':raw (ergoemacs-translate-shifted
(replace-regexp-in-string
"\\<[CSMS]-" "" _key))))
(setq ret (plist-put ret ':raw-key (read-kbd-macro (plist-get ret ':raw) t)))
(setq ret (plist-put ret ':raw-pretty (ergoemacs-pretty-key
(plist-get ret ':raw))))
(if (assoc (plist-get ret ':raw) ergoemacs-shifted-assoc)
(progn
(setq ret (plist-put ret ':raw-shift
(ergoemacs-translate-shifted
(replace-regexp-in-string
"\\<[CSM]-" ""
(cdr (assoc (plist-get ret ':raw) ergoemacs-shifted-assoc))))))
(setq ret (plist-put ret ':raw-shift-key
(read-kbd-macro (plist-get ret ':raw-shift) t)))
(setq ret (plist-put ret ':raw-shift-pretty
(ergoemacs-pretty-key
(plist-get ret ':raw-shift)))))
(setq ret (plist-put ret ':raw-shift nil))
(setq ret (plist-put ret ':raw-shift-key nil))
(setq ret (plist-put ret ':raw-shift-pretty nil)))
(setq ret (plist-put ret ':alt (ergoemacs-translate-shifted
(concat "M-" unshifted-key))))
(setq ret (plist-put ret ':alt-key (read-kbd-macro (plist-get ret ':alt) t)))
(setq ret (plist-put ret ':alt-pretty (ergoemacs-pretty-key (plist-get ret ':alt))))
(when unshifted-key
(setq ret (plist-put ret ':alt-ctl (ergoemacs-translate-shifted
(concat "M-C-" unshifted-key))))
(setq ret (plist-put ret ':alt-ctl-key (read-kbd-macro (plist-get ret ':alt-ctl) t)))
(setq ret (plist-put ret ':alt-ctl-pretty (ergoemacs-pretty-key (plist-get ret ':alt-ctl)))))
(when shifted-key
(setq ret (plist-put ret ':ctl-shift (ergoemacs-translate-shifted
(concat "C-" shifted-key))))
(setq ret (plist-put ret ':ctl-shift-key (read-kbd-macro (plist-get ret ':ctl-shift) t)))
(setq ret (plist-put ret ':ctl-shift-pretty (ergoemacs-pretty-key (plist-get ret ':ctl-shift))))
(setq ret (plist-put ret ':alt-shift (ergoemacs-translate-shifted
(concat "M-" shifted-key))))
(setq ret (plist-put ret ':alt-shift-key (read-kbd-macro (plist-get ret ':alt-shift) t)))
(setq ret (plist-put ret ':alt-shift-pretty (ergoemacs-pretty-key (plist-get ret ':alt-shift))))
(setq ret (plist-put ret ':alt-ctl-shift (ergoemacs-translate-shifted
(concat "M-C-" shifted-key))))
(setq ret (plist-put ret ':alt-ctl-shift-key (read-kbd-macro (plist-get ret ':alt-ctl-shift) t)))
(setq ret (plist-put ret ':alt-ctl-shift-pretty (ergoemacs-pretty-key (plist-get ret ':alt-ctl-shift)))))
(maphash
(lambda(_key plist)
(setq ret (ergoemacs-translation-install plist orig-key ret)))
ergoemacs-translations)
(puthash orig-key ret ergoemacs-translate-hash)
(puthash _key ret ergoemacs-translate-hash)
ret)))
next prev parent reply other threads:[~2014-07-14 19:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 12:25 bug#18014: 24.3; Unused Lexical argument warning, when argument is used in a function Matthew Fidler
2014-07-14 12:28 ` Matthew Fidler
2014-07-14 14:47 ` Eli Zaretskii
[not found] ` <CAOmN8O5ROfi5W44fBJe=sUs28TR1CDVQ2hWZoU0D4BTOGmKESg@mail.gmail.com>
2014-07-14 14:58 ` bug#18014: Fwd: " Matthew Fidler
2014-07-14 15:30 ` Eli Zaretskii
2014-07-14 15:46 ` Matthew Fidler
2014-07-14 15:47 ` Matthew Fidler
2014-07-14 16:01 ` Matthew Fidler
2014-07-14 16:18 ` Eli Zaretskii
2014-07-14 19:46 ` Matthew Fidler [this message]
2014-07-15 14:18 ` Eli Zaretskii
2014-07-14 16:17 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOmN8O4CKA+FGwv1S4AMz8Wb=jfDcAZAMB2w_BzErMPNGx7UGg@mail.gmail.com' \
--to=matthew.fidler@gmail.com \
--cc=18014@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).