Hot answers tagged

64

I personally stick to writing things in org-mode with flyspell-mode and langtool... org-mode is fantastic for typing any sort of document quickly in Emacs, flyspell takes care of spelling, and langtool worries about the grammar. Everything is highly customizable too, so you can customize anything to your heart's content. Here is a quick little type-up in ...


19

Here's a function that will convert DOuble CApitals to Single Capitals. I'd originally suggested adding it to post-self-insert-hook, but below is an option for a glorified minor mode so that you only add to that hook when you really want it: (defun dcaps-to-scaps () "Convert word in DOuble CApitals to Single Capitals." (interactive) (and (= ?w (char-...


15

I write novels using Emacs, and have developed a workflow over time based on certain unique advantages of it. (Example: My most recent book was conceived, composed, and edited with Emacs.) That said, it is not a road without difficulties. Org-mode Org-mode is the reason I began using Emacs. Being able to fold and unfold sections of a ~50K-words manuscript ...


15

The EmacsWiki category Writing is the place to start. It lists dozens of libraries that support writing text using Emacs, with one-liner descriptions and links to the detail pages. There is no sense listing such info again here - consult it there. (But perhaps others here will have specific recommendations.) I will mention only the subcategory page ...


13

Try setting sentence-end-double-space to nil.


11

Spin off of the original answer to the linked question. Grammar Check: I am not aware of any dedicated grammar parsers for emacs yet. I will mention writegood-mode available in MELPA which highlights weasel words and passive voice in the buffer. It gets you half the way there. Another possibly useful library is dupwords.el which can highlight if a ...


8

My preference is to simply create a new function that does what the usual self-insert-command would do plus more. Here are few reasons: Finer control on which major modes should have this auto-correcting capability. For this use case, it could be text-only modes like org-mode, text-mode, etc. For the type of correction requested in the question, user would ...


7

I don't know of such built-in function, but here's something I could put together while waiting for compilation to finish: (defun char-stats (&optional case-sensitive) (interactive "P") (message "case-sensitive: %s" case-sensitive) (let ((chars (make-char-table 'counting 0)) current) (cl-labels ((%collect-statistics ()...


7

Something like Markdown or Org seems appropriate here, but if you are just looking for an easier way to manage footnotes you can enable footnote-mode. That provides key-bindings for adding a new footnote, jumping between the reference and the footnote, and so on.


6

The documentation offers a couple of options: https://www.gnu.org/software/emacs/manual/html_node/elisp/Fringe-Size_002fPos.html One of the options mentioned uses buffer-local variables -- i.e., left-window-fringe and right-window-fringe. However, the documentation discusses some exceptions when those settings will not take effect immediately. The ...


5

Search and replace already exists in Emacs! C-M-% ^.*?[0-9]:.*?seconds RET RET . C-M-% invokes query-replace-regexp. You enter a regular expression, then the replacement text (empty). The final . says to perform one replacement only, you can press Y instead to replace all remaining occurrences, y or n to replace the current occurrence or not and move to ...


5

Yes: there's for example text-clone-create which can be used for that (typically used for small chunks of text such as the tag names in XML's tag pairs), as well as the lentic package.


5

This is controlled by the variable auto-mode-alist, which you can modify by adding the following line to your emacs init file: (add-to-list 'auto-mode-alist '("\\.pdb$" . text-mode)) The "\\.pdb$" part is a regular expression that matches files ending in pdb. The part after the period is the mode you want to use instead of the default.


5

The format of output (org-mode table) is inspired by the link in your question. (require 'cl-lib) (defvar punctuation-marks '("," "." "'" "&" "\"") "List of Punctuation Marks that you want to count.") (defun count-raw-word-list (raw-word-...


5

In the following I assume that the order of the lines in the result buffer is irrelevant. For medium size buffers you can use cl-intersection: (defun txt-intersection (buffer-a buffer-b) "Only keep the set theoretic intersection of lines in BUFFER-A and BUFFER-B." (interactive "bBuffer A: \nbBuffer B: ") (with-current-buffer (generate-new-buffer (...


4

IMHO the standard way is: Go to the top of your buffer. Type C-M-% for query-replace-regexp. Input ^\s-+ as regular expression and RET. (See explanation below.) Leave the replacement string empty, i.e., press RET again. You are prompted by query-replace-regexp in the minibuffer. Press ! to perform all replacements at once. Explanation of the regular ...


4

There are lots of ways you could do that. Assuming this is text in a buffer, a simple regexp-based approach is to use M-x replace-regexp to replace . with \& (n.b. that's \&SPC) to replace each non-newline character with itself followed by a space. As that does match the final character of each non-blank line, that will introduce a space at the end ...


4

You can simply run M-x eval-expression and type ?O. You will get the following output in the minibuffer: 79 (#o117, #x4f, ?O)


3

As can be inferred from the question, a possible answer would be: (apply #'max (mapcar #'string-width (split-string STR "\n"))) but this may still not be sufficient depending on your particular needs (e.g. do you need to take into account proportional fonts, or possible presence of images, or ...), so you may like to expand your question by explaining what ...


3

You could try pandoc, e.g. with ox-pandoc. The command line would be like this: pandoc -t plain -o outfile.txt YOUR_ORG_FILE.org The output is: HEADER 1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Header 2 code block


3

My question is: how can I turn this function into a command I can call interactively? Use the special form interactive, also see manual (elisp) Defining Commands. Here is a command named foo which uses your mu-convert-to-acronym. (defun foo (arg) "Convert word at (or next to) point to its acronym with `mu-convert-to-acronym'. With numerical argument ...


3

Eval the following code and type M-x word-frequency in a buffer with the text. You will get a buffer with the number of word occurence and percent value. (defvar word-frequency-table (make-hash-table :test 'equal :size 128)) (defvar word-frequency-buffer "*frequencies*" "Buffer where frequencies are displayed.") (defun word-frequency-incr (word) (...


3

Based on the screenshot, you are only interested in quotes spanning multiple lines. Here's a patten for that: "\\(``\\(?:[^'\n]\\|'[^'\n]\\)*'?\\)\n\\(?:.\\|\n\\)*?''" Or in rx syntax: (rx (seq (group "``" (zero-or-more (or (not (in "\n'")) (seq "'" (not (in "\n'"))))) (zero-or-one "'")) "\n"...


3

If you use regular expressions as suggested by one of the other answers, you have to be careful to avoid checking text outside of quotes for uppercase letters. If you use just a single regular expression, you probably end up with the wrong result for This is a "text" with some UPPERCASE letters outside the "quoted text" You probably need to iterate through ...


2

(defun line-length (n) "Length of the Nth line." (save-excursion (goto-char (point-min)) (if (zerop (forward-line (1- n))) (- (line-end-position) (line-beginning-position))))) or calculate the length of all lines in current-buffer (or of the accessible portion): (defun line-lengths () (let (lengths) (save-excursion ...


2

A brief Google search ("open source English grammar checker" and "langtool emacs") led me to langtool.el, which can be installed using MELPA. PS: I haven't tried it yet, but I definitely will.


2

Like said, there are no standard ways of doing complicated things in emacs. Assuming project is defined as a git repository, you can do the following: Install abo-abo's swiper/ivy/councel, https://github.com/abo-abo/swiper, and wgrep from ELPA. Bind the necessary commands to keys of your choice, especially ivy-occur that is usually C-c C-o and wgrep (C-x C-...


2

While not exactly what you need but... You can try comment-box command together with C-u 20 prefix (or whatever number you want): You can also write your own function to do it (just grab the sources of the comment-box and try to adjust it to remove 1st and last comment lines + add padding you need). ... ... ... Now, I had a look into the source code ...


2

Does this do the right thing? (count-matches paragraph-start)


2

Here is how the builtin count-lines works: (- (buffer-size) (forward-line (buffer-size))) The following changes forward-line to forward-paragraph to implement the function. (defun count-paragraphs (start end) "Return number of paragraphs between START and END." (save-excursion (save-restriction (narrow-to-region start end) (goto-char (...


Only top voted, non community-wiki answers of a minimum length are eligible