How to automatically enter brackets on autocomplete? - atom-editor

Whenever I use the autocomplete for atom it doesn't include the brackets. For example if i start typing "print" I hit enter and it enters print but doesn't include the brackets.

The default Python snippets only supports the print keyword, not the print() function. Since I haven't found another package that does, you're problably best off adding a snippet (Atom > Open Your Snippets) such as:
'.source.python':
'print()':
'prefix': 'print-function'
'body': 'print($1)'
The prefix will trigger the snippet defined in the body, in case prefer to call it differently.

Related

How to correctly combine "dot notation" and "braces notation" in cocoascript (sketch)?

In sketch documentation it's stated that dot and braces notations can be mixed with each other. It's even an example available:
[[context.document currentPage] deselectAllLayers];
Unfortunately, this code doesn't work in sketch and produce error if executed by "run custom script" command:
SyntaxError: Unexpected identifier 'currentPage'. Expected either a closing ']' or a ',' following an array element..
Plugin “untitled script”, line 2.
» [context.document currentPage]; «Error in command untitled script Script at path (null) does not contain a handler function named: onRun
Script executed in 0.023666s
This can be avoided by adding additional ( and ):
[[(context.document) currentPage] deselectAllLayers];
Why this happens? Is it any documentation available how exactly braces and dot notation can be mixed? Is it some error or expected behaviour?
It seems to me it's an error, but in Sketch documentation. Besides this case you showed, I couldn't find any other example where dot and braces notations are used together in the same statement, without parentheses.
The documentation page about Selections, for instance, tells that you'd use the following code to unselect everything:
var doc = context.document
[[doc currentPage] deselectAllLayers]
Follow this link and look under Clearing the selection header: http://bohemiancoding.com/sketch/support/developer/02-common-tasks/01.html
Even their example plugins don't mix both notations, as you can see here: https://github.com/BohemianCoding/ExampleSketchPlugins/blob/master/Hello%20World/Hello%20World.sketchplugin/Contents/Sketch/script.cocoascript.
In that example, context.document is also assigned to a new variable before being used within braces.

How to send code from Sublime3 to evernote?

I've installed the package control "evernote plugin"and view in browser for Sublime3. When I passed the code to evernote, Sublime3 come out an alert as follows.
Evernote complained:
The contents of the note are not valid.
The inline HTML tag 'iostream' is not allowed in Evernote notes.
Retry?
My code is as follows.
#include <iostream>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}
How can I cope with it?
From the sublime-evernote package wiki:
Raw HTML
Take extra care in not using prohibited elements (see here).
Evernote will complain if you use unsupported elements (such as <style>) or unsupported attributes (such as class or id).
If you wish to have the code within a raw html block interpreted as Markdown, specify a markdown="1" attribute for the outermost element:
<div markdown="1">
**Note**:
This is important!
</div>
Source: https://github.com/bordaigorl/sublime-evernote/wiki/Supported-Markdown#raw-html
You have to use
<iostream>
Otherwise it will be interpreted by Markdown as literal HTML (and passed as such to Evernote)
-- update--
You can deal with this problem by reinstall the sublime-evernot.I have tried, and it works well!
clone this repository with
$ git clone --recursive http://github.com/bordaigorl/sublime-evernote.git
in
Windows: %APPDATA%/Roaming/Sublime Text 3/Packages/
OSX: ~/Library/Application Support/Sublime Text 3/Packages/
Linux: ~/.Sublime Text 3/Packages/
https://github.com/timlockridge/SublimeEvernote
sublime-evernote supports Fenced Code Blocks of GitHub as mentioned in its wiki. Quoting the wiki:
Fenced code blocks GitHub style are supported. If a language is specified, pygments is used to highlight the code.
So the correct way to send code is to include it within a block of triple backticks. Quoting the Github help link for fenced code blocks:
You can create fenced code blocks by placing triple backticks ``` before and after the code block. We recommend placing a blank line before and after code blocks to make the raw formatting easier to read.
You can add an optional language identifier to enable syntax highlighting in your fenced code block.
We use Linguist to perform language detection and syntax highlighting. You can find out which keywords are valid in the languages YAML file.
As mentioned above, you can also specify the language after the backticks. For example, for your code, you need to enclose it within:
```c++
```
After enclosing it like this, send it to evernote, and it will appear with proper syntax highlighting.

ZSH: How to disable default completion for `make`?

I wrote my auto-completion function for make command, and placed it in ~/.zsh:
function __comp_make {
# ... function body ....
}
compctl -K __comp_make make
Unfortunately, it will not work because completion for make is already defined in
/usr/share/zsh/functions/Completion/Unix/_make
and apparently it takes precedence over my rule.
I had to rename _make to unused_make so it is not loaded at zsh initialization. It works, but it is rather ugly solution.
My question is: how should I set my completion rule so it takes precedence over the loaded defaults?
Related:
How does one override an existing zsh keyboard completion?
Edit:
zsh 4.3.17
You need to set your fpath. See here.
In your ~/.zshrc, something like:
fpath=( ~/.zshfunctions $fpath )
where ~/.zshfunctions contains your custom completion files, should solve this for you. Note that your functions are loaded before the system ones. This will not work:
fpath=( $fpath ~/.zshfunctions )
As an aside, you're using compctl. It's old. I'd recommend using compsys instead, although a decent link explaining why escapes me at the moment.
These go into some detail about writing completion functions, including the fpath. You might find them useful for reference.
Z-shell completion functions: introduction
Writing z-shell completion functions

Evaluating buffer until the cursor

I am trying to create a key binding for "Evaluate buffer till here" in Emacs & ESS, which is situated in ESS => ESS Eval menu. Most of the commands in that menu are listed in help files (http://ess.r-project.org/Manual/ess.html, and in Emacs options), but this particular one is not. If I place following code in .emacs file:
(eval-after-load "ess-mode" '(define-key ess-mode-map (kbd "C-.") 'ess-eval-buffer-till-here))
I get a following message when trying to use the binding: Symbol´s function definition is void: ess-eval-buffer-till-here. Obviously I am calling for wrong name. What is the right name for this command and how can I see all of the commands for ESS?
So it's a menu item? Type C-hk and then select that item.
(Menus are implemented as keymaps, so this is just the normal describe-key functionality.)
You can also see the non-interactive call form of the last command with C-xESCESC or C-xM-:. It's easy to figure out the command name once you have that. (thanks event_jr)
For listing all commands, most modes will list all their key bindings in their docstring, so you can use C-hm to describe the modes in use in the buffer.
As there may be commands without bindings, you could also use M-x apropos-command to list them all (most likely specifying ^ess as a pattern, if it uses that as a consistent name space).

How do I edit the VIM Omni Completion so that all CSS properties do not end in a colon?

I have been exploring some way in VIM to automatically append closing characters to a line of code. In my case it is CSS. I came across this tip http://vim.wikia.com/wiki/Automatically_append_closing_characters and tweaked the code it tells me to add to my .vimrc like so
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
so when I write
body
and then press { and ENTER in rapid succession what results is
body {
}
Note that the cursor will be indented and on the 2nd line so I will be ready to write code in that block.
Also I should mention that I also added the following to my .vimrc
inoremap :: :;<Left>
so that when I type : and : in rapid succession I will get :; with the cursor located in between the : and ;. This exactly where I want to be so I can start writing code right away.
I got that working fine but I quickly realized that the auto complete plug in that I installed (AutoComplPop VIM plug-in http://www.vim.org/scripts/script.php?script_id=1879) conflicts with the above .vimrc tweak.
So for example, if I start to write color I get the drop auto completion drop down menu of all options. The problem is that the option for color is actually color:.
You see it has a colon already added to it so when I select it, the colon is already there and then I have to manually add the closing ; character. This basically defeats the whole purpose of adding the auto appending closing character code to my .vimrc since in this case, it does not auto append the closing semicolon.
So how do I make a custom edit to VIM's Omni Completion so that all CSS properties do not end in a colon?
CSS auto completion options for VIM and came across AutoComplPop here http://www.vim.org/scripts/script.php?script_id=1879
Assuming you are on a UNIX-like system…
Copy
/usr/share/vim/vim7x/autoload/csscomplete.vim
to
~/.vim/autoload/csscomplete.vim
Find the loop that generates the list of properties, for me it's at line 92.
Remove the colon from the second parameter of the two add().
These lines:
call add(res, m . ':')
call add(res2, m . ':')
become:
call add(res, m)
call add(res2, m)
Save the file.
Also there are many plugins for "auto closing" pairs of characters. I use DelimitMate.
And the issue is not related to ACP at all.

Resources