vimclojure doesn't respect #_ commented lines - vim

Even though it says it does in the release notes for V 2.1.2 (which was quite a while ago). Obviously the code runs as it should, but it's distracting to have these forms syntax colored as though they were uncommented code. Does anyone have this working or know how to fix it?

Highlighting #_ correctly is hard. Since #_ 5 comments the 5 and #_ (foo) comments (foo) one has to highlight arbitrary expressions. Which may be separated from #_ by arbitrary whitespace. I never had enough pain to make it work. I'm not even sure, that Vim's highlighting capabilities are sufficient.
The issue tracker is here. However VimClojure's development is officially frozen. You might want to consider using the newer plugins.

Related

Haskell Guards and SublimeText 3

I switched over to Sublime Text 3 but now that I was coding some Haskell in ST3 I noticed something quite odd, which is the syntax highlighting logic for guards.
As you can see, when I write it this way, it highlights the first guard in white colour and the different sign in a mix of white/magenta:
Only when I use this wrong syntax (with an equal sign after the argument) it displays correctly.
Does anyone know how to fix this?
You're probably using the default Haskell syntax highlighting. I would recommend disabling the Haskell package and installing SublimeHaskell. Its syntax highlighting is much better, and it recognizes things like otherwise as being a "built-in" (it's mainly Prelude functions that are considered built-in).
If you're using the built-in Haskell highlighting, you can check that it's buggy by using the CtrlAltShiftP shortcut. Highlight each guard pipe individually and then hit this shortcut. In the status bar it'll briefly show the syntax scope names associated with the region. For the first pipe, you'll get source.haskell meta.function.type-declaration.haskell, and for the second you'll get source.haskell keyword.operator.haskell. Using SublimeHaskell's syntax you'll get source.haskell keyword.operator.haskell for both pipes. I won't say that SublimeHaskell's is perfect (try indenting an entire file after module Name where), but it's definitely better. Since the syntaxes have the same name and because SublimeHaskell comes with snippets and whatnot that cover everything that the built-in does, I recommend disabling the Haskell plugin and only leaving SublimeHaskell's syntax selectable.
(NOT SURE!!!)
I now believe this is not a bug, instead I believe this is actually ST3's way of telling you you have non-exaustive patterns in that function.
Non-exaustive: http://i.imgur.com/74o4sgp.png
Exaustive: http://i.imgur.com/M9a4TTL.png

Is VIM omni-completion really so limited? Or am I missing something?

Ruby:
file = File.new("some.txt", "r")
lines = file.readlines
Omni-completion tests
file.readl
---------
readline <- PASSED
readlines
---------
"hola".capital
---------
capitalize <- PASSED
capitalize!
---------
lines.
<-- FAILED (no suggestions)
lines[0].capital
<-- FAILED (no suggestions)
I tried Python as well, and it worked in similar way. So it looks like omni-completion can't be used for real development, as it fails on pretty simple cases?
Am I missing some thing? May be the intellisense can be improved some how for Ruby/Python?
The issue is that Vim does not know if line is a String, an Array or some other Class. There is no deep syntactical analysis in Vim. Vim has no idea of scope, if a variable or method has been defined, etc.
It is only suggesting similar words. So yes, Vim is more limited than an IDE in this aspect. This is also why Eclipse can suggest errors as you typed them, and Vim can't.
Vim is much more basic: in a way, everything is text, and not necessarily seen as "code".
So you are right this is one of Vim limitation.
There are some plugins to work around those limitations (omnicpp is using ctags to determine the scope of some methods) but they are often developed on a per-language basis and there is no silver bullet.

Haskell autocompletion in Emacs using haskell-mode

I installed haskel-mode in emacs. Then I write in my .emacs:
(load "~/.emacs.d/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'haskell-font-lock-symbols t)
(put 'downcase-region 'disabled nil)
What must I add in my conf file that emacs could autocomplete for Haskell? Or Haskell mode there is no such possibility?
When there is no language-specific support, you can use tags. This is a generic completion mechanism.
Generate a TAGS file, which contains a list of identifiers and where they are defined. Emacs comes with the etags program to do this in many languages, but not Haskell; ghc comes with hasktags.
Load the TAGS file with M-x visit-tags-table.
Tags are not context-dependent, so they'll indiscriminately suggest types, values, constructors, etc everywhere. They also won't provide advanced features such as easily showing the type of a value. The most important tags commands are:
M-TAB (complete-symbol) completes an identifier according to the loaded list of tags.
M-. (find-tag) goes to the place where the identifier at point is defined, opening the containing file if necessary.
M-* (pop-tag-mark) goes back where you were before M-..
M-x tags-apropos shows a list of identifiers matching a regexp.
For more information, look under "Tags" in the Emacs manual.
For an even cruder, but fully automatic mechanism, there is the dynamic abbrev feature. C-M-/ (dabbrev-completion) looks in most open buffers for a completion; this is completely language-independent, so it'll even find words in strings, comments, whatever. M-/ (dabbrev-expand) is similar, but directly completes to the nearest match before point.
ghc-mod provides some completion for Haskell within Emacs, as well as checking with hlint and ghc. In combination with M-/, it's good enough for me.
haskell-mode currently provides no such possibility. There is some work on implementation of haskell parser for CEDET - in this case, users will get autocompletion features automatically. But this work had started not so much time ago...
My setup is a little more complicated. It uses the auto-complete infrastructure which
shows a dropdown list of candidates automatically similar to traditional IDEs. I downloaded this script that hardcodes all the keywords. In addition to that, I use ghc-mod to generate module names.
As a "cheap and cheerful" autocompletion mechanism, don't overlook M-/. It's completely heuristic and language-independent, but surprisingly effective.
Besides autocompletion for your own code, you can also get autocompletion (with apidocs even) for the standard library, import names, and pragma names using company-ghc. I found this guide to be very helpful. Note, I didn't get it to work fully for myself yet, but I can feel I'm close :-)

Which editors out of Emacs, Vim and JEdit support multiple simultaneous text insertion points?

Background: JEdit (and some other text editors as well) support a feature called Multiple simultaneous text insertion points. (at least that's what I'm calling it here).
To understand what this means, take a look at the link.
Out of all the features in use in modern text editors, initial research seems to indicate that this is one feature that both Emacs and Vim do not actually support. If correct, this would be pretty exceptional since it's quite difficult to find a text editor feature that has not made its way into at least one of these two old-school editors.
Question: Has anyone ever seen or implemented this feature in either Emacs, Vim, or both? If so, please point me to a link, script, reference or summary that explains the details.
If you know an alternate way to do the same (or similar) thing, please let me know.
The vim way to do this is the . command which repeats the last change. So, for instance, if I change a pointer to a reference and I have a bunch of
obj->func
that I want to change to
obj.func
then I search for obj->, do 2cw to change the obj-> to obj., then do n.n.n. until all the instances are changed.
Perhaps not a flexible as what you're talking about, but it works frequently and is very intuitive and fast when it does.
moccur-edit.el almost does what you want. All the locations matching the regexp are displayed, and the editing the matches makes changes in the corresponding source. However, the editing is done on a single instance of the occurrence.
I imagine it'd be straight forward to extend it to allow you to edit them all simultaneously (at least in the simple case).
There is a demo of it found here.
Turns out, the newest versions of moccur-edit don't apply changes in real-time - you must apply the changes. The changes are also now undoable (nice win).
In EMACS, you could/would do it with M-x find-grep and a macro. If you really insist that it be fully automatic, then you'd include the find-next in the macro.
But honestly, this strikes me as a sort of Microsoft-feature: yes, it adds to the feature list, but why bother? And would you remember it existed in six months, when you want to use it again?
For emacs, multiple-cursors does exactly that.
Have a look at emacsrocks episode 13, by the author of the module.
I don't think this feature has a direct analogue in either Emacs or Vim, which is not to say that everything achievable with this feature is not possible in some fashion with the two 'old-school' editors. And like most things Emacs and Vim, power-users would probably be able to achieve such a task exceedingly quickly, even if mere mortals like myself could spend five minutes figuring out the correct grep search and replace with appropriate back-references, for example.
YASnippet package for Emacs uses it. See 2:13 and 2:44 in the screencast.
Another slight similarity: In Emacs, the rectangle editing features provided by cua-selection-mode (or cua-mode) automatically gives you multiple insertion points down the left or right edge of the marked rectangle, so that you can type a common prefix or suffix to all of those lines.
e.g.:
M-x cua-selection-mode RET (enable the global minor mode, if you don't already use this or cua-mode)
C-RET down down down (marks a 1x3 character rectangle)
type prefix here
C-RET (unmark the rectangle to return to normal editing)
It should be something like this in vim:
%s/paint.\((.*),/\1.paint(/
Or something like that, I am really bad at "mock" regular expressions.
The idea is substitute the pattern:
/paint(object,/
with
/object.paint(/
So, yes, it is "supported"
It seemed simple to do a basic version of this in Emacs lisp. This is for when you just want two places to insert text in parallel:
(defun cjw-multi-insert (text)
"insert text at both point and mark"
(interactive "sText:")
(insert-before-markers text)
(save-excursion
(exchange-point-and-mark)
(insert-before-markers text)))
When you run it, it prompts for text and inserts it at both point (current position) and mark. You can set the mark with C-SPC. This could be easily extended for N different positions. A function like set-insert-point would record current position (stored as an Emacs marker) into a list and then when you run the multi-insert command, it just iterates through the list adding text at each.
I'm not sure about what would a simple way to handle a more general "multi-editing" feature.
Nope. This would be quite difficult to do with a primarily console-based UI.
That said, there is similar features in vim (and emacs, although I've not used it nearly as much) - search and replace, as people have said, and more similarly, column insert mode: http://pivotallabs.com/users/brian/blog/articles/350-column-edit-mode-in-vi

Emacs equivalent of Vim's foldmethod = indent

Question: Does Emacs have a canonical equivalent of Vim's Folding with Foldmethod=indent?
I am particularly interested in something that can work alongside any Emacs major mode and any file. The Emacs searches have not turned up a definitive answer.
Seems like it can, though I don't use folding myself, so I've not tried it. Not surprisingly, the Python folks are all about this feature. See the following:
http://mail.python.org/pipermail/tutor/2002-September/017482.html
http://www.nabble.com/Code-folder-with-Emacs-td16189193.html
http://groups.google.ca/group/comp.lang.python/msg/956f1c2d37f93995
maybe selective-display? I have the following function bound to [f2]
;; http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
(defun jao-toggle-selective-display (column)
(interactive "P")
(set-selective-display
(if selective-display nil (or column 1))))
That's pretty bare-bones, though, and you'd really want it to be Pythony-indentation sensitive....
UPDATE: I was staring at this last night, and realized that I was tired of C-u entering the column I was on (plus 1).... so I coded it up:
(defun toggle-selective-display-column ()
"set selective display fold everything greater than the current column, or toggle off if active"
(interactive)
(set-selective-display
(if selective-display nil (or (+ (current-column) 1) 1))))
Further elaboration should combine the two functions.
See also: How to achieve code folding effects in emacs
I tried all of the suggestions by Joe Casadonte and Michael Paulukonis, but none works as nicely as the vim's one. So it seems that the more accurate answer to the OP's question may be NO at the moment.

Resources