 ;;
 ;; 1. Display a message to warn that flagged, not marked, files will be deleted.
 ;; 2. Use `diredp-internal-do-deletions', so it works with all Emacs versions.
+;; 3. Applies fix for bug #48805.
 ;;
 ;;;###autoload
 (defun dired-do-flagged-delete (&optional no-msg) ; Bound to `x'

      ;; Hence we don't need to worry about converting `\\' back to `\'.
      (setq file  (read (concat "\"" file "\"")))

      ;; Above `read' returns a unibyte string if FILE contains eight-bit-control/graphic chars.
      (when (and (fboundp 'string-to-multibyte) ; Emacs 22
                 enable-multibyte-characters
                 (not (multibyte-string-p file)))
        (setq file  (string-to-multibyte file))))

    )
  (let* ((dired-marker-char  dired-del-marker)
         (regexp             (dired-marker-regexp))
         (case-fold-search   nil)
         (markers            ()))
    (if (save-excursion (goto-char (point-min)) (re-search-forward regexp nil t))
        (diredp-internal-do-deletions
         (nreverse
          ;; This cannot move point since last arg is nil.
          (dired-map-over-marks (cons (dired-get-filename) (let ((mk  (point-marker)))
                                                             (push mk markers)
                                                             mk))
                                nil))
         nil
         'USE-TRASH-CAN)             ; This arg is for Emacs 24+ only.
      (dolist (mk  markers) (set-marker mk nil))
      (unless no-msg (message "(No deletions requested.)")))))


