Why I should not use push-mark

I implemented a small function that parses an SQL INSERT statement and highlights the column value when the cursor is on the column name and vice versa.

Then I wanted to add the ability to quickly jump between the column name and the column value. I used push-mark in my implementation, so I can jump from Cx to Cx (exchange point and mark). This works too, the only thing that bothers me is the elisp document, which says

Newbie Emacs Lisp programmers often try to use a sign for the wrong purpose. The icon saves the location for user convenience. Most editing teams should not sign.

My use of tag is right? Or what would be the best solution?

+5
source share
2 answers

Consider the analogy with the position of a point: the user only wants the point to move when they issue a command to move the point. It would be extremely unpleasant if random operations, such as blocking fonts, moved the point. Therefore, it is recommended to wrap functional bodies in (save-excursion ...).

If your function explicitly sets a sign for the user, that’s fine. (In this case, I suggest calling your function something like sql-mark-column-value, so that it’s clear that setting a label is one of the things that it does.) The citation point that you are quoting is that the commands should not be checked as a result, do something else.

, SQL-, , , . , SQL; , , ! , , sql-goto-column-value , exchange-point-and-mark.

, , .

+7

AFAIK, push-. , push- save-excursion .

+2
source

All Articles