I'm using wc-mode to count characters in org-mode. However, when I do org-narrow-to-subtree, my modeline continues to count all the characters in the entire org file.
How do I direct wc-mode to count only the characters in the currently active buffer, i.e. the current subtree?
You need to customize wc-modeline-format. The following line, for example, will give you the total number of words and total number of characters in the buffer (even when narrowed).
(setq wc-modeline-format "[Words: %tw, Chars: %tc]")
Related
I posted this in org-mode ML. No responses there so far, so cross-posting it here too.
I have one persistent tag set with a key character like this:
'(org-tag-persistent-alist (quote (("a" . 97))))
There are no file based #+TAGS in any of org files.
I also like to have access to all tags in all files, so I set this up:
(org-complete-tags-always-offer-all-agenda-tags t)
Finally I'd like to have a fast selection splash screen:
(org-use-fast-tag-selection (quote auto))
Now the problems:
1. Running C-c-q in an org file on a heading shows a fast selection splash window. It shows all the tags from all the org files. The main problem is that apart from [a] defined in org-tag-persistent-alist other characters are assigned for fast pick randomly and are not only 'a-z', but also seemingly non-ASCII characters which are shown as:
- [\200] tagname1
- [\204] tagname2
- etc
There seems to be no way to select tagname1 or tagname2.
With all the above variables unchanged hitting the TAB here for selection of tags in the minibuffer only allows tags already in the file, ignoring the (org-complete-tags-always-offer-all-agenda-tags t) variable. Disabling 'org-use-fast-tag-selection' by setting it to 'nil' and hitting TAB after C-q
produces : and the Completions buffer is not opened. However, typing a first character of a tag, say b and hitting TAB opens 'Completions' buffer and lists all tags starting with b .
Note that org ido completion (which would be shown as 'Ido Completions' buffer name) is not used (although (org-completion-use-ido t)) if
(org-use-fast-tag-selection (quote nil )) .
In addition to problem 1., and problem 2., TAB does not show a full list of tags in the Completions buffer which start with 'a' {probably due to the tag a defined above}, but selecting another starting letter and hitting TAB opens Completion buffer with all tags starting with b .
So, fast select seems broken.
I would expect it behave like this:
Having (org-complete-tags-always-offer-all-agenda-tags t) and (org-use-fast-tag-selection (quote auto)) should limit the tags selection to ASCII only characters or offer double character selection like [aa]-[zz] if there are more tags that az permits. Use numbers perhaps too?.
If 1. is not possible then perhaps limit the characters to 'a-z' and leaving other tags out of the fast select but allow TAB to choose all tags in all org files using org-ido?
I'm forced currently to disable (org-use-fast-tag-selection (quote auto)) setting it to (org-use-fast-tag-selection (quote nil)) and use the Completions buffer, which seems to work more consistently.
This answer nicely provides a way to display characters rather than tabs (in the example it suggests ">", but I confirmed it works for ".").
It uses setting the active window display table to do it.
Now my goal is to display 4 spaces as 4 dots. Using the font-face and a regular expression, I am confident that I can display it nicely. I am aware that I could have Emacs automatically use tab characters rather than whitespaces, but I always prefer to have whitespace characters in my files.
I've also looked at whitespace mode, but I tweaked many parameters and in the end I never get the simple dots (with a face that makes it a little less "jump" out).
So: how can I, rather than display tab characters as dots, display 4 spaces elegantly as dots in Emacs?
OK, here's how to mark 4 or more spaces at beginning of line
(setq whitespace-space-regexp "^\\( \\{4,\\}\\)")
And here's how to get rid of the centered dot character for space:
(setq whitespace-display-mappings
'((space-mark ?\ [?\ ] [?.])
(space-mark ?\xA0 [?\ ] [?_])
(newline-mark ?\n [?$ ?\n])
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])))
The changes take effect not immediately but when you revert-buffer or
close it and open again with customizations above already set.
Sometimes, I have a text file like this in Emacs:
some text 123 17
other text 1 0
still more 12 8
last one 1234 123
I would like to right-align the numbers (using spaces), changing it into something like this:
some text 123 17
other text 1 0
still more 12 8
last one 1234 123
How can this be done in Emacs?
align-regexp can do this. Mark the region, and then use:
C-uM-x align-regexp RET \(\s-+[0-9]*\)[0-9] RET -1 RET 4 RET y
That should be the simplest approach.
(Edit: In fact, you don't even need to separate out that final digit; \(\s-+[0-9]+\) works just as well for the regexp.)
See the interactive prompts and C-hf align-regexp RET and the align-rules-list variable for what that is actually doing.
The noteworthy part is that by specifying a negative number for the group, align-regexp sets the justify attribute:
`justify'
It is possible with `regexp' and `group' to identify a
character group that contains more than just whitespace
characters. By default, any non-whitespace characters in
that group will also be deleted while aligning the
alignment character. However, if the `justify' attribute
is set to a non-nil value, only the initial whitespace
characters within that group will be deleted. This has
the effect of right-justifying the characters that remain,
and can be used for outdenting or just plain old right-
justification.
Alternatively the various table-editing options can also deal with this (e.g. org, ses, table-capture/release), or you could do it with an elisp replacement pattern.
e.g. The following should do more or less what you're looking for, provided that the file is already using spaces for alignment (you can use untabify to remove the tabs if not), and that all lines are the same length (i.e. trailing spaces are needed on some lines if the final column is of varying length).
C-M-% \([0-9]+\)\([[:space:]]+\) RET \,(format (concat "%" (number-to-string (1- (length \&))) "d ") (string-to-number \1)) RET
How can I make Emacs automatically wrap lines of text that I've already written such that no line is longer than, say, 70 characters. In other words, I'd like to do "auto-fill-mode" after-the-fact.
Is this possible?
Look at fill-paragraph and fill-region. If I remember correctly, it's bound to M-q by default. To set the line width, use C-xf.
In addition to fill-paragraph and fill-region, take a look at these commands:
file-individual-paragraphs: "Fill paragraphs of uniform indentation within the region.
This command divides the region into "paragraphs",
treating every change in indentation level or prefix as a paragraph boundary,
then fills each paragraph using its indentation level as the fill prefix.
There is one special case where a change in indentation does not start
a new paragraph. This is for text of this form:
foo> This line with extra indentation starts
foo> a paragraph that continues on more lines.
These lines are filled together."
fill-nonuniform-paragraphs: "Fill paragraphs within the region, allowing varying indentation within each.
This command divides the region into "paragraphs",
only at paragraph-separator lines, then fills each paragraph
using as the fill prefix the smallest indentation of any line
in the paragraph."
How can I make org-mode markup work for a part of a word? For example, I'd like it to work for cases like this:
=Class=es
and this:
/Method/s
Based on my tests it seems like org-mode markup syntax works on complete words only.
These days, there is a way to do this (without using quoted HTML tags):
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
Explanation
The manual says that org-emphasis-regexp-components can be used to
fine tune what characters are allowed before and after the markup characters [...].
It is a list containing five entries. The first entry lists characters that are allowed to immediately precede markup characters, and the second entry lists characters that are allowed to follow markup characters. By default, letters are not included in either one of these entries. So in order to successfully apply formatting to strings immediately preceded or followed by a letter, we have to add [:alpha:] (which matches any letter) to both entries.
This is what the calls to setcar do. The purpose of the third line is to rebuild the regular expression for emphasis based on the modified version of org-emphasis-regexp-components.
I don't think you can do it so that it shows up in the buffer as bold. If you just need it so that it appears bold when you export it to html, you can use:
th#<b>is is ha#</b>lf bold
See Quoting HTML tags
No, you can't do that. I searched for the same solution before and found nothing. A (very) bad hack is to do something like *Class* es (with a whitespace).
Perhaps you can write a short message to the creator, Carsten Dominik (Homepage), and ask him for a solution. He seems to be a nice guy.
A solution that has not been mentioned is to use a unicode zero width space (U+200B) in between the desired bolded and unbolded parts of a word.
To get the desired bolding of the word "Classes":
Type 'Class*es' in the buffer (without quotes).
Move the cursor between the '*' and 'e' characters.
Press C-x 8 RET (to execute the insert-char command).
Type 'zero width space' (without quotes) and press RET.
Move the cursor to the beginning of the word and insert a '*' character.
The word "Classes" should now have the desired appearance.
Note that there is the possibility that this will cause problems when exporting.
src_latex{\textbf{Class}es and \textit{Method}s}
Building up on the previous excellent answer
I had to modify it a bit in order to make it work with spacemacs. Indeed, from the spacamacs org-layer documentation, available here, we can read
Because of autoloading, calling to org functions will trigger the
loading up of the org shipped with emacs which will induce conflicts.
One way to avoid conflict is to wrap your org config code in a
with-eval-after-load block [...]
So, I put the following lines inside my dotspacemacs/user-config ()
(eval-after-load "org"
'(progn
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
))