unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: [Solved]
  2010-08-14  8:05             ` Eli Zaretskii
@ 2010-08-14 21:18               ` Memnon Anon
  2010-08-14 22:27                 ` [Solved] Eli Zaretskii
  0 siblings, 1 reply; 24+ messages in thread
From: Memnon Anon @ 2010-08-14 21:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> I urge you to reconsider.  Sending an email saying that the doc string
> of org-clock-in does not say what value to assign to the SELECT
> argument in a non-interactive call does not need any high level of
> expertise.  

Sending the mail does not need expertise. But recognizing if something
really is a deficiency does. Bug reports are great, but creating
"noise" is not; and I really don't want to be a nuisance to the experts
who provide me with so excellent tools. And even if I did recognize a
lack of precision - which requires some knowledge of best practice in
doc strings - I would want to send a patch, which requires even more
knowledge of doc strings in general (= not only seeing what is wrong but
also 'fixing' it).

One way is looking for other docstrings that seem to be "better".
In org, I found lots of functions that are usually called interactively
that have a doc string like the one before.
see eg:

,----[ org-remember.el ]
| (defun org-remember (&optional goto org-force-remember-template-char)
|   "Call `remember'.  If this is already a remember buffer, re-apply template.
| If there is an active region, make sure remember uses it as initial content
| of the remember buffer.
| 
| When called interactively with a \\[universal-argument] \
| prefix argument GOTO, don't remember
| anything, just go to the file/headline where the selected template usually
| stores its notes.  With a double prefix argument \
| \\[universal-argument] \\[universal-argument], go to the last
| note stored by remember.
| 
| Lisp programs can set ORG-FORCE-REMEMBER-TEMPLATE-CHAR to a character
| associated with a template in `org-remember-templates'."
|   (interactive "P")
|   (org-require-remember)
|   (cond
|    ((equal goto '(4)) (org-go-to-remember-target))
|    ((equal goto '(16)) (org-remember-goto-last-stored))
`----

I (so far) only found one docstring that seems "better" in this regard:

,----[ org-agenda.el ]
| (defun org-agenda-set-restriction-lock (&optional type)
|   "Set restriction lock for agenda, to current subtree or file.
| Restriction will be the file if TYPE is `file', or if type is the
* universal prefix '(4), or if the cursor is before the first headline
| ^^^^^^^^^^^^^^^^^^^^^^               
| in the file.  Otherwise, restriction will be to the current subtree."
`----

This one says explicitly '(4) is what is tested against.

So should I look for all interactive functions that check against a
universal argument with 

          (when (equal arg '(4)) ... 

and suggest the docstring, which usually only says something like: "When 
using \\[universal-argument], ..." to be modified like:
"When using \\[universal-argument] '(4)"? (Of course on a case to case
basis whenever it seems not clear so far.)

> If a doc string does not explain what are the valid values of the
> function's arguments, then that doc string needs to be improved.
> Documenting this is the absolute minimum of any doc string; without
> that, the doc string is useless.  It is sometimes okay to omit these
> details if the valid values are clear from the text and the context.
> But I cannot see how someone could claim that the value '(4) could be
> "clear".

Mhhh.
Please have a look at this docstring:

,----[ org-agenda.el ]
| (defun org-agenda-clock-out (&optional arg)
|   "Stop the currently running clock."
|   (interactive "P")
|   (unless (marker-buffer org-clock-marker)
|     (error "No running clock"))
|   (let ((marker (make-marker)) newhead)
|     (org-with-remote-undo (marker-buffer org-clock-marker)
|       (with-current-buffer (marker-buffer org-clock-marker)
| 	(save-excursion
| 	  (save-restriction
| 	    (widen)
| 	    (goto-char org-clock-marker)
| 	    (org-back-to-heading t)
| 	    (move-marker marker (point))
| 	    (org-clock-out)
| 	    (setq newhead (org-get-heading))))))
|     (org-agenda-change-all-lines newhead marker)
|     (move-marker marker nil)))
`----

This function takes an (optioal) arg, but it is in now way explain what
this arg does.

To tell the truth, in contrast to `org-agenda-clock-in', I do not even
see where this arg is used anywhere in the function...

Should I really file bug reports when I obviously do not understand
whats going on? I don't think so.

Plus: All these points are not really important, because these functions
are meant to be used interactively, what they usually are ...  except
when someone wants to bind them to a key with a lambda like in the case
of C-u C-c C-x C-i (org-clock-in) before.


Memnon

P.S.: Cool, I saw you really use the convention to start a new sentence
      with <SPC> <SPC>. I never saw anyone really that :)



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Solved]
  2010-08-14 21:18               ` [Solved] Memnon Anon
@ 2010-08-14 22:27                 ` Eli Zaretskii
  0 siblings, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2010-08-14 22:27 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Memnon Anon <gegendosenfleisch@googlemail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Sat, 14 Aug 2010 23:18:21 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I urge you to reconsider.  Sending an email saying that the doc string
> > of org-clock-in does not say what value to assign to the SELECT
> > argument in a non-interactive call does not need any high level of
> > expertise.  
> 
> Sending the mail does not need expertise. But recognizing if something
> really is a deficiency does. Bug reports are great, but creating
> "noise" is not; and I really don't want to be a nuisance to the experts
> who provide me with so excellent tools. And even if I did recognize a
> lack of precision - which requires some knowledge of best practice in
> doc strings - I would want to send a patch, which requires even more
> knowledge of doc strings in general (= not only seeing what is wrong but
> also 'fixing' it).

Sending a patch is fine.  But if you cannot send a patch, at least
make a bug report.  Doing nothing after you spotted a problem is IMO
worse than sending a bug report out of mistake or misunderstanding.

> One way is looking for other docstrings that seem to be "better".
> In org, I found lots of functions that are usually called interactively
> that have a doc string like the one before.

Even more reason to submit a report: it sounds like many doc strings
there need the same treatment.

> Should I really file bug reports when I obviously do not understand
> whats going on?

Yes.  An unclear doc string needs improvement.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* how to randomize (scample) regions in a an (org) buffer
@ 2021-10-06 15:53 Uwe Brauer
  2021-10-06 16:35 ` [SOLVED] (was: how to randomize (scample) regions in a an (org) buffer) Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2021-10-06 15:53 UTC (permalink / raw)
  To: help-gnu-emacs



Hi

I need to replace private information in my org files, but only region wide.

I found 
https://www.reddit.com/r/emacs/comments/6pc0ts/sanitize_buffer_by_replacing_words_with_random/

Where two such functions are discussed, one is even for org files,
however only buffer wide and the code looks rather complicated to me.

Anybody knows about such a function?

Thanks 

Uwe Brauer 




^ permalink raw reply	[flat|nested] 24+ messages in thread

* [SOLVED] (was: how to randomize (scample) regions in a an (org) buffer)
  2021-10-06 15:53 how to randomize (scample) regions in a an (org) buffer Uwe Brauer
@ 2021-10-06 16:35 ` Uwe Brauer
  2021-10-06 19:59   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2021-10-06 16:35 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:

> Hi

> I need to replace private information in my org files, but only region wide.

> I found 
> https://www.reddit.com/r/emacs/comments/6pc0ts/sanitize_buffer_by_replacing_words_with_random/

> Where two such functions are discussed, one is even for org files,
> however only buffer wide and the code looks rather complicated to me.

Actually it was quite easy as in 

(defun randomise-region ()
  "Like `ap/replace-words-randomly', but only replace inside region if it is active.
If the region is not active, replace from point to the end of the
buffer.  The region is never considered active outside
`transient-mark-mode'. "
  (interactive)
  (if (or (and (boundp 'zmacs-region-active-p) zmacs-region-active-p)
	  (and (boundp 'transient-mark-mode) transient-mark-mode mark-active))
      (save-restriction
        (save-excursion
          (narrow-to-region (point) (mark))
          (goto-char (point-min))
          (ap/replace-words-randomly)))
    (ap/replace-words-randomly)))

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED] (was: how to randomize (scample) regions in a an (org) buffer)
  2021-10-06 16:35 ` [SOLVED] (was: how to randomize (scample) regions in a an (org) buffer) Uwe Brauer
@ 2021-10-06 19:59   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-06 20:24     ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 19:59 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

> Actually it was quite easy as in 
>
> (defun randomise-region ()
>   "Like `ap/replace-words-randomly', but only replace inside region if it is active.
> If the region is not active, replace from point to the end of the
> buffer.  The region is never considered active outside
> `transient-mark-mode'. "
>   (interactive)
>   (if (or (and (boundp 'zmacs-region-active-p) zmacs-region-active-p)
> 	  (and (boundp 'transient-mark-mode) transient-mark-mode mark-active))
>       (save-restriction
>         (save-excursion
>           (narrow-to-region (point) (mark))
>           (goto-char (point-min))
>           (ap/replace-words-randomly)))
>     (ap/replace-words-randomly)))

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/sort-incal.el
;;;   https://dataswamp.org/~incal/emacs-init/sort-incal.el

(require 'edit)
(require 'erc)
(require 'sort)

(setq sort-fold-case t)

(defun sort-second-field (beg end)
  (interactive "r")
  (sort-fields 2 beg end) )
(defalias 's2f #'sort-second-field)

(defun sort-lines-length (beg end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (list (point-min) (point-max)) ))
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (sort-subr nil
                 #'forward-line
                 #'end-of-line
                 nil nil
                 (lambda (a b) (> (- (cdr a) (car a))
                                  (- (cdr b) (car b)) ))))))
(defalias 'sll #'sort-lines-length)

(defun sort-lines-random (beg end)
  (interactive "r")
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (sort-subr nil
                 #'forward-line
                 #'end-of-line
                 nil nil
                 (lambda (_ __) (zerop (random 2)) )))))
(defalias 'r #'sort-lines-random)

;; test here:
;; aaa
;; ccc
;; bbb
;; ddd

(defun sort-buffer-random ()
  (interactive)
  (sort-lines-random (point-min) (point-max))
  (save-buffer) )

(defun sort-whole-lines (beg end)
  (interactive "r")
  (save-excursion
    (let ((s (progn (goto-char beg) (line-beginning-position)))
          (e (progn (goto-char end) (line-end-position))) )
      (sort-lines nil s e) )))

(defun sort-buffer-and-save ()
  (interactive)
  (sort-lines nil (point-min) (point-max))
  (save-buffer) )
(defalias 'bs #'sort-buffer-and-save)

(defun insert-string-list (string-list)
  (when string-list
    (insert (format "%s" (car string-list)))
    (dolist (s (cdr string-list))
      (insert (format " %s" s)))))

(defun sort-line-words (beg end &optional set-delim)
  (interactive "r\nP")
  (let*((str       (region-to-string))
        (delim-str (when set-delim
                     (read-string "delimiter: ") ))
        (str-list  (split-string str delim-str))
        (sorted    (erc-sort-strings str-list)) )
    (kill-region beg end)
    (if set-delim
        (progn
          (dolist (s (nreverse (cdr (nreverse sorted))))
            (insert (format "%s%s" s delim-str)))
          (insert (format "%s" (car (last sorted)))))
      (insert-string-list sorted) )))
;;; sort me: a is just string test this
;;; sorted:  a is just string test this
;;;
;;; and me with a dash delim: this-is-just-a-test-string

(defun scramble (beg end)
  "Shuffle chars in region from BEG to END."
  (interactive "r")
  (when (use-region-p)
    (save-excursion
      (let*((str        (region-to-string))
            (chars      (delete "" (split-string str "")))
            (rand-chars (sort chars (lambda (_ __) (zerop (random 2))))) )
        (delete-region beg end)
        (dolist (c rand-chars)
          (insert c) )))))

(require 'seq)
(defun scramble-string (str)
  "Randomize the characters of a string."
  (interactive "sscramble me: ")
  (let ((rand-str (seq-sort (lambda (_ __) (zerop (random 2))) str )))
    (if (called-interactively-p 'any)
        (message rand-str)
      rand-str) ))

(defun comic-book-insult ()
  (interactive)
  (insert (concat (scramble-string "@#$%&") "!")) )

;; (comic-book-insult) ; @#$%&!
;; (comic-book-insult) ; $&#@%!

;; (scramble-string "Hello there, Emacs is very cool piece of software")
;; "aye eposrr lvre olsec,ewfico ceti ftomH hseoa l E"

(provide 'sort-incal)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2021-10-06 19:59   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 20:24     ` Uwe Brauer
  2021-10-06 20:58       ` [SOLVED] Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2021-10-06 20:24 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]

>>> "EBvUlftGEte" == Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:

> Uwe Brauer wrote:
>> Actually it was quite easy as in 
>> 
>> (defun randomise-region ()
>> "Like `ap/replace-words-randomly', but only replace inside region if it is active.
>> If the region is not active, replace from point to the end of the
>> buffer.  The region is never considered active outside
>> `transient-mark-mode'. "
>> (interactive)
>> (if (or (and (boundp 'zmacs-region-active-p) zmacs-region-active-p)
>> (and (boundp 'transient-mark-mode) transient-mark-mode mark-active))
>> (save-restriction
>> (save-excursion
>> (narrow-to-region (point) (mark))
>> (goto-char (point-min))
>> (ap/replace-words-randomly)))
>> (ap/replace-words-randomly)))

> ;;; -*- lexical-binding: t -*-
> ;;;
> ;;; this file:
> ;;;   http://user.it.uu.se/~embe8573/emacs-init/sort-incal.el
> ;;;   https://dataswamp.org/~incal/emacs-init/sort-incal.el

> (require 'edit)
> (require 'erc)
> (require 'sort)

Thanks but the file edit, is missing at least not included in my emacs

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2021-10-06 20:24     ` [SOLVED] Uwe Brauer
@ 2021-10-06 20:58       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-07  7:05         ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 20:58 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

> Thanks but the file edit, is missing at least not included
> in my emacs

You are right, "must" fix the names, try these and only these:

(defun region-to-string ()
  "Return the region text as a string. Replace newlines with spaces."
  (when (use-region-p)
    (let ((beg (region-beginning))
          (end (region-end) ))
    (let ((text (buffer-substring-no-properties beg end)))
      (replace-regexp-in-string "\n" " " text) ))))

(defun scramble (beg end)
  "Shuffle chars in region from BEG to END."
  (interactive "r")
  (when (use-region-p)
    (save-excursion
      (let*((str        (region-to-string))
            (chars      (delete "" (split-string str "")))
            (rand-chars (sort chars (lambda (_ __) (zerop (random 2))))) )
        (delete-region beg end)
        (dolist (c rand-chars)
          (insert c) )))))

(require 'seq)
(defun scramble-string (str)
  "Randomize the characters of a string."
  (interactive "sscramble me: ")
  (let ((rand-str (seq-sort (lambda (_ __) (zerop (random 2))) str )))
    (if (called-interactively-p 'any)
        (message rand-str)
      rand-str) ))

(defun comic-book-insult ()
  (interactive)
  (insert (concat (scramble-string "@#$%&") "!")) )

;; (comic-book-insult) ; @#$%&!
;; (comic-book-insult) ; $&#@%!

;; (scramble-string "Hello there, Emacs is very cool piece of software")
;; "aye eposrr lvre olsec,ewfico ceti ftomH hseoa l E"

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2021-10-06 20:58       ` [SOLVED] Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-07  7:05         ` Uwe Brauer
  2021-10-07  8:15           ` [SOLVED] Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2021-10-07  7:05 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

>>> "EBvUlftGEte" == Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:

> Uwe Brauer wrote:
>> Thanks but the file edit, is missing at least not included
>> in my emacs

> You are right, "must" fix the names, try these and only these:

Thanks that works nicely, it is a bit different from the package I use
because mine replaces words by some randomly picked words of the same
size yours randomise also the words. Both approaches work, yours is
independent from any external tool, tough.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2021-10-07  7:05         ` [SOLVED] Uwe Brauer
@ 2021-10-07  8:15           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-07  8:15 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

>>>> "EBvUlftGEte" == Emanuel Berg via Users list for the GNU
>>> Emacs text editor <help-gnu-emacs@gnu.org> writes:
>
>> Uwe Brauer wrote:
>>> Thanks but the file edit, is missing at least not included
>>> in my emacs
>
>> You are right, "must" fix the names, try these and only these:
>
> Thanks that works nicely, it is a bit different from the package I use
> because mine replaces words by some randomly picked words of the same
> size yours randomise also the words. Both approaches work, yours is
> independent from any external tool, tough.

You mean zmacs-region-active-p and/or
ap/replace-words-randomly ?

Yeah, I don't have either ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-24 19:51       ` [SOLVED] (was: problems with better-registers: turn-off-all-minor modes or remove all text-properties) Uwe Brauer
@ 2022-07-24 22:36         ` Michael Heerdegen
  2022-07-25  5:37           ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2022-07-24 22:36 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer <oub@mat.ucm.es> writes:

> Thanks, that did not occur to me. I tried to advice since a while
> since it makes debugging difficult.

Not much, IME.

> (defadvice copy-to-register (before removeproperties activate)
>   "Remove all text properties before setting the property"
>   (let ((inhibit-read-only t))
>     (set-text-properties (point-min) (point-max) nil)))

It would be better and cleaner to change the value that is saved in the
register instead of modifying the buffer.

Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-24 22:36         ` [SOLVED] Michael Heerdegen
@ 2022-07-25  5:37           ` Uwe Brauer
  2022-07-25  5:49             ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-25  5:37 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 970 bytes --]

>>> "MH" == Michael Heerdegen <michael_heerdegen@web.de> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>> Thanks, that did not occur to me. I tried to advice since a while
>> since it makes debugging difficult.

> Not much, IME.

>> (defadvice copy-to-register (before removeproperties activate)
>> "Remove all text properties before setting the property"
>> (let ((inhibit-read-only t))
>> (set-text-properties (point-min) (point-max) nil)))

> It would be better and cleaner to change the value that is saved in the
> register instead of modifying the buffer.

Well I tried that, but I couldn't. As I said modify set-register did not
work for me.

I am not happy about my solution and would appreciate any suggestion.

Uwe 




-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-25  5:37           ` [SOLVED] Uwe Brauer
@ 2022-07-25  5:49             ` Uwe Brauer
  2022-07-25 17:09               ` [SOLVED] Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-25  5:49 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:

>>> "MH" == Michael Heerdegen <michael_heerdegen@web.de> writes:
>> Uwe Brauer <oub@mat.ucm.es> writes:
>>> Thanks, that did not occur to me. I tried to advice since a while
>>> since it makes debugging difficult.

>> Not much, IME.

>>> (defadvice copy-to-register (before removeproperties activate)
>>> "Remove all text properties before setting the property"
>>> (let ((inhibit-read-only t))
>>> (set-text-properties (point-min) (point-max) nil)))

>> It would be better and cleaner to change the value that is saved in the
>> register instead of modifying the buffer.

I just realized that I did not read your message carefully enough.

It seems you suggest 

(defadvice copy-to-register (before removeproperties activate)
  "Remove all text properties before setting the property"
  (let ((inhibit-read-only t))
    (set-text-properties (region-beginning) (region-end) nil)))

Which is what I intended but copied the code incorrectly.

-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-25  5:49             ` [SOLVED] Uwe Brauer
@ 2022-07-25 17:09               ` Stefan Monnier via Users list for the GNU Emacs text editor
  2022-07-25 19:49                 ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-07-25 17:09 UTC (permalink / raw)
  To: help-gnu-emacs

> It seems you suggest 
>
> (defadvice copy-to-register (before removeproperties activate)
>   "Remove all text properties before setting the property"
>   (let ((inhibit-read-only t))
>     (set-text-properties (region-beginning) (region-end) nil)))

No, that still modifies the buffer.  He suggests you apply
`set-text-properties` to the extracted string.


        Stefan




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-25 17:09               ` [SOLVED] Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-07-25 19:49                 ` Uwe Brauer
  2022-07-25 22:37                   ` [SOLVED] Michael Heerdegen
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-25 19:49 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

>>> "SMvUlftGEte" == Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:

>> It seems you suggest 
>> 
>> (defadvice copy-to-register (before removeproperties activate)
>> "Remove all text properties before setting the property"
>> (let ((inhibit-read-only t))
>> (set-text-properties (region-beginning) (region-end) nil)))

> No, that still modifies the buffer.  He suggests you apply
> `set-text-properties` to the extracted string.


Well I tried 

(defadvice set-property (before removeproperties activate)
  "Remove all text properties before setting the property"
  (let ((inhibit-read-only t))
(set-text-properties (region-beginning) (region-end) nil)))

But it did not work

Uwe 




-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-25 19:49                 ` [SOLVED] Uwe Brauer
@ 2022-07-25 22:37                   ` Michael Heerdegen
  2022-07-26  4:57                     ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Heerdegen @ 2022-07-25 22:37 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer <oub@mat.ucm.es> writes:

> Well I tried 
>
> (defadvice set-property (before removeproperties activate)
>   "Remove all text properties before setting the property"
>   (let ((inhibit-read-only t))
> (set-text-properties (region-beginning) (region-end) nil)))
>
> But it did not work

Wouldn't it be appropriate to refresh your knowledge about advices?

Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-25 22:37                   ` [SOLVED] Michael Heerdegen
@ 2022-07-26  4:57                     ` Uwe Brauer
  2022-07-26 13:01                       ` [SOLVED] Thorsten Bonow
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-26  4:57 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 3123 bytes --]

>>> "MH" == Michael Heerdegen <michael_heerdegen@web.de> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>> Well I tried 
>> 
>> (defadvice set-property (before removeproperties activate)
>> "Remove all text properties before setting the property"
>> (let ((inhibit-read-only t))
>> (set-text-properties (region-beginning) (region-end) nil)))
>> 
>> But it did not work

> Wouldn't it be appropriate to refresh your knowledge about advices?

Well I tried this as well, and tried out the new advice-add
functionality.

Here is what I tried 


(defun my-remove-all-text-properties-region ()
  (interactive) ;; that is not important
  (let ((inhibit-read-only t))
    (set-text-properties (region-beginning) (region-end) nil)))

Then 

(advice-add 'set-property :before #'my-remove-all-text-properties-region)

or 

(advice-add 'set-property :around #'my-remove-all-text-properties-region)

Result: no effect


I tried 

(advice-add 'copy-to-register :before  #'my-remove-all-text-properties-region)
or 
(advice-add 'copy-to-register :around  #'my-remove-all-text-properties-region)

Results in an  error:

,----
| Debugger entered--Lisp error: (wrong-number-of-arguments
|   #f(compiled-function () (interactive nil) #<bytecode
|   0x1f6825029d2a6658>) 1)
|   my-remove-all-text-properties-region(#f(compiled-function (register
|   start end &optional delete-flag region) "Copy region into register
|   REGISTER.\nWith prefix arg, delete as well.\nCalled from program,
|   takes five args: REGISTER, START, END, DELETE-FLAG,\nand REGION. START
|   and END are buffer positions indicating what to copy.\nThe optional
|   argument REGION if non-nil, indicates that we're not just\ncopying
|   some text between START and END, but we're copying the
|   region.\n\nInteractively, reads the register using
|   `register-read-with-preview'." (interactive #f(compiled-function ()
|   #<bytecode -0x19b31a6142e6ce87>)) #<bytecode 0x18af6be063d3e91b>))
|   apply(my-remove-all-text-properties-region #f(compiled-function
|   (register start end &optional delete-flag region) "Copy region into
|   register REGISTER.\nWith prefix arg, delete as well.\nCalled from
|   program, takes five args: REGISTER, START, END, DELETE-FLAG,\nand
|   REGION. START and END are buffer positions indicating what to
|   copy.\nThe optional argument REGION if non-nil, indicates that we're
|   not just\ncopying some text between START and END, but we're copying
|   the region.\n\nInteractively, reads the register using
|   `register-read-with-preview'." (interactive #f(compiled-function ()
|   #<bytecode -0x19b31a6142e6ce87>)) #<bytecode 0x18af6be063d3e91b>) nil)
|   copy-to-register() funcall-interactively(copy-to-register)
|   call-interactively(copy-to-register nil nil)
|   command-execute(copy-to-register)
`----

At this point I give up

Uwe 




-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-26  4:57                     ` [SOLVED] Uwe Brauer
@ 2022-07-26 13:01                       ` Thorsten Bonow
  2022-07-26 15:02                         ` [SOLVED] Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Thorsten Bonow @ 2022-07-26 13:01 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> Uwe Brauer <oub@mat.ucm.es> writes: 
 
[...] 
 
> At this point I give up 
 
> Uwe 

Don't loose heart...

(defun copy-to-register--no-properties (orig-fun &rest args) 
  "Remove properties of region when calling `copy-to-register'." 
  (let ((filter-buffer-substring-function (lambda (beg end 
  &optional delete) 
					    (if delete 
						(delete-and-extract-region 
						beg end) 
						(buffer-substring-no-properties 
						beg end))))) 
    (apply orig-fun args))) 
(advice-add 'copy-to-register :around 
#'copy-to-register--no-properties) 

Works for me, but the way I understand the manual, instead of 
advising a function, better-registers.el should just modify 
`filter-buffer-substring-function' for its needs.

Hope this helps.

Toto 

-- 
Sent from my GNU Emacs running on GNU/Linux




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-26 13:01                       ` [SOLVED] Thorsten Bonow
@ 2022-07-26 15:02                         ` Uwe Brauer
  2022-07-26 16:23                           ` [SOLVED] Yuri Khan
  0 siblings, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-26 15:02 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

>>> "TB" == Thorsten Bonow <thorsten.bonow@post.rwth-aachen.de> writes:

Hello Thorsten
>>>>>> Uwe Brauer <oub@mat.ucm.es> writes: 
> [...]  > At this point I give up  > Uwe Don't loose heart...

Ok I will not (and it seems I can count on «with a little help of my
friends 😉)

> (defun copy-to-register--no-properties (orig-fun &rest args)   "Remove
> properties of region when calling `copy-to-register'."   (let
> ((filter-buffer-substring-function (lambda (beg end   &optional
> delete) 					    (if delete
> (delete-and-extract-region
> beg end)
> (buffer-substring-no-properties
> beg end)))))     (apply orig-fun args))) (advice-add 'copy-to-register
> :around #'copy-to-register--no-properties) Works for me, but the way I
> understand the manual, instead of advising a function,
> better-registers.el should just modify
> `filter-buffer-substring-function' for its needs.



> Hope this helps.



It does very much so, that solution would not have occurred to me. So thanks for 
the code.


BTW, I found it strange that «vanilla» Emacs does not provide saving
registers, but then this is a question of demand, and it seems only a
few users use that functionality.

Uwe 




-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-26 15:02                         ` [SOLVED] Uwe Brauer
@ 2022-07-26 16:23                           ` Yuri Khan
  2022-07-26 23:28                             ` [SOLVED] Michael Heerdegen
  2022-07-27 10:50                             ` [SOLVED] Uwe Brauer
  0 siblings, 2 replies; 24+ messages in thread
From: Yuri Khan @ 2022-07-26 16:23 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, 26 Jul 2022 at 22:08, Uwe Brauer <oub@mat.ucm.es> wrote:

> BTW, I found it strange that «vanilla» Emacs does not provide saving
> registers, but then this is a question of demand, and it seems only a
> few users use that functionality.

I don’t remember who said it doesn’t but do we consider desktop.el
“vanilla” or some other flavor? My .emacs.desktop has a ‘(setq
register-alist '…)’ and it persists across Emacs sessions. (I have not
encountered unreadable properties in there, or maybe I did but did not
make the connection.)



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-26 16:23                           ` [SOLVED] Yuri Khan
@ 2022-07-26 23:28                             ` Michael Heerdegen
  2022-07-27 10:50                             ` [SOLVED] Uwe Brauer
  1 sibling, 0 replies; 24+ messages in thread
From: Michael Heerdegen @ 2022-07-26 23:28 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> I don’t remember who said it doesn’t but do we consider desktop.el
> “vanilla” or some other flavor? My .emacs.desktop has a ‘(setq
> register-alist '…)’ and it persists across Emacs sessions. (I have not
> encountered unreadable properties in there, or maybe I did but did not
> make the connection.)

Seems it is silently stripping (all) properties when such a problem
appears - see `desktop--v2s'.

Michael.




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-26 16:23                           ` [SOLVED] Yuri Khan
  2022-07-26 23:28                             ` [SOLVED] Michael Heerdegen
@ 2022-07-27 10:50                             ` Uwe Brauer
  2022-07-27 15:04                               ` [SOLVED] Yuri Khan
  1 sibling, 1 reply; 24+ messages in thread
From: Uwe Brauer @ 2022-07-27 10:50 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]

>>> "YK" == Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Tue, 26 Jul 2022 at 22:08, Uwe Brauer <oub@mat.ucm.es> wrote:
>> BTW, I found it strange that «vanilla» Emacs does not provide saving
>> registers, but then this is a question of demand, and it seems only a
>> few users use that functionality.

> I don’t remember who said it doesn’t but do we consider desktop.el
> “vanilla” or some other flavor? 

Since desktop is part of Emacs it is vanilla.

> My .emacs.desktop has a ‘(setq
> register-alist '…)’ and it persists across Emacs sessions. (I have not
> encountered unreadable properties in there, or maybe I did but did not
> make the connection.)

Aha, thanks I did not know that, I really never used desktop that much, 
but can you use list-register and then edit the registers?
Ok I realized that list-register is not part of emacs vanilla neither.



-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-07-27 10:50                             ` [SOLVED] Uwe Brauer
@ 2022-07-27 15:04                               ` Yuri Khan
  2022-07-28 14:46                                 ` [SOLVED$ Uwe Brauer
  0 siblings, 1 reply; 24+ messages in thread
From: Yuri Khan @ 2022-07-27 15:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 27 Jul 2022 at 17:51, Uwe Brauer <oub@mat.ucm.es> wrote:

> Since desktop is part of Emacs it is vanilla.

[…]

> Aha, thanks I did not know that, I really never used desktop that much,
> but can you use list-register and then edit the registers?
> Ok I realized that list-register is not part of emacs vanilla neither.

Is it not? Works for me and I do not remember doing anything for it to
work, and it lives in /usr/share/emacs/29.0.50/lisp/register.el.gz, so
I guess it’s also vanilla by your definition.

I cannot edit registers directly, but I can insert the text from a
register into a buffer, edit the text there, and copy it back to the
register, and it will be persisted the next time I restart Emacs.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED$
  2022-07-27 15:04                               ` [SOLVED] Yuri Khan
@ 2022-07-28 14:46                                 ` Uwe Brauer
  0 siblings, 0 replies; 24+ messages in thread
From: Uwe Brauer @ 2022-07-28 14:46 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1270 bytes --]

>>> "YK" == Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Wed, 27 Jul 2022 at 17:51, Uwe Brauer <oub@mat.ucm.es> wrote:
>> Since desktop is part of Emacs it is vanilla.

> […$

>> Aha, thanks I did not know that, I really never used desktop that much,
>> but can you use list-register and then edit the registers?
>> Ok I realized that list-register is not part of emacs vanilla neither.

> Is it not? Works for me and I do not remember doing anything for it to
> work, and it lives in /usr/share/emacs/29.0.50/lisp/register.el.gz, so
> I guess it’s also vanilla by your definition.

> I cannot edit registers directly, but I can insert the text from a
> register into a buffer, edit the text there, and copy it back to the
> register, and it will be persisted the next time I restart Emacs.

May I suggest then list-register (found in the package system):
it lists registers and allows to edit them,

There is also register-list 
(remember Monty Python: 
«The People's Front of Judea»  vs «Judean People's Front» )



-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [SOLVED]
  2022-10-03 11:33   ` Emanuel Berg
@ 2022-10-09  5:51     ` Uwe Brauer
  0 siblings, 0 replies; 24+ messages in thread
From: Uwe Brauer @ 2022-10-09  5:51 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

>>> "EB" == Emanuel Berg <incal@dataswamp.org> writes:

> Uwe Brauer wrote:
>> a simple describe-variable suggests to use 
>> 
>> (defun my-changelog-date-format (&optional time zone)
>> (format-time-string "%Y-%m-%d %H:%M"))
>> 
>> Which indeed worked

> What time zone is that?

None, 

The code in add-log reads

(defun add-log-iso8601-time-zone (&optional time zone)
  (declare (obsolete nil "26.1"))
  (format-time-string "%:::z" time zone))

(defvar add-log-iso8601-with-time-zone nil)

(defun add-log-iso8601-time-string (&optional time zone)
  (format-time-string
   (if add-log-iso8601-with-time-zone "%Y-%m-%d %:::z" "%Y-%m-%d") time zone))

Since I don't think I will ever use time zones, I did not bother to set
this right up.

-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-10-09  5:51 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-06 15:53 how to randomize (scample) regions in a an (org) buffer Uwe Brauer
2021-10-06 16:35 ` [SOLVED] (was: how to randomize (scample) regions in a an (org) buffer) Uwe Brauer
2021-10-06 19:59   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:24     ` [SOLVED] Uwe Brauer
2021-10-06 20:58       ` [SOLVED] Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-07  7:05         ` [SOLVED] Uwe Brauer
2021-10-07  8:15           ` [SOLVED] Emanuel Berg via Users list for the GNU Emacs text editor
  -- strict thread matches above, loose matches on Subject: below --
2022-10-02 20:18 add-log-time-format with time? Uwe Brauer
2022-10-03  6:49 ` [SOLVED] (was: add-log-time-format with time?) Uwe Brauer
2022-10-03 11:33   ` Emanuel Berg
2022-10-09  5:51     ` [SOLVED] Uwe Brauer
2022-07-23 16:45 problems with better-registers: turn-off-all-minor modes or remove all text-properties Uwe Brauer
2022-07-24  0:09 ` Michael Heerdegen
2022-07-24  3:59   ` Michael Heerdegen
2022-07-24  5:39     ` Uwe Brauer
2022-07-24 19:51       ` [SOLVED] (was: problems with better-registers: turn-off-all-minor modes or remove all text-properties) Uwe Brauer
2022-07-24 22:36         ` [SOLVED] Michael Heerdegen
2022-07-25  5:37           ` [SOLVED] Uwe Brauer
2022-07-25  5:49             ` [SOLVED] Uwe Brauer
2022-07-25 17:09               ` [SOLVED] Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-25 19:49                 ` [SOLVED] Uwe Brauer
2022-07-25 22:37                   ` [SOLVED] Michael Heerdegen
2022-07-26  4:57                     ` [SOLVED] Uwe Brauer
2022-07-26 13:01                       ` [SOLVED] Thorsten Bonow
2022-07-26 15:02                         ` [SOLVED] Uwe Brauer
2022-07-26 16:23                           ` [SOLVED] Yuri Khan
2022-07-26 23:28                             ` [SOLVED] Michael Heerdegen
2022-07-27 10:50                             ` [SOLVED] Uwe Brauer
2022-07-27 15:04                               ` [SOLVED] Yuri Khan
2022-07-28 14:46                                 ` [SOLVED$ Uwe Brauer
2010-08-13 14:37 Prefix-Arg (non-interactive!) in Info Memnon Anon
2010-08-13 15:17 ` Eli Zaretskii
2010-08-13 15:50   ` Memnon Anon
2010-08-13 16:09     ` Eli Zaretskii
2010-08-13 17:04       ` Memnon Anon
2010-08-13 19:33         ` Eli Zaretskii
2010-08-13 20:58           ` [Solved] (was: Prefix-Arg (non-interactive!) in Info) Memnon Anon
2010-08-14  8:05             ` Eli Zaretskii
2010-08-14 21:18               ` [Solved] Memnon Anon
2010-08-14 22:27                 ` [Solved] Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).