Show tabs with a different character (Emacs) - configuration

I'd be happy to have very soft character ">>" instead of white-space, like this:
Mono develop http://primates.ximian.com/~miguel/pictures/Valabinding-classpad.png
How can I achieve that in Emacs?

EDIT: Just realized that blank-mode is superseded by whitespace. Load this and customize whitespace-style to at least contain tabs and tabs-mark. I currently have:
(setq whitespace-style '(trailing tabs newline tab-mark newline-mark))
There is also blank-mode which allows you to achive what you want and it gives you some nice functions to cleanup the whitespace to your likings:
http://www.emacswiki.org/emacs/BlankMode

On my Emacs version (24.3) no additional modules are needed. It's enough to launch
M-x whitespace-mode
To customize go to whitespace-style variable help,
C-h C-h v whitespace-style
This mode has many functionalities. To made it simpler one may choose not to use `Face visualization'.

Use "M-:" (M-x eval-expression) and enter the following expression:
(let ((d (make-display-table)))
(aset d 9 (vector ?> ?>))
(set-window-display-table nil d))
To get back to normal enter:
(set-window-display-table nil nil)

Google search brought up show whitespace-mode. Haven't tried it myself.

Related

How to prevent maxima to rewrite the output of 2*sqrt(2) to 2^(3/2)?

Maxima input of
2*sqrt(2)
by default returns the output
2^(3/2)
How can I get Maxima to just return 2*sqrt(2) ?
(I use this in the tex() function.)
To the best of my knowledge, there is no way to prevent Maxima from simplifying 2*sqrt(2) to 2^(3/2), with two probably-hard-to-use exceptions:
(1) Turn off simplification entirely. But that disables all simplifications, e.g. 1 + 1 simplifying to 2. But if you want to try it: just enter simp : false;.
(2) Disable the simplification sqrt(2) to 2^(1/2) via :lisp (setf (get '%sqrt 'operators) nil) But then Maxima for the most part doesn't know what to do with sqrt.
I don't recommend either one of these.
You can try something like
simp: false;
tex(2*sqrt(2));
block code...;
simp: true;
That way you don't have to disable the simplification permanently.
You can do this:
(%i1) matchdeclare(n_, integerp,m_, integerp)$
tellsimp(n_*sqrt(m_), n_*sqrt(box(m_)))$
and afterwards:
(%i3) 2*sqrt(2);
(%o3) 2 √2
(%i4) sqrt(3)*9;
(%o4) 9 √3
You'll notice that the number under the square root sign in the output is colored red, because of box(). But if you select the expression in wxMaxima, and then popup "Copy LaTeX", you'll get exactly what you want, e. g.
\[2\,\sqrt{2}\]
Unfortunately if you try tex(2*sqrt(2)) to get the TeX code, you'll get $$2\,\sqrt{\boxed{2}}$$instead.

Selection function comments while expanding in Lisp modes

I'm using a keyboard shortcut bound to:
er/expand-region, which is an interactive Lisp function in `expand-region-core.el'.
to expand the region.
For example when I want to select a function and move it around.
My problem is that if I want to select any function like, say:
;; some comment related to the function
(defn foo [x]
...)
I cannot "expand" to include ";; some comment". As soon as I expand more than the function (without the comment) it expends the full buffer.
While I'd like it to first expand to include the function and the comment and then the full buffer.
It's bothering me so much that I'm temporarily doing this as a workaround:
(defn foo [x]
;; some comment
...)
How can I modify er/expand-region (or another function) so that after expanding to the full function it expands the comments right above the function before expanding to the whole buffer?
From Magnar Sveen, the creator of the package expand-region, taken from his github:
Example:
Let's say you want expand-region to also mark paragraphs and pages in
text-mode. Incidentally Emacs already comes with mark-paragraph and
mark-page. To add it to the try-list, do this:
(defun er/add-text-mode-expansions () (make-variable-buffer-local
'er/try-expand-list) (setq er/try-expand-list (append
er/try-expand-list
'(mark-paragraph
mark-page))))
(add-hook 'text-mode-hook 'er/add-text-mode-expansions)
Add that to
its own file, and add it to the expand-region.el-file, where it says
"Mode-specific expansions"
Warning: Badly written expansions might slow down expand-region
dramatically. Remember to exit quickly before you start traversing the
entire document looking for constructs to mark.
I would say you could add "er/mark-paragraph" to the expand-region list, that should do it.
Following user Dualinity's advice, I added the following to clojure-mode-expansions.el (can be done for other modes than Clojure of course) :
;; added this line at the beginning of the file
(require 'org-mode-expansions)
Then I added the line er/mark-paragraph to the expand list inside the er/add-clojure-mode-expansions method:
(defun er/add-clojure-mode-expansions ()
"Adds clojure-specific expansions for buffers in clojure-mode"
(set (make-local-variable 'er/try-expand-list) (append
er/try-expand-list
'(er/mark-clj-word
er/mark-clj-regexp-literal
er/mark-paragraph ; added this line
er/mark-clj-function-literal))))
I restarted Emacs (not too sure as to what was needed to be sure it was taken into account so I restarted the whole thing).
And that's it: now expanding selects "outer" function comments too.

how to accept a clang_complete match?

I was trying out the vim clang_complete plugin. Once I type the C-x C-u on the following code fragment, positioned after some below
inline void someSizeChecks()
{
// ...
}
void foo()
{
some
}
I get a selection menu like:
Gui challenged question: How do I select the function that the clang_complete plugin spits out in this pink selection menu? I tried space, enter, f, and tab. I also don't see anything in the plugin docs on how to use the menus once presented.
You select the option using CTRL-N and CTRL-P and select it using CTRL-Y.
It was in the help:
*g:clang_complete_auto*
If equal to 1, automatically complete after ->, ., ::
Default: 1
At that point, you could either use the arrows of your keyboard, or use C-n and C-p to browse through the list of completion results.
In order to select items in the menu generated by clang_complete you simply need to use the up and down keys to make your select your choice, finally hit enter to finish the completion.

Why doesn't the cursor stay at the same place?

I have a very strange problem which I can't resolve after trying the whole morning.
This is my function and mapping:
nnoremap ,zz :call SwapAW("2-2","5")<CR>
nnoremap ,zc :call SwapAW("2-2","5")<CR>
function! SwapAW(keyw,number)
let li = line('.')
let co = col('.')
exe "call cursor(li,co)"
let linew= line('.')
let conew= col('.')
echo linew conew
endfunction
,zc --> moves the cursor to the right
,zz --> the cursor stays where it is
I changed everything but can't find out why the cursor doesn't stay where it is in both cases.
I changed p.e. the mapping, from ,zc to ,zd and ,zz to ,zw (tried others as well) and changed the leaderkey from , to \, and tried to swap both mapping lines.
Nothing changes.
What's happening?
What did I wrong?
Thanks in advance.
You have a trailing <Space> character in your ,zc mapping (after the <CR>). That moves the cursor after the function invocation.
With mappings, one must be careful with hidden characters. Therefore, it's advisable (and sometimes, e.g. at the beginning of a mapping, necessary) to literally write the special form <Space> when you actually need to include one.
My ShowTrailingWhitespace plugin will highlight those trailing spaces and tabs, as many code guidelines frown on them. The plugin page also contains links to alternatives.

Sublime Text 2, faster alternative to find and replace regex?

$_POST['daily_limit'];
$whatever = $_POST['smoke'];
$_POST['soup'] + $_POST['cake'];
to
$this->input->post('daily_limit');
$whatever = $this->input->post('smoke');
$this->input->post('soup') + $this->input->post('cake');
In this example, is there any faster way to switch from $_POST[] to $this->input->post() without writing up a regular expression find and replace? I don't care if it takes multiple steps. Writing the regex for this (find: \$_POST\[(.*?)\] replace: \$this->input->post\($1\)) takes longer than changing them all manually (maybe I'm just not good at regex). Any ideas?
I'm making a brash assumption here, that you have only one variable within each pair of brackets and that the variables only contain alphanumeric characters. ['soup'+'bacon'] will break this trick, as will ['soup-with-bacon'].
With your cursor, highlight an instance of $_POST[ - nothing else.
Hit Alt+F3 if you're on Windows/Linux (Cmd+ShiftG in Mac?)
Try to scroll through and see if everything that's selected is everything you want to replace.
Type $this->input->post( - nothing else.
Press → to move all cursors to the right of the first quote.
Press Ctrl+→ (this is the only remotely wtfh4xxy part of the process, and only if you're not used to navigating by word with the cursor) to navigate over the variable.
Press → twice to move all cursors to the right of the next quote.
Replace the ]with a ).
#nnnn I did a variation of your version to remove the wtfh4xxy part.
select:$_POST
altf3
type: $this->input->post(
ctrlshiftm
ctrlx
ctrlshiftm
ctrlv
type: )
Sublime text ftw!