all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Mattias Engdegård" <mattiase@acm.org>,
	grindeg@yandex.ru, 36085@debbugs.gnu.org
Subject: bug#36085: 26.2; find-dired octal escapes instead of Cyrillic text
Date: Sun, 13 Mar 2022 11:35:01 +0530	[thread overview]
Message-ID: <87ilsigzg2.fsf@gmail.com> (raw)
In-Reply-To: <83o938nl9j.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 08 Jun 2019 18:34:48 +0300")

[சனி, ஜூன் 08 2019] Eli Zaretskii wrote:

Hi Eli,

>> From: Mattias Engdegård <mattiase@acm.org>
>> Date: Sat, 8 Jun 2019 17:14:11 +0200
>> 
>> Eli wrote:
>> 
>> > P.S. Emacs could perhaps go above and beyond the call of duty, and
>> > attempt to convert the octal escapes back to readable text. But I
>> > don't think we should do it, as it's a clear bug in
>> > 'find'. Nonetheless, if someone wants to submit patches to do such
>> > a conversion, I won't block them.
>> 
>> The default (BSD) find in macOS does not seem to escape anything;
>> files named Портрет or APL\360 are printed exactly that way. Thus,
>> Emacs would need to know what 'find' it is running. This appears to
>> validate your recommendation.
>
> Indeed, the hard part is to distinguish between \nnn an octal escape
> and the literal string "\nnn".  That difficulty is one reason why
> gdb-mi.el performs a similar decoding only as an opt-in optional
> behavior.

After being annoyed by the same exact behaviour, and with the helpful
hint about gdb-mi.el, I came up with the following function.  With a
preliminary testing, it does not choke on literal "\nnn" and it does not
noticeably slow down find-dired unlike the xargs option.  Maybe, we can
include something like this, WDYT?

    (defun vz/find-dired-unescape ()
      "Unescape the C-style octal escape strings."
      (while (not (eobp))
        (when-let ((beg (next-single-property-change (point) 'dired-filename))
                   (props (text-properties-at beg)))
          (goto-char beg)
          (while (and (re-search-forward (rx "\\" (group (any "0-7") (? (any "0-7") (? (any "0-7")))))
                                         (line-end-position) 'noerror)
                      (not (eq (char-before (match-beginning 0)) ?\\)))
            (let ((num (string-to-number (match-string 1) 8)))
              (replace-match (unibyte-string num) t nil nil 0)))
          (decode-coding-region beg (line-end-position) buffer-file-coding-system)
          (set-text-properties  beg (line-end-position) props))
        (forward-line)))

    (custom-set-variables
     '(find-ls-option (cons "-ls" "-dlis"))
     '(find-dired-refine-function #'vz/find-dired-unescape))





      parent reply	other threads:[~2022-03-13  6:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  3:43 bug#36085: 26.2; find-dired octal escapes instead of Cyrillic text Nikita
2019-06-04 11:44 ` bug#36085: Screenshots for th bug Никита Никита
2019-06-08 12:20 ` bug#36085: 26.2; find-dired octal escapes instead of Cyrillic text Eli Zaretskii
2019-06-09 12:34   ` Tomas Nordin
2019-06-09 12:51     ` Eli Zaretskii
2019-06-08 15:14 ` Mattias Engdegård
2019-06-08 15:34   ` Eli Zaretskii
2019-06-09  5:22     ` Eli Zaretskii
2019-06-09  9:08       ` Mattias Engdegård
2019-06-09 10:57         ` Eli Zaretskii
2019-06-09 12:39           ` Mattias Engdegård
2019-06-09 12:49             ` Eli Zaretskii
2022-03-13  6:05     ` Visuwesh [this message]

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=87ilsigzg2.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=36085@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=grindeg@yandex.ru \
    --cc=mattiase@acm.org \
    /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.