From: Eshel Yaron Date: Mon, 13 May 2024 20:03:31 +0000 (+0200) Subject: Allow text properties in minibuffer output unconditionally X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7c6682ee2b988f93ac95fd95aec57329c21f41c1;p=emacs.git Allow text properties in minibuffer output unconditionally (minibuffer-allow-text-properties): Obsolete. (read_minibuf): Drop 'allow_props' argument. (choose-completion): Retain text properties. --- diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 59f63ed7901..4a5064e8d28 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -184,12 +184,6 @@ symbol @code{t}, history is not recorded. You can optionally specify a starting position in the history list as well. @xref{Minibuffer History}. -If the variable @code{minibuffer-allow-text-properties} is -non-@code{nil}, then the string that is returned includes whatever text -properties were present in the minibuffer. Otherwise all the text -properties are stripped when the value is returned. (By default this -variable is @code{nil}.) - @vindex minibuffer-prompt-properties The text properties in @code{minibuffer-prompt-properties} are applied to the prompt. By default, this property list defines a face to use @@ -350,25 +344,6 @@ or a list of strings. See @code{read-regexp} above for details of how these values are used. @end defopt -@defvar minibuffer-allow-text-properties -If this variable is @code{nil}, the default, then -@code{read-from-minibuffer} strips all text properties from the -minibuffer input before returning it. Otherwise, the minibuffer input -is returned as is, along with its text properties. Moreover, if this -variable is non-@code{nil}, most text properties on strings from the -completion table are preserved as well. - -@lisp -(let ((minibuffer-allow-text-properties t)) - (completing-read "String: " (list (propertize "foobar" 'data 'zot)))) -=> #("foobar" 3 6 (data zot)) -@end lisp - -In this example, the user typed @samp{foo} and then hit the @kbd{TAB} -key, so the text properties are only preserved on the last three -characters. -@end defvar - @vindex minibuffer-mode-map @defvar minibuffer-local-map This @@ -469,20 +444,9 @@ This function reads a Lisp object using the minibuffer, and returns it without evaluating it. The arguments @var{prompt} and @var{initial} are used as in @code{read-from-minibuffer}. -This is a simplified interface to the -@code{read-from-minibuffer} function: - -@smallexample -@group -(read-minibuffer @var{prompt} @var{initial}) -@equiv{} -(let (minibuffer-allow-text-properties) - (read-from-minibuffer @var{prompt} @var{initial} nil t)) -@end group -@end smallexample - -Here is an example in which we supply the string @code{"(testing)"} as -initial input: +This is a simplified interface to the @code{read-from-minibuffer} +function. Here is an example in which we supply the string +@code{"(testing)"} as initial input: @smallexample @group diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index c92fd42322a..5ac10165584 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -5700,8 +5700,7 @@ If FACE is non-nil, it will be used to propertize the prompt. If it is nil, (defun erc-input-message () "Read input from the minibuffer." (interactive) - (let ((minibuffer-allow-text-properties t) - (read-map minibuffer-local-map)) + (let ((read-map minibuffer-local-map)) (insert (read-from-minibuffer "Message: " (string last-command-event) read-map)) diff --git a/lisp/imenu.el b/lisp/imenu.el index 2b1d4f5ce85..3b9b77bb4fc 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -758,8 +758,8 @@ Return one of the entries in index-alist or nil." (unless imenu-eager-completion-buffer (minibuffer-completion-help))) (setq name (completing-read prompt - prepared-index-alist - nil t nil 'imenu--history-list name))) + prepared-index-alist + nil t nil 'imenu--history-list name))) (when (stringp name) (setq choice (assoc name prepared-index-alist)) diff --git a/lisp/isearch.el b/lisp/isearch.el index 88921c3179c..43b8afad10a 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1846,9 +1846,7 @@ The following additional command keys are active while editing. (let* ((message-log-max nil) ;; Binding minibuffer-history-symbol to nil is a work-around ;; for some incompatibility with gmhist. - (minibuffer-history-symbol) - ;; Search string might have meta information on text properties. - (minibuffer-allow-text-properties t)) + (minibuffer-history-symbol)) (setq isearch-new-string (minibuffer-with-setup-hook (let ((setup (minibuffer-lazy-highlight-setup))) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index b5ce4a57e0f..ad88822ff16 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1425,14 +1425,8 @@ Moves point to the end of the new text." ;; The properties on `newtext' include things like the ;; `completions-first-difference' face, which we don't want to ;; include upon insertion. - (setq newtext (copy-sequence newtext)) ;Don't modify the arg by side-effect. - (if minibuffer-allow-text-properties - ;; If we're preserving properties, then just remove the faces - ;; and other properties added by the completion machinery. - (remove-text-properties 0 (length newtext) '(face completion-score) - newtext) - ;; Remove all text properties. - (set-text-properties 0 (length newtext) nil newtext)) + (setq newtext (copy-sequence newtext)) + (remove-text-properties 0 (length newtext) '(face) newtext) ;; Maybe this should be in subr.el. ;; You'd think this is trivial to do, but details matter if you want ;; to keep markers "at the right place" and be robust in the face of @@ -6198,6 +6192,9 @@ This applies to `completions-auto-update-mode', which see." (defvar minibuffer-help-form nil "Unused obsolete variable.") (make-obsolete-variable 'minibuffer-help-form 'help-form "30.1") +(defvar minibuffer-allow-text-properties nil "Unused obsolete variable.") +(make-obsolete-variable 'minibuffer-allow-text-properties nil "30.1") + (defvar-local minibuffer-hint-timer nil) (defcustom minibuffer-hint-idle-time 0.4 diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el index 61a9229adf1..6b6664fc375 100644 --- a/lisp/org/org-protocol.el +++ b/lisp/org/org-protocol.el @@ -745,8 +745,7 @@ the cdr of an element in `org-publish-project-alist', reuse (working-suffix (if (plist-get project-plist :base-extension) (concat "." (plist-get project-plist :base-extension)) ".org")) - (insert-default-directory t) - (minibuffer-allow-text-properties nil)) + (insert-default-directory t)) (setq base-url (read-string "Base URL of published content: " base-url nil base-url t)) (or (string-suffix-p "/" base-url) diff --git a/lisp/replace.el b/lisp/replace.el index ce18f6269ed..14b16172e45 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -228,7 +228,6 @@ wants to replace FROM with TO." (query-replace-descr (cdr from-to)))) query-replace-defaults)) (symbol-value query-replace-from-history-variable))) - (minibuffer-allow-text-properties t) ; separator uses text-properties (default (when (and query-replace-read-from-default (not regexp-flag)) (funcall query-replace-read-from-default))) (prompt diff --git a/lisp/simple.el b/lisp/simple.el index 3eb3874f116..154f3f587de 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10169,8 +10169,7 @@ minibuffer, but don't quit the completions window." (setq beg (or (previous-single-property-change beg 'completion--string) beg)) - (substring-no-properties - (get-text-property beg 'completion--string)))))) + (get-text-property beg 'completion--string))))) (unless (buffer-live-p buffer) (error "Destination buffer is dead")) diff --git a/src/minibuf.c b/src/minibuf.c index 74588c20c23..569316c1356 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -563,16 +563,14 @@ If the current buffer is not a minibuffer, return its entire contents. */) DEFALT specifies the default value for the sake of history commands. - If ALLOW_PROPS, do not throw away text properties. - if INHERIT_INPUT_METHOD, the minibuffer inherits the current input method. */ static Lisp_Object -read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, - bool expflag, - Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, - bool allow_props, bool inherit_input_method) +read_minibuf (Lisp_Object map, Lisp_Object initial, + Lisp_Object prompt, bool expflag, Lisp_Object histvar, + Lisp_Object histpos, Lisp_Object defalt, + bool inherit_input_method) { Lisp_Object val; specpdl_ref count = SPECPDL_INDEX (); @@ -910,10 +908,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, /* Make minibuffer contents into a string. */ Fset_buffer (minibuffer); - if (allow_props) - val = Fminibuffer_contents (); - else - val = Fminibuffer_contents_no_properties (); + val = Fminibuffer_contents (); /* VAL is the string of minibuffer text. */ @@ -1301,10 +1296,6 @@ Sixth arg DEFAULT-VALUE, if non-nil, should be a string, which is used Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits the current input method and the setting of `enable-multibyte-characters'. -If the variable `minibuffer-allow-text-properties' is non-nil, - then the string which is returned includes whatever text properties - were present in the minibuffer. Otherwise the value has no text properties. - If `inhibit-interaction' is non-nil, this function will signal an `inhibited-interaction' error. @@ -1363,7 +1354,6 @@ and some related functions, which use zero-indexing for POSITION. */) val = read_minibuf (keymap, initial_contents, prompt, !NILP (read), histvar, histpos, default_value, - minibuffer_allow_text_properties, !NILP (inherit_input_method)); return val; } @@ -2328,11 +2318,6 @@ is added with Some uses of the echo area also raise that frame (since they use it too). */); minibuffer_auto_raise = 0; - DEFVAR_BOOL ("minibuffer-allow-text-properties", - minibuffer_allow_text_properties, - doc: /* Whether `read-from-minibuffer' preserves text properties. */); - minibuffer_allow_text_properties = 0; - DEFVAR_LISP ("minibuffer-prompt-properties", Vminibuffer_prompt_properties, doc: /* Text properties that are added to minibuffer prompts. These are in addition to the basic `field' property, and stickiness