summaryrefslogtreecommitdiffstats
path: root/SOURCES/readline-5.2-conf.patch
blob: 448efe19bba0d2839dd31eae717055a30bfdb18c (plain)
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
Index: lib/readline/bind.c
===================================================================
--- lib/readline/bind.c.orig
+++ lib/readline/bind.c
@@ -751,6 +751,9 @@ rl_function_of_keyseq (keyseq, map, type
 /* The last key bindings file read. */
 static char *last_readline_init_file = (char *)NULL;
 
+/* Flag to read system init file */
+static int read_system_init_file = 0;
+
 /* The file we're currently reading key bindings from. */
 static const char *current_readline_init_file;
 static int current_readline_init_include_level;
@@ -816,11 +819,14 @@ rl_re_read_init_file (count, ignore)
   return r;
 }
 
+/* Forward declarations */
+static int sv_bell_style PARAMS((const char *));
+
 /* Do key bindings from a file.  If FILENAME is NULL it defaults
    to the first non-null filename from this list:
      1. the filename used for the previous call
      2. the value of the shell variable `INPUTRC'
-     3. ~/.inputrc
+     3. /etc/inputrc and ~/.inputrc
      4. /etc/inputrc
    If the file existed and could be opened and read, 0 is returned,
    otherwise errno is returned. */
@@ -832,16 +838,37 @@ rl_read_init_file (filename)
   if (filename == 0)
     filename = last_readline_init_file;
   if (filename == 0)
-    filename = sh_get_env_value ("INPUTRC");
+    {
+      filename = sh_get_env_value ("INPUTRC");
+      if (filename && !strncmp(SYS_INPUTRC, filename, strlen(SYS_INPUTRC)))
+	{
+	  struct stat st;
+	  char *default_inputrc = tilde_expand(DEFAULT_INPUTRC);
+
+	  if ((stat(default_inputrc, &st) == 0))
+	    {
+	      filename = DEFAULT_INPUTRC;
+	      read_system_init_file = 1;
+	    }
+	  else
+	    read_system_init_file = 0;
+
+	  free(default_inputrc);
+	}
+      else
+	read_system_init_file = 1;
+    }
   if (filename == 0 || *filename == 0)
     {
       filename = DEFAULT_INPUTRC;
-      /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */
-      if (_rl_read_init_file (filename, 0) == 0)
-	return 0;
-      filename = SYS_INPUTRC;
+      read_system_init_file = 1;
     }
 
+  sv_bell_style(sh_get_env_value("DEFAULT_BELL_STYLE"));
+
+  if (read_system_init_file)
+    _rl_read_init_file (SYS_INPUTRC, 1);
+
 #if defined (__MSDOS__)
   if (_rl_read_init_file (filename, 0) == 0)
     return 0;
@@ -1352,7 +1379,14 @@ rl_parse_and_bind (string)
 	  rl_macro_bind (seq, &funname[1], _rl_keymap);
 	}
       else
-	rl_bind_keyseq (seq, rl_named_function (funname));
+	{
+#if defined (PREFIX_META_HACK)
+	  if (_rl_stricmp (funname, "prefix-meta") == 0)
+	    rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap);
+	  else
+#endif
+	  rl_bind_keyseq (seq, rl_named_function (funname));
+	}
 
       xfree (seq);
       return 0;
@@ -1490,7 +1524,6 @@ typedef int _rl_sv_func_t PARAMS((const
 #define V_INT		2
 
 /* Forward declarations */
-static int sv_bell_style PARAMS((const char *));
 static int sv_combegin PARAMS((const char *));
 static int sv_dispprefix PARAMS((const char *));
 static int sv_compquery PARAMS((const char *));
Index: lib/readline/rlconf.h
===================================================================
--- lib/readline/rlconf.h.orig
+++ lib/readline/rlconf.h
@@ -33,7 +33,7 @@
 #define HANDLE_SIGNALS
 
 /* Ugly but working hack for binding prefix meta. */
-#define PREFIX_META_HACK
+#undef PREFIX_META_HACK
 
 /* The next-to-last-ditch effort file name for a user-specific init file. */
 #define DEFAULT_INPUTRC "~/.inputrc"
Index: lib/readline/doc/rluser.texi
===================================================================
--- lib/readline/doc/rluser.texi.orig
+++ lib/readline/doc/rluser.texi
@@ -347,7 +347,8 @@ file is taken from the value of the envi
 @end ifclear
 that variable is unset, the default is @file{~/.inputrc}.  If that
 file does not exist or cannot be read, the ultimate default is
-@file{/etc/inputrc}.
+@file{/etc/inputrc}. If both @file{~/.inputrc} and @file{/etc/inputrc}
+exist Readline will read first @file{/etc/inputrc} and then @file{~/.inputrc}.
 
 When a program which uses the Readline library starts up, the
 init file is read, and the key bindings are set.