VSCode extension: remove all indentation with language-configuration rule - visual-studio-code

I am wondering whether it is possible for a VSCode extension to have an unindent rule that removes all indentation when there is a regex match. I can specify indentation rules in a language-configuration.json file but decreaseIndentPattern only decreases indentation by 1. (Also, I wouldn't want all the other decreaseIndentPatterns to drop all their indentations.)
Example
Normally what you get is this
program main
integer :: a
#ifdef DEBUG
integer :: b
#endif
end program main
which is not compilable code for Fortran so you have to manually indent the preprocessor directives (lines starting with #).
Ideally, what I would want is when typing the # character in VSCode, to drop all indentation for that line.
program main
integer :: a
#ifdef DEBUG ! the # character should drop all indentation only for this line
integer :: b
#endif
end program main

Related

org-indent-line always adds a comma before an leading asterisk in code block

Launch Emacs with emacs -q and write in org-mode:
#+BEGIN_SRC C
/*
* This is a comment line
*/
#+END_SRC
Press TAB inside the block. It becomes:
#+BEGIN_SRC C
/*
,* This is a comment line
,*/
#+END_SRC
Is there any way to get rid of this behevior?
This is a quoting mechanism to make sure that the asterisks are not interpreted as headline markers and throwing off Org mode's parser. See Literal Examples in the manual.
There is no way to turn it off and you shouldn't anyway because Org mode will be very confused otherwise. The commas do not affect the exporting of the document or the evaluation of a source block: they are properly stripped at the appropriate time.

Emacs semicolon presses indent to width of entire previous line, declaring private class variables. How to fix & stop? (c-electric-semi&comma?)

Everything is indented normally in my .cpp file until the moment I press the semicolon ; on the following lines --- at which point emacs indents all the way to the full length of the last line typed...
This oddly doesn't happen if I remove the access modifier and declare vars int x and int y for any class or struct..
class Blah {
private int x;
private int y;
private int z;
};
If I highlight the whole field and press < TAB >, Emacs views this as the proper indent for the region. Can't seem to find anything else related on this besides other qs on indent customization
Additional details:
C-h k ; yields this description, so it might have to do with this feature ---- though I don't understand because the indentation described appears to refer to the immediate next newline not the current the cursor is on.
; runs the command c-electric-semi&comma (found in c++-mode-map),
which is an interactive compiled Lisp function in ‘cc-cmds.el’.
It is bound to ,, ;.
(c-electric-semi&comma ARG)
Insert a comma or semicolon.
If ‘c-electric-flag’ is non-nil, point isn’t inside a literal and a
numeric ARG hasn’t been supplied, the command performs several electric
actions:
(a) When the auto-newline feature is turned on (indicated by "/la" on
the mode line) a newline might be inserted. See the variable
‘c-hanging-semi&comma-criteria’ for how newline insertion is determined.
(b) Any auto-newlines are indented. The original line is also
reindented unless ‘c-syntactic-indentation’ is nil.
(c) If auto-newline is turned on, a comma following a brace list or a
semicolon following a defun might be cleaned up, depending on the
settings of ‘c-cleanup-list’.
; is one of many keys that triggers the "correct this line's indentation" command. There's nothing special about ; here, it's just that Emacs normally keeps your indentation right according to the style defined for the file.
As 0x5453 says in a comment, your C++ file is syntactically invalid, and the indenter is trying its best to come up with a reasonable indentation for this incorrect file. If you fix your code to be legal, the indentation will also be resolved.

How to change primary command in Edit

I want to add some shortcuts in ISPF Edit.
For instance, I'd like to type T for "TOP" and B for "BOT". How can I do this? I tried to enter
define t alias top
in the command line, but it didn't work: I have "COMMAND TOP NOT FOUND" if I use the shortcut.
How can I achieve this? And how to have this shortcut available each time I open Edit?
A flexible solution would be to create an initial edit macro that does double duty. On first invocation as the initial edit macro, it defines commands such as T and B as aliases to itself. These commands then cause ISPF to invoke the same macro and perform the appropriate action. For this, use the ISPF variable ZEDTMCMD as the main logic driver; it is set by the editor with the command that invoked the macro.
Here is a very general REXX solution called MYMACRO:
/* REXX */
address 'ISREDIT'
parse source . . s3 .
'MACRO' /* You can specify optional arguments if you want */
/* Easier to work with upper case and no leading or trailing blanks */
address 'ISPEXEC' 'VGET (ZEDTMCMD)'
invoke_cmd = translate(strip(zedtmcmd))
select
when invoke_cmd == s3 then do /* first time call */
'DEFINE T ALIAS' s3
'DEFINE B ALIAS' s3
end
when invoke_cmd == 'T' then 'UP MAX'
when invoke_cmd == 'B' then 'DOWN MAX'
otherwise nop
end
exit 0
Next, specify MYMACRO as a initial edit macro. This can be specified in several places, but the easiest is on the main edit panel (option 2).
Note that your macro needs to be in the standard lookup (DD SYSEXEC, SYSPROC, or DD SYSUEXEC or SYSUPROC if ALTLIB is active, or ISPCLIB) to be found.
If you decide to write a program, it is a little bit more complicated. You have to:
prefix the name in the initial edit macro field with an exclamation point ! so ISPF knows to invoke it as a program rather than a script (this means 7 characters maximum for the name);
remove the leading exclamation point before executing the SELECT;
and add 'DEFINE MYMACRO MACRO PGM' as the first line in the first time call logic, so ISPF knows that it is a program, not a script.
In this scenario, when executed as the initial edit macro, ZEDTMCMD will have the leading exclamation point.
By creating one macro, you can make it easier to add new commands in the future.
The ISPF installation SAMPLIB (usually named ISP.SISPSAMP, but it may be different at your installation) has several example macros, all beginning with ISR*. There are REXX scripts, CLISTs, COBOL, and PL/I examples. (No assembler, but creating one is a trivial exercise.)
TOP and BOTTOM are commands in the ISPF command table. They are not EDIT commands. They are ALIAS's for UP MAX and DOWN MAX. An ISPF command must be at least 2 bytes in length, so you can not create a new ALIAS in the command table for UP MAX using a 1 byte character.
You can define an Edit macro called T. The macro could do something like
/* REXX */
address ISREDIT "MACRO"
address ISREDIT "LOCATE 0"
exit(0)
B for BOTTOM could be
/* REXX */
address ISREDIT "MACRO"
address ISREDIT "LOCATE .ZLAST"
exit(0)
Note that B would put you on the last line and not the last full page like BOTTOM actually does. For TOP and BOTTOM I would personally just use PF7 or PF8 with M on the command line to do the max scroll. Its just 1 character with a PFKEY as opposed to the enter key.

Temporarily disable tab completion in Scala Repl

I occasionally work with code that has hard tabs instead of spaces. Is there any repl command to instruct the interpreter to process the tabs as normal whitespace at least temporarily - along the lines of :paste ?
Indeed :paste sounds like a good option but if you really want to override keybindings you can provide your own settings file like this:
scala -Djline.keybindings=myfile
The format of the file that I looked up from default scala jar is like this:
from file scala/tools/jline/keybindings.properties in jline.jar:
# Keybinding mapping for JLine. The format is:
# [key code]=[logical operation]
# CTRL-A: move to the beginning of the line
1=MOVE_TO_BEG
# CTRL-B: move to the previous character
2=PREV_CHAR
# CTRL-D: close out the input stream
4=EXIT
# CTRL-E: move the cursor to the end of the line
5=MOVE_TO_END
# CTRL-F: move to the next character
6=NEXT_CHAR
# CTRL-G: abort
7=ABORT
# BACKSPACE, CTRL-H: delete the previous character
# 8 is the ASCII code for backspace and therefor
# deleting the previous character
8=DELETE_PREV_CHAR
# TAB, CTRL-I: signal that console completion should be attempted
9=COMPLETE
Replace the command matching option 9 with empty string.
http://www.scala-sbt.org/release/docs/Howto/interactive.html#change-keybindings

Indenting template arguments in Emacs

I'm having no luck getting Emacs (cc-mode) to indent multiline template arguments. Here's an example line:
typedef ::boost::zip_iterator< ::boost::tuple<
vector<int>::const_iterator, vector<float>::const_iterator > >;
I'd like the second line to be indented, as like in a function. It is indented, until I enter the second-to-last >, at which point the second line up moves to the left to align with the typedef.
When I start typing the second line, the syntactic analysis is ((statement-cont 52)), until the second-to-last >, at which point it becomes ((defun-block-intro 46)). Deleting the character doesn't return to the old syntactic analysis.
I expected to have template-args-cont as the syntactic analysis.
I'm using the emacs 22.2 (ubuntu intrepid) and cc-mode version 5.31.5 that came with it.
You should just need to set template-args-cont to some useful value. To experiment with it, put your cursor on the second line and enter C-cC-o for c-set-offset. Insert a convenient value. With 4, I get:
typedef ::boost::zip_iterator< ::boost::tuple<
vector<int>::const_iterator, vector<float>::const_iterator > >;
If that doesn't work, check your version: I have cc-mode version 5.31.6. To check, do M-x c-version. I get
Using CC Mode version 5.31.6