Bind multiple actions to one key in lighttable - key-bindings

I'm using the vim plugin in lighttable.
When I'm in insert-mode and press ESC while a code completion window is shown, it closes that window but doesn't exit insert mode.
I'd like lighttable to do both at the same time when pressing ESC because I got so used to it in plain vim.
I've tried to bind ESC to both of those actions:
[:app "esc" [
:auto-complete.remove
:vim.send-key "esc"
]
]
But this doesn't work. Is this even possible? Is there another workaround for that problem?

You should be able to do this by adding the following to your user.keymap file:
[:editor "esc" :auto-complete.remove (:vim.send-key "<Esc>")]
But this isn't currently possible.
I created an issue for this on GitHub for the LT Vim plugin repo. 'Fixing' this is relatively minor change to CodeMirror upstream of LT. I'll update this answer again if any other progress is made.

Related

How to use AppleScript or Lua to do an ALT + TAB after results on the Calculator.app

I use the Calculator.app, and after hitting the ENTER key, I would like it to automatically do an ALT + TAB to go to the previous App I was using: Excel or Firefox or Chrome, ... you name it.
I have the same question for just .lua, but if it can't be done with .lua I'd like to do it with AppleScript or with the Automator.
What's the hot key for TAB in .lua? hammerspoon?
UPDATE:
As user3439894 says, CMD + TAB works fine.
But in my end, the TAB is not released, therefore, I keeps on showing all the open apps. So, I tried to put a RETURN as of the documentation. I also tried ENTER , but non of them work.
hs.eventtap.keyStroke({"cmd"}, "tab")
hs.eventtap.keyStroke({"return"})
-- hs.eventtap.keyStroke({"enter"})
Assuming your are using this in conjunction of one of the answers I gave you back in mid November regarding Calculator, then the modified Lua code below works for me to switch to the previous application when pressing the enter key while in Calculator.
Example Lua code:
-- Create a hotkey used to trap the enter key and disable it.
-- It will then be enabled/disabled as Calculator is focused/unfocused
-- When enabled and the enter key is pressed it presses = then command C.
applicationCalculatorEnterHotkey = hs.hotkey.bind({}, "return", function()
-- Press the '=' key to finish the calculation.
hs.eventtap.keyStroke({}, "=")
-- Copy the result to the clipboard.
hs.eventtap.keyStroke({"cmd"}, "C")
-- Bring up the App Switcher.
hs.eventtap.keyStroke({"cmd"}, "tab")
-- Act on the selected App in the App Switcher.
-- This works in testing with Calculator, however
-- may not work in other applications.
hs.eventtap.keyStroke({}, "=")
end)
applicationCalculatorEnterHotkey:disable()
Notes:
I've added two hs.eventtap.keyStroke to the original code with comments.
Executing hs.eventtap.keyStroke({"cmd"}, "tab") in the Console Hammerspoon does automatically switch to the previous application without showing the App Switcher, however when used in the applicationCalculatorEnterHotkey function it shows the App Switcher as if ⌘-Tab has been pressed and the ⌘ key not released. This may be a bug, not sure as not enough testing/research into the issue was done as the obvious solution would be to follow up with programmatically pressing the enter key, however that can not be done from within the applicationCalculatorEnterHotkey function because it is already trapping the enter key in Calculator.
In this particular use case, however this is where hs.eventtap.keyStroke({}, "=") is used to act as if the enter key had been pressed again and is unique to Calculator.

PEPPER (SoftBank Robotics): ALSpeechRecognition Engine issue - How to restart it when it doesnìt work?

During my test on Pepper, I found some difficulties in realizing continuative collaborative dialog.
In particular, after about 10 minutes, it seems that the ALSpeechRecognition engine stops working.
In other words, Pepper dialog panel remains empty and/or the robot does not understand my words, even if the structure worked some minute before.
I tried to stop and restart it (i.e., the engine) via SSH terminal, by using:
qicli call ALSpeechRecognition.pause 1
qicli call ALSpeechRecognition.pause 0
It should restart the engine according to the guidelines shown here, but it does not work.
Thank you so much guys.
Sincerely,
Giovanni
According to the tutorial, starting and stopping the speech recognition engine is done by subscribing/unsubscribing it.
The recommended way to do this is unsubscribing and subscribing back to it. For me it also worked changing the speech reco language and chaging it back to the one you had previously.
Luis is right and to do so just create a function as below given and call it if ActiveListenning event comes false from ALSpeechRecognition module. Note: Use ALMemory module to get data from ALSpeechRecogntion.
asr_service = ALProxy("ALSpeechRecognition",ip,port)
memory = ALProxy("ALMemory",ip,port)
def reset():
asr_service.unsubscribe("ASR_Engine")
asr_service.subscribe("ASR_Engine")
ALS = memory.getData("ALSpeechRecognition/ActiveListening")
if ALS==False:
reset()

Standard print button is inoperative in custom Report

My customer has reported a problem that standard ''print'' button in Z-report which a developer wrote before is not working.
How can I enable the button?
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
ENDCASE.
ENDMODULE.
Then button needs a usercommand assigned, which is then processed in pai. usually with a general form called get_ucomm (many developers call it similar). You also can issue /h in transaction field and then press the print-button. /h will trigger the debugger and You can inspect the report step by step.
That's all I can say without seeing the code. Hope this will help.
Which user command do you define in your GUI status?
If you have a standard list (what I expect when you write about a z-report), then you should define the command PRI to print the list:
If you define a screen (using the screen painter) or an ALV-Grid... then this solution will not help you.
If you don't know, what a GUI status is: Scan your source code for the command
SET PF-STATUS 'XXXX'.
Then double click on 'XXXX' and you should be directed to the status definition. There may by multiple status (and status with generic names).
I've seen your code and for the &RNT option there's no code to execute, so if the user wants to print the button will do nothing.
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
" There's no code
ENDCASE.
ENDMODULE.
I've used the 'STANDARD' GUI Status from the function group 'KKBL' and '&RNT' is the code of the print button and that's why I think that is the print button you are refering in your program.
Can you post the GUI Status you are using please?

Responsive Compile-and-Run Vim Mapping

I have the following mapping in my .vimrc.
:nmap <F5> :<C-U>make %:r && ./%:r<CR>
I press F5 in VIM, and it compiles, exits VIM, and runs my code. When the program terminates, it asks me to "press ENTER or enter a command to continue." It then takes me to a blank screen with the text (1 of 5): and the same "press ENTER or enter a command to continue" prompt. I press enter and it finally returns me back to VIM. This behavior is consistent across the board. Is there a way to remove any or both of those occurrences? Perhaps have the mapping press ENTER twice after the program terminates? If so, how?
EDIT: So I realized appending two more <CR>'s doesn't quite solve the problem. As soon as the program terminates, it IMMEDIATELY goes back to VIM and I don't have time to review the output. Can I make the mapping wait for ME to press the first enter, and automatically press the 2nd ENTER afterwards?
Would this work:
nmap <F5> :<C-U>silent make %:r<CR>:redraw!<CR>:!./%:r<CR>
A longer solution but this one also allows you to see errors (reference):
:function! MakeAndRun()
: silent make %:r
: redraw!
: if len(getqflist()) == 1
: !./%:r
: else
: for i in getqflist()
: if i['valid']
: cwin
: winc p
: return
: endif
: endfor
: endif
:endfunction
:nmap <F5> :call MakeAndRun()<cr>
Yes and yes (you answered your own question):
:nmap <F5> :<C-U>make %:r && ./%:r<CR><CR>
For me this works fine:
" Compile
noremap <F4> :<C-U>silent make<CR>:redraw!<CR>
" Automatically open, but do not go to (if there are errors) the quickfix /
" location list window, or close it when is has become empty.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
It compiles, and immediately jumps to vim, showing the quickfix window. No intermediate enters.

How to monitor a text file in realtime [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
For debugging purposes in a somewhat closed system, I have to output text to a file.
Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time?
I like tools that will perform more than one task, Notepad++ is a great notepad replacement and has a Document Monitor plugin (installs with standard msi) that works great. It also is portable so you can have it on a thumb drive for use anywhere.
For a command line option, PowerShell (which is really a new command line) has a great feature already mentioned.
Get-Content someFile.txt -wait
But you can also filter at the command line using a regular expression
Get-Content web.log -wait | where { $_ -match "ERROR" }
Tail for Win32
Apache Chainsaw - used this with log4net logs, may require file to be in a certain format
When using Windows PowerShell you can do the following:
Get-Content someFile.txt -wait
I use "tail -f" under cygwin.
I use BareTail for doing this on Windows. It's free and has some nice features, such as tabs for tailing multiple files and configurable highlighting.
Tail is the best answer so far.
If you don't use Windows, you probably already have tail.
If you do use Windows, you can get a whole slew of Unix command line tools from here. Unzip them and put them somewhere in your PATH.
Then just do this at the command prompt from the same folder your log file is in:
tail -n 50 -f whatever.log
This will show you the last 50 lines of the file and will update as the file updates.
You can combine grep with tail with great results - something like this:
tail -n 50 -f whatever.log | grep Error
gives you just lines with "Error" in it.
Good luck!
FileSystemWatcher works a treat, although you do have to be a little careful about duplicate events firing - 1st link from Google - but bearing that in mind can produce great results.
Late answer, though might be helpful for someone -- LOGEXPERT seems to be interesting tail utility for windows.
Try SMSTrace from Microsoft (now called CMTrace, and directly available in the Start Menu on some versions of Windows)
Its a brilliant GUI tool that monitors updates to any text file in real time, even if its locked for writing by another file.
Don't be fooled by the description, its capable of monitoring any file, including .txt, .log or .csv.
Its ability to monitor locked files is extremely useful, and is one of the reasons why this utility shines.
One of the nicest features is line coloring. If it sees the word "ERROR", the line becomes red. If it sees the word "WARN", the line becomes yellow. This makes the logs a lot easier to follow.
I have used FileSystemWatcher for monitoring of text files for a component I recently built. There may be better options (I never found anything in my limited research) but that seemed to do the trick nicely :)
Crap, my bad, you're actually after a tool to do it all for you..
Well if you get unlucky and want to roll your own ;)
Yor can use the FileSystemWatcher in System.Diagnostics.
From MSDN:
public class Watcher
{
public static void Main()
{
Run();
}
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public static void Run()
{
string[] args = System.Environment.GetCommandLineArgs();
// If a directory is not specified, exit program.
if(args.Length != 2)
{
// Display the proper way to call the program.
Console.WriteLine("Usage: Watcher.exe (directory)");
return;
}
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
Console.WriteLine("Press \'q\' to quit the sample.");
while(Console.Read()!='q');
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
}
}
You can also follow this link Watching Folder Activity in VB.NET
Snake Tail. It is a good option.
http://snakenest.com/snaketail/
Just a shameless plug to tail onto the answer, but I have a free web based app called Hacksaw used for viewing log4net files. I've put in an auto refresh options so you can give yourself near real time updates without having to refresh the browser all the time.
Yeah I've used both Tail for Win32 and tail on Cygwin. I've found both to be excellent, although I prefer Cygwin slightly as I'm able to tail files over the internet efficiently without crashes (Tail for Win32 has crashed on me in some instances).
So basically, I would use tail on Cygwin and redirect the output to a file on my local machine. I would then have this file open in Vim and reload (:e) it when required.
+1 for BareTail. I actually use BareTailPro, which provides real-time filtering on the tail with basic search strings or search strings using regex.
To make the list complete here's a link to the GNU WIN32 ports of many useful tools (amongst them is tail).
GNUWin32 CoreUtils
Surprised no one has mentioned Trace32 (or Trace64). These are great (free) Microsoft utilities that give a nice GUI and highlight any errors, etc. It also has filtering and sounds like exactly what you need.
Here's a utility I wrote to do just that:
It uses a FileSystemWatcher to look for changes in log files within local folders or network shares (don't have to be mounted, just provide the UNC path) and appends the new content to the console.
on github: https://github.com/danbyrne84/multitail
http://www.danielbyrne.net/projects/multitail
Hope this helps
#echo off
set LoggingFile=C:\foo.txt
set lineNr=0
:while1
for /f "usebackq delims=" %%i in (`more +%lineNr% %LoggingFile%`) DO (
echo %%i
set /a lineNr+=1
REM Have an appropriate stop condition here by checking i
)
goto :while1
A command prompt way of doing it.
FileMon is a free stand alone tool that can detect all kinds of file access. You can filter out any unwanted. It does not show you the data that has actually changed though.
I second "tail -f" in cygwin. I assume that Tail for Win32 will accomplish the same thing.
Tail for Win32
I did a tiny viewer by my own:
https://github.com/enexusde/Delphi/wiki/TinyLog

Resources