bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24603: [PATCHv5 07/11] Introduce ‘buffer-language’ buffer-locar vari


From: Michal Nazarewicz
Subject: bug#24603: [PATCHv5 07/11] Introduce ‘buffer-language’ buffer-locar variable
Date: Thu, 9 Mar 2017 22:51:46 +0100

At the time unused, ‘buffer-language’ variable denotes the language
buffer is in.

* src/buffer.h (struct buffer): New ‘buffer-language’ buffer-local
variable.
* lisp/international/mule-cmds.el (set-locale-environment): Set
‘buffer-language’ on locale change.
---
 lisp/international/mule-cmds.el | 8 ++++++--
 src/buffer.c                    | 8 ++++++++
 src/buffer.h                    | 8 ++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index bdba8eeb112..d883e8c2298 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2601,7 +2601,7 @@ set-locale-environment
        (setq system-messages-locale locale)
        (setq system-time-locale locale))
 
-      (if (string-match "^[a-z][a-z]" locale)
+      (when (string-match "^[a-z][a-z]" locale)
           ;; The value of 'current-iso639-language' is matched against
           ;; the ':lang' property of font-spec objects when selecting
           ;; and prioritizing available fonts for displaying
@@ -2613,7 +2613,11 @@ set-locale-environment
                 ;; match mentioned above uses memq, and ':lang'
                 ;; properties have lower-case values, the letter-case
                 ;; must match exactly.
-                (intern (downcase (match-string 0 locale))))))
+                (intern (downcase (match-string 0 locale))))
+
+          ;; ‘buffer-language’ is used to identify language buffer is in for 
the
+          ;; purpose of performing language-specific operations.
+          (setq-default buffer-language locale)))
 
     (setq woman-locale
           (or system-messages-locale
diff --git a/src/buffer.c b/src/buffer.c
index c00cc40d6f2..7a56ace20d9 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -934,6 +934,7 @@ reset_buffer (register struct buffer *b)
   bset_display_time (b, Qnil);
   bset_enable_multibyte_characters
     (b, BVAR (&buffer_defaults, enable_multibyte_characters));
+  bset_language (b, BVAR (&buffer_defaults, language));
   bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
   bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
 
@@ -5113,6 +5114,7 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, scroll_up_aggressively), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, scroll_down_aggressively), idx); 
++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx;
+  XSETFASTINT (BVAR (&buffer_local_flags, language), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), 
idx); ++idx;
@@ -5175,6 +5177,7 @@ init_buffer_once (void)
   bset_ctl_arrow (&buffer_defaults, Qt);
   bset_bidi_display_reordering (&buffer_defaults, Qt);
   bset_bidi_paragraph_direction (&buffer_defaults, Qnil);
+  bset_language (&buffer_defaults, Qnil);
   bset_cursor_type (&buffer_defaults, Qt);
   bset_extra_line_spacing (&buffer_defaults, Qnil);
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
@@ -6096,6 +6099,11 @@ and disregard a `read-only' text property if the 
property value
 is a member of the list.  */);
   Vinhibit_read_only = Qnil;
 
+  DEFVAR_PER_BUFFER ("buffer-language", &BVAR (current_buffer, language), Qnil,
+                    doc: /* A locale string describing what natural language 
text in the buffer is in.
+Nil indicates the buffer does not have natural language text or the language
+is not specified.  */);
+
   DEFVAR_PER_BUFFER ("cursor-type", &BVAR (current_buffer, cursor_type), Qnil,
                     doc: /* Cursor to use when this buffer is in the selected 
window.
 Values are interpreted as follows:
diff --git a/src/buffer.h b/src/buffer.h
index a2bdc4e7294..d86bca888a9 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -735,6 +735,9 @@ struct buffer
      window.  Nil means that scrolling method isn't used.  */
   Lisp_Object scroll_down_aggressively_;
 
+  /* A locale string describing what (natural) language current buffer is in. 
*/
+  Lisp_Object language_;
+
   /* Desired cursor type in this buffer.  See the doc string of
      per-buffer variable `cursor-type'.  */
   Lisp_Object cursor_type_;
@@ -994,6 +997,11 @@ bset_undo_list (struct buffer *b, Lisp_Object val)
   b->undo_list_ = val;
 }
 INLINE void
+bset_language (struct buffer *b, Lisp_Object val)
+{
+  b->language_ = val;
+}
+INLINE void
 bset_upcase_table (struct buffer *b, Lisp_Object val)
 {
   b->upcase_table_ = val;
-- 
2.12.0.246.ga2ecc84866-goog






reply via email to

[Prev in Thread] Current Thread [Next in Thread]