GNU bug report logs - #29286
kill-visible/kill-ring-save-visible commands

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: charles@HIDDEN (Charles A. Roelli); merged with #19471, #25131; dated Mon, 13 Nov 2017 19:29:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 19471 25131 29286. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Nov 2017 19:28:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 13 14:28:34 2017
Received: from localhost ([127.0.0.1]:38878 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eEKPJ-0005gi-OO
	for submit <at> debbugs.gnu.org; Mon, 13 Nov 2017 14:28:33 -0500
Received: from eggs.gnu.org ([208.118.235.92]:52442)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <charles@HIDDEN>) id 1eEKPI-0005gR-2g
 for submit <at> debbugs.gnu.org; Mon, 13 Nov 2017 14:28:32 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <charles@HIDDEN>) id 1eEKPB-00016I-RA
 for submit <at> debbugs.gnu.org; Mon, 13 Nov 2017 14:28:26 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:33185)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <charles@HIDDEN>) id 1eEKPB-000164-NC
 for submit <at> debbugs.gnu.org; Mon, 13 Nov 2017 14:28:25 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43408)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <charles@HIDDEN>) id 1eEKPA-0006q5-Kc
 for bug-gnu-emacs@HIDDEN; Mon, 13 Nov 2017 14:28:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <charles@HIDDEN>) id 1eEKP7-00013m-GD
 for bug-gnu-emacs@HIDDEN; Mon, 13 Nov 2017 14:28:24 -0500
Received: from [2a03:2040:2:1b::1] (port=59444 helo=sinyavsky.aurox.ch)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <charles@HIDDEN>) id 1eEKP7-00011D-7d
 for bug-gnu-emacs@HIDDEN; Mon, 13 Nov 2017 14:28:21 -0500
Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1])
 by sinyavsky.aurox.ch (Postfix) with ESMTP id 6BC63225BA
 for <bug-gnu-emacs@HIDDEN>; Mon, 13 Nov 2017 19:21:02 +0000 (UTC)
Authentication-Results: sinyavsky.aurox.ch (amavisd-new);
 dkim=pass (1024-bit key) reason="pass (just generated, assumed good)"
 header.d=aurox.ch
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h=
 subject:subject:to:from:from:message-id:date:date; s=dkim; t=
 1510600860; x=1511464861; bh=6b4RFqY3L68P2jl3ic4HrPUBk2ekILE93hw
 nUHmf9B0=; b=YMd8qYDHiPwswXHwKuNO/Qna9hhp8hX9ITwjYoKHAfZqZjyCDt4
 oO9uLCNLV9pPvfHJukmN4TvcgUO3+CqeYbQfOS7dw78e90A2+5HIhKw6bqcsRhST
 YxRYpgH7SZ5KYSyH5jqcoO3Pq2C2jHb7l4FPzr+9cv/FzsrxipbS4BuE=
X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com
Received: from sinyavsky.aurox.ch ([127.0.0.1])
 by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new,
 port 10026) with ESMTP id IQONR95SYu5Z for <bug-gnu-emacs@HIDDEN>;
 Mon, 13 Nov 2017 19:21:00 +0000 (UTC)
Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch
 [178.192.85.125])
 by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 726A422570
 for <bug-gnu-emacs@HIDDEN>; Mon, 13 Nov 2017 19:21:00 +0000 (UTC)
Date: Mon, 13 Nov 2017 20:28:18 +0100
Message-Id: <m2o9o6vuzx.fsf@HIDDEN>
From: charles@HIDDEN (Charles A. Roelli)
To: bug-gnu-emacs@HIDDEN
Subject: kill-visible/kill-ring-save-visible commands
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

It can be convenient sometimes to kill text exactly as it is
displayed.  For example, if you have some text in a program hidden
with "hs-minor-mode", then want to copy part of the buffer including
the hidden text, the hidden text will still be part of the killed
text.  Or if you kill text in an Info node, you sometimes find that
you've also yanked some invisible text with it.  I wrote the following
commands to test omission of invisible text:

  (defun kill-visible-region (beg end &optional delete)
     (interactive (list (mark) (point) t))
     (let ((filter-buffer-substring-function 'visible-buffer-substring))
       (kill-ring-save beg end region)))

  (defun kill-ring-save-visible-region (beg end &optional delete)
     (interactive (list (mark) (point) nil))
     (let ((filter-buffer-substring-function 'visible-buffer-substring))
       (kill-ring-save beg end delete)))

  (defun visible-buffer-substring (beg end delete)
     "Return visible text in BEG to END in the current buffer.

  Delete if DELETE is non-nil."
     (let ((text "") (ellipse-p nil))
       (save-excursion
	 (goto-char beg)
	 (while (< (point) end)
	  (let ((invis (invisible-p (point))))
	    (cond ((eq invis nil)
		   (setq text (concat text (make-string
					    1 (char-after (point))))
			 ellipse-p nil))
		  ((eq invis t) (setq ellipse-p nil))
		  ((and invis (not ellipse-p))
		   (setq text (concat text (make-string 3 ?.))
			 ellipse-p t)))
	    (goto-char (1+ (point))))))
       (if delete (delete-region beg end))
       text))

They work for the purpose of killing text partially hidden by
hs-minor-mode, but the solution is not general, since there are many
ways to make text in Emacs display something other than its
characters.

I had also written another command using `text-char-description' to
kill text in a lossy way, so that literal characters like ^@ would be
killed as the two characters "^@".  It would also make sense to make
that part of `kill-visible-region', if it's possible.




Acknowledgement sent to charles@HIDDEN (Charles A. Roelli):
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#29286; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.