help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : What is the difference between (deactivate-mark) and (s


From: Drew Adams
Subject: RE: [External] : What is the difference between (deactivate-mark) and (setq deactivate-mark t)?
Date: Sat, 3 Apr 2021 04:24:22 +0000

Here are some examples from my code:

1. `mark-buffer-after-point'.  The purpose of the command
   is precisely to select some text as the region.

(defun mark-buffer-after-point (reversep)
  "Select the part of the buffer after point.
With a prefix argument, select the part before point."
  (interactive "P")
  (push-mark (if reversep (point-min) (point-max)) nil t)
  (setq deactivate-mark  nil))

2. `isearchp-set-region-around-search-target'.  Again,
   the purpose is to select some text (the search hit)
   and leave it selected.

(defun isearchp-set-region-around-search-target ()
  "Set the region around the last search or query-replace target."
  (interactive)
  (case last-command
    ((isearch-forward isearch-backward
      isearch-forward-regexp isearch-backward-regexp)
     (push-mark isearch-other-end t 'activate))
    (t (push-mark (match-beginning 0) t 'activate)))
  (setq deactivate-mark  nil))

3. `Info-change-visited-status'.  Do stuff, but first
   record whether the region was active at the outset.
   When done, if it was active then re-activate it; if
   it wasn't then deactivate it.

 (Info-change-visited-status START END &optional ARG)

 Change whether the nodes in the region have been visited.
 If the region is not active then act on only the node at point.
 No prefix arg means toggle the visited status of each node.
 A non-negative prefix arg means consider the nodes visited.
 A negative prefix arg means consider the nodes not visited.

   The command does stuff, but it ends with this, where
   variable `active' is non-nil if the region was active
   at the outset.

(if (not active)
    (deactivate-mark)
  (activate-mark)
  (setq deactivate-mark  nil))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]