How can I keep footnotes together with message text when top-posting? - emacs

I want better control of the footnote positioning within an email message. I could write the code to modify footnote-mode to do what I want, but first I want to see if somebody else has already solved this problem.
When I am top-posting with message-mode and add an entry with footnote-mode the footnotes go to the end of the buffer, but instead I want it to come before the previous message citation which starts out with something like:
Elvis Presley <the.king#graceland.com> writes:
If I have a signature automatically added based on footnote-signature-separator then the footnotes get positioned before the signature, however in email I don't use a signature. And furthermore, when I use a closing like:
-Elvis
or
Thanks,
Elvis
then I usually want to footnotes to come after that closing.
What I would like is to have the best optimal position detected automatically whether I am top-posting or in-line posting. I expect the best solution will be to use text-properties-at to detect gnus-cite-* lines and maybe to define text properties for the footnotes section. And/or maybe overlays?
Also note that suggestions like the following will not work:
(setq footnote-signature-separator "^-- $\\|#.*writes:")
Not only is that overly simplistic for the kind of positioning control I would like, but it also simply does not work correctly.

Related

Howto include file content in a Scribble document

I am using Scribble to write assignments and would like to have the ability to include common text snippets somewhere in the document. For example:
#lang scribble/manual
#section{Some section}
#include-file["common-pretext.scrbl"] #; my imaginary command
Some additional text after the pretext
#section{Next section}
More text...
I would like #include-file to include the contents of common-pretext.scrbl just as if I had copy/pasted its contents at the specified position. That is, I would like its contents to be part of Some section and also properly handle Scribble commands occurring in common-pretext.scrbl.
I know that Scribble has #include-section, which is similar to what I want. However, #include-section always starts a new section and text following it until the next section is silently dropped (I am not sure why this happens, but presumably because of how the document is constructed). I also tried Racket's #include, but then the contents are not shown at all. Lastly, I tried building a macro that does what I want, but failed to make it work (if a macro is the way to go, then I am happy to share my attempts so far).
Is there such a command already and if not how can I build one?
This question is pretty old, but if you are still looking, this package does what you want:
https://docs.racket-lang.org/scribble-include-text/index.html

Collision with two lines of code makes code does not work the way it is meant by me(?)

Try running the following code yourself, and you would notice that "/hello" changes to "/HELLO", but I want it to change it to "hi". On the other hand, I want to keep the 1.st line of code, which changes "hello" to "HELLO". How could I achieve this(?)
This code problem is very related to my last problem:
Collision with two lines of code make code does not work the way it is meant by me, what could I do different to get this work(?)
The soltuion for my last problem was good for that problem, but it is not working for the new above mentioned problem.
::hello::HELLO
::/hello::hi
That is interesting. I really expected it to work by removing / from the EndChars. But after looking at it for a while, it becomes obvious why it's behaving this way. When you type "/hello" it actually matches to both hotstrings, so AHK chooses the first one defined. Anyway, there are two solutions that I know of:
Reorder your hotstrings. Place ::/hello::hi above the other one and you'll always get the desired result. Additionally, you don't need to change the EndChars since / is the first character.
Use the asterisk option on the second hotstring. This will make it update immediately, which may or may not be desirable (I prefer it).

Disabling thing-at-point inside helm-ff-guess-ffap-filenames

I have helm-find-files bound to C-x C-f since it provides a much more convenient way to open files. Unfortunately for me, if point is currently inside something that looks like a filename then that alters helm-find-files's behaviour, often changing its current directory. (See https://github.com/emacs-helm/helm/issues/1178 )
Is there a straightforward way for me to nobble thing-at-point inside helm-find-files-initial-input so that it never believes point is inside a filename? I thought that defadvice would help but I'm having trouble working out how.
Or perhaps there's a better way to make helm-find-files behave consistently no matter where point is without modifying its implementation directly?
You can set helm-find-file-ignore-thing-at-point to t.
Documentation:
Use only ‘default-directory’ as default input in ‘helm-find-files’.
I.e text under cursor in ‘current-buffer’ is ignored.
Note that when non-nil you will be unable to complete filename at point
in ‘current-buffer’.

Docco ignore blocks of comments

I am using docco as a tool for creating coffeescript documentation.
By default, every comment I make in coffeescript source is treated as documentation and moved to the left (explainatory) column.
The problem is, in my source there are some lines of code commented out, left as alternate options, which I want to remain in the right (code) column.
Is there a way to tell docco- "do not touch that, leave this like it is a normal code"?
"#!" or "#ignore" maybe?
Thanks in advance.
Have you tried it? It will ignore #! hashbang lines.
Ignore hashbangs and interpolations...
l.commentFilter = /(^#![/]|^\s*#\{)/
languages
languages = buildMatchers languages
From the source, line 277 https://github.com/jashkenas/docco/blob/master/docco.litcoffee
If nothing else, you should be able to edit the source to add whatever opt out you would like there.

why shouldn't I use a push-mark

I implemented a small function, which parses an SQL INSERT statement and highlights a column value when a cursor is on a column name and vice versa.
Then I wanted to add a possibility to quickly jump between column name and column value. I used push-mark in my implementation, so I can jump with C-x C-x (exchange-point-and-mark). It works too, the only thing which bothers me is a elisp doc, which says
Novice Emacs Lisp programmers often
try to use the mark for the wrong
purposes. The mark saves a location
for the user's convenience. Most
editing commands should not alter the
mark.
My usage of mark - is it correct? Or what would be a better solution?
Consider an analogy with the position of point: the user only wants point to move when they issue a point-moving command. It would be exceedingly annoying if random operations like font-locking moved the point. Hence the recommendation to wrap function bodies in (save-excursion ...).
If your function sets the mark explicitly for the user, that's fine. (In this case I suggest calling your function something like sql-mark-column-value to make it clear that setting the mark is one of the things it does.) The point of the documentation you quoted is that commands should not set the mark incidentally as a result of doing something else.
If your function just happens to set the mark when the user places point on a a column name in a SQL statement, that's probably not so convenient. Imagine a use case of someone trying to cut or copy a section of a SQL statement; every time they try to move point within the statement their mark gets clobbered! For this use case you probably want to provide a separate command like sql-goto-column-value instead of relying on exchange-point-and-mark.
Of course, if this is purely for your own use, anything goes.
AFAIK, this is the correct use of push-mark. I think the documentation discourages the use of push-mark instead of save-excursion for the purpose of saving the state of the buffer while performing certain operations.