looking for helm-ls-git tutorial (emacs, helm) [closed] - emacs

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 8 years ago.
Improve this question
https://github.com/emacs-helm/helm-ls-git
Found no tutorial for it on google.
That means it doesn't exist in our universe?
I'm looking for a way to find files and grep files within emacs.
Hopefully as easy as in sublime with project directory opened.
(Your search is automatically limited to the directory you specified in sublime)

The functionality you are after is something dired has been doing successfully for years. The file you have linked in your post is a minor enhancement for a convenience feature added on top of the built-in functionality, it doesn't really deal with searching for files outside the context of Git version control system.
Here are some examples of how you could do it with dired:
M-xfind-name-dired, answer the prompts to select the directory where you want to search and possibly refine by providing a regular expression to match file names. You then will be presented with the buffer listing all files you have selected so far. You can further refine from here by % m and providing it with a regexp to filter the file names on, or just hit t selecting all files in the buffer.
Then hit A and write the regexp to search for inside the selected files. The effect of this command will be to open the file, where the match is found. After you close the file, or return to the original buffer, you can press M-, to move to the next match.
If this sounds too elaborate, then you could just do M-xfind-dired to invoke find in the directory you choose with the arguments you can normally provide to find
To just grep and have the matches shown in a dedicated buffer you could do M-xfind-grep - this will invoke find with the output from it piped to grep. You will then need to modify the command used to invoke this to your taste.
M-xfind-grep-dired will do something similar, however it will display the files, where the match was found in a dired buffer, rather then the lines, where the match occurred.
Finally, there may be a bunch more ways to do this, depending on your particular task and what, in the end, you are trying to accomplish. Perhaps, some times, invoking a shell command to place the results directly in the buffer would be the best way to do it. Other times you may want to write your own eLisp function to do something more elaborate with the results. Sky is he limit :)

I saw this question recently and updated the README on the repo page to reflect installation and usage:
https://github.com/emacs-helm/helm-ls-git
Hope it helps!

This might not answer your entire question but I use the following bit of elisp as a shortcut for greping all files with a set list of extensions under a specific folder:
(defun pgrep (regexp)
"rgrep files inside a project folder"
(interactive
(list (grep-read-regexp)))
(grep-compute-defaults)
(rgrep regexp "*rb *erb *js *css *scss" "~/path/to/folder/"))
Then I just run M-x pgrep foo
For anything more complicated I just run rgrep directly - it lets you specify the root folder, search string, and extension.

Related

fish shell: ctrl-p is not working but ARROW UP is [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 10 months ago.
Improve this question
I recently installed various fisher plugins and updated to fish 3.4.1 and now "ctrl-p" does not cycle through my commands anymore, but ARROW UP is still working. When I switch to the bash shell, ctrl-p is working. I observe the same behaviour in the gnome terminal and kitty terminal. I have no clue what the problem is and would appreciate a lot if someone could help me, thanks in advance!
It appears one of your plugins rebound ctrl-p.
In general, to find out what a key sequence is bound to, you need to:
Figure out what the key sequence is by starting fish_key_reader and pressing it
Pass that to bind
So, you run fish_key_reader, which tells you:
bind \cP 'do something'
That means ctrl-p sends \cP.
So, we ask what \cP is bound to:
bind \cP
which by default gives us
bind --preset \cp up-or-search
(yes, the case is indeed irrelevant after a \c as \cp and \cP encode the same).
And if you had bound something differently, it might print multiple lines like
bind --preset \cp up-or-search
bind \cp 'echo oops'
What can also happen here is that one of your plugins enabled vi-mode (this can happen even for things you might think are entirely unrelated, for instance there's at least one semi-popular prompt that believes it's entitled to enable it).
In that case, bind \cP will output nothing, and you can also ask bind -M insert \cP to ask what ctrl-p is bound to in insert mode.
To disable vi-mode and go back to the default emacs-inspired bindings (where that binding for ctrl-p originated), run fish_default_key_bindings.

How to reset my PATH after breaking it accidentally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I think I run something incorrectly trying to add a directory to PATH in fish. Perhaps it was this:
set -g PATH my_foobar_directory "$PATH"
From fish tutorial I now understand that I shouldn't have added the double-quotes.
Better yet, should've used fish_add_path my_foobar_directory.
Lesson learned; however, the change has persisted somewhere, and nothing I try seems to recover the previous state. I also cannot find the previous PATH value — the console logs with it were washed away by copious fish: Unknown command: python etc, from fish_prompt bells & whistles.
Falling back to bash gives me bogus PATH as well — even after set -e PATH.
What do? How do I start over?
So for myself, I solved it like this.
In the process tree, I found a sufficiently long-running process. In my case, cinnamon-session worked — though any not-so-distant fish parent would do.
The idea being that in that process's environment, the previous PATH value could still be intact. It was.
Then basically — let's say the pid was 661 — print environment of pid 661 in fish format:
/bin/tr \0 ' ' < /proc/661/environ
# copy output
Then just pick that output, and feed it into the "universal" variant (fish-specific) of the PATH variable, taking care to erase all other variants:
set -e PATH
set -eg PATH
set -Ux PATH <paste>

How can i beautify my code in Matlab (tabs, deleting unnecessary spaces etc.)? [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 2 years ago.
Improve this question
i'm looking to find a way to beautify my code in MATLAB. I'm talking about tabs, deleting unnecessary spaces etc., the way Eclipse does it with Ctrl+Shift+F
The smart indentation (ctrl + I) is probably all you need (as #Matteo V and #Cris Luengo already mentioned).
However, there are a few other neat tricks that you might want to have a look at if you are really into code development:
Well, first have a look at the Improve Code Readability site of MATLAB. You could use the Apply smart indenting while typing option in the Preferences > MATLAB > Editor/Debugger > Language > Indenting section (it should be turned on per default but I like the Indent all functions setting). There are a bunch of other settings that you may want to explore
If you dig yourself deeper in the MATLAB IDE, you will notice that you can adjust almost everything to your preferences, but the way is not always documented in the web.... however, the local documentation (call doc) contains the info you may be looking for, see this blog-post
I am not aware of an automatic detection of double spaces or similar but you might end up writing your own little callback-function. Most languages ignore this anyway (perhaps except for Python). Code readability is usually a topic that the programmer(s) should care about... and not the machines ;)
Further tips:
respect the Right-hand text limit, which is the vertical gray line in your editor and shall indicate how many characters a single line of code should have as maximum. If it is a comment, wrap it. If it is an expression, try to outsource some commands to a dedicated variable
use equally long variable names. (There is no style guide as in Python, which says that you should use normal words and underscores etc) E.g. if you have two variables describing a commanded and a measured velocity, you could call them v_cmd and v_act and your code perfectly aligns if you apply the same manipulations to both variables ;)
use section. With %% (the space is important) at the beginning of a line in the editor, you create a section (you'll note the slight yellow background color and the bold writing that follows this command). It is convenient to structure your code. You can even run entire sections Editor-Tab > Run > Run section
Although there are programmers claiming that a good code speaks for itself (and therefore doesn't need any comments), to my experience writing comments has never been a bad idea. It improves the readability of your code
The answer might have been a bit elaborate for such an innocent question ... oO

Syntax Highlighting Pager [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 3 years ago.
Improve this question
Right now, I use most as my pager. While it has helpful syntax highlighting for man pages, it lacks colored syntax highlighting for anything else (I'm specifically looking for diff/C++).
Meanwhile, pygments is a wonderful program. I can easily make colorized output with it:
# ./pygmentize -f console256 ${file}
hg diff | ./pygmentize -f console256 -l diff
Now, I would like to be able to page the output, so I just use:
# ./pygmentize -f console256 ${file} | most
hg diff | ./pygmentize -f console256 -l diff | most
At this point, most dumps all the colorizing control characters to my screen like so:
^[[38;5;28;01mclass^[[39;00m ^[[38;5;21;01mheap_allocator^[[39;00m
{
^[[38;5;28;01mpublic^[[39;00m^[[38;5;241m:^[[39m
This is, of course, unreadable. I looked though the man page for most, but I couldn't find any "Hey, show those control characters as colors instead of printing them" options. less has the same garbage behavior as most, but more shows the colors perfectly fine, with the obvious limitations of being more.
Is there a pager that supports syntax highlighting or some crazy combination of parameters and programs I can string together to make this work? Ultimately, I would like to get diffs and logs from Mercurial to be highlighted, so maybe there is a shortcut in there...
Might I suggest vimpager?
First off, recent vim distributions (I believe 6.0 and above) come with a pager-esque-mode script. It's quite simple and functional, and operates similarly to less. Try: vim '+help less' +only.
Even better, however, Rafael Kitover has written a much more robust and powerful script called vimpager. It's available on GitHub (or vimscripts). If you are on OS X and using Homebrew, it's as easy as brew install vimpager.
At that point, you can simply set $PAGER=vimpager, or even alias less=vimpager. It works excellently.
less -R shows ANSI color sequences as-is (instead of expanding to caret notation). That'll make syntax highlighting work!
You can also create an environment variable LESS=-R to make this the default behavior. Similarly for other options; see man less.
Look for bat: A cat(1) clone with wings.
bat supports syntax highlighting for a large number of programming and markup languages.
It is not a pager, but it automatically redirects output to less if needed.
You might try using jed. Yes, it's a text editor, not a pager, but it's quite lightweight and the default install contains excellent colorschemes for a wide variety of file types and languages.
Jed has syntax highlighting modes for different languages, simillar to the emacs ones. For example if you piped a C program to it, you can turn on the highlighting by pressing 'ESC', then 'x', then typing 'c-mode' . If it is a php program - change the last part to 'php-mode' and so on ...

What is the best code template facility for Emacs? [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 4 years ago.
Improve this question
Particularly, what is the best snippets package out there?
Features:
easy to define new snippets (plain text, custom input with defaults)
simple navigation between predefined positions in the snippet
multiple insertion of the same custom input
accepts currently selected text as a custom input
cross-platform (Windows, Linux)
dynamically evaluated expressions (embedded code) written in a concise programming language (Perl, Python, Ruby are preferred)
nicely coexists with others packages in Emacs
Example of code template, a simple for loop in C:
for (int i = 0; i < %N%; ++i) {
_
}
It is a lot of typing for such common code. I want to invoke a code template or snippet which inserts
that boilerplate code for me. Additionally it stops (on TAB or other keystroke) at %N% (my input replaces it) and final position of the cursor is _.
TextMate's snippets is the most closest match but it is not a cross-platform solution and not for Emacs.
The second closest thing is YASnippet (screencast shows the main capabilities). But it interferes with hippie-expand package in my setup and the embedded language is EmacsLisp which I'm not comfortable with outside .emacs.
EDIT: Posted my answer here to allow voting on YASnippet.
Personally, I've been using Dmacro for years (ftp://ftp.sgi.com/other/dmacro/dmacro.tar.gz).
Here's a review of it that also mentions some alternatives: http://linuxgazette.net/issue39/marsden.html
The EmacsWiki has a page of template engines.
Of these, I've used tempo in the (distant) past to add table support to html-helper-mode, but don't know how it has progressed in the last 15 years.
I'd add my vote for tempo snippets ... easy to setup, powerful (you can run arbitrary elisp in your template - so that you can downcase things, lookup filenames & classes, count things, etc), set the indentation, integrate with abbrevs ... I use it a lot ;)
I vote for http://cedet.sourceforge.net/srecode.shtml
It has very clean syntax and has access to code environment through Semantic.
Also it is a part of a large well supported CEDET distribution (which was built into Emacs for 24.x version series).
UPDATE YASnippet is also a powerful template engine. But it uses an ugly file naming schema (your file name === template name) for you can't put several templates into a single file and have issues with national character sets...
You can try a lightweight solution muban.el
It is written completely in Elisp and has a very simple syntax.