Is there equivalent plugin like modeline_magic from VIM?
So each file could look like e.g.:
/* vim: set tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab */
int main(int, char *) {}
and indentation would be passed to other clients?
You can add local (file) variables by having a line formatted as
-*- mode: modename; var: value; ... -*-
at the start of your file. Any number of var: value; pairs can appear in the line. If you're finding that you have too many local variables, you can change the style to
# Local Variables:
# mode: python
# comment-column: 0
# End:
Emacs searches for the string "Local Variables", and is smart enough to work out that the prefix and suffix (in this case # and nothing) should be reused for the following lines. This means that if the file is something other than python, you can change the prefix/suffix to match the different comment characters, e.g. /* and */ for ANSI C.
You can read more at the emacs manual.
Related
I wrote a program in Java that accepts input via command line arguments.
I get an input of two numbers and an operator from the command line.
To multiply two numbers, I have to give input as e.g. 5 3 *, but it's not working as written.
Why is it not accepting * from the command line?
That's because * is a shell wildcard: it has a special meaning to the shell, which expands it before passing it on to the command (in this case, java).
Since you need a literal *, you need to escape it from the shell. The exact way of escaping varies depending on your shell, but you can try:
java ProgramName 5 3 "*"
Or:
java ProgramName 5 3 \*
By the way, if you want to know what the shell does with the *, try printing the content of String[] args to your main method. You'll find that it will contain names of the files in your directory.
This can be handy if you need to pass some filenames as command line arguments.
See also
Wikipedia: glob
For example, if a directory contains two files, a.log and b.log then the command cat *.log will be expanded by the shell to cat a.log b.log
Wikipedia: Escape character
In Bourne shell (sh), the asterisk (*) and question mark (?) characters are wildcard characters expanded via globbing. Without a preceding escape character, an * will expand to the names of all files in the working directory that don't start with a period if and only if there are such files, otherwise * remains unexpanded. So to refer to a file literally called "*", the shell must be told not to interpret it in this way, by preceding it with a backslash (\).
Under MS WINDOWS not quite true: "java.exe" silently expands command line arguments with the wildcards
*
?
[abc]
, but only in the last component, so
a/*/*
does not work as you may expect.
It also ignores the entries "." and "..", but does honor other file names starting with ".".
To avoid misunderstandings: If I look at the command line of the running JAVA process with PROCEXP, I see the unexpanded args!
I found no way to work around this. In other words: As long as you have at least one file or directory in the current directory, "java Calc 3 * 7" will NOT work!
This is VERY ugly, and seems to always having been there in all JRE versions up to and including Java 8.
Does anybody have an idea how to disable Java's nasty command line expansion?
* has special meaning in shell interpreters. How to get a * literally is depending on what shell interpreter you are using. For Bash, you should put single quotes around the *, i.e. '*', instead of double quotes like "*".
Try surrounding the * with quotes like "*". The star is a reserved symbol on the command line.
Use single quotes:
java FooBar 5 3 '*'
This works with most of the popular shells (including bash and ksh).
Expanding on #Arno Unkrig's answer:
On Windows, some JVMs definitely do expand the "*" character, and it is not the shell expanding the path. You can confirm this by writing a small Java program that prints out the arguments:
public class TestArgs {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
System.out.println("Arg " + i + ": " + args[i]);
}
}
}
The good news is, there is a workaround! You can use #filename as an argument to JVM like this:
java #args.txt where args.txt is a text file that contains the arguments for each line. Example content:
TestArgs
*
This is equivalent to calling java with two arguments TestArgs and *. Most importantly, * is not expanded when it is included using the #filename method. I was able to find the details from this page.
I need to be able to store certain Unicode characters in a few of my registry keys, but am unable to find the syntax to do this in an .iss file. I am using the Unicode version of Inno Setup
The Inno Setup site says this about Unicode values:
you can for example instead use encoded Unicode characters to build Unicode strings (like S := #$0100 + #$0101 + 'Aa';), or load the string from a file using LoadStringsFromFile, or use a {cm:...} constant.
For example one of the one's I want to enter is the degrees Fahrenheit symbol (℉) which is #$2109.
I can't put #$2109 directly into the value string because that just prints out that text.
I tried to create a #define constant but it doesn't recognize the # and $ characters.
So I want:
[Registry]
Root: HKLM; Subkey: "MyPath"; ValueType string; ValueName: "MyName; \
ValueData: "Temperature [℉]"
but obviously I cannot put it in directly.
How do I get Unicode characters into the registry section, either directly or via some variable/constant, I'm fairly new to Inno Setup.
Thanks in advance!
Just make sure your .iss file is UTF-8 encoded with BOM.
Then you can use UTF-8 strings directly in it (with Unicode version of Inno Setup), as the documentation says:
Unicode Inno Setup supports UTF-8 encoded .iss files (but not UTF-16).
[Registry]
Root: HKLM; Subkey: "MyPath"; ValueType: string; ValueName: "MyName"; \
ValueData: "Temperature [℉]"
(note that the entry syntax in your question is wrong, you are missing a colon and a quote)
An easy way to save the file in UTF-8 with BOM:
Open the .iss file in Inno Setup Compiler GUI.
Go to File > Save Encoding and select UTF-8.
Save the file.
You need to do this before inserting your UTF-8 string. Also note that the Inno Setup Compiler editor cannot display the ℉, but it will still work ok, when compiled.
Another way is:
Open the .iss file in Windows Notepad.
Go to File > Save As.
Select UTF-8 in Encoding drop down box.
Click Save.
Windows Notepad can display the ℉ (with an appropriate font, like the default Consolas or Lucida Console).
An easy way is to write what you need into Notepad++
e.g. : Temperature + (ALT+2109) //
Set the encode to UTF-8 without BOM
select the whole line and (Ctrl+C) copy
paste to the ValueData the copied line "Temperature [?]"
[Registry]
Root: ... ValueType: string; ValueName: "AString"; ValueData: "Temperature [?]"
That's all
Another solution we use a constant and a function :
FHcnst1 = #$2109#$20#$54#$65#$6D#$70; // ℉ Temp
and we add together (℉ Temperature Const)
℉ Temp
erature Const
... ValueType: string; ValueName: "AConst"; ValueData: "{code:SetTemperature|1}erature Const"
The function "SetTemperature"
[Code]
var
UserPage: TInputQueryWizardPage;
UsagePage: TInputOptionWizardPage;
DataDirPage: TInputDirWizardPage;
const
FHcnst1 = #$2109#$20#$54#$65#$6D#$70; // ℉ Temp
FHcnst2 = #$2109#$20;
...
function SetTemperature(Param: String): String;
begin
if Param = '1' then Result := FHcnst1;
if Param = '2' then Result := FHcnst2;
end;
The Result :
The Hack:
You must write to the registry three bytes.
Only the Unicode #$2109 will not work.
A good one is #$20 space (because invisible)
FHcnst2 = #$2109#$20;
Correct Version:
#+BIND: org-html-postamble-format (("en" "abcxyz"))
but if the format string is very long, is there a way to wrap it to multilines?
something like this:
#+BIND: org-html-postamble-format (("en" "abc ~
# xyz"))
Unfortunately no. Keywords in org-mode are constrained to a single line and there is no wrapping character. If you feel strongly about your line length you might consider:
Using the #+SETUPFILE mechanism (see: In-buffer settings)
Defining that format in your dotemacs file so you can span multiple lines.
Using some form of local file or directory variables. For example local variables may span multiple lines:
# Local Variables:
# eval: (setq org-html-postamble t)
# eval: (setq org-html-postamble-format '(("en" "foo
# bar \
# baz")))
# End:
Note: You may notice that some some particular keywords have "wrapping" behavior such as node properties (http://orgmode.org/manual/Property-syntax.html):
#+PROPERTY: var foo=1
#+PROPERTY: var+ bar=2
Behavior like this is special and limited to those keywords. No equivalent wrapping behavior exists for the BIND keyword.
Current org-mode version (as of this post): 8.3.4
With Yasnippet recently updated from MELPA, I would like to be able to deactivate only the snippets xxx and todo that come with text-mode. The first expands with x and the other with t, which bother me because I write math texts in org-mode and I need to write several x's and t's by themselves, and then press TAB to exit parenthesis.
From yas-buffer-local-condition, it seems that I might be able to do something if there was a #condition: directive in the snippets, but the mentioned snippets don't have one.
I get my way if I just delete the files, but unfortunately they reappear at each update of Yasnippet.
One possible solution would be to control the snippets with key bindings by adding a line of code to each snippet -- e.g., # binding: C-I a b c or # binding: C-I d e f The combination C-I is equivalent to the tab key and the space between the following letters means that they are pressed individually one at a time. In addition, the following lines of code can also be modified to reflect different key(s): # key: a_b_c and # key: d_e_f.
The variable yas-snippet-dirs can be used to control the location(s) of snippets. It may be a good idea to move snippets to a different location so that they are not touched by future updates (e.g., el-get).
The xxx snippet looks like this:
ORIGINAL
# -*- mode: snippet -*-
# name: xxx
# key: x
# --
`(yas-with-comment "XXX: ")`
MODIFIED
# -*- mode: snippet -*-
# name: xxx
# key: a_b_c
# binding: C-I a b c
# --
`(yas-with-comment "XXX: ")`
The todo snippet looks like this:
ORIGINAL
# -*- mode: snippet -*-
# name: todo
# key: t
# --
`(yas-with-comment "TODO: ")`
MODIFIED
# -*- mode: snippet -*-
# name: todo
# key: d_e_f
# binding: C-I d e f
# --
`(yas-with-comment "TODO: ")`
For those who are curious, the function yas-with-comment looks like this
(defun yas-with-comment (str)
(format "%s%s%s" comment-start str comment-end))
I am recently working with a F90 code project. I am using gfortran (linux and MinGW) to compile it. There is something interesting in file loct.F90.
# define TYPE real(4)
# define SUBNAME(x) s ## x
# include "loct_inc.F90"
# undef SUBNAME
# undef TYPE
# define TYPE real(8)
# define SUBNAME(x) d ## x
# include "loct_inc.F90"
# undef SUBNAME
# undef TYPE
...
The loct_inc.F90 file looks like this:
subroutine SUBNAME(loct_pointer_copy_1)(o, i)
...
end subroutine SUBNAME(loct_pointer_copy_1)
subroutine SUBNAME(loct_pointer_copy_2)(o, i)
...
end subroutine SUBNAME(loct_pointer_copy_2)
...
I think in the file loct.F90 the author used sets of macros (C/C++ style). Each set is used to define a data type (e.g. real(4), real(8), character, etc). The file loct_inc.F90 provide a set of function which is the same except the type of the variables.
These two files works together as a template of c++ in my opinion.
In the end one should have a set of subroutines:
sloct_pointer_copy_1(o, i)
sloct_pointer_copy_2(o, i)
...
dloct_pointer_copy_1(o, i)
dloct_pointer_copy_2(o, i)
...
But when I tried to compile loct.F90 (gfortran -c loct.F90), I get some errors.
basic/loct_inc.F90:21.13:
Included at basic/loct.F90:256:
subroutine s ## loct_pointer_copy_1(o, i)
1 Error: Syntax error in SUBROUTINE statement at (1)
It seems gfortran replace SUBNAME(loct_pointer_copy_1)(o, i) with s ## loct_pointer_copy_1(o, i). But according to c++ macro, the correct replace should be sloct_pointer_copy_1(o, i).
Could anyone tell me why this happened?
GNU Fortran uses the GNU C Preprocessor in traditional mode, in which mode the macro pasting operator ## is not available. That's why Fortran projects which were written to also compile with the GNU toolchain perform explicit preprocessing in additional Makefile targets, e.g. all *.F90 are first preprocessed with cpp to temporary .f90 files which are then compiled.