1. 17 Apr, 2020 2 commits
    • Paul Eggert's avatar
      Prefer more inline functions in character.h · 27d10183
      Paul Eggert authored
      * src/buffer.h (fetch_char_advance, fetch_char_advance_no_check)
      (buf_next_char_len, next_char_len, buf_prev_char_len)
      (prev_char_len, inc_both, dec_both): New inline functions,
      replacing the old character.h macros FETCH_CHAR_ADVANCE,
      FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS,
      DEC_POS, INC_BOTH, DEC_BOTH respectively.  All callers changed.
      These new functions all assume buffer primitives and so need
      to be here rather than in character.h.
      * src/casefiddle.c (make_char_unibyte): New static function,
      replacing the old MAKE_CHAR_UNIBYTE macro.  All callers changed.
      (do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead
      of open-coding it.
      * src/ccl.c (GET_TRANSLATION_TABLE): New static function,
      replacing the old macro of the same name.
      * src/character.c (string_char): Omit 2nd arg.  3rd arg can no
      longer be NULL.  All callers changed.
      * src/character.h (SINGLE_BYTE_CHAR_P): Move up.
      (MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY)
      (STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE)
      (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH)
      (DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove.
      (make_char_multibyte): New static function, replacing
      the old macro MAKE_CHAR_MULTIBYTE.  All callers changed.
      (CHAR_STRING_ADVANCE): Remove; all callers changed to use
      CHAR_STRING.
      (NEXT_CHAR_BOUNDARY): Remove; it was unused.
      (raw_prev_char_len): New inline function, replacing the
      old PREV_CHAR_BOUNDARY macro.  All callers changed.
      (string_char_and_length): New inline function, replacing the
      old STRING_CHAR_AND_LENGTH macro.  All callers changed.
      (STRING_CHAR): Rewrite in terms of string_char_and_length.
      (string_char_advance): New inline function, replacing the old
      STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_advance): New inline function, replacing the
      old FETCH_STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_as_multibyte_advance): New inline function,
      replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro.
      All callers changed.
      (fetch_string_char_advance_no_check): New inline function,
      replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro.  All
      callers changed.
      * src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used.
      * src/syntax.c (scan_lists): Use dec_bytepos instead of
      open-coding it.
      * src/xdisp.c (string_char_and_length): Rename from
      string_char_and_length to avoid name conflict with new function in
      character.h.  All callers changed.
      27d10183
    • Paul Eggert's avatar
      Prefer inline functions in character.h · 3e46a231
      Paul Eggert authored
      In character.h, replace macros with inline functions or enums
      when this is easy.  This improves maintainability and
      on my platform (Fedora 31 x86-64, gcc -O2) improved CPU
      performance very slightly (0.3%) on ‘make compile-always’.
      * src/buffer.h (SANE_TAB_WIDTH, CHARACTER_WIDTH):
      Move here from character.h, and make them inline functions.
      Tune CHARACTER_WIDTH so that ASCII_CHAR_WIDTH is no longer needed.
      (sanitize_tab_width, sanitize_char_width):
      Move here from character.h.
      * src/character.h (MAX_CHAR, MAX_UNICODE_CHAR, MAX_1_BYTE_CHAR)
      (MAX_2_BYTE_CHAR, MAX_3_BYTE_CHAR, MAX_4_BYTE_CHAR)
      (MAX_5_BYTE_CHAR, MIN_MULTIBYTE_LEADING_CODE)
      (MAX_MULTIBYTE_LEADING_CODE, MAX_MULTIBYTE_LENGTH):
      Now enum constants instead of macros.
      * src/character.h (CHAR_BYTES): Redo to avoid conditional branches.
      (CHAR_BYTE8_P, BYTE8_TO_CHAR, UNIBYTE_TO_CHAR, CHAR_TO_BYTE8)
      (CHAR_TO_BYTE_SAFE, CHAR_BYTE8_HEAD_P, CHARACTERP)
      (CHECK_CHARACTER, CHECK_CHARACTER_CAR, CHECK_CHARACTER_CDR)
      (CHAR_PRINTABLE_P, CHAR_BYTES, CHAR_LEADING_CODE, BYTE8_STRING)
      (LEADING_CODE_P, TRAILING_CODE_P, CHAR_HEAD_P)
      (BYTES_BY_CHAR_HEAD):
      Now inline functions instead of macros.
      (ASCII_CHAR_WIDTH): Remove; no longer used.
      * src/conf_post.h (ATTRIBUTE_PURE): New macro.
      * src/lisp.h (char_table_ref): Use it, for better inlining.
      * src/fns.c (base64_decode_1): Add now-necessary casts.
      3e46a231
  2. 31 Mar, 2020 1 commit
    • Stefan Monnier's avatar
      Remove `all_buffers` and the associated `next` field of buffers · cddf85d2
      Stefan Monnier authored
      * src/alloc.c (enum mem_type): Remove MEM_TYPE_BUFFER.
      (allocate_buffer): Allocate like any other pseudovector.
      Don't register on `all_buffers` any more.
      (live_buffer_holding, live_buffer_p): Delete functions.
      (mark_maybe_object, valid_lisp_object_p): Don't pay attention to
      MEM_TYPE_BUFFER any more.
      (garbage_collect): Only compact the live buffers.
      (mark_buffer): Mark the undo_list of dead buffers here.
      (mark_object): Buffers are normal pseudovectors now.
      (sweep_buffers): Don't do the actual sweep here, just cleanup the
      markers and only for live buffers.
      
      * src/buffer.c (all_buffers): Remove variable.
      (Fkill_buffer): Don't check indirect dead buffers.
      Set the undo_list before we remove ourselves from the list of live buffers.
      (Fbuffer_swap_text, Fset_buffer_multibyte): Don't check indirect dead
      buffers.
      (init_buffer_once): Don't set `all_buffers`.
      (init_buffer): Don't map new memory for dead buffers.
      
      * src/buffer.h (struct buffer): Remove `next` field.
      (FOR_EACH_BUFFER): Remove macro.
      
      * src/pdumper.c (dump_buffer): Don't dump the `next` field.
      cddf85d2
  3. 27 Mar, 2020 1 commit
    • Paul Eggert's avatar
      Treat out-of-range positions consistently · de00a933
      Paul Eggert authored
      If a position argument to get-byte etc. is an out-of-range integer,
      treat it the same regardless of whether it is a fixnum or a bignum.
      * src/buffer.c (fix_position): New function.
      * src/buffer.c (validate_region):
      * src/character.c (Fget_byte):
      * src/coding.c (Ffind_coding_systems_region_internal)
      (Fcheck_coding_systems_region):
      * src/composite.c (Ffind_composition_internal):
      * src/editfns.c (Fposition_bytes, Fchar_after, Fchar_before)
      (Finsert_buffer_substring, Fcompare_buffer_substrings)
      (Fnarrow_to_region):
      * src/fns.c (Fsecure_hash_algorithms):
      * src/font.c (Finternal_char_font, Ffont_at):
      * src/fringe.c (Ffringe_bitmaps_at_pos):
      * src/search.c (search_command):
      * src/textprop.c (get_char_property_and_overlay):
      * src/window.c (Fpos_visible_in_window_p):
      * src/xdisp.c (Fwindow_text_pixel_size):
      Use it instead of CHECK_FIXNUM_COERCE_MARKER, so that
      the code is simpler and treats bignums consistently with fixnums.
      * src/buffer.h (CHECK_FIXNUM_COERCE_MARKER): Define here
      rather than in lisp.h, and reimplement in terms of fix_position
      so that it treats bignums consistently with fixnums.
      * src/lisp.h (CHECK_FIXNUM_COERCE_MARKER): Move to buffer.h.
      * src/textprop.c (validate_interval_range): Signal with original
      bounds rather than modified ones.
      de00a933
  4. 01 Jan, 2020 1 commit
  5. 19 Sep, 2019 1 commit
  6. 05 Sep, 2019 1 commit
    • Juri Linkov's avatar
      Don't use hook pre-redisplay-functions. Set buffer-local tab-line-format. · 2a016475
      Juri Linkov authored
      * lisp/tab-line.el (tab-line-format): Move to C.
      (tab-line-update-window-parameter): Remove function.
      (global-tab-line-mode): Set the default value of tab-line-format.
      
      * src/buffer.c (syms_of_buffer): Define buffer-local variable
      tab-line-format.
      
      * src/buffer.h (struct buffer): Add tab_line_format_.
      
      * src/window.c (window_wants_tab_line):
      * src/xdisp.c (pos_visible_p, display_mode_lines):
      Check for buffer-local tab_line_format.
      2a016475
  7. 04 Sep, 2019 2 commits
    • Paul Eggert's avatar
      Prefer functions to macros in buffer.h · d84b4f83
      Paul Eggert authored
      In buffer.h, prefer inline functions to function-like macros
      when either will do.  This helps avoid confusion about how
      many times an arg is evaluated.  On my platform, this patch
      improves performance of ‘make compile-always’ by 5.7%.
      Also, prefer enum constants to object-like macros
      when either will do.
      * src/buffer.h (BEG, BEG_BYTE, GAP_BYTES_DFL, GAP_BYTES_MIN)
      (MAX_PER_BUFFER_VARS, NONEXISTENT_MODTIME_NSECS)
      (UNKNOWN_MODTIME_NSECS, BUFFER_LISP_SIZE, BUFFER_REST_SIZE):
      Now enum constants, instead of macros.
      (BUFFER_CEILING_OF, BUFFER_FLOOR_OF, BUF_BEG, BUF_BEG_BYTE)
      (BUF_BEGV, BUF_BEGV_BYTE, BUF_PT, BUF_PT_BYTE, BUF_ZV)
      (BUF_ZV_BYTE, BUF_GPT_ADDR, BUF_Z_ADDR, BUF_GAP_END_ADDR)
      (BUF_COMPUTE_UNCHANGED, SET_PT, TEMP_SET_PT, SET_PT_BOTH)
      (TEMP_SET_PT_BOTH, BUF_TEMP_SET_PT, SET_BUF_BEGV, SET_BUF_ZV)
      (SET_BUF_BEGV_BOTH, SET_BUF_ZV_BOTH, SET_BUF_PT_BOTH)
      (BYTE_POS_ADDR, CHAR_POS_ADDR, CHAR_TO_BYTE, BYTE_TO_CHAR)
      (PTR_BYTE_POS, FETCH_CHAR, FETCH_CHAR_AS_MULTIBYTE)
      (BUF_BYTE_ADDRESS, BUF_CHAR_ADDRESS, BUF_PTR_BYTE_POS)
      (BUF_FETCH_CHAR, BUF_FETCH_CHAR_AS_MULTIBYTE, BUF_FETCH_BYTE)
      (BUFFER_PVEC_INIT, BUFFER_LIVE_P, BUFFER_HIDDEN_P)
      (BUFFER_CHECK_INDIRECTION, OVERLAY_POSITION, PER_BUFFER_VALUE_P)
      (SET_PER_BUFFER_VALUE_P, PER_BUFFER_IDX):
      Now inline functions instead of macros.
      d84b4f83
    • Paul Eggert's avatar
      Take last_per_buffer_idx private · 97cfda26
      Paul Eggert authored
      This will simplify future changes.  Turn the runtime check
      into an eassert, since it’s not needed in production.
      * src/buffer.c (last_per_buffer_idx): Now static.
      (valid_per_buffer_idx): New function.
      * src/buffer.h (PER_BUFFER_VALUE_P, SET_PER_BUFFER_VALUE_P): Use it.
      97cfda26
  8. 07 May, 2019 1 commit
    • Stefan Monnier's avatar
      * src/marker.c (buf_bytepos_to_charpos): Re-add the CHAR_HEAD_P assertion · 32cf0781
      Stefan Monnier authored
      This assertion was removed in 1c349c62
      because the assumption was invalid during set_intervals_multibyte_1.
      So we change set_intervals_multibyte_1 to solve the problem in the same
      way as in the rest of Fset_buffer_multibyte, which actually simplifies
      the code.
      
      * src/buffer.c (advance_to_char_boundary): Not static any more.
      * src/buffer.h (advance_to_char_boundary): Add prototype.
      * src/intervals.c (set_intervals_multibyte_1): Use it.
      32cf0781
  9. 08 Apr, 2019 1 commit
  10. 30 Mar, 2019 1 commit
    • Eli Zaretskii's avatar
      Don't run buffer-related hooks in " *code conversion work*" buffers · 9c0fa117
      Eli Zaretskii authored
      Note: portions of this change were mistakenly pushed as part
      of an unrelated commit a35a1f6a.
      
      * src/buffer.c (Fget_buffer_create): Set inhibit_buffer_hooks
      non-zero for temporary buffers created by coding.c.  Don't run
      buffer-list-update-hook for such buffers.
      (Frename_buffer, Fkill_buffer, record_buffer)
      (Fbury_buffer_internal): Don't run hooks for buffers whose
      inhibit_buffer_hooks flag is set.
      * src/buffer.h (struct buffer): New member
      inhibit_buffer_hooks.
      * src/pdumper.c (dump_buffer): Dump the new field.  Update the
      hash value in HASH_buffer_XXX.
      * src/coding.c (make_conversion_work_buffer): Function deleted;
      code moved to code_conversion_save.
      (code_conversion_save): Insert code from
      make_conversion_work_buffer, but arrange for unwind-protecting
      the current buffer before switching to the work buffer.  This
      avoids leaving reused_workbuf_in_use set if user presses C-g
      during encoding/decoding.
      (Vcode_conversion_workbuf_name): Now external variable.
      * src/coding.h (Vcode_conversion_reused_workbuf): Declare.
      9c0fa117
  11. 31 Jan, 2019 1 commit
    • Paul Eggert's avatar
      Widen modiff counts to avoid wraparound · 05d2fc71
      Paul Eggert authored
      Widen modification counts to at least 64 bits, to make
      wraparound practically impossible.
      * doc/lispref/buffers.texi (Buffer Modification):
      Don’t say the modification-count can wrap around.
      * src/buffer.c (Frestore_buffer_modified_p, Fbuffer_swap_text)
      (modify_overlay):
      * src/insdel.c (insert_1_both, insert_from_string_1)
      (insert_from_gap, insert_from_buffer_1)
      (adjust_after_replace, replace_range, replace_range_2)
      (del_range_2, modify_text):
      * src/textprop.c (modify_text_properties):
      Use modiff_incr instead of incrementing	directly.
      (Fbuffer_modified_tick, Fbuffer_chars_modified_tick):
      Don’t assume modification counts fit into fixnums.
      * src/buffer.h (struct buffer_text, struct buffer):
      * src/cmds.c (internal_self_insert):
      * src/fileio.c (Finsert_file_contents):
      * src/indent.c (last_known_column_modified):
      * src/keyboard.c (command_loop_1):
      * src/marker.c (cached_modiff):
      * src/syntax.c (find_start_modiff, parse_sexp_propertize)
      (find_defun_start):
      * src/window.h (struct window):
      Use modiff_count for modification counts.
      * src/editfns.c (Fsubst_char_in_region):
      Copy instead of incrementing modification counts,
      since integer overflow checking is not needed here.
      * src/lisp.h (modiff_count): New type.
      (modiff_incr, modiff_to_integer): New inline functions.
      * src/pdumper.c (dump_buffer): Update hash.
      05d2fc71
  12. 01 Jan, 2019 1 commit
  13. 22 Aug, 2018 1 commit
  14. 08 Aug, 2018 1 commit
    • Tom Tromey's avatar
      More macro renamings for bignum · d1ec3a0a
      Tom Tromey authored
      * src/alloc.c, src/bidi.c, src/buffer.c, src/buffer.h, src/bytecode.c,
      src/callint.c, src/callproc.c, src/casefiddle.c, src/casetab.c,
      src/category.c, src/ccl.c, src/character.c, src/character.h,
      src/charset.c, src/charset.h, src/chartab.c, src/cmds.c, src/coding.c,
      src/composite.c, src/composite.h, src/data.c, src/dbusbind.c,
      src/decompress.c, src/dired.c, src/dispextern.h, src/dispnew.c,
      src/disptab.h, src/doc.c, src/dosfns.c, src/editfns.c,
      src/emacs-module.c, src/emacs.c, src/eval.c, src/fileio.c,
      src/floatfns.c, src/fns.c, src/font.c, src/font.h, src/fontset.c,
      src/frame.c, src/frame.h, src/fringe.c, src/ftcrfont.c, src/ftfont.c,
      src/gfilenotify.c, src/gnutls.c, src/gtkutil.c, src/image.c,
      src/indent.c, src/insdel.c, src/intervals.c, src/json.c,
      src/keyboard.c, src/keymap.c, src/kqueue.c, src/lcms.c, src/lisp.h,
      src/lread.c, src/macros.c, src/marker.c, src/menu.c, src/minibuf.c,
      src/msdos.c, src/print.c, src/process.c, src/profiler.c, src/search.c,
      src/sound.c, src/syntax.c, src/syntax.h, src/sysdep.c, src/term.c,
      src/termhooks.h, src/textprop.c, src/undo.c, src/w32.c,
      src/w32console.c, src/w32fns.c, src/w32font.c, src/w32inevt.c,
      src/w32proc.c, src/w32select.c, src/w32term.c, src/w32term.h,
      src/w32uniscribe.c, src/window.c, src/xdisp.c, src/xfaces.c,
      src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c, src/xml.c,
      src/xrdb.c, src/xselect.c, src/xsettings.c, src/xterm.c, src/xwidget.c
      Rename XINT->XFIXNUM, XFASTINT->XFIXNAT, XUINT->XUFIXNUM.
      d1ec3a0a
  15. 13 Jul, 2018 1 commit
    • Tom Tromey's avatar
      Rename integerp->fixnum, etc, in preparation for bignums · 42fe787b
      Tom Tromey authored
      * src/json.c, src/keyboard.c, src/keyboard.h, src/keymap.c,
      src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c,
      src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c,
      src/process.c, src/profiler.c, src/search.c, src/sound.c,
      src/syntax.c, src/sysdep.c, src/term.c, src/terminal.c,
      src/textprop.c, src/undo.c, src/w16select.c, src/w32.c,
      src/w32console.c, src/w32cygwinx.c, src/w32fns.c, src/w32font.c,
      src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c,
      src/w32uniscribe.c, src/widget.c, src/window.c, src/xdisp.c,
      src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c,
      src/xrdb.c, src/xselect.c, src/xterm.c, src/xwidget.c: Rename
      INTEGERP->FIXNUM, make_number->make_fixnum, CHECK_NUMBER->CHECK_FIXNUM,
      make_natnum->make_fixed_natum, NUMBERP->FIXED_OR_FLOATP,
      NATNUMP->FIXNATP, CHECK_NATNUM->CHECK_FIXNAT.
      42fe787b
  16. 10 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Use native alignment to access Lisp object data · 0303fab3
      Paul Eggert authored
      Instead of using __builtin_assume_aligned (P, GCALIGNMENT) to
      tell GCC that P has alignment 8, use (T *) P where T is the
      type of the pointed-to object, to tell GCC that P has native
      alignment.  This is simpler, matches the intent better, and
      should help simplify future improvements.  Some of these
      changes are to pacify gcc -Wnull-dereference, since GCC is
      smarter about pointers now that Emacs no longer uses
      __builtin_assume_aligned; these minor changes should improve
      code efficiency slightly.  On Fedora 28 x86-64 with default
      optimization this patch shrinks the size of the Emacs text
      segment by 0.36%.
      * src/conf_post.h (__has_builtin, __builtin_assume_aligned):
      Remove; no longer used.
      * src/dbusbind.c (XD_OBJECT_TO_DBUS_TYPE):
      Pacify -Wnull-dereference by using XCAR instead of CAR_SAFE
      and XCDR instead of CDR_SAFE when this is safe.
      * src/fileio.c (Fexpand_file_name):
      * src/font.c (clear_font_cache):
      Pacify -Wnull-dereference by removing unnecessary NILP test.
      * src/keyboard.c (xevent_start): New function.
      (read_char, read_key_sequence): Pacify -Wnull-dereference by
      using xevent_start instead of EVENT_START.
      * src/lisp.h (lisp_h_XUNTAG): Remove; XUNTAG is always a macro
      now, since it can no longer be implemented as a function.
      (XUNTAG): New third argument CTYPE.  All uses changed.
      Cast result to CTYPE * instead of using __builtin_assume_aligned.
      Simplify by using LISP_WORD_TAG.
      (LISP_WORD_TAG): New macro.
      (TAG_PTR): Use it.
      * src/menu.c (x_popup_menu_1):
      Pacify -Wnull-dereference by using XCAR instead of Fcar and
      XCDR instead of Fcdr where this is safe.
      0303fab3
  17. 01 Jan, 2018 1 commit
  18. 09 Dec, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix tool-tip display when display margins are non-zero by default · 122e7264
      Eli Zaretskii authored
      * src/buffer.h (bset_left_margin_cols, bset_right_margin_cols):
      New inline functions.
      * src/xfns.c (Fx_show_tip):
      * src/w32fns.c (Fx_show_tip): Force display margins of the tip
      buffer to zero, as it will be displayed in a pseudo-window, which
      doesn't support display margins.  (Bug#29627)
      122e7264
  19. 13 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Change vectorlike from struct to union · 5d68dc9a
      Paul Eggert authored
      * src/lisp.h (vectorlike_headed): Change from struct to union.
      All uses changed.  Since it has only one member, this does not
      change semantics.  This is designed to simplify future changes
      needed to fix bugs like Bug#29040.  All uses changed.
      5d68dc9a
  20. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
      bc511a64
  21. 17 Jul, 2017 1 commit
    • Eli Zaretskii's avatar
      Allow user control on what starts and ends a paragraph for bidi · d7f7fef1
      Eli Zaretskii authored
      * src/buffer.h (struct buffer): New members
      bidi_paragraph_separate_re_ and bidi_paragraph_start_re_.
      * src/buffer.c (bset_bidi_paragraph_start_re)
      (bset_bidi_paragraph_separate_re): New setters/
      (Fbuffer_swap_text): Swap the values of bidi-paragraph-start-re and
      bidi-paragraph-separate-re.
      (init_buffer_once): Init the values of bidi-paragraph-start-re and
      bidi-paragraph-separate-re.
      (syms_of_buffer) <bidi-paragraph-start-re, bidi-paragraph-separate-re>:
      New per-buffer variables.
      * src/bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start):
      Support bidi-paragraph-start-re and bidi-paragraph-separate-re.
      (bidi_move_to_visually_next): Handle correctly the case when the
      separator matches an empty string.  (Bug#27526)
      
      * doc/emacs/mule.texi (Bidirectional Editing):
      * doc/lispref/display.texi (Bidirectional Display): Document
      bidi-paragraph-start-re and bidi-paragraph-separate-re.
      
      * etc/NEWS: Mention bidi-paragraph-start-re and
      bidi-paragraph-separate-re.
      d7f7fef1
  22. 17 Jun, 2017 1 commit
    • Philipp Stephani's avatar
      Add command to replace buffer contents · d682f0da
      Philipp Stephani authored
      Add a new command 'replace-buffer-contents' that uses the Myers diff
      algorithm to non-destructively replace the accessible portion of the
      current buffer.  The Myers algorithm is implemented in Gnulib.
      
      * src/editfns.c (Freplace_buffer_contents): New command.
      (set_bit, bit_is_set, buffer_chars_equal): New helper functions.
      (syms_of_editfns): Define new command.
      
      * test/src/editfns-tests.el (replace-buffer-contents-1)
      (replace-buffer-contents-2): New unit tests.
      
      * src/buffer.h (BUF_FETCH_CHAR_AS_MULTIBYTE): New helper macro.
      
      * admin/merge-gnulib (GNULIB_MODULES): Add diffseq.h and minmax.h.
      d682f0da
  23. 16 Feb, 2017 1 commit
  24. 15 Feb, 2017 1 commit
    • Michal Nazarewicz's avatar
      casing: don’t assume letters are *either* upper- or lower-case (bug#24603) · 6220faeb
      Michal Nazarewicz authored
      A compatibility digraph characters, such as Dž, are neither upper- nor
      lower-case.  At the moment however, those are reported as upper-case¹
      despite the fact that they change when upper-cased.
      
      Stop checking if a character is upper-case before trying to up-case it
      so that title-case characters are handled correctly.  This fixes one of
      the issues mentioned in bug#24603.
      
      ¹ Because they change when converted to lower-case.  Notice an asymmetry
        in that for a character to be considered lower-case it must not be
        upper-case (plus the usual condition of changing when upper-cased).
      
      * src/buffer.h (upcase1): Delete.
      (upcase): Change to upcase character unconditionally just like downcase
      does it.  This is what upcase1 was.
      
      * src/casefiddle.c (casify_object, casify_region): Use upcase instead
      of upcase1 and don’t check !uppercasep(x) before calling upcase.
      
      * src/keyboard.c (read_key_sequence): Don’t check if uppercase(x), just
      downcase(x) and see if it changed.
      
      * test/src/casefiddle-tests.el (casefiddle-tests--characters,
      casefiddle-tests-casing): Update test cases which are now passing.
      6220faeb
  25. 01 Jan, 2017 1 commit
  26. 25 Dec, 2016 1 commit
    • Paul Eggert's avatar
      Reorder lisp.h to declare types before using them · f5b9c1e5
      Paul Eggert authored
      This puts basic functions for types to be after the corresponding
      type definitions.  This is a more-common programming style in C,
      and will make it easier to port Emacs to gcc
      -fcheck-pointer-bounds, since the functions now have access to the
      corresponding types' sizes.  This patch does not change the code;
      it just moves declarations and definitions and removes
      no-longer-needed forward declarations (Bug#25128).
      * src/buffer.c, src/data.c, src/image.c:
      Include process.h, for PROCESSP.
      * src/buffer.h (BUFFERP, CHECK_BUFFER, XBUFFER):
      * src/process.h (PROCESSP, CHECK_PROCESS, XPROCESS):
      * src/termhooks.h (TERMINALP, XTERMINAL):
      * src/window.h (WINDOWP, CHECK_WINDOW, XWINDOW):
      * src/thread.h (THREADP, CHECK_THREAD, XTHREAD, MUTEXP, CHECK_MUTEX)
      (XMUTEX, CONDVARP, CHECK_CONDVAR, XCONDVAR):
      Move here from lisp.h.
      * src/intervals.h: Include buffer.h, for BUFFERP.
      Include lisp.h, for Lisp_Object.
      * src/lisp.h: Reorder declarations and definitions as described
      above.  Move thread includes to be later, so that they can use the
      reordered definitions.  Move some symbols to other headers (noted
      elsewhere).  Remove forward decls that are no longer needed.
      * src/thread.h: Include systhread.h here, not in lisp.h,
      since lisp.h itself does not need systhread.h.
      f5b9c1e5
  27. 12 Dec, 2016 1 commit
    • Eli Zaretskii's avatar
      Fix point motion in cloned buffers · a416e1d6
      Eli Zaretskii authored
      * src/thread.c (post_acquire_global_lock): Call
      set_buffer_internal_2 instead of tricking set_buffer_internal_1
      into resetting the current buffer even if it didn't change.  This
      avoids bug#25165, caused by failing to record the modified values
      of point and mark, because current_buffer was set to NULL.  Also,
      don't bother re-setting the buffer if there was no thread switch,
      as that just wastes cycles.
      * src/buffer.c (set_buffer_internal_2): New function, with most of
      the body of set_buffer_internal_1, but without the test for B
      being identical to the current buffer.
      (set_buffer_internal_1): Call set_buffer_internal_2 if B is not
      identical to the current buffer.
      * src/buffer.h (set_buffer_internal_2): Add prototype.
      
      * test/src/thread-tests.el (thread-sticky-point): New test.
      a416e1d6
  28. 23 Sep, 2016 1 commit
  29. 09 Sep, 2016 1 commit
  30. 10 Mar, 2016 1 commit
    • Paul Eggert's avatar
      Rework C source files to avoid ^( · 7352c6c6
      Paul Eggert authored
      Work around Bug#22884 by rewording comments and strings to avoid ‘(’
      at the start of a line unless it starts a function.  This change
      is a short-term hack; in the longer run we plan to fix cc-mode’s
      performance for C files that have ‘(’ at the start of a line in a
      comment or string.
      7352c6c6
  31. 01 Jan, 2016 1 commit
  32. 16 Oct, 2015 1 commit
    • Paul Eggert's avatar
      Make src headers idempotent and standalone · 55ba8c02
      Paul Eggert authored
      Redo src/*.h so that each include file is idempotent (that is, can
      be included multiple times with the latter inclusions having no
      effect) and standalone (that is, can be included by itself,
      with no include file other than config.h needed as a prerequisite).
      This is standard practice in GNU programs nowadays.
      * lwlib/lwlib-widget.h, src/buffer.h, src/category.h, src/character.h:
      * src/charset.h, src/coding.h, src/commands.h, src/disptab.h:
      * src/fontset.h, src/gnutls.h, src/indent.h, src/keymap.h, src/macros.h:
      * src/regex.h [emacs]:
      * src/syntax.h, src/systty.h, src/termhooks.h:
      Include lisp.h, for Lisp_Object.
      * src/buffer.h, src/category.h, src/cm.h, src/commands.h, src/disptab.h:
      * src/indent.h, src/intervals.h, src/keyboard.h, src/macros.h:
      * src/process.h, src/puresize.h, src/region-cache.h, src/syntax.h:
      * src/syssignal.h, src/sysstdio.h, src/systty.h, src/termchar.h:
      * src/termopts.h, src/tparam.h, src/unexec.h:
      Protect against multiple inclusion.
      * src/buffer.h: Include character.h, for STRING_CHAR.
      * src/emacsgtkfixed.h (struct frame):
      * src/fontset.h (struct face):
      * src/region-cache.h (struct buffer):
      * src/termhooks.h (struct glyph):
      * src/xsettings.h (struct x_display_info):
      Add possibly-forward decl.
      * src/syntax.h: Include buffer.h, for BVAR.
      * src/sysselect.h: Include lisp.h, for eassume.
      * src/termchar.h: Include <stdio.h>, for FILE.
      * src/widget.h: Include <X11/IntrinsicP.h>, for Widget.
      * src/xsettings.h: Include <X11/Xlib.h>, for XEvent.
      55ba8c02
  33. 29 Apr, 2015 1 commit
  34. 05 Jan, 2015 1 commit
    • Paul Eggert's avatar
      Compute C decls for DEFSYMs automatically · 58f2d6ef
      Paul Eggert authored
      Fixes Bug#15880.
      This patch also makes Q constants (e.g., Qnil) constant addresses
      from the C point of view.
      * make-docfile.c: Revamp to generate table of symbols, too.
      Include <stdbool.h>.
      (xstrdup): New function.
      (main): Don't process the same file twice.
      (SYMBOL): New constant in enum global_type.
      (struct symbol): Turn 'value' member into a union, either v.value
      for int or v.svalue for string.  All uses changed.
      (add_global): New arg svalue, which overrides value, so that globals
      can have a string value.
      (close_emacs_global): New arg num_symbols; all uses changed.
      Output lispsym decl.
      (write_globals): Output symbol globals too.  Output more
      ATTRIBUTE_CONST, now that Qnil etc. are C constants.
      Output defsym_name table.
      (scan_c_file): Move most of guts into ...
      (scan_c_stream): ... new function.  Scan for DEFSYMs and
      record symbols found.  Don't read past EOF if file doesn't
      end in newline.
      * alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle:
      * casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c:
      * composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c:
      * doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c:
      * frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c:
      * image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c:
      * macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m:
      * nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c:
      * search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c:
      * window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c:
      * xselect.c, xsettings.c, xterm.c:
      Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs).
      These names are now defined automatically by make-docfile.
      * alloc.c (init_symbol): New function.
      (Fmake_symbol): Use it.
      (c_symbol_p): New function.
      (valid_lisp_object_p, purecopy): Use it.
      * alloc.c (marked_pinned_symbols):
      Use make_lisp_symbol instead of make_lisp_ptr.
      (garbage_collect_1): Mark lispsym symbols.
      (CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro.
      (mark_object): Use it.
      (sweep_symbols): Sweep lispsym symbols.
      (symbol_uses_obj): New function.
      (which_symbols): Use it.  Work for lispsym symbols, too.
      (init_alloc_once): Initialize Vpurify_flag here; no need to wait,
      since Qt's address is already known now.
      (syms_of_alloc): Add lispsym count to symbols_consed.
      * buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0),
      when testing whether storage is all bits zero.
      * dispextern (struct image_type):
      * font.c (font_property_table):
      * frame.c (struct frame_parm_table, frame_parms):
      * keyboard.c (scroll_bar_parts, struct event_head):
      * xdisp.c (struct props):
      Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and
      Lisp_Object *, since Qfoo is no longer an object whose address can be
      taken.  All uses changed.
      * eval.c (run_hook): New function.  Most uses of Frun_hooks changed to
      use it, so that they no longer need to take the address of a Lisp sym.
      (syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable.
      * frame.c (syms_of_frame): Add defsyms for the frame_parms table.
      * keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here.
      DEFSYM Qdeactivate_mark before the corresponding var.
      * keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line
      instead of interning their symbols; this avoids duplicates.
      (LISP_INITIALLY, TAG_PTR)
      (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT):
      New macros.
      (LISP_INITIALLY_ZERO): Use it.
      (enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol)
      (EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*):
      Move decls up, to avoid forward uses.  Include globals.h earlier, too.
      (make_lisp_symbol): New function.
      (XSETSYMBOL): Use it.
      (DEFSYM): Now just a placeholder for make-docfile.
      * lread.c (DEFINE_SYMBOLS): Define, for globals.h.
      (intern_sym): New function, with body taken from old intern_driver.
      (intern_driver): Use it.  Last arg is now Lisp integer, not ptrdiff_t.
      All uses changed.
      (define_symbol): New function.
      (init_obarray): Define the C symbols taken from lispsym.
      Use plain DEFSYM for Qt and Qnil.
      * syntax.c (init_syntax_once): No need to worry about
      Qchar_table_extra_slots.
      58f2d6ef
  35. 01 Jan, 2015 2 commits
  36. 17 Sep, 2014 1 commit
    • Paul Eggert's avatar
      Fix minor problems found by static checking. · 9356a872
      Paul Eggert authored
      * alloc.c, lisp.h (SAVE_TYPE_INT_OBJ, make_save_int_obj):
      Remove; now unused.
      * buffer.h (decode_buffer): Doc and indentation fixes.
      * fns.c (Qstring_collate_lessp, Qstring_collate_equalp): Now static.
      9356a872
  37. 07 Sep, 2014 1 commit
    • Paul Eggert's avatar
      Use SAFE_ALLOCA etc. to avoid unbounded stack allocation. · b3bf18b3
      Paul Eggert authored
      This follows up on the recent thread in emacs-devel on alloca; see:
      http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00042.html
      This patch also cleans up alloca-related glitches noted while
      examining the code looking for unbounded alloca.
      * alloc.c (listn):
      * callproc.c (init_callproc):
      Rewrite to avoid need for alloca.
      * buffer.c (mouse_face_overlay_overlaps)
      (report_overlay_modification):
      * buffer.h (GET_OVERLAYS_AT):
      * coding.c (make_subsidiaries):
      * doc.c (Fsnarf_documentation):
      * editfns.c (Fuser_full_name):
      * fileio.c (Ffile_name_directory, Fexpand_file_name)
      (search_embedded_absfilename, Fsubstitute_in_file_name):
      * fns.c (Fmake_hash_table):
      * font.c (font_vconcat_entity_vectors, font_update_drivers):
      * fontset.c (fontset_pattern_regexp, Ffontset_info):
      * frame.c (Fmake_terminal_frame, x_set_frame_parameters)
      (xrdb_get_resource, x_get_resource_string):
      * ftfont.c (ftfont_get_charset, ftfont_check_otf, ftfont_drive_otf):
      * ftxfont.c (ftxfont_draw):
      * image.c (xbm_load, xpm_load, jpeg_load_body):
      * keyboard.c (echo_add_key, menu_bar_items, tool_bar_items):
      * keymap.c (Fdescribe_buffer_bindings, describe_map):
      * lread.c (openp):
      * menu.c (digest_single_submenu, find_and_call_menu_selection)
      (find_and_return_menu_selection):
      * print.c (PRINTFINISH):
      * process.c (Fformat_network_address):
      * scroll.c (do_scrolling, do_direct_scrolling, scrolling_1):
      * search.c (search_buffer, Fmatch_data, Fregexp_quote):
      * sound.c (wav_play, au_play):
      * syntax.c (skip_chars):
      * term.c (tty_menu_activate, tty_menu_show):
      * textprop.c (get_char_property_and_overlay):
      * window.c (Fset_window_configuration):
      * xdisp.c (safe__call, next_overlay_change, vmessage)
      (compute_overhangs_and_x, draw_glyphs, note_mouse_highlight):
      * xfaces.c (face_at_buffer_position):
      * xmenu.c (x_menu_show):
      Use SAFE_ALLOCA etc. instead of plain alloca, since the
      allocation size isn't bounded.
      * callint.c (Fcall_interactively): Redo memory_full check
      so that it can be done at compile-time on some platforms.
      * coding.c (MAX_LOOKUP_MAX): New constant.
      (get_translation_table): Use it.
      * callproc.c (call_process): Use SAFE_NALLOCA instead of
      SAFE_ALLOCA, to catch integer overflows on size calculation.
      (exec_failed) [!DOS_NT]: New function.
      (child_setup) [!DOS_NT]: Use it.
      * editfns.c (Ftranspose_regions):
      Hoist USE_SAFE_ALLOC + SAFE_FREE out of 'if'.
      * editfns.c (check_translation):
      Allocate larger buffers on the heap.
      * eval.c (internal_lisp_condition_case):
      Check for MAX_ALLOCA overflow.
      * fns.c (sort_vector): Use SAFE_ALLOCA_LISP rather than Fmake_vector.
      (Fbase64_encode_region, Fbase64_decode_region):
      Avoid unnecessary calls to SAFE_FREE before 'error'.
      * buffer.c (mouse_face_overlay_overlaps):
      * editfns.c (Fget_pos_property, check_translation):
      * eval.c (Ffuncall):
      * font.c (font_unparse_xlfd, font_find_for_lface):
      * ftfont.c (ftfont_drive_otf):
      * keyboard.c (echo_add_key, read_decoded_event_from_main_queue)
      (menu_bar_items, tool_bar_items):
      * sound.c (Fplay_sound_internal):
      * xdisp.c (load_overlay_strings, dump_glyph_row):
      Use an ordinary auto buffer rather than alloca, since the
      allocation size is fixed and small.
      * ftfont.c: Include <c-strcase.h>.
      (matching_prefix): New function.
      (get_adstyle_property): Use it, to avoid need for alloca.
      * keyboard.c (echo_add_key):
      * keymap.c (describe_map): Use ptrdiff_t, not int.
      * keyboard.c (echo_add_key): Prefer sizeof to strlen.
      * keymap.c (Fdescribe_buffer_bindings): Use SBYTES, not SCHARS,
      when counting bytes.
      * lisp.h (xlispstrdupa): Remove, replacing with ...
      (SAFE_ALLOCA_STRING): ... new macro with different API.
      This fixes a portability problem, namely, alloca result
      passed to another function.  All uses changed.
      (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Check for MAX_ALLOCA,
      not MAX_ALLOCA - 1.
      * regex.c (REGEX_USE_SAFE_ALLOCA, REGEX_SAFE_FREE)
      (REGEX_ALLOCATE): New macros.
      (REGEX_REALLOCATE, REGEX_ALLOCATE_STACK, REGEX_REALLOCATE_STACK)
      (REGEX_FREE_STACK, FREE_VARIABLES, re_match_2_internal):
      Use them.
      * xdisp.c (message3): Use SAFE_ALLOCA_STRING rather than doing it
      by hand.
      (decode_mode_spec_coding): Store directly into buf rather than
      into an alloca temporary and copying the temporary to the buf.
      
      Fixes: debbugs:18410
      b3bf18b3