all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 85e872a9407db329d0958738cea8105671ad1206 4595 bytes (raw)
name: src/category.h 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
/* Declarations having to do with Emacs category tables.
   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
     2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
     National Institute of Advanced Industrial Science and Technology (AIST)
     Registration Number H14PRO021
   Copyright (C) 2003
     National Institute of Advanced Industrial Science and Technology (AIST)
     Registration Number H13PRO009

This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */

#ifndef EMACS_CATEGORY_H
#define EMACS_CATEGORY_H

/* We introduce here three types of object: category, category set,
   and category table.

   A category is like syntax but differs in the following points:

   o A category is represented by a mnemonic character of the range
   ` '(32)..`~'(126) (printable ASCII characters).

   o A category is not exclusive, i.e. a character has multiple
   categories (category set).  Of course, there's a case that a
   category set is empty, i.e. the character has no category.

   o In addition to the predefined categories, a user can define new
   categories.  Total number of categories is limited to 95.

   A category set is a set of categories represented by Lisp
   bool-vector of length 128 (only elements of 31th through 126th
   are used).

   A category table is like syntax-table, represented by a Lisp
   char-table.  The contents are category sets or nil.  It has two
   extra slots, for a vector of doc string of each category and a
   version number.

   The first extra slot is a vector of doc strings of categories, the
   length is 95.  The Nth element corresponding to the category N+32.

   The second extra slot is a version number of the category table.
   But, for the moment, we are not using this slot.  */

#include "lisp.h"

INLINE_HEADER_BEGIN

#define CATEGORYP(x) RANGED_FIXNUMP (0x20, x, 0x7E)

#define CHECK_CATEGORY(x) \
  CHECK_TYPE (CATEGORYP (x), Qcategoryp, x)

#define CATEGORY_SET_P(x) \
  (BOOL_VECTOR_P (x) && bool_vector_size (x) == 128)

/* Return a new empty category set.  */
#define MAKE_CATEGORY_SET (Fmake_bool_vector (make_fixnum (128), Qnil))

#define CHECK_CATEGORY_SET(x) \
  CHECK_TYPE (CATEGORY_SET_P (x), Qcategorysetp, x)

/* Return the category set of character C in the current category table.  */
#define CATEGORY_SET(c) char_category_set (c)

/* Return true if CATEGORY_SET contains CATEGORY.
   Faster than '!NILP (Faref (category_set, make_fixnum (category)))'.  */
INLINE bool
CATEGORY_MEMBER (EMACS_INT category, Lisp_Object category_set)
{
  return bool_vector_bitref (category_set, category);
}

/* Return true if category set of CH contains CATEGORY.  */
INLINE bool
CHAR_HAS_CATEGORY (int ch, int category)
{
  Lisp_Object category_set = CATEGORY_SET (ch);
  return CATEGORY_MEMBER (category, category_set);
}

/* The standard category table is stored where it will automatically
   be used in all new buffers.  */
#define Vstandard_category_table BVAR_DEFAULT (category_table)

/* Return the doc string of CATEGORY in category table TABLE.  */
#define CATEGORY_DOCSTRING(table, category)				\
  AREF (Fchar_table_extra_slot (table, make_fixnum (0)), ((category) - ' '))

/* Set the doc string of CATEGORY to VALUE in category table TABLE.  */
#define SET_CATEGORY_DOCSTRING(table, category, value)			\
  ASET (Fchar_table_extra_slot (table, make_fixnum (0)), ((category) - ' '), value)

/* Return the version number of category table TABLE.  Not used for
   the moment.  */
#define CATEGORY_TABLE_VERSION (table) \
  Fchar_table_extra_slot (table, make_fixnum (1))

/* Return true if there is a word boundary between two
   word-constituent characters C1 and C2 if they appear in this order.
   There is no word boundary between two word-constituent ASCII and
   Latin-1 characters.  */
#define WORD_BOUNDARY_P(c1, c2)					\
  (!(SINGLE_BYTE_CHAR_P (c1) && SINGLE_BYTE_CHAR_P (c2))	\
   && word_boundary_p (c1, c2))

extern bool word_boundary_p (int, int);

INLINE_HEADER_END

#endif /* EMACS_CATEGORY_H */

debug log:

solving 85e872a940 ...
found 85e872a940 in https://yhetil.org/emacs/20201119153814.17541-6-sbaugh@catern.com/ ||
	https://yhetil.org/emacs/221b8fb4daac6da7bde9d609f4bf766ad2d5b1d6.1606009917.git.sbaugh@catern.com/ ||
	https://yhetil.org/emacs/20210509170933.27338-3-sbaugh@catern.com/
found cc32990478 in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 cc3299047845bca169b43edd53d0b3c7f269303d	src/category.h

applying [1/1] https://yhetil.org/emacs/20201119153814.17541-6-sbaugh@catern.com/
diff --git a/src/category.h b/src/category.h
index cc32990478..85e872a940 100644

Checking patch src/category.h...
Applied patch src/category.h cleanly.

skipping https://yhetil.org/emacs/221b8fb4daac6da7bde9d609f4bf766ad2d5b1d6.1606009917.git.sbaugh@catern.com/ for 85e872a940
skipping https://yhetil.org/emacs/20210509170933.27338-3-sbaugh@catern.com/ for 85e872a940
index at:
100644 85e872a9407db329d0958738cea8105671ad1206	src/category.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.