From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Stephen Leake <stephen_leake@stephe-leake.org>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: change pcomplete/make to include targets in included files
Date: Sat, 14 Sep 2019 21:43:41 -0400 [thread overview]
Message-ID: <jwvd0g2pkfh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86muf7p5w7.fsf@stephe-leake.org> (Stephen Leake's message of "Sat, 14 Sep 2019 02:46:16 -0700")
Stephen Leake [2019-09-14 02:46:16] wrote:
> The patch below changes pcomplete/make to include targets in included
> files. The new user option pcmpl-gnu-makefile-includes allows disabling
> this.
>
> Ok to commit?
Sounds good to me, but see comments below.
> To make this actually work in the prompt for 'compile', I had to modify
> `shell-dynamic-complete-functions' to contain just
> `pcomplete-completions-at-point'; I have not figured out why yet.
I don't see this change in the patch (which I think is good), so
I assume you're waiting to figure it out before acting on it, right?
> +(defcustom pcmpl-gnu-makefile-includes t
> + "If non-nil, `pcomplete/make' includes targets in included files."
> + :type 'boolean
> + :group 'pcmpl-gnu)
AFAICT the ":group 'pcmpl-gnu" is redundant here (as it is on the other
defcustoms in this file).
> + (let (targets)
> + (goto-char (point-min))
> + (while (re-search-forward
> + "^\\s-*\\([^\n#%.$][^:=\n]*\\)\\s-*:[^=]" nil t)
> + (setq
> + targets
> + (append (split-string
> + (buffer-substring-no-properties
> + (match-beginning 1) (match-end 1)))
> + targets)))
I see you replaced (match-string 1) with
(buffer-substring-no-properties (match-beginning 1) (match-end 1)).
I think dropping text-properties is OK, but you can do it with
(match-string-no-properties 1).
Other than dropping properties, you can also optimize the code using
`nconc` instead of `append`.
> + (while (search-forward-regexp "^include +\\(.*\\)$" nil t)
> + (push (buffer-substring-no-properties
> + (match-beginning 1) (match-end 1))
> + filenames)
> + (forward-line 1))
Same here, and I think the forward-line is not needed.
> +(defun pcmpl-gnu-make-all-targets (makefile)
> + "Return a list of target names in MAKEFILE and all included files."
> + (with-temp-buffer
> + (ignore-errors ;Could be a directory or something.
> + (insert-file-contents makefile))
I think we could use `with-demoted-errors` here, since the error case
should only occur in cases where there's really something odd which the
user may want to be know about.
> + (let ((filenames (when pcmpl-gnu-makefile-includes (pcmpl-gnu-make-includes)))
> + (targets (pcmpl-gnu-make-targets)))
> + (dolist (file filenames)
> + (when (file-readable-p file)
> + (setq targets (append (pcmpl-gnu-make-all-targets file) targets))))
> + targets)))
You can completely eliminate this `append` by passing the `targets`
argument as an additional arg to pcmpl-gnu-make-all-targets (itself
passed to pcmpl-gnu-make-targets).
Stefan
next prev parent reply other threads:[~2019-09-15 1:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-14 9:46 change pcomplete/make to include targets in included files Stephen Leake
2019-09-14 10:08 ` Eli Zaretskii
2019-09-14 10:57 ` Eli Zaretskii
2019-09-14 22:04 ` Stephen Leake
2019-09-14 22:03 ` Stephen Leake
2019-09-15 1:43 ` Stefan Monnier [this message]
2019-09-15 19:50 ` Stephen Leake
2019-09-15 20:56 ` Stefan Monnier
2019-09-16 23:33 ` Stephen Leake
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvd0g2pkfh.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=stephen_leake@stephe-leake.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.