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
Lars Ingebrigtsen
af359de917
Allow `string-limit' to work on encoded strings
...
* doc/lispref/strings.texi (Creating Strings): Document it.
* lisp/emacs-lisp/subr-x.el (string-limit): Allow limiting on
encoded strings.
2020-12-25 05:58:09 +01:00
Lars Ingebrigtsen
269cec13a2
Remove `string-slice' -- it's not very well defined
...
* doc/lispref/strings.texi (Creating Strings): Ditto.
* lisp/emacs-lisp/subr-x.el (string-slice): Remove.
2020-12-25 05:16:46 +01:00
Lars Ingebrigtsen
5c86a53296
Improve the string-limit doc string
...
* lisp/emacs-lisp/subr-x.el (string-limit): Mention
truncate-string-to-width in the doc string.
2020-12-23 07:59:24 +01:00
Lars Ingebrigtsen
22c1f00d99
Allow string-slice to take zero-length matches
...
* lisp/emacs-lisp/subr-x.el (string-slice): Allow zero-length
matches. Code adapted from s.el by Magnar Sveen.
2020-12-23 07:45:19 +01:00
Basil L. Contovounesios
e42a63a960
; Fix docstrings in last change to subr-x.el
2020-12-22 09:01:47 +00:00
Lars Ingebrigtsen
051d8f7535
Make string-pad take an optional START parameter
...
* lisp/emacs-lisp/subr-x.el (string-pad): Alter the calling
convention.
2020-12-22 06:59:25 +01:00
Lars Ingebrigtsen
9480169f1b
Change the string-limit parameter semantics
...
* lisp/emacs-lisp/subr-x.el (string-limit): Alter the calling
convention.
2020-12-22 06:54:32 +01:00
Lars Ingebrigtsen
d2b8611862
Further string-clean-whitespace tweaks
...
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace): Put \r
back, which was mistakenly removed.
2020-12-22 04:24:25 +01:00
Basil L. Contovounesios
27fab4b140
Tiny string-clean-whitespace simplification
...
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace): Streamline by
treating replacement string as being literal and having fixed case.
2020-12-21 22:36:55 +00:00
Lars Ingebrigtsen
7e86d3bb9b
Make string-chop-newline more efficient
...
* lisp/emacs-lisp/subr-x.el (string-chop-newline): Make more
efficient.
2020-12-21 23:18:05 +01:00
Lars Ingebrigtsen
768522750d
Make string-clean-whitespace work on non-ASCII whitespace, too
...
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace): Also clean
up non-ASCII whitespace.
2020-12-21 22:41:37 +01:00