Commit graph

125 commits

Author SHA1 Message Date
Lars Ingebrigtsen
84801d468a Autoload string-join
* lisp/emacs-lisp/subr-x.el (string-join): Autoload since it's
being used more now.
2022-09-17 12:31:24 +02:00
Stefan Kangas
c4505fed53 Hide local variable section in emacs-news-modes
* lisp/textmodes/emacs-authors-mode.el
(emacs-authors-mode--hide-local-variables): Move from here...
* lisp/emacs-lisp/subr-x.el (emacs-etc--hide-local-variables):
...to here.

* lisp/textmodes/emacs-authors-mode.el (subr-x): Require.
(emacs-authors-mode): Use above renamed function.

* lisp/textmodes/emacs-news-mode.el (subr-x): Require.
(emacs-news--mode-common): Call 'emacs-etc--hide-local-variables'
to hide local variables section.
2022-08-12 22:28:17 +02:00
Mattias Engdegård
d8d582dc3c ; * lisp/emacs-lisp/subr-x.el (string-pad): Optimise. 2022-08-10 13:06:12 +02:00
Stefan Kangas
581fa3d958 Autoload string-blank-p
* lisp/eshell/em-hist.el (subr-x):
* lisp/net/eudc.el (subr-x): Don't require.
* lisp/emacs-lisp/subr-x.el (string-blank-p): Autoload.
2022-08-09 21:58:00 +02:00
Lars Ingebrigtsen
51f5c4b773 Fix off-by-one error in string-truncate-left
* lisp/emacs-lisp/subr-x.el (string-truncate-left): Fix off-by-one
error (bug#56685).
2022-07-23 08:58:53 +02:00
Lars Ingebrigtsen
bebf39f292 Autoload named-let
* lisp/emacs-lisp/subr-x.el (named-let): Autoload `named-let' for
easier use (bug#56473).
2022-07-11 12:18:04 +02:00
Eli Zaretskii
99872bedf0 ; * lisp/emacs-lisp/subr-x.el (string-limit): Clarify doc string. 2022-07-05 19:45:35 +03:00
Lars Ingebrigtsen
8681bf1e85 Mention byte order marks in string-limit doc string
* lisp/emacs-lisp/subr-x.el (string-limit): Mention byte order
marks (bug#48324).
2022-07-05 18:27:42 +02:00
Lars Ingebrigtsen
b72e4b1493 Make string-limit with encoding return complete glyphs
* lisp/emacs-lisp/subr-x.el (string-limit): Return more correct
results in the CODING-SYSTEM case for coding systems with BOM and
charset designations (bug#48324).  Also amend the algorithm to
return complete glyphs, not just complete code points.
2022-07-03 14:08:14 +02:00
Lars Ingebrigtsen
2f346b0ab1 Re-fix build warnings about subr-x defsubsts
* lisp/term/haiku-win.el (require):
* lisp/progmodes/elisp-mode.el (require):
* lisp/isearch.el (require): Require subr-x at compile time, since
these use defsubsts/macros from there.

* lisp/emacs-lisp/subr-x.el (string-empty-p): Move from here...
* lisp/simple.el (string-empty-p): ... to here.  This is to help
with a build problem where files.el is using the defsubst, but
requiring subr-x.el at compile time leads to load errors.
2022-06-25 12:20:05 +02:00
Lars Ingebrigtsen
49910adf87 Fix cl-generic bootstrap problems
* lisp/sqlite-mode.el (require):
* lisp/net/eudc.el (require):
* lisp/arc-mode.el (require): Require subr-x, since these files
are using macros from there.
* lisp/emacs-lisp/subr-x.el (with-memoization): Move from here...
* lisp/subr.el (with-memoization): ... to here, as it's used from
the preloaded cl-generic.el file.

* lisp/emacs-lisp/cl-generic.el (cl--generic-compiler): Don't use
the autoloaded `byte-compile' function during bootstrap.
(cl--generic-get-dispatcher): Don't require subr-x, either.

cl-generic has been preloaded since 2015, and most usages of it (in
preloaded files) work fine.  In particular, using `cl-defgeneric' is
unproblematic.  However, `cl-defmethod' would end up pulling in the
byte compiler (at load time), which would make it impossible to use
`cl-defmethod' in pre-loaded files, and this change fixes that (but
possibly not in the most self-evidently correct way).
2022-06-24 11:04:51 +02:00
Mattias Engdegård
4311bd0bd7 Slightly faster hash-table-keys and hash-table-values
* lisp/emacs-lisp/subr-x.el (hash-table-keys, hash-table-values):
Omit the reversal of the returned list.  It is not ordered anyway.
* test/lisp/emacs-lisp/subr-x-tests.el
(subr-x--hash-table-keys-and-values): New test.
2022-06-17 19:16:52 +02:00
Robert Pluim
eaa198cd75 ; Re-fix last change in doc of 'with-buffer-unmodified-if-unchanged'. 2022-05-04 14:53:34 +02:00
Eli Zaretskii
1a72248901 ; Fix last change in doc string of 'with-buffer-unmodified-if-unchanged'. 2022-05-04 13:08:53 +03:00
Eli Zaretskii
69521ffcb0 Clarify the doc string of 'with-buffer-unmodified-if-unchanged'
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Describe better what is meant by "buffer changes".  (Bug#4587)
2022-05-04 11:46:01 +03:00
Lars Ingebrigtsen
0a2f0e7f8c Make with-buffer-unmodified-if-unchanged more efficient
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Make more efficient.
2022-05-03 22:06:31 +02:00
Lars Ingebrigtsen
b7ddd0f2fd Make with-buffer-unmodified-if-unchanged more resilient
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Make more resilient.
2022-05-03 22:04:39 +02:00
Stefan Monnier
b5db5a6443 with-buffer-unmodified-if-unchanged: Tweak the implementation
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Skip the hash if the buffer was not modified at all.
Use `restore-buffer-modified-p`.
Also mention that it's imperative that the current buffer is preserved.
2022-05-03 15:35:47 -04:00
Lars Ingebrigtsen
59353ec7b5 Add new macro with-buffer-unmodified-if-unchanged
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
New macro.
* lisp/textmodes/fill.el (fill-paragraph): Macro code copied from
here.  Adjust and use the macro.
2022-05-03 21:22:53 +02:00
Lars Ingebrigtsen
b05a103ea7 Move the when-let family of macros to subr.el
* lisp/subr.el (internal--build-binding)
(internal--build-bindings): Moved from subr-x.el and rewritten to
not use the threading macro.
(if-let*, when-let*, and-let*, if-let, when-let): Moved from
subr-x.el.  This avoids breaking the build every time somebody
uses these macros in functions that end up being called during
bootstrap.
2022-04-30 16:42:44 +02:00
Lars Ingebrigtsen
781c43de3d Fix bootstrap errors after previous easy-mmode change
* lisp/subr.el (ensure-empty-lines, string-lines): Moved from
subr-x so that they can be used in early bootstrap files.

* lisp/emacs-lisp/easy-mmode.el (easy-mmode--mode-docstring):
Don't use string-empty-p because of bootstrap issues.
2022-04-02 16:53:24 +02:00
Lars Ingebrigtsen
d710b84225 Make string-pixel-width about 40% faster
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up.
2022-02-20 16:14:05 +01:00
Lars Ingebrigtsen
babfb064c4 Make string-pixel-width slightly speedier
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up
string-pixel-width in the zero-length string case.
2022-02-19 14:21:19 +01:00
Phil Sainty
1c1d5eee4c Add new function to prompt a user for a process name
* lisp/emacs-lisp/subr-x.el (read-process-name): New function
(bug#32640).
2022-01-23 14:37:32 +01:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Lars Ingebrigtsen
e99bf27158 Remove APPEND argument from add-display-text-property
* doc/lispref/display.texi (Display Property): Update doc.
* lisp/emacs-lisp/subr-x.el (add-display-text-property): Remove
the append argument -- it's nonsensical.
2021-11-24 20:10:17 +01:00
Lars Ingebrigtsen
fde9363a57 Add new function 'add-display-text-property'
* doc/lispref/display.texi (Display Property): Document it.
* lisp/emacs-lisp/subr-x.el (add-display-text-property): New function.
2021-11-24 19:38:41 +01:00
Lars Ingebrigtsen
3a2eee6f74 Fix string-glyph-split infloop
* lisp/emacs-lisp/subr-x.el (string-glyph-split): Fix infloop when
applied to (string-glyph-split "✈️🌍") (bug#52067).
2021-11-24 08:27:22 +01:00
martin rudalics
61c254cafc Add new function buffer-text-pixel-size
* doc/lispref/display.texi (Size of Displayed Text): Document it.

* lisp/emacs-lisp/subr-x.el (string-pixel-width): Use
buffer-text-pixel-size (bug#51995).

* src/xdisp.c (window_text_pixel_size): Factor out from
Fwindow_text_pixel_size.
(Fbuffer_text_pixel_size): New function.
2021-11-22 12:02:42 +01:00
Robert Pluim
a491b73c76 Improve 'ensure-empty-lines' docstring
* lisp/emacs-lisp/subr-x.el (ensure-empty-lines): Fix typo and improve
wording.
2021-11-10 17:42:30 +01:00
Lars Ingebrigtsen
c23cb2861e Add new function string-glyph-split
* doc/lispref/strings.texi (Creating Strings): Document it.
* lisp/emacs-lisp/shortdoc.el (string): Mention it.

* lisp/emacs-lisp/subr-x.el (string-glyph-split): New function.
2021-10-30 15:22:36 +02:00
Eli Zaretskii
c30f95078c Merge from origin/emacs-28
20ebd91a73 Improve documentation of string truncation APIs
3f998a3fc8 * lisp/textmodes/css-mode.el: Fix typo.  (Bug#51488)
2021-10-30 04:07:09 -04:00
Eli Zaretskii
20ebd91a73 Improve documentation of string truncation APIs
* doc/lispref/display.texi (Size of Displayed Text):
* lisp/international/mule-util.el (truncate-string-to-width):
Document caveats of using 'truncate-string-to-width' when
character composition is involved.

* lisp/emacs-lisp/subr-x.el (string-limit):
* doc/lispref/strings.texi (Creating Strings): Improve the
documentation of 'string-limit'.
2021-10-30 10:26:38 +03:00
Stefan Monnier
c22b735f0c (string-pixel-width): Rewrite to avoid side effects
* src/xdisp.c (Fwindow_text_pixel_size): Allow `window` to be a buffer.
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Simplify accordingly.
2021-10-27 14:03:43 -04:00
Lars Ingebrigtsen
7c6f7dc99b Simplify string-pixel-width
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Simplify --
save-window-excursion saves dedication status (and the code was
buggy).
2021-10-27 16:50:40 +02:00
Lars Ingebrigtsen
03366de394 Add new function 'string-pixel-width'
* doc/lispref/display.texi (Size of Displayed Text): Mention it.
* lisp/emacs-lisp/shortdoc.el (string): Mention it.

* lisp/emacs-lisp/subr-x.el (string-pixel-width): New function.
2021-10-27 15:41:32 +02:00
Stefan Kangas
d652efcd08 Make 'mapconcat' argument 'separator' optional
* src/fns.c (Fmapconcat): Make third 'separator' argument
optional.  (Bug#50965)
* doc/lispref/functions.texi (Mapping Functions): Update
documentation for above change.
* test/src/fns-tests.el (fns-tests-mapconcat): New test.

* doc/misc/cl.texi (Obsolete Setf Customization): Don't use third
mapconcat argument in example.
* lisp/emacs-lisp/subr-x.el (string-join): Doc fix.
2021-10-05 15:38:38 +02:00
Lars Ingebrigtsen
8b4a6a722a Add new command 'ensure-empty-lines'.
* doc/lispref/text.texi (Commands for Insertion): Document it.

* lisp/emacs-lisp/subr-x.el (ensure-empty-lines): New command.
2021-10-04 13:23:22 +02:00
Stefan Monnier
3c972723e4 * lisp/emacs-lisp/subr-x.el (with-memoization): New macro
Extracted from `cl-generic.el`.

* lisp/emacs-lisp/cl-generic.el (cl--generic-get-dispatcher)
(cl--generic-build-combined-method, cl-generic-generalizers): Use it.
(cl--generic-with-memoization): Delete.
2021-10-01 14:33:37 -04:00
Lars Ingebrigtsen
2a73673809 Change how thread-first/thread-last indent the first argument
* lisp/doc-view.el (doc-view--current-cache-dir): Reindent.

* lisp/emacs-lisp/subr-x.el (thread-first):
(thread-last): Change indentation to match examples.
(internal--build-binding): Reindent.

* test/lisp/emacs-lisp/subr-x-tests.el
(subr-x-test-thread-first-function-names-are-threaded):
(subr-x-test-thread-first-examples):
(subr-x-test-thread-last-function-names-are-threaded):
(subr-x-test-thread-last-examples): Reindent.
2021-09-22 05:57:48 +02:00
Lars Ingebrigtsen
e91b574bf8 Add new functions for lax mail address splitting
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace): Autoload.
* lisp/mail/mail-parse.el (mail-header-parse-addresses-lax)
(mail-header-parse-address-lax): New functions.
2021-08-14 15:20:59 +02:00
Lars Ingebrigtsen
b188861af4 Attempt to make defclass documentation more legible
* lisp/emacs-lisp/cl-extra.el (cl--print-table): Attempt to make
defclass documentation more readable (bug#30998).
(cl--describe-class-slots): Ditto.
2021-06-24 20:24:43 +02:00
Stefan Monnier
84e207c811 * lisp/emacs-lisp/subr-x.el (if-let*, if-let): Use looser Edebug spec
This makes the same spec work both for `if-let` and `when-let`.

(when-let*, and-let*, when-let): Simplify accordingly.
2021-05-22 10:21:59 -04:00
Philipp Stephani
33a52cb458 Give 'when-let' and 'when-let*' their own Edebug specification.
The Edebug specification of 'if-let' and 'if-let*' doesn't work if the
body is empty.  While that's a pathological case, it's not wrong per
se, and could arguably happen due to macro expansion.

* lisp/emacs-lisp/subr-x.el (when-let*, when-let): Don't reuse Edebug
specification from 'if-let*' and 'if-let'.
2021-05-22 13:29:50 +02:00
Philipp Stephani
9676d41b83 * lisp/emacs-lisp/subr-x.el (if-let): Swap &or branches (Bug#48489) 2021-05-18 09:26:49 +02:00
Eli Zaretskii
98e5639c3c Fix the tests for 'string-limit'
* test/lisp/emacs-lisp/subr-x-tests.el (subr-string-limit-coding):
Fix the expected results of string-limit when encoding with
UTF-16.  Add tests for UTF-8 with BOM.  (Bug#48324)

* lisp/emacs-lisp/subr-x.el (string-limit): Add FIXME comment
about the current implementation, which is faulty by design.
2021-05-12 16:41:03 +03:00
Lars Ingebrigtsen
a4ececf004 Move string-trim functions to subr.el
* doc/lispref/strings.texi (Creating Strings): Document them.

* lisp/faces.el: Don't require subr-x, because that leads to build
errors.

* lisp/subr.el (string-trim, string-trim-right)
(string-trim-left): Move here from subr-x.el.

* lisp/emacs-lisp/shortdoc.el (string): Adjust.
2021-03-24 09:22:44 +01:00
Stefan Monnier
0d3635536d * lisp/emacs-lisp/subr-x.el (named-let): New macro 2021-01-20 14:13:15 -05:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00