all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Marcin Borkowski <mbork@mbork.pl>,
	Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: RE: [External] : What is the difference between (deactivate-mark) and (setq deactivate-mark t)?
Date: Sat, 3 Apr 2021 04:24:22 +0000	[thread overview]
Message-ID: <SA2PR10MB4474E38A7BF87F1299FB05EBF3799@SA2PR10MB4474.namprd10.prod.outlook.com> (raw)
In-Reply-To: <SA2PR10MB44744BBB485D902F0AFCD49CF3799@SA2PR10MB4474.namprd10.prod.outlook.com>

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	other threads:[~2021-04-03  4:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-03  3:42 What is the difference between (deactivate-mark) and (setq deactivate-mark t)? Marcin Borkowski
2021-04-03  4:11 ` [External] : " Drew Adams
2021-04-03  4:13   ` Drew Adams
2021-04-03  4:24     ` Drew Adams [this message]
2021-04-07  5:14   ` Marcin Borkowski
2021-04-07  7:25     ` tomas
2021-04-07 14:58       ` Drew Adams
2021-04-07 15:30         ` tomas
2021-04-07 14:54     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SA2PR10MB4474E38A7BF87F1299FB05EBF3799@SA2PR10MB4474.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mbork@mbork.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.