Function Browsing In Spacemacs And CIDER - clojure

In Spacemacs, with an active CIDER REPL, is there a way to browse and jump to the functions in the current clojure-mode buffer?
I have tried cider-browse-ns. However, that appears to just display the functions and variables in the current namespace, along with their docstrings. The list cannot be used to jump directly to the function/var in the source code. I am also aware that g d will jump directly to the definition of the function under point. So the pieces of what I am looking for seem to all be available, I just cannot find how to wire them together.
An analogy to what I am looking for is IntelliJ's Structure sidebar.
It would be awesome if IntelliJ's Navigate -> Symbol functionality was possible as well. Searching for the function name, using /, comes pretty close (albeit without the handy fuzzy matching).

would SPC s j (help-jump-in-buffer) be what you search ?

Pressing backslash then S \s will help you jump to the definition.
Here is the list of the available commands in browse-ns. But since Spacemacs puts you in evil-mode by default, you should precede each command by a \ which temporarily disables it.

Related

How to prevent the running of auto macros when starting ms word in c++ automation

I'm generating thumbnails for office files using c++. I open and save the files using automation similar to this: https://support.microsoft.com/en-us/kb/179494. Since there are many files, this takes a lot of time and the program should run through the night.
Everything works fine, except when a file contains an auto start macro, which doesn't even exist.
Sub AutoOpen()
Application.Run ("stupidMacroWhichDoesntExist")
End Sub
In this case, the Loop stops, and an error message appears that the macro couldn't be executed.
Off Course, I have set the macro settings in the trust center to -> disable all macros without notification
The error message still appears
In Excel, I can prevent this with:
objExcelApp.SetEnableEvents(false);
Unfortunately, the word application in c++ doesn't have a SetEnableEvents method. I have googled a lot and found a lot of VB Code to prevent this. Mostly it was something like:
objWord.WordBasic.DisableAutoMacros 1
But I haven't found anything in c++
I'm very thankful for your help.
I believe you're looking for:
WordApplication.AutomationSecurity = msoAutomationSecurityForceDisable
The Trust Center setting doesn't apply to documents being opened using automation. This property and its MsoAutomationSecurity enumeration correspond to that setting in the object model.
FWIW the WordBasic approach should also be possible using C++. I don't know C++ syntax, but with C# I'd need to use PInvoke (GetType().InvokeMember) to communicate directly with the IDispatch (I think that's the right term).
I have solved it. I'm backing up the actual macro (vbaData.xml and vbaProject.bin in the word folder), put a dummy macro into the word file, open it via automation and save it to generate the thumbnail. After that, I put back the backed up macro into the word file.
Since the dummy macro does nothing I am safe that nothing will be executed, whatever is programmed in the original macro.

Vim Folding with RainbowParentheses

So, I've looked everywhere for a good rainbow parentheses plugin that will give different level parentheses different colors. I really like the couple that I've found, because they both do a good job of customizability while highlighting the right thing. It supports more than parentheses; chevrons, braces and brackets all get highlighted, which I really like.
It seems like there are quite a few plugins for this!; I'm currently using oblitum's because his is optimized for dark backgrounds (I often work straight from the shell).
So, following the tip at the github for that plugin, I have the "always on" snippet in my .vimrc. But when the always on block is above "syntax enable" it doesn't show {} as being highlighted for cpp files. When the always on block is below syntax enable, folding doesn't work. I think its the nature of the plugin that makes it do this; it goes though the file and adds coloration information. I notice that if I use the command :syntax enable after I've loaded the file when its not recognizing folds, then it does recognize the folds. But at this point, it removes the coloration that rainbow parentheses put on it.
In my .vimrc, I have the follow pertinent lines:
syntax enable
set foldmethod=syntax
set foldenable
set foldlevel=100
let g:rainbow_operators=2
au FileType c,cpp,objc,objcpp call rainbow#activate()
I think that, from looking at syntax files that come with vim, such as c.vim, you can see that certain blocks are annotated as folding. I bet that if you could just write a regex based upon it, you could identify characters as syntactic groups. Then you could just define a colorscheme for it. In fact, the rainbow plugin is actually calling "syn region" commands, so I think that this route is very doable, I'm just not that knowledgable with vim scripting.
Can anybody help me modify possibly the plugin or come up with a script or something that achieves both?
Sorry the lateness, I've tried to solve it at Fix disabled folding (issue #2)
I dimly remember having had the same or a similar problem.
Also XML code highlighting was broken IIRC.
I put 'always on' off, and activated the colored parentheses only when I needed it.
So my working solution was just a shortcut to toggle the plugin on and off.

Looking up symbol documentation in Counterclockwise

In Counterclockwise, if I use CTRL-Space to complete a symbol name, and there are more than one possibility, it gives me a list, and on the right and side of the list is a box with the documentation for each symbol as I scroll through the names.
Is there any way to get this documentation window without using completion, or if there is only one option for the completion? Right now I am looking up documentation by deleting enough letters for the symbol to be ambiguous, then reselecting the symbol I want, but this is pretty inefficient. Usually I just want to know what order the arguments are. I'm not a huge emacs fan, but one thing I like about slime is that I seem to remember when I used it the status bar had a little list of the arguments for whatever function I was calling.
I've googled the problem and also looked on the counterclockwise web page, but I must be using the wrong search terms because I haven't come up with anything.
-Harry
You should be able to hover the mouse over the symbol, and the documentation will popup. Or press F2 while the cursor is over the symbol.

Filter Eclipse's "Open Call Hierarchy" to just my company/project

One of my favorite features of Eclipse is the ability to open a caller/callee hierarchy of a method.
By default, the view shows calls to/from classes that are outside of my codebase... which I don't usually care about.
There is an option to filter out specific package names I don't want, but I need to do the opposite... to filter out all packages except the one I want. What is the appropriate regex to use here to "match all strings except those that start with com.mycompany.?"
I had the same problem lately and exploring the options of the Call Hierarchy led me to the Search In option. It is activated by clicking on the triangle
The filtering options are pretty simple and effective:
It appears that "Filter Calls" uses glob syntax for filter patterns, not regular expressions. You can't specify something that should not match with glob patterns. Sorry.
It is not exactly what you are looking for, but it is an alternate solution. Take a look at nWire for Java. It is a code exploration plugin. Among many other things, it will present the call hierarchy. However, it will only show calls which originate from your own code, so it should fit your needs.
Another approach is to open the 'Type Hierarchy' view's View menu, select 'Select Working Set' and select an existing or new working set that only includes the project you're currently interested in (create one just for this purpose if necessary, e.g. called 'TypeHierarchyFilterWorkingSet').
I just did this using Eclipse Indigo, by the way, not sure whether the other versions have something similar.
After "Open Call Hierarchy" right click on the root of the results and select under "References" or "Declarations" the project you interest in:
One solution (though somewhat brute force) is to remove the other code from Eclipse's reach. Either put them into separate workspaces, or, if you sometimes do need them in one workspace, close the other projects when you don't want to see them.
You could try to add a parameter to the method, than all calls will be shown as error on rebuild.
you could filter out org., net., java.* and so on. This (in my case) reduces the list enormously

How can I refactor C++ source code using emacs?

I'm interested mostly in C++ and method/class name/signature automatic changes.
In recent Emacs versions (24), Semantic is able to this.
Possibly activate semantic mode M-x semantic-mode RET.
Bring up the Symref buffer with C-c , g.
Press C-c C-e to open all references.
Rename with R.
If you can program in elisp, you can look to combination of cedet + srecode from CEDET libraries - it provide all instruments for this task - find callers of functions, get signature, etc. But you need to create refactory tool yourself, using these instruments
I do this a lot, so I'm axiously awaiting other replies too.
The only tricks I know are really basic. Here are my best friends in Emacs when refactoring code:
M-x query-replace
This allows you to do a global search and replace. You'll be doing this a ton when you move methods and commonly-accessed data to other classes or namespaces.
C-x 3
This gives you a display with two buffers side-by side. You can then proceed to load different files in them, and move your cursor from one to the other with C-x o. This is pretty basic stuff, but I mention it because of how powerful it makes the next one...
C-x (
(type any amount of stuff and/or emacs commands here)
C-x )
This is how you define a macro in emacs. Any time you find yourself needing to do the same thing over and over to a bunch of code (and it is too complex for query-replace), this is a lifesaver. If you mess up, you can hit C-g to stop the macro definition, and then undo (C-_) until you are back to where you started. The keys to invoke the macro are C-x e. If you want to do it a bunch of times, you can hit Esc and type in a number first. Eg: Esc 100 C-x e will try to invoke your macro 100 times.
(Note: On Windows you can get "Meta" by hitting the Esc key, or holding down Alt).
The current (2022) state of the art is, I would say, using emacs lsp-mode with a suitable language server.
With the clangd or ccls, which provide the "language server protocol" (lsp) and connect to lsp-mode, you can refactor names with:
M-x lsp-rename
To simplify this setup, I'd recommend using Spacemacs with c-c++ and lsp layers (and using clangd).
For somewhere in between refactoring tools and simple regex, since Emacs 22 you can embed arbitrary elisp expressions in your replacement text, which allows you to do incredibly powerful text manipulation. Steve Yegge wrote a good article on this a while ago.
A friend of mine was playing with xrefactory and said it worked pretty well. It isn't cheap though.
Build cscope symbols.
lookup the symbol you want to refactor.
get into the cscope window, and start a macro after placing cursor on first occurence
ret
c-f your symbol start
navigate to start of your symbol
modify the word
c-x o (back to cscope)
n (for next cscope symbol)
you have to just c-x c-e now
I totally agree that find-and-replace work fine. However , a really nice feature of cedet is 'semantic-symref-list'.
With the cursor on a method, run this command, and you will be presented with a buffer that lists all of the places in your code that reference this tag.
You can still use find-and-replace tricks, and this will confirm that you have changed all the references.
I've been using cquery for my C++ completion which uses Microsoft LSP for IDE <-> Tool communication. cquery server satisfies the requests of the LSP protocol using a clang backend.
lsp-emacs is the package that sits between emacs and the cquery backend (cquery-emacs) which exposes an lsp-rename function. As a completion system, cquery has been very reliable and fast by the way, highly recommended.
Give it a try, follow the getting-started guide on the cquery github:
https://github.com/cquery-project/cquery/wiki/Emacs
Once you've got cquery setup:
Hover your cursor over an identifier (class, var, whatever) you'd like to rename.
M-x lsp-rename
Enter the new name for the identifier.
Do C-x s (save some buffers), which will prompt you to save
all the buffers that were touched by the refactor.
You should probably go through all modified buffers and check what was done after refactoring with any tool/language.