Eli Zaretskii [Fri, 7 Jun 2019 19:02:25 +0000 (22:02 +0300)]
Support text shaping with HarfBuzz
The code to support HarfBuzz was written by these individuals:
Khaled Hosny <dr.khaled.hosny@gmail.com>
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Eli Zaretskii <eliz@gnu.org>
* src/xftfont.c (xftfont_list): Call ftfont_list2.
(xftfont_match): Call ftfont_match2.
(xftfont_open) [HAVE_HARFBUZZ]: Set the font driver to
xfthbfont_driver as required. Reset xftfont_info->hb_font to
NULL.
(xftfont_close) [HAVE_HARFBUZZ]: Dispose of the hb_font object.
(xftfont_shape): Accept an additional argument DIRECTION and
pass it to ftfont_shape.
(xfthbfont_list, xfthbfont_match, xfthbfont_begin_hb_font)
(xfthbfont_end_hb_font) [HAVE_HARFBUZZ]: New functions.
(syms_of_xftfont): New DEFSYM 'xfthb'.
(syms_of_xftfont_for_pdumper) [HAVE_HARFBUZZ]: Initialize
xfthbfont_driver.
* src/xfns.c (Fx_create_frame, x_create_tip_frame)
[HAVE_HARFBUZZ]: Register the HarfBuzz font driver.
* src/w32uniscribe.c (bswap_32) [HAVE_HARFBUZZ]: Define to use
the builtin for GCC 4.3.9 and newer; else use byteswap.h from
Gnulib.
(struct uniscribe_font_info): New member 'scale'. The member
'cache' is now used both by Uniscribe and HarfBuzz backends.
(uniscribe_open): Set the font backend as required by the font
entity's font_type field.
(uniscribe_close) [HAVE_HARFBUZZ]: Dispose of the hb_font
object.
(uniscribe_shape): Accept an additional argument DIRECTION.
(w32hb_list, w32hb_match, free_cb, w32hb_get_font_table)
(w32hb_get_font, w32hb_encode_char, w32hb_begin_font)
(w32hb_get_variation_glyphs, load_harfbuzz_funcs)
[HAVE_HARFBUZZ]: New functions.
(syms_of_w32uniscribe_for_pdumper): Initialize
harfbuzz_font_driver if loading the requisite functions from
the HarfBuzz DLL succeeded.
* src/w32font.c (syms_of_w32font): New DEFSYM 'harfbuzz'.
* src/w32fns.c (Fx_create_frame, w32_create_tip_frame):
Determine whether we should register the HarfBuzz backend, or
Uniscribe backend, or both for the new frame.
* src/ftfont.h [HAVE_HARFBUZZ]: Include hb.h and hb-ft.h.
(struct font_info): New member hb_font.
* src/ftfont.c (ftfont_list2, ftfont_list_family): New functions.
(ftfont_open) [HAVE_HARFBUZZ]: Reset ftfont_info->hb_font to
NULL. Set the font backend to fthbfont_driver when required.
(ftfont_close) [HAVE_HARFBUZZ]: Dispose of ftfont_info->hb_font.
(ftfont_glyph_metrics): New function.
(ftfont_text_extents): Call ftfont_glyph_metrics instead of
FT_Load_Glyph.
(ftfont_shape): Accept an additional argument DIRECTION.
(ftfont_variation_glyphs) [!HAVE_OTF_GET_VARIATION_GLYPHS]:
Support for variation glyphs without FLT.
(fthbfont_begin_hb_font) [HAVE_HARFBUZZ]: New function.
(syms_of_ftfont): New DEFSYM freetypehb.
(syms_of_ftfont_for_pdumper): Initialize fthbfont_driver.
* src/ftcrfont.c (ftcrfont_list): Call ftfont_list2.
(ftcrfont_match): Call ftfont_match2.
(ftcrfont_open) [HAVE_HARFBUZZ]: Set the font backend to
ftcrhbfont_driver as required. Reset ftcrfont_info->hb_font
to NULL.
(ftcrfont_close) [HAVE_HARFBUZZ]: Discard of
ftcrfont_info->hb_font.
(ftcrfont_shape): Pass DIRECTION to ftfont_shape.
(ftcrhbfont_list, ftcrhbfont_match)
(ftcrhbfont_begin_hb_font, ftcrhbfont_end_hb_font)
[HAVE_HARFBUZZ]: New functions.
(syms_of_ftcrfont): New DEFSYM ftcrhb.
(syms_of_ftcrfont_for_pdumper): Initialize ftcrhbfont_driver.
* src/font.h [HAVE_HARFBUZZ]: Include hb.h.
(struct font_driver): Update comments and function signatures
to reflect the new argument DIRECTION accepted by the 'shape'
method. New methods 'begin_hb_font' and 'end_hb_font'.
(hbfont_shape, hbfont_combining_capability)
(fthbfont_begin_hb_font) [HAVE_HARFBUZZ]: Add prototypes.
* src/font.c (Ffont_shape_gstring): Accept an additional
argument DIRECTION, and pass it to the font driver's 'shape'
method.
(Ffont_variation_glyphs): Doc fix.
(syms_of_font): New DEFSYMS L2R and R2L.
* src/composite.c (autocmp_chars): Accept additional argument
DIRECTION, and pass it to auto-composition-function. All
callers changed.
(composition_reseat_it): Accept additional argument
BIDI_LEVEL, and use it to determine the DIRECTION argument to
be passed to autocmp_chars. All callers changed.
(syms_of_composite) <auto-composition-function>: Improve the
doc string; document the meaning of the new argument
DIRECTION.
* src/chartab.c (get_unicode_property): New function,
refactored from the body of get-unicode-property-internal.
(Fget_unicode_property_internal): Call get_unicode_property
after validating the input arguments.
* src/Makefile.in (HARFBUZZ_CFLAGS, HARFBUZZ_LIBS): New macros.
(EMACS_CFLAGS): Use HARFBUZZ_CFLAGS.
(SOME_MACHINE_OBJECTS): Add hbfont.o
(LIBES): Add HARFBUZZ_LIBS.
* lisp/language/tv-util.el (tai-viet-composition-function):
* lisp/language/thai-util.el (thai-composition-function):
* lisp/language/misc-lang.el (arabic-shape-gstring):
* lisp/language/lao-util.el (lao-composition-function):
* lisp/language/japanese.el (compose-gstring-for-variation-glyph):
* lisp/language/hebrew.el (hebrew-shape-gstring):
* lisp/language/ethio-util.el (ethio-composition-function):
* lisp/composite.el (compose-chars-after)
(compose-gstring-for-graphic)
(compose-gstring-for-dotted-circle)
(compose-gstring-for-terminal, auto-compose-chars): All
composition functions that call shapers now accept an
additional argument DIRECTION, either L2R or R2L.
* etc/NEWS: Document the HarfBuzz support.
* etc/HELLO: Add diacritics to Hebrew greetings.
* doc/lispref/frames.texi (Font and Color Parameters):
* doc/emacs/msdos.texi (Windows Fonts): Describe the
'harfbuzz' font backend on MS-Windows and how it is preferred
to 'uniscribe'.
* configure.ac (--wthout-harfbuzz): New option.
(HAVE_HARFBUZZ): New tests.
(FONT_OBJ) [HAVE_HARFBUZZ]: Add hbfont.o
(emacs_config_features): Add HARFBUZZ.
John Shahid [Sat, 27 Apr 2019 16:21:38 +0000 (12:21 -0400)]
Consider line spacing and font height when deriving proc window size
* lisp/window.el (window-adjust-process-window-size): Use
window-screen-lines instead of window-body-height.
* lisp/term.el (term-mode): Use window-screen-lines to set the initial
window height.
* src/image.c (image_set_crop) [HAVE_NATIVE_TRANSFORMS]: Don't call
compute_image_size, as it is already called from image_set_size.
(image_set_size, image_set_crop) [HAVE_NATIVE_TRANSFORMS]: Use harmless
matrix transformation code also for USE_CAIRO and HAVE_NTGUI cases,
though image_set_transform is not yet implemented on them.
Paul Eggert [Fri, 7 Jun 2019 04:18:11 +0000 (21:18 -0700)]
Use copy_file_range to copy files
The copy_file_range syscall (introduced in Linux kernel
version 4.5) can copy files more efficiently via server-side
copy etc.
* admin/merge-gnulib (GNULIB_MODULES): Add copy-file-range.
* lib/copy-file-range.c, m4/copy-file-range.m4:
New files, copied from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* src/fileio.c (Fcopy_file): Try copy_file_range first,
falling back on read+write only if copy_file_range failed or
if the input is empty and so could be a /proc file.
Paul Eggert [Thu, 6 Jun 2019 15:09:58 +0000 (08:09 -0700)]
Fix overflow issues in image rotation
Also, do some refactoring to simplify code.
* src/dispextern.h (INIT_MATRIX, COPY_MATRIX, MULT_MATRICES): Remove.
* src/image.c (matrix3x3): New type, replacing all uses of 3x3 double.
(matrix3x3_copy, matrix3x3_mult): New functions, replacing
COPY_MATRIX, MULT_MATRICES. Replace INIT_MATRIX by C initializers.
(image_set_rotation): Use Fmod to avoid undefined behavior on
double-to-int conversion and to reduce bignum rotations correctly.
(image_set_crop): Finish up previous correction, by not re-setting
width and height if compute_image_size has set them.
Prefer shifting right by 1 to dividing by 2 if either will do.
Steve Scott [Mon, 3 Jun 2019 00:55:34 +0000 (21:55 -0300)]
Check rcirc-server for auto authentication (Bug#10162)
Since the hostname returned by irc.freenode.net can be something other
than irc.freenode.net, e.g. niven.freenode.net, the entries for
rcirc-authinfo and rcirc-server-alist will not match.
* lisp/net/rcirc.el (rcirc-handler-001): Check rcirc-server (the
hostname connected to) instead of rcirc-server-name (the hostname
returned), this corresponds with what rcirc-authenticate does.
Moreover, if rcirc-auto-authenticate-flag is set, check the
corresponding rcirc-authinfo, regardless of whether the
rcirc-authenticate-before-join must happen.
Noam Postavsky [Wed, 5 Jun 2019 23:24:58 +0000 (19:24 -0400)]
Keep nxml prolog updated via syntax-propertize
Instead of using after-change-functions. Also, stop consulting
nxml-prolog-regions during syntax-propertize. It turns out the
problems fixed by using prolog information are actually due to using
the wrong syntax table during propertizing. This was fixed in
2019-06-04 "* lisp/emacs-lisp/syntax.el: Use syntax-ppss-table for
syntax-propertize." so consulting the prolog data is no longer needed.
* lisp/nxml/nxml-rap.el (nxml-maybe-rescan-prolog): Remove.
* lisp/nxml/nxml-mode.el (nxml-mode): Stop using it.
(nxml-syntax-propertize): Don't use nxml-prolog-regions, just call
nxml-scan-prolog if needed before delegating to
sgml-syntax-propertize.
* test/lisp/nxml/nxml-mode-tests.el (nxml-mode-edit-prolog): New test.
Alan Third [Wed, 5 Jun 2019 20:51:33 +0000 (21:51 +0100)]
Add native image rotation and cropping
* lisp/image.el (image--get-imagemagick-and-warn): Only fallback to
ImageMagick if native transforms aren't available.
* src/dispextern.h (INIT_MATRIX, COPY_MATRIX, MULT_MATRICES): New
macros for matrix manipulation.
(HAVE_NATIVE_SCALING, HAVE_NATIVE_TRANSFORMS): Rename and change all
relevant locations.
* src/image.c (x_set_image_rotation):
(x_set_transform): New functions.
(x_set_image_size): Use transform matrix for resizing under X and NS.
(x_set_image_crop): New function.
(lookup_image): Use the new transform functions.
(Fimage_scaling_p, Fimage_transforms_p): Rename and update all
callers.
* src/nsimage.m (ns_load_image): Remove rotation code.
(ns_image_set_transform): New function.
([EmacsImage dealloc]): Release the saved transform.
([EmacsImage rotate:]): Remove unneeded method.
([EmacsImage setTransform:]): New method.
* src/nsterm.h (EmacsImage): Add transform property and update method
definitions.
* src/nsterm.m (ns_dumpglyphs_image): Use the transform to draw the
image correctly.
* src/xterm.c (x_composite_image): Use PictOpSrc as we don't care
about alpha values here.
* doc/lispref/display.texi (Image Descriptors): Add :rotation.
(ImageMagick Images): Remove :rotation.
Stefan Monnier [Wed, 5 Jun 2019 01:48:06 +0000 (21:48 -0400)]
* lisp/emacs-lisp/syntax.el: Use syntax-ppss-table for syntax-propertize.
`syntax-ppss` uses `syntax-ppss-table` while parsing the buffer as well
as when it calls `syntax-propertize`, but `syntax-propertize` can also
be called directly rather than via `syntax-ppss` so it needs to explicitly
use `syntax-ppss-table` as well in order to avoid using sometimes one
table and sometimes another.
(syntax-ppss-table): Move before new use.
(syntax-propertize): Use it.
Specify the matching chars for JSX open/close parenthesis
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Indicate the
matching parenthesis character (since JSX’s < and > aren’t typical
parenthesis) for the sake of packages like rainbow-delimiters which
need that information.
We ended up deciding against using this in js2-mode. Instead,
js2-mode may eventually use js-mode’s syntax-propertize-function to
set syntax-table text properties.
Paul Eggert [Tue, 4 Jun 2019 15:29:37 +0000 (08:29 -0700)]
Adjust comments/debug to match C bignum code
* doc/lispintro/emacs-lisp-intro.texi (Digression into C):
Adjust to match current C code.
* lisp/emacs-lisp/ert.el (ert--force-message-log-buffer-truncation):
Simplify.
* src/.gdbinit (Lisp_Object_Printer.to_string): Return
a string that says "make_fixnum", not "make_number".
Paul Eggert [Tue, 4 Jun 2019 15:13:20 +0000 (08:13 -0700)]
Always allow at least double-precision bignums
Without this fix, Emacs can get into a tight loop reporting
a range error when calculating timestamps.
* doc/lispref/numbers.texi (Integer Basics):
* src/alloc.c (syms_of_alloc): Document this.
* src/bignum.c (make_bignum_bits): Always allow bignums
of at least twice the width of (u)intmax_t.
Noam Postavsky [Sat, 18 May 2019 18:54:36 +0000 (14:54 -0400)]
Keep nxml-prolog-end up to date (Bug#18871)
The change on 2016-01-16 "lisp/nxml: Use syntax-tables for comments"
removed the update of nxml-prolog-end, although it already failed to
work correctly after 2013-10-07 "* lisp/nxml/nxml-mode.el: Use
lexical-binding and syntax-propertize."
* lisp/nxml/nxml-rap.el: New function.
* lisp/nxml/nxml-mode.el (nxml-mode): Add it to
after-change-functions.
Noam Postavsky [Sat, 18 May 2019 18:37:51 +0000 (14:37 -0400)]
Don't sgml-syntax-propertize-inside XML prolog (Bug#32823)
* lisp/nxml/nxml-mode.el (nxml-syntax-propertize): New function.
(nxml-mode): Use it as the syntax-propertize-function.
* test/lisp/nxml/nxml-mode-tests.el (nxml-mode-doctype-and-quote-syntax)
(nxml-mode-prolog-comment): New tests.
Noam Postavsky [Sun, 26 May 2019 21:41:22 +0000 (17:41 -0400)]
Don't fontify text outside of SGML/XML tags (Bug#33887)
* lisp/textmodes/sgml-mode.el (sgml-font-lock-syntactic-face): New
function.
(sgml-mode):
* lisp/nxml/nxml-mode.el (nxml-mode): Use it as
font-lock-syntactic-face-function value.
Noam Postavsky [Sun, 26 May 2019 15:07:14 +0000 (11:07 -0400)]
Fix some SGML syntax edge cases (Bug#33887)
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-rules): Handle
single and double quotes symmetrically. Don't skip quoted comment
enders.
* test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax):
Add more test cases.
(sgml-mode-quote-in-long-text): New test.
* lisp/net/tramp.el (tramp-dissect-file-name): Check for proper method.
(tramp-file-name-for-operation): Take only 2nd argument into
account for file name handler.
(tramp-file-name-handler): Suppress checks for `file-remote-p'.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test02-file-name-dissect): Suppress check for wrong
method.
* test/lisp/net/tramp-tests.el (tramp--test-instrument-test-case):
Dump *all* Tramp buffers.
(tramp-test02-file-name-dissect)
(tramp-test02-file-name-dissect-simplified)
(tramp-test02-file-name-dissect-separate): Check also wrong method.
(tramp-test03-file-name-defaults): Check, that the respective
Tramp package is loaded.
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name)
(tramp-test06-directory-file-name, tramp-test44-auto-load):
Suppress check for wrong method.
(tramp-test30-make-process): Remove instrumentation code.
(tramp-test31-interrupt-process, tramp-test36-vc-registered):
Guarantee that connection is established prior starting process.
Noam Postavsky [Sat, 25 May 2019 23:44:41 +0000 (19:44 -0400)]
Let untarring (and hence package installation) go faster (Bug#35909)
* lisp/subr.el (progress-reporter-update)
(progress-reporter-force-update, progress-reporter-do-update): Accept
new optional argument, SUFFIX.
* doc/lispref/display.texi (Progress): Document it.
* etc/NEWS: Announce it.
* lisp/tar-mode.el (tar-untar-buffer): Use a progress reporter instead
of calling message. Suppress message from write-region. Let-bind
write-region-inhibit-fsync to t.
Stefan Monnier [Mon, 3 Jun 2019 17:44:23 +0000 (13:44 -0400)]
* lisp/gnus/gnus-async.el: Use lexical-binding
Remove redundant :group args.
(gnus-async-post-fetch-function): Make it always be a function.
(gnus-make-async-article-function, gnus-async-prefetch-headers):
Use a closure rather than `(lambda ...)
the message seding is handled by an external program, so no Unicode
encoding is performed in Emacs. Thus Emacs must not assert that the
Unicode encoding was performed.
* lisp/gnus/gnus-sum.el (gnus-data-find-in): New function.
(gnus-data-find, gnus-data-find-list): Use it.
(gnus-summary-article-subject): Make it a function.
(gnus--dummy-data-list): New const.
(gnus-update-summary-mark-positions): Use it.
Glenn Morris [Sun, 2 Jun 2019 02:37:35 +0000 (19:37 -0700)]
Skip some flymake tests on hydra.nixos.org
* test/lisp/progmodes/flymake-tests.el (perl-backend)
(included-c-header-files, recurrent-backend):
Skip on hydra.nixos due to frequent intermittent failures. (Bug#32764)
Stefan Kangas [Sun, 2 Jun 2019 01:51:06 +0000 (18:51 -0700)]
Use lexical-binding in morse.el and studly.el and add tests
* lisp/play/morse.el: Use lexical-binding.
* lisp/play/studly.el: Use lexical-binding.
* test/lisp/play/morse-tests.el: New file.
* test/lisp/play/studly-tests.el: New file.
Stefan Kangas [Sun, 2 Jun 2019 01:47:14 +0000 (18:47 -0700)]
Use lexical-binding in paragraphs.el and add tests
* lisp/textmodes/paragraphs.el: Use lexical-binding.
(repunctuate-sentences): Make it work non-interactively.
* test/lisp/textmodes/paragraphs-tests.el: New file.
Noam Postavsky [Mon, 27 May 2019 00:17:38 +0000 (20:17 -0400)]
Handle argument to rcirc /part properly (Bug#11157)
* lisp/net/rcirc.el (part): Split out channel name and part reason.
* doc/misc/rcirc.texi (rcirc commands): Clarify that channel name may
be provided to /part.
Alan Mackenzie [Sat, 1 Jun 2019 20:15:13 +0000 (20:15 +0000)]
Debug and disentangle the literal cacheing in CC Mode
(Final Commit)
* lisp/progmodes/cc-engine.el (c-semi-trim-near-cache): Correct a comparison
with the wrong ...-limit variable.
(c-semi-pp-to-literal): Remove a wrong setting of c-lit-pos-cache-limit.
(c-full-get-near-cache-entry): Eliminate extravagant and unneeded coding.
(c-state-cache-init, c-record-parse-state-state): No longer manipulate
c-lit-pos-cache, which is no longer regarded as part of c-parse-state.
* lisp/progmodes/cc-mode.el (c-basic-common-init): Call
c-truncate-lit-pos-cache to initialize the literal cache.
* lisp/progmodes/cc-engine.el (c-semi-near-cache-limit): New variable.
(c-truncate-lit-pos-cache): This now truncates the cache variables for all
three lit- sub-caches.
(c-semi-put-near-cache-entry): Increase c-semi-near-cache-limit to the
position of the new entry.
(c-full-near-cache-limit, c-full-lit-near-cache): New variables.
(c-full-trim-near-cache, c-full-get-near-cache-entry)
(c-full-put-near-cache-entry): New functions.
(c-full-pp-to-literal): Amend to use the new functions, and to optimize the
use of the available caches, similarly to c-semi-pp-to-literal.
Paul Eggert [Sat, 1 Jun 2019 19:07:48 +0000 (12:07 -0700)]
Port hbfont.c to GCC 9 with --enable-gcc-warnings
* src/hbfont.c (hbfont_shape): Use ptrdiff_t, not int,
for indexes that in theory might overflow int.
Add UNINIT to pacify GCC 9 and omit an unnecessary initialization.
Glenn Morris [Sat, 1 Jun 2019 19:04:43 +0000 (12:04 -0700)]
Merge from origin/emacs-26
008b263 (origin/emacs-26, emacs-26) * lisp/gnus/gnus.el: Mark autoloa... daf32f1 Speed up redisplay of HELLO d8a6d82 Improve documentation of 'safe-local-variable' property
Glenn Morris [Sat, 1 Jun 2019 19:04:42 +0000 (12:04 -0700)]
Merge from origin/emacs-26
134edc1 Warn about wrong number of args for subrs (Bug#35767) 5f01af6 Use plain symbols for eieio type descriptors (Bug#29220) 4b24b01 Pacify GCC 9 -Wredundant-decls
Eli Zaretskii [Sat, 1 Jun 2019 11:49:07 +0000 (14:49 +0300)]
Prefer HarfBuzz to Uniscribe on MS-Windows
* src/w32fns.c (Fx_create_frame, w32_create_tip_frame):
Register the Uniscribe font backend only if HarfBuzz is not
available, or if explicitly requested via frame parameters
or resources.
Eli Zaretskii [Sat, 1 Jun 2019 09:53:41 +0000 (12:53 +0300)]
Move common HarfBuzz code to a common file hbfont.c
* src/hbfont.c: New file, with code moved from w32uniscribe.c
and renamed/modified as appropriate.
* src/w32uniscribe.c: Move to hbfont.c DEF_DLL_FN and macro
definitions for HarfBuzz functions used in hbfont.c
(load_harfbuzz_funcs): Move loading of HarfBuzz functions used
by hbfont.c to hbfont.c:hbfont_init_w32_funcs, and call that
function from here.
(syms_of_w32uniscribe_for_pdumper): Fill the 'shape' and
'combining_capability' members with hbfont.c function names.
* src/w32common.h (hbfont_init_w32_funcs) [HAVE_HARFBUZZ]: Add
prototype.
* src/font.h (hbfont_shape, hbfont_combining_capability)
[HAVE_HARFBUZZ]: Add prototypes.
* src/Makefile.in (SOME_MACHINE_OBJECTS): Add hbfont.o.
* configure.ac (FONT_OBJ): Add hbfont.o if HAVE_HARFBUZZ.
Eli Zaretskii [Fri, 31 May 2019 09:13:56 +0000 (12:13 +0300)]
Unbreak MinGW64 build with pthreads.h installed
* nt/mingw-cfg.site (gl_cv_func_pthread_sigmask_macro): Set to
"no", to avoid compiling Gnulib's pthread_sigmask.c.
Reported by Richard Copley <rcopley@gmail.com>.