I'm using autotools to build my project and I'd like to globally set AM_CPPFLAGS to -I$(top_srcdir)/include.
https://stackoverflow.com/a/325436/2592351 this answer helped me and I'm doing the "include $(top_srcdir)/include" hack and it works.
However I'd like to do the "AC_SUBST" way described there as it looks cleaner. The problem is when I add this to my configure.ac:
AC_SUBST([AM_CPPFLAGS], [-I$(top_srcdir)/include])
then $(top_srcdir) is expanded too soon and I get AM_CPPFLAGS = -I/include in subdir/Makefile{,.in}.
And I don't get how to escape it.
-I#top_srcdir#/include
-I\$(top_srcdir)/include
-I$$(top_srcdir)/include
all these failed for various reasons.
Please help. How should I write the AC_SUBST so $(top_srcdir) is not escaped before it gets to Makefile{,.in}? Or maybe I should use something other than AC_SUBST?
Don't set AM_CPPFLAGS in your configure.ac. If you find yourself repeating the same preamble in multiple Makefile.am you should be using non-recursive automake.
But in this particular case, you should get away with it if you do
AM_CPPFLAGS='-I$(top_srcdir)/include'
AC_SUBST([AM_CPPFLAGS])
Because then the string is set quoted in the bash variable, and afterward expanded as a literal. Using AC_SUBST to set it up, it gets quoted by "" which then causes $(top_srcdir) to be shell-expanded.
Related
I am writing a configure.ac script for gnu autotools. In my code I have some if test statements where I want to set flags based on the compiler name. My original test looked like this:
if test "x$NETCDF_FC" = xifort; then
but sometimes the compiler name is more complicated (e.g., mpifort, mpiifort, path prepended, etc...), and so I want to check if the string ifort is contained anywhere within the variable $NETCDF_FC.
As far as I can understand, to set up a comparison using a wildcard or regex, I cannot use test but instead need to use the double brackets [[ ]]. But when configure.ac is parsed by autoconf to create configure, square brackets are treated like quotes and so one level of them is stripped from the output. The only solution I could get to work is to use triple brackets in my configure.ac, like this:
if [[[ $NETCDF_FC =~ ifort ]]]; then
Am I doing this correctly? Would this be considered best practices for configure.ac or is there another way?
Use a case statement. Either directly as shell code:
case "$NETCDF_FC" in
*ifort*)
do_whatever
;;
*)
do_something_else
;;
esac
or as m4sh code:
AS_CASE([$NETCDF_FC],
[*ifort*], [do_whatever],
[do_something_else])
I would not want to rely on a shell capable of interpreting [[ ]] or [[[ ]]] being present at configure runtime (you need to escape those a bit with [] to have the double or triple brackets make it into configure).
If you need a character class within a case pattern (such as e.g. *[a-z]ifort*), I would advise you to check the generated configure file for the case statement patterns which actually end up being used until you have enough [] quotes added around the pattern in the source configure.ac file.
Note that the explicit case statements often contain # ( shell comments at the end of the lines directly before the ) patterns to avoid editors becoming confused about non-matching opening/closing parentheses.
Just as title says, I want matchpairs option to work with with the signs '¿' and '?'. It works with other signs, for example after setting:
I'm able to jump between spanish exclamation marks ('¡' and '!') with just pressing '%'. The problem comes when doing the same with questions marks by:'
I will obtain a error message explaining some kind of function failing dealing with regex:
At first sight, the function would seem to come from one of my plugins so I tried to find which by replacing my .vimrc with a blank file but vim continued showing the same error so my personal plugins are not the problem.
As far as I know, when using nocompatible mode in vim several integrated plugins are charged. I think some of those plugins is the guilty, because when I call vim without any config fail by "vim -u NONE" the problem disappears. However, anyone here would be with me in that using no config file would be a little unpleasant.
Then my questions are:
What is the easiest way to solve this problem?
What is causing it? Is really something related with regular expressions (I have tried placing a '\' before the '?' without results)'?
You could use matchit plugin (which most likely is already installed in your computer as the function causing the error, Match_wrapper(), is defined on matchit.vim. To check if matchit.vim is loaded, use the command :scriptnames in Vim). Then add this auto command to .vimrc:
autocmd! BufWinEnter,BufEnter * if exists("b:match_words") |
\ let b:match_words=b:match_words.',¿:?' |
\ endif
To keep .vimrc clean you may want to follow the advice on help :matchit:
... you can add autocommands to the script or to your vimrc file, but the recommended method is to add a line such as
let b:match_words = '\<foo\>:\<bar\>'
to the filetype-plugin for your language.
Background
This relates to an older stackoverflow question. I was hoping to ask for more details but haven't got the Reputation to write comments yet.
Circumstances are the same: I'm adding codecheck warnings that I want to ignore, by editing the "IgnoredCodeIssues" section of Omnisharp's config.json file.
The question
What wildcard/regexp characters work here and how? Is it perhaps a known standard with its own docs somewhere that I can read?
Example
If I enter an issue warning verbatim it works, but it would be way more efficient to use wildcards. For example this warning:
Method 'Update' has the same with 'Start'
is a warning I don't care about and it's going to pop up a lot. A good solution would be to configure it to work for all instances of this issue, i.e. to use wildcards at the 'Update' and 'Start' parts.
Using a typical regexp it would look like this:
/(Method)\s'\w+'\shas the same with\s'\w+'/g
but that's obviously not the syntax here and would just break the config file. So I'm hoping to understand the particular syntax of wildcards in this particular file.
More details
I use Omnisharp-sublime and Sublime Text 3.
I've read the docs and rummaged around the GitHub page (no links as my reputation is too low for 2+ links) but the only relevant information is an example config file with a couple of ignored issues:
"IgnoredCodeIssues": [
"^Keyword 'private' is redundant. This is the default modifier.$",
".* should not separate words with an underscore.*"
],
EDIT:
Using
"Method '.*.' has the same with.*",
(note the .*.) makes the warnings go away but I have no idea if there are side-effects or other consequences like hiding warnings that I might do want to be notified of. Is there anyone who has seen wildcard expansions like that before? Would be great to be able to look it up and study it before adding more to my config.json
Based on the examples in the config file, you should just use standard regex inside double quotes. Don't use the Perl style of /regex/replace/options. config.json is read by the OmniSharp server, which is written in C#, so if you're looking to do anything fancy with your regexes, make sure they're C#-compatible.
So, for instance, your example regex would look like this:
"(Method)\s'\w+'\shas the same with\s'\w+'"
In building a C++ project with the GNU tool chain, make tells me ~
src/Adapter_FS5HyDE.d:1: *** multiple target patterns. Stop.
Search, search, search, and I found out that make thinks that it has multiple targets because the path to my included headers has spaces in it. If you've got your headers stored in some sane place like C:\Program Files then you can take care of this by using the old DOS paths (e.g. C:\PROGRA~1). However, when you have your headers in a truly insane place like My Documents you can get around the problem with MY DOC~1 because there's still a space.
Any idea how to tell my compiler to look in My Documents for headers without make confusing the path as two objects?
(Note: Feel free to throw tomatoes at me for putting header files in My Documents if you'd like, but there is a little rationale for doing that which I don't feel like explaining. If the solution to this question is easy, I'd rather keep it the way it is.)
You can figure out what the old path is by doing a DIR /X in your command prompt.
Or, most of the time you can fake it with the first 6 characters - spaces + ~1 + extension (8.3 paths won't have spaces).
Or, you can use quotes: "C:\Documents and Settings\Administrator\My Documents".
I don't know about make specficially, but the normal way around this is to put quotes around the path i.e.
cd "C:\Program Files\"
does that work?
Side note: the short name (8.3) for the same folder might not be the same on different OS installations. Thus, you can't be sure that C:\Program Files will always be C:\PROGRA~1.
Short names can't contain spaces in them either, so the usual short name for My Documents is MYDOCU~1, not MY DOC~1.
You can find the exact short name for any folder or file (including My Documents) using dir /x <filename>.
If you are using the GNU toolchain from Windows command line (cmd.exe), you should be able to use quotes (") around the folder/file names to work around this problem.
For some folders, including My Documents, you can specify an alternative location. To do this, right-click the folder, select Properties, select Location tab, and away you go. I use this to put my downloads and music on another drive (D:).
Write a wrapper script (e.g. batchfile) to translate the path names to short form.
I have a script "runwin" that does stuff like this - instead of, e.g. gcc <args> I can call runwin gcc <args>;
runwin will make heuristic guesses as to which arguments are filename paths and translate them, then call gcc on the resulting string of arguments.
I want to comment out lines in some code I have. I have different kinds of codes, and they use different comment leaders. E.g. in latex: '%', in Fortran 90: '!' and in python: '#'. I want to do a substitute command that looks something like this:
:g/<search-string>/s/^/<add-comment-leader-here>/
If this is possible, I could also make a command in Vim that automatically commented out the selected text. Something like this:
vmap <z> :'<,'>s/^/<add-comment-leader-here>/
Any ideas are welcome! :)
If you haven't seen it already, you may be interested in the NERD Commenter Vim plugin.
Check out Enhanced Commentify: I think this does what you want: it determines the comment leader based on the file type.
If you want to do it yourself, the easiest way would be to define a mapping that uses exec to build a command and include a variable that is set in your ~/.vim/after/ftplugin/c.vim and other ftplugin files. Alternatively, just add the same mapping (with a different leader) to each ftplugin file.