zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: completion for compilers (cc, gcc...) and -o
Date: Thu, 30 Apr 2020 22:17:47 +0200	[thread overview]
Message-ID: <20200430201747.GA818727@zira.vinc17.org> (raw)
In-Reply-To: <20200430181459.051d3fd1@tarpaulin.shahaf.local2>

On 2020-04-30 18:14:59 +0000, Daniel Shahaf wrote:
> Vincent Lefevre wrote on Thu, 30 Apr 2020 10:51 +0200:
> > The -o option is currently handled by
> > 
> >   '-o:output file:_files -g "^*.(c|h|cc|C|cxx)(-.)"'
> > 
> > I wonder whether .i files (preprocessed files, e.g. for bug reports)
> > should be excluded too. One can choose such files for output with
> > "gcc -E", but:
> >   * in this case, one generally chooses to use the shorter ">" (or a
> >     pipe) rather than "-o" (gcc -E file.c > file.i);
> 
> I don't see how the existence of other ways to create .i files is
> a reason not to complete .i files after -o.

I've googled a bit, and most examples with -E and storage in a file
used the redirection. BTW, all examples used the -E first, so perhaps
accept .i files for -o only when -E is present.

Note that GCC describes .i files as source files (among other
extensions of source files).

> >   * using such files as a source may be more common.
> 
> Assuming so arguendo, how does that bear on what the completion function should do?
> 
> > Moreover, if I have a C source "myprogram.c", I generally want the
> > output file (program name) to be "myprogram", or if I need several
> > versions (e.g. because I test several options), I choose this as a
> > prefix, e.g. for "myprogram1", "myprogram2", "myprogram-ok", etc.
> > Now, when "myprogram.c" exists, but not any of the program files,
> > and I try to complete with
> > 
> >   cc -o my[TAB]
> > 
> > I'd like the "myprogram" to be taken into account.
> > 
> > Currently it seems that if there are no matches without the excluded
> > pattern, the completion is done on all files, that is, one gets
> > 
> >   cc -o myprogram.c
> > 
> > This does not make any sense since a .c file should normally not be
> > an output file. IMHO, instead of that, one should get the filename
> > without the filename extension:
> > 
> >   cc -o myprogram
> 
> Offering basenames seems rather like your own personal preference, not
> something that the completion system should assume everybody does.
> However, refraining from offering .c files when there are no non-.c
> files around is probably a good idea.

Actually, many people do this (for compiling individual source
files, otherwise for multi-source projects, a Makefile is used
in general). But it's true that the output file may not be one
that is the basename of a source file. I think of 2 possibilities
(perhaps this should be configurable by the user) for -o:

1. For the completion, consider all existing non-source items
   (files and directories) + the basename of each source file.

2. Consider all existing non-source items, and if there are no
   candidates for the completion, then consider the basename of
   each source file.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

  reply	other threads:[~2020-04-30 20:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30  8:51 Vincent Lefevre
2020-04-30 17:57 ` Bart Schaefer
2020-04-30 18:14 ` Daniel Shahaf
2020-04-30 20:17   ` Vincent Lefevre [this message]
2020-04-30 20:32     ` Bart Schaefer
2020-04-30 20:54       ` Vincent Lefevre
2020-04-30 22:34         ` Daniel Shahaf
2020-04-30 22:36           ` Daniel Shahaf
2020-04-30 23:07             ` Bart Schaefer
2020-04-30 22:05     ` Daniel Shahaf
2020-05-01  1:11       ` Vincent Lefevre
2020-05-02  0:43         ` Daniel Shahaf
2020-05-02  1:26           ` Bart Schaefer
2020-05-03 23:17           ` Vincent Lefevre
2020-05-04 23:58             ` Daniel Shahaf

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=20200430201747.GA818727@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=zsh-workers@zsh.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.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).