From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: associating bookmarks with paragraphs Date: Thu, 6 Dec 2018 16:42:20 +0000 (UTC) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1544114608 21479 195.159.176.226 (6 Dec 2018 16:43:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Dec 2018 16:43:28 +0000 (UTC) To: Michael Maurer , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 06 17:43:23 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUwkE-0005SN-Uh for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Dec 2018 17:43:23 +0100 Original-Received: from localhost ([::1]:41913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUwmL-000357-Kx for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Dec 2018 11:45:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUwjT-0000yX-4t for help-gnu-emacs@gnu.org; Thu, 06 Dec 2018 11:42:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUwjP-0001D4-PH for help-gnu-emacs@gnu.org; Thu, 06 Dec 2018 11:42:35 -0500 Original-Received: from userp2120.oracle.com ([156.151.31.85]:40570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gUwjP-0001BM-DI for help-gnu-emacs@gnu.org; Thu, 06 Dec 2018 11:42:31 -0500 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB6GfXpH115706; Thu, 6 Dec 2018 16:42:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=H6gHSwDj5FKfbv1nJiB80vsk5LB8bnsiGbDDJ63bAtw=; b=zFcdTw6gwheCGmMb+VX+zT+bN9aJbD9hwBQRkD5qslR9TKg738gWym0CSq5PgNNdL2sw syq7sWJt590XVmjkX/YlXUHomZapJPc5e/XrwdUFDLXetOatJqbf0dy+1mdltVFsOd/D wufreztEEmNsqNToDKr5/6TiNkW7MAqORIyg3DL5SKx0qu5oI1DRy5jkzNAm/i2FgdzB SSCdosdLr4WwwzEfKN91Cj0X4p4hBLoQeUUGNkj+g2Xb/xxGAR3XN0ni1GWY3ToGJw1E IvCZ9Mrmkw9vATWKUJw+phvyYZgoaMBhMWPTQaEGpuIDB4QkO/UNoueQ15qQgT/ZSsd7 og== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2p3jxrs91g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 06 Dec 2018 16:42:26 +0000 Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB6GgKnU017586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Dec 2018 16:42:21 GMT Original-Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB6GgKQc002280; Thu, 6 Dec 2018 16:42:20 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9098 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060142 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118895 Archived-At: > as far as I know, the bookmark option is tied to a line > number. is it possible to associate it with a paragraph, > so when you cut and paste the paragraph to a different > position in your document, the bookmark moves with it? Emacs bookmarks (but perhaps not Org or EWW "bookmarks" - can't speak for those) can bookmark pretty much anything. By default, they bookmark a single position in a buffer, typically a file buffer, not a line number. The position is recorded, but so (by default) are some text before and after the position. If, when you jump to a bookmark, the bookmarked position is not between such text snippets then Emacs tries to reposition the bookmark position, by searching forward and backward for those saved text sequences (context). It's not clear to me what you want to bookmark: (1) A snippet of text that you (by jumping to the bookmark) paste here and there? (2) Automatic relocation of a bookmarked position (e.g. of a paragraph)? (3) Something else? 1. If you use Bookmark+ then you can do #1 by using a snippet bookmark. That records a snippet of text (e.g. your paragraph), and when you jump to the bookmark that text gets copied to the `kill-ring', so you can paste it anywhere. You can create (set) a snippet bookmark using command `bmkp-set-snippet-bookmark', bound by default to `C-x p c M-w' (bookmark-creation commands are put on prefix key `C-x p c', by default). You can jump to (i.e., use) a snippet bookmark using command `bmkp-snippet-to-kill-ring', bound by default to `C-x j M-w' (bookmark-jump commands are put on prefix key `C-x j', by default). (Or you can jump to it using the ordinary command `bookmark-jump', which is bound by default to `C-x j j'. But in that case the available bookmark-name completion candidates are all bookmarks, not just snippet bookmarks.) But you also say "so when you cut and paste the paragraph to a different position in your document, the bookmark moves with it." That's unclear - makes no sense to me. When you use a snippet bookmark the bookmarked snippet of text becomes available for pasting. When you paste that text no bookmark is created in the buffer where you paste it. What bookmark do you want to "move with" the pasted text? 2. But maybe you meant something completely different. Maybe meant only that you want to bookmark the position of a paragraph and then jump to that later, and have that jump be accurate even if that paragraph has been moved to a different location in your buffer/file? If that's all you're asking then the answer is yes, that's what Emacs does already - see above, about automatically relocating a bookmarked position by searching for its recorded context. However, if the recorded context is no longer relevant at all then Emacs won't be able to relocate the new position accurately. There is another possibility that can help here. With Bookmark+ you can bookmark not only a single position, with its surrounding context, but two positions, with their surrounding context. This happens if you bookmark the active region, i.e., select your paragraph before bookmarking it. If option `bmkp-use-region' is non-nil (the default) then when you jump to a bookmark that records the region (beginning and end positions, and surrounding text), the targeted text that you jump to is highlighted as the active region. --- You can also define your own region handler for bookmarks that record regions. (This is in addition to being able to define bookmark handlers.) Use option `bmkp-handle-region-function' for this. As one example, command `bmkp-region-jump-narrow-indirect-other-window' binds the option to a function that narrows the targeted region in a cloned indirect buffer. (You need library `narrow-indirect.el' for that command.) https://www.emacswiki.org/emacs/BookmarkPlus