aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-06-30 22:20:09 -0700
committerPaul Eggert2011-06-30 22:20:09 -0700
commitd0672f86c94e9dbf52e783e2bc4162b9cf3b5f44 (patch)
treee0e9fc7f479bce996d52c4356052480b3a088c56
parentb9444d97feca73cb2a90559241bc79584692da54 (diff)
parentbbc6b304672eb229e6750692a1b4e83277ded115 (diff)
downloademacs-d0672f86c94e9dbf52e783e2bc4162b9cf3b5f44.tar.gz
emacs-d0672f86c94e9dbf52e783e2bc4162b9cf3b5f44.zip
Merge from trunk.
-rw-r--r--lisp/ChangeLog27
-rw-r--r--lisp/emacs-lisp/find-func.el21
-rw-r--r--lisp/eshell/em-smart.el1
-rw-r--r--lisp/gnus/ChangeLog19
-rw-r--r--lisp/gnus/auth-source.el2
-rw-r--r--lisp/gnus/gnus-draft.el16
-rw-r--r--lisp/gnus/plstore.el107
-rw-r--r--lisp/progmodes/cfengine3.el331
-rw-r--r--lisp/window.el30
-rw-r--r--src/ChangeLog10
-rw-r--r--src/eval.c23
11 files changed, 518 insertions, 69 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 87de0957574..780ec1001ff 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12011-07-01 Paul Eggert <eggert@cs.ucla.edu> 12011-07-01 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Time-stamp simplifications and fixes.
4 These improve accuracy slightly, and future-proof the code
5 against some potential changes to current-time format.
6
3 * woman.el (woman-decode-buffer, WoMan-log-end): Log fractional secs 7 * woman.el (woman-decode-buffer, WoMan-log-end): Log fractional secs
4 by using time-since and float-time. 8 by using time-since and float-time.
5 9
@@ -25,6 +29,27 @@
25 * emacs-lisp/benchmark.el (benchmark-elapse): 29 * emacs-lisp/benchmark.el (benchmark-elapse):
26 * allout-widgets.el (allout-elapsed-time-seconds): Use float-time. 30 * allout-widgets.el (allout-elapsed-time-seconds): Use float-time.
27 31
322011-07-01 Stefan Monnier <monnier@iro.umontreal.ca>
33
34 * window.el (bury-buffer): Don't iconify the only frame.
35 (switch-to-buffer): Revert to Emacs<23 behavior, i.e. do not fallback
36 to pop-to-buffer. Use pop-to-buffer-same-frame if you don't like that.
37
382011-07-01 Chong Yidong <cyd@stupidchicken.com>
39
40 * eshell/em-smart.el (eshell-smart-display-navigate-list):
41 Add mouse-yank-primary.
42
432011-07-01 Teodor Zlatanov <tzz@lifelogs.com>
44
45 * progmodes/cfengine3.el: New file to support CFEngine 3.x.
46
472011-07-01 Stefan Monnier <monnier@iro.umontreal.ca>
48
49 * emacs-lisp/find-func.el (find-library--load-name): New fun.
50 (find-library-name): Use it to find relative load names when provided
51 absolute file name (bug#8803).
52
282011-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 532011-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
29 54
30 * textmodes/flyspell.el (flyspell-word): Consider words that 55 * textmodes/flyspell.el (flyspell-word): Consider words that
@@ -41,7 +66,7 @@
41 66
42 * progmodes/cc-guess.el: New file. 67 * progmodes/cc-guess.el: New file.
43 68
44 * progmodes/cc-langs.el (c-mode-menu): Added "Style..." submenu. 69 * progmodes/cc-langs.el (c-mode-menu): Add "Style..." submenu.
45 70
46 * progmodes/cc-styles.el (cc-choose-style-for-mode): New function 71 * progmodes/cc-styles.el (cc-choose-style-for-mode): New function
47 derived from `c-basic-common-init'. 72 derived from `c-basic-common-init'.
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 9c4a3e9832c..0194af2e3a8 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -141,6 +141,15 @@ See the functions `find-function' and `find-variable'."
141 (dolist (suffix (get-load-suffixes) (nreverse suffixes)) 141 (dolist (suffix (get-load-suffixes) (nreverse suffixes))
142 (unless (string-match "elc" suffix) (push suffix suffixes))))) 142 (unless (string-match "elc" suffix) (push suffix suffixes)))))
143 143
144(defun find-library--load-name (library)
145 (let ((name library))
146 (dolist (dir load-path)
147 (let ((rel (file-relative-name library dir)))
148 (if (and (not (string-match "\\`\\.\\./" rel))
149 (< (length rel) (length name)))
150 (setq name rel))))
151 (unless (equal name library) name)))
152
144(defun find-library-name (library) 153(defun find-library-name (library)
145 "Return the absolute file name of the Emacs Lisp source of LIBRARY. 154 "Return the absolute file name of the Emacs Lisp source of LIBRARY.
146LIBRARY should be a string (the name of the library)." 155LIBRARY should be a string (the name of the library)."
@@ -148,13 +157,23 @@ LIBRARY should be a string (the name of the library)."
148 ;; the same name. 157 ;; the same name.
149 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library) 158 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
150 (setq library (replace-match "" t t library))) 159 (setq library (replace-match "" t t library)))
151 (or 160 (or
152 (locate-file library 161 (locate-file library
153 (or find-function-source-path load-path) 162 (or find-function-source-path load-path)
154 (find-library-suffixes)) 163 (find-library-suffixes))
155 (locate-file library 164 (locate-file library
156 (or find-function-source-path load-path) 165 (or find-function-source-path load-path)
157 load-file-rep-suffixes) 166 load-file-rep-suffixes)
167 (when (file-name-absolute-p library)
168 (let ((rel (find-library--load-name library)))
169 (when rel
170 (or
171 (locate-file rel
172 (or find-function-source-path load-path)
173 (find-library-suffixes))
174 (locate-file rel
175 (or find-function-source-path load-path)
176 load-file-rep-suffixes)))))
158 (error "Can't find library %s" library))) 177 (error "Can't find library %s" library)))
159 178
160(defvar find-function-C-source-directory 179(defvar find-function-C-source-directory
diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el
index f08fec8f8fa..259072d9750 100644
--- a/lisp/eshell/em-smart.el
+++ b/lisp/eshell/em-smart.el
@@ -120,6 +120,7 @@ only if that output can be presented in its entirely in the Eshell window."
120(defcustom eshell-smart-display-navigate-list 120(defcustom eshell-smart-display-navigate-list
121 '(insert-parentheses 121 '(insert-parentheses
122 mouse-yank-at-click 122 mouse-yank-at-click
123 mouse-yank-primary
123 mouse-yank-secondary 124 mouse-yank-secondary
124 yank-pop 125 yank-pop
125 yank-rectangle 126 yank-rectangle
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 88ba910912e..7d1e7ed7198 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -3,7 +3,24 @@
3 * nntp.el (nntp-record-command): 3 * nntp.el (nntp-record-command):
4 * gnus-util.el (gnus-message-with-timestamp-1): 4 * gnus-util.el (gnus-message-with-timestamp-1):
5 Use format-time-string rather than decoding time stamps by hand. 5 Use format-time-string rather than decoding time stamps by hand.
6 This is simpler and insulates the code from changes to time formats. 6 This is simpler and insulates the code from potential changes to
7 current-time format.
8
92011-07-01 Katsumi Yamaoka <yamaoka@jpl.org>
10
11 * gnus-draft.el (gnus-draft-clear-marks): Mark deleted articles as read.
12
132011-07-01 Daiki Ueno <ueno@unixuser.org>
14
15 * plstore.el (plstore-select-keys, plstore-encrypt-to): New variable.
16 (plstore-save): Support public key encryption.
17 (plstore--init-from-buffer): New function.
18 (plstore-open): Use it; fix error when opening a non-existent file.
19 (plstore-revert): Use plstore--init-from-buffer.
20
212011-07-01 Daiki Ueno <ueno@unixuser.org>
22
23 * auth-source.el (auth-source-backend): Fix :initarg for data slot.
7 24
82011-06-30 Katsumi Yamaoka <yamaoka@jpl.org> 252011-06-30 Katsumi Yamaoka <yamaoka@jpl.org>
9 26
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 9391bf23d37..9d62d6a81c4 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -116,7 +116,7 @@ let-binding."
116 :type t 116 :type t
117 :custom string 117 :custom string
118 :documentation "The backend protocol.") 118 :documentation "The backend protocol.")
119 (data :initarg :arg 119 (data :initarg :data
120 :initform nil 120 :initform nil
121 :documentation "Internal backend data.") 121 :documentation "Internal backend data.")
122 (create-function :initarg :create-function 122 (create-function :initarg :create-function
diff --git a/lisp/gnus/gnus-draft.el b/lisp/gnus/gnus-draft.el
index 1709b1c4a05..a2a4cd3e07d 100644
--- a/lisp/gnus/gnus-draft.el
+++ b/lisp/gnus/gnus-draft.el
@@ -325,10 +325,18 @@ If DONT-POP is nil, display the buffer after setting it up."
325 (error "The draft %s is under edit" file))))) 325 (error "The draft %s is under edit" file)))))
326 326
327(defun gnus-draft-clear-marks () 327(defun gnus-draft-clear-marks ()
328 (setq gnus-newsgroup-reads nil 328 (setq gnus-newsgroup-marked nil
329 gnus-newsgroup-marked nil 329 gnus-newsgroup-unreads (gnus-uncompress-range
330 gnus-newsgroup-unreads 330 (gnus-active gnus-newsgroup-name)))
331 (gnus-uncompress-range (gnus-active gnus-newsgroup-name)))) 331 ;; Mark articles except for deleted ones as unread.
332 (let (rest)
333 (dolist (article gnus-newsgroup-reads)
334 (when (and (consp article)
335 (eq (cdr article) gnus-canceled-mark))
336 (push article rest)
337 (setq gnus-newsgroup-unreads
338 (delq (car article) gnus-newsgroup-unreads))))
339 (setq gnus-newsgroup-reads (nreverse rest))))
332 340
333(provide 'gnus-draft) 341(provide 'gnus-draft)
334 342
diff --git a/lisp/gnus/plstore.el b/lisp/gnus/plstore.el
index 392437d1dea..360388d002e 100644
--- a/lisp/gnus/plstore.el
+++ b/lisp/gnus/plstore.el
@@ -44,6 +44,40 @@
44 44
45(require 'epg) 45(require 'epg)
46 46
47(defgroup plstore nil
48 "Searchable, partially encrypted, persistent plist store"
49 :version "24.1"
50 :group 'files)
51
52(defcustom plstore-select-keys 'silent
53 "Control whether or not to pop up the key selection dialog.
54
55If t, always asks user to select recipients.
56If nil, query user only when `plstore-encrypt-to' is not set.
57If neither t nor nil, doesn't ask user. In this case, symmetric
58encryption is used."
59 :type '(choice (const :tag "Ask always" t)
60 (const :tag "Ask when recipients are not set" nil)
61 (const :tag "Don't ask" silent))
62 :group 'plstore)
63
64(defvar plstore-encrypt-to nil
65 "*Recipient(s) used for encrypting secret entries.
66May either be a string or a list of strings.")
67
68(put 'plstore-encrypt-to 'safe-local-variable
69 (lambda (val)
70 (or (stringp val)
71 (and (listp val)
72 (catch 'safe
73 (mapc (lambda (elt)
74 (unless (stringp elt)
75 (throw 'safe nil)))
76 val)
77 t)))))
78
79(put 'plstore-encrypt-to 'permanent-local t)
80
47(defvar plstore-cache-passphrase-for-symmetric-encryption nil) 81(defvar plstore-cache-passphrase-for-symmetric-encryption nil)
48(defvar plstore-passphrase-alist nil) 82(defvar plstore-passphrase-alist nil)
49 83
@@ -107,35 +141,39 @@
107(defun plstore-get-file (this) 141(defun plstore-get-file (this)
108 (buffer-file-name (plstore--get-buffer this))) 142 (buffer-file-name (plstore--get-buffer this)))
109 143
144(defun plstore--init-from-buffer (plstore)
145 (goto-char (point-min))
146 (when (looking-at ";;; public entries")
147 (forward-line)
148 (plstore--set-alist plstore (read (point-marker)))
149 (forward-sexp)
150 (forward-char)
151 (when (looking-at ";;; secret entries")
152 (forward-line)
153 (plstore--set-encrypted-data plstore (read (point-marker))))
154 (plstore--merge-secret plstore)))
155
110;;;###autoload 156;;;###autoload
111(defun plstore-open (file) 157(defun plstore-open (file)
112 "Create a plstore instance associated with FILE." 158 "Create a plstore instance associated with FILE."
113 (let ((store (vector 159 (with-current-buffer (find-file-noselect file)
114 (find-file-noselect file) 160 ;; make the buffer invisible from user
115 nil ;plist (plist) 161 (rename-buffer (format " plstore %s" (buffer-file-name)))
116 nil ;encrypted data (string) 162 (let ((store (vector
117 nil ;secret plist (plist) 163 (current-buffer)
118 nil ;merged plist (plist) 164 nil ;plist (plist)
119 ))) 165 nil ;encrypted data (string)
120 (plstore-revert store) 166 nil ;secret plist (plist)
121 store)) 167 nil ;merged plist (plist)
168 )))
169 (plstore--init-from-buffer store)
170 store)))
122 171
123(defun plstore-revert (plstore) 172(defun plstore-revert (plstore)
124 "Replace current data in PLSTORE with the file on disk." 173 "Replace current data in PLSTORE with the file on disk."
125 (with-current-buffer (plstore--get-buffer plstore) 174 (with-current-buffer (plstore--get-buffer plstore)
126 (revert-buffer t t) 175 (revert-buffer t t)
127 ;; make the buffer invisible from user 176 (plstore--init-from-buffer plstore)))
128 (rename-buffer (format " plstore %s" (buffer-file-name)))
129 (goto-char (point-min))
130 (when (looking-at ";;; public entries\n")
131 (forward-line)
132 (plstore--set-alist plstore (read (point-marker)))
133 (forward-sexp)
134 (forward-char)
135 (when (looking-at ";;; secret entries\n")
136 (forward-line)
137 (plstore--set-encrypted-data plstore (read (point-marker))))
138 (plstore--merge-secret plstore))))
139 177
140(defun plstore-close (plstore) 178(defun plstore-close (plstore)
141 "Destroy a plstore instance PLSTORE." 179 "Destroy a plstore instance PLSTORE."
@@ -304,20 +342,37 @@ SECRET-KEYS is a plist containing secret data."
304 "Save the contents of PLSTORE associated with a FILE." 342 "Save the contents of PLSTORE associated with a FILE."
305 (with-current-buffer (plstore--get-buffer plstore) 343 (with-current-buffer (plstore--get-buffer plstore)
306 (erase-buffer) 344 (erase-buffer)
307 (insert ";;; public entries\n" (pp-to-string (plstore--get-alist plstore))) 345 (insert ";;; public entries -*- mode: emacs-lisp -*- \n"
346 (pp-to-string (plstore--get-alist plstore)))
308 (if (plstore--get-secret-alist plstore) 347 (if (plstore--get-secret-alist plstore)
309 (let ((context (epg-make-context 'OpenPGP)) 348 (let ((context (epg-make-context 'OpenPGP))
310 (pp-escape-newlines nil) 349 (pp-escape-newlines nil)
350 (recipients
351 (cond
352 ((listp plstore-encrypt-to) plstore-encrypt-to)
353 ((stringp plstore-encrypt-to) (list plstore-encrypt-to))))
311 cipher) 354 cipher)
312 (epg-context-set-armor context t) 355 (epg-context-set-armor context t)
313 (epg-context-set-passphrase-callback 356 (epg-context-set-passphrase-callback
314 context 357 context
315 (cons #'plstore-passphrase-callback-function 358 (cons #'plstore-passphrase-callback-function
316 plstore)) 359 plstore))
317 (setq cipher (epg-encrypt-string context 360 (setq cipher (epg-encrypt-string
318 (pp-to-string 361 context
319 (plstore--get-secret-alist plstore)) 362 (pp-to-string
320 nil)) 363 (plstore--get-secret-alist plstore))
364 (if (or (eq plstore-select-keys t)
365 (and (null plstore-select-keys)
366 (not (local-variable-p 'plstore-encrypt-to
367 (current-buffer)))))
368 (epa-select-keys
369 context
370 "Select recipents for encryption.
371If no one is selected, symmetric encryption will be performed. "
372 recipients)
373 (if plstore-encrypt-to
374 (epg-list-keys context recipients)))))
375 (goto-char (point-max))
321 (insert ";;; secret entries\n" (pp-to-string cipher)))) 376 (insert ";;; secret entries\n" (pp-to-string cipher))))
322 (save-buffer))) 377 (save-buffer)))
323 378
diff --git a/lisp/progmodes/cfengine3.el b/lisp/progmodes/cfengine3.el
new file mode 100644
index 00000000000..68a4286657c
--- /dev/null
+++ b/lisp/progmodes/cfengine3.el
@@ -0,0 +1,331 @@
1;;; cfengine3.el --- mode for editing Cfengine 3 files
2
3;; Copyright (C) 2001-2011 Free Software Foundation, Inc.
4
5;; Author: Ted Zlatanov <tzz@lifelogs.com>
6;; Keywords: languages
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; Supports only cfengine 3, unlike the older cfengine.el which
26;; supports 1.x and 2.x.
27
28;; Possible customization for auto-mode selection:
29
30;; (push '(("^cfagent.conf\\'" . cfengine3-mode)) auto-mode-alist)
31;; (push '(("^cf\\." . cfengine3-mode)) auto-mode-alist)
32;; (push '(("\\.cf\\'" . cfengine3-mode)) auto-mode-alist)
33
34;;; Code:
35
36(defgroup cfengine3 ()
37 "Editing CFEngine 3 files."
38 :group 'languages)
39
40(defcustom cfengine3-indent 2
41 "*Size of a CFEngine 3 indentation step in columns."
42 :group 'cfengine3
43 :type 'integer)
44
45(eval-and-compile
46 (defconst cfengine3-defuns
47 (mapcar
48 'symbol-name
49 '(bundle body))
50 "List of the CFEngine 3.x defun headings.")
51
52 (defconst cfengine3-defuns-regex
53 (regexp-opt cfengine3-defuns t)
54 "Regex to match the CFEngine 3.x defuns.")
55
56 (defconst cfengine3-class-selector-regex "\\([[:alnum:]_().&|!]+\\)::")
57
58 (defconst cfengine3-category-regex "\\([[:alnum:]_]+\\):")
59
60 (defconst cfengine3-vartypes
61 (mapcar
62 'symbol-name
63 '(string int real slist ilist rlist irange rrange counter))
64 "List of the CFEngine 3.x variable types."))
65
66(defvar cfengine3-font-lock-keywords
67 `(
68 (,(concat "^[ \t]*" cfengine3-class-selector-regex)
69 1 font-lock-keyword-face)
70 (,(concat "^[ \t]*" cfengine3-category-regex)
71 1 font-lock-builtin-face)
72 ;; Variables, including scope, e.g. module.var
73 ("[@$](\\([[:alnum:]_.]+\\))" 1 font-lock-variable-name-face)
74 ("[@$]{\\([[:alnum:]_.]+\\)}" 1 font-lock-variable-name-face)
75 ;; Variable definitions.
76 ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
77
78 ;; CFEngine 3.x faces
79 ;; defuns
80 (,(concat "\\<" cfengine3-defuns-regex "\\>"
81 "[ \t]+\\<\\([[:alnum:]_]+\\)\\>"
82 "[ \t]+\\<\\([[:alnum:]_]+\\)\\((\\([^)]*\\))\\)?")
83 (1 font-lock-builtin-face)
84 (2 font-lock-constant-name-face)
85 (3 font-lock-function-name-face)
86 (5 font-lock-variable-name-face))
87 ;; variable types
88 (,(concat "\\<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\>")
89 1 font-lock-type-face)))
90
91(defun cfengine3-beginning-of-defun ()
92 "`beginning-of-defun' function for Cfengine 3 mode.
93Treats body/bundle blocks as defuns."
94 (unless (<= (current-column) (current-indentation))
95 (end-of-line))
96 (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
97 (beginning-of-line)
98 (goto-char (point-min)))
99 t)
100
101(defun cfengine3-end-of-defun ()
102 "`end-of-defun' function for Cfengine 3 mode.
103Treats body/bundle blocks as defuns."
104 (end-of-line)
105 (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
106 (beginning-of-line)
107 (goto-char (point-max)))
108 t)
109
110(defun cfengine3-indent-line ()
111 "Indent a line in Cfengine mode.
112Intended as the value of `indent-line-function'."
113 (let ((pos (- (point-max) (point)))
114 parse)
115 (save-restriction
116 (narrow-to-defun)
117 (back-to-indentation)
118 (setq parse (parse-partial-sexp (point-min) (point)))
119 (message "%S" parse)
120 (cond
121 ;; body/bundle blocks start at 0
122 ((looking-at (concat cfengine3-defuns-regex "\\>"))
123 (indent-line-to 0))
124 ;; categories are indented one step
125 ((looking-at (concat cfengine3-category-regex "[ \t]*$"))
126 (indent-line-to cfengine3-indent))
127 ;; class selectors are indented two steps
128 ((looking-at (concat cfengine3-class-selector-regex "[ \t]*$"))
129 (indent-line-to (* 2 cfengine3-indent)))
130 ;; Outdent leading close brackets one step.
131 ((or (eq ?\} (char-after))
132 (eq ?\) (char-after)))
133 (condition-case ()
134 (indent-line-to (save-excursion
135 (forward-char)
136 (backward-sexp)
137 (current-column)))
138 (error nil)))
139 ;; inside a string and it starts before this line
140 ((and (nth 3 parse)
141 (< (nth 8 parse) (save-excursion (beginning-of-line) (point))))
142 (indent-line-to 0))
143 ;; inside a defun, but not a nested list (depth is 1)
144 ((= 1 (nth 0 parse))
145 (indent-line-to (* (+ 2 (nth 0 parse)) cfengine3-indent)))
146 ;; Inside brackets/parens: indent to start column of non-comment
147 ;; token on line following open bracket or by one step from open
148 ;; bracket's column.
149 ((condition-case ()
150 (progn (indent-line-to (save-excursion
151 (backward-up-list)
152 (forward-char)
153 (skip-chars-forward " \t")
154 (cond
155 ((looking-at "[^\n#]")
156 (current-column))
157 ((looking-at "[^\n#]")
158 (current-column))
159 (t
160 (skip-chars-backward " \t")
161 (+ (current-column) -1
162 cfengine3-indent)))))
163 t)
164 (error nil)))
165 ;; Else don't indent.
166 (t (indent-line-to 0))))
167 ;; If initial point was within line's indentation,
168 ;; position after the indentation. Else stay at same point in text.
169 (if (> (- (point-max) pos) (point))
170 (goto-char (- (point-max) pos)))))
171
172;; (defvar cfengine3-smie-grammar
173;; (smie-prec2->grammar
174;; (smie-merge-prec2s
175;; (smie-bnf->prec2
176;; '((token)
177;; (decls (decls "body" decls)
178;; (decls "bundle" decls))
179;; (insts (token ":" insts)))
180;; '((assoc "body" "bundle")))
181;; (smie-precs->prec2
182;; '((right ":")
183;; (right "::")
184;; (assoc ";")
185;; (assoc ",")
186;; (right "=>"))))))
187
188;; (defun cfengine3-smie-rules (kind token)
189;; (pcase (cons kind token)
190;; (`(:elem . basic) 2)
191;; (`(:list-intro . ,(or `"body" `"bundle")) t)
192;; (`(:after . ":") 2)
193;; (`(:after . "::") 2)))
194
195;; (defun cfengine3-show-all-tokens ()
196;; (interactive)
197;; (goto-char (point-min))
198;; (while (not (eobp))
199;; (let* ((p (point))
200;; (token (funcall smie-forward-token-function)))
201;; (delete-region p (point))
202;; (insert-before-markers token)
203;; (forward-char))))
204
205;; (defun cfengine3-line-classes ()
206;; (interactive)
207;; (save-excursion
208;; (beginning-of-line)
209;; (let* ((todo (buffer-substring (point)
210;; (save-excursion (end-of-line) (point))))
211;; (original (concat (loop for c across todo
212;; collect (char-syntax c)))))
213;; (format "%s\n%s" original todo))))
214
215;; (defun cfengine3-show-all-classes ()
216;; (interactive)
217;; (goto-char (point-min))
218;; (while (not (eobp))
219;; (let ((repl (cfengine3-line-classes)))
220;; (kill-line)
221;; (insert repl)
222;; (insert "\n"))))
223
224;; specification: blocks
225;; blocks: block | blocks block;
226;; block: bundle typeid blockid bundlebody
227;; | bundle typeid blockid usearglist bundlebody
228;; | body typeid blockid bodybody
229;; | body typeid blockid usearglist bodybody;
230
231;; typeid: id
232;; blockid: id
233;; usearglist: '(' aitems ')';
234;; aitems: aitem | aitem ',' aitems |;
235;; aitem: id
236
237;; bundlebody: '{' statements '}'
238;; statements: statement | statements statement;
239;; statement: category | classpromises;
240
241;; bodybody: '{' bodyattribs '}'
242;; bodyattribs: bodyattrib | bodyattribs bodyattrib;
243;; bodyattrib: class | selections;
244;; selections: selection | selections selection;
245;; selection: id ASSIGN rval ';' ;
246
247;; classpromises: classpromise | classpromises classpromise;
248;; classpromise: class | promises;
249;; promises: promise | promises promise;
250;; category: CATEGORY
251;; promise: promiser ARROW rval constraints ';' | promiser constraints ';';
252;; constraints: constraint | constraints ',' constraint |;
253;; constraint: id ASSIGN rval;
254;; class: CLASS
255;; id: ID
256;; rval: ID | QSTRING | NAKEDVAR | list | usefunction
257;; list: '{' litems '}' ;
258;; litems: litem | litem ',' litems |;
259;; litem: ID | QSTRING | NAKEDVAR | list | usefunction
260
261;; functionid: ID | NAKEDVAR
262;; promiser: QSTRING
263;; usefunction: functionid givearglist
264;; givearglist: '(' gaitems ')'
265;; gaitems: gaitem | gaitems ',' gaitem |;
266;; gaitem: ID | QSTRING | NAKEDVAR | list | usefunction
267
268;; # from lexer:
269
270;; bundle: "bundle"
271;; body: "body"
272;; COMMENT #[^\n]*
273;; NAKEDVAR [$@][(][a-zA-Z0-9_\200-\377.]+[)]|[$@][{][a-zA-Z0-9_\200-\377.]+[}]
274;; ID: [a-zA-Z0-9_\200-\377]+
275;; ASSIGN: "=>"
276;; ARROW: "->"
277;; QSTRING: \"((\\\")|[^"])*\"|\'((\\\')|[^'])*\'|`[^`]*`
278;; CLASS: [.|&!()a-zA-Z0-9_\200-\377]+::
279;; CATEGORY: [a-zA-Z_]+:
280
281;;;###autoload
282(define-derived-mode cfengine3-mode prog-mode "CFEngine3"
283 "Major mode for editing cfengine input.
284There are no special keybindings by default.
285
286Action blocks are treated as defuns, i.e. \\[beginning-of-defun] moves
287to the action header."
288 (modify-syntax-entry ?# "<" cfengine3-mode-syntax-table)
289 (modify-syntax-entry ?\n ">#" cfengine3-mode-syntax-table)
290 (modify-syntax-entry ?\" "\"" cfengine3-mode-syntax-table)
291 ;; variable substitution:
292 (modify-syntax-entry ?$ "." cfengine3-mode-syntax-table)
293 ;; Doze path separators:
294 (modify-syntax-entry ?\\ "." cfengine3-mode-syntax-table)
295 ;; Otherwise, syntax defaults seem OK to give reasonable word
296 ;; movement.
297
298 ;; (smie-setup cfengine3-smie-grammar #'cfengine3-smie-rules)
299 ;; ;; :forward-token #'cfengine3-smie-forward-token
300 ;; ;; :backward-token #'cfengine3-smie-backward-token)
301 ;; (set (make-local-variable 'smie-indent-basic) 'cfengine3-indent)
302
303 (set (make-local-variable 'parens-require-spaces) nil)
304 (set (make-local-variable 'comment-start) "# ")
305 (set (make-local-variable 'comment-start-skip)
306 "\\(\\(?:^\\|[^\\\\\n]\\)\\(?:\\\\\\\\\\)*\\)#+[ \t]*")
307 (set (make-local-variable 'indent-line-function) #'cfengine3-indent-line)
308 (setq font-lock-defaults
309 '(cfengine3-font-lock-keywords nil nil nil beginning-of-defun))
310 ;; Fixme: set the args of functions in evaluated classes to string
311 ;; syntax, and then obey syntax properties.
312 (set (make-local-variable 'syntax-propertize-function)
313 ;; In the main syntax-table, \ is marked as a punctuation, because
314 ;; of its use in DOS-style directory separators. Here we try to
315 ;; recognize the cases where \ is used as an escape inside strings.
316 (syntax-propertize-rules ("\\(\\(?:\\\\\\)+\\)\"" (1 "\\"))))
317
318 ;; use defuns as the essential syntax block
319 (set (make-local-variable 'beginning-of-defun-function)
320 #'cfengine3-beginning-of-defun)
321 (set (make-local-variable 'end-of-defun-function)
322 #'cfengine3-end-of-defun)
323
324 ;; Like Lisp mode. Without this, we lose with, say,
325 ;; `backward-up-list' when there's an unbalanced quote in a
326 ;; preceding comment.
327 (set (make-local-variable 'parse-sexp-ignore-comments) t))
328
329(provide 'cfengine3)
330
331;;; cfengine3.el ends here
diff --git a/lisp/window.el b/lisp/window.el
index 15e603bc6c9..49698ff8bb7 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2802,7 +2802,9 @@ displayed there."
2802 ((or buffer-or-name (not (eq buffer (window-buffer))))) 2802 ((or buffer-or-name (not (eq buffer (window-buffer)))))
2803 ((not (window-dedicated-p)) 2803 ((not (window-dedicated-p))
2804 (switch-to-prev-buffer nil 'bury)) 2804 (switch-to-prev-buffer nil 'bury))
2805 ((frame-root-window-p (selected-window)) 2805 ((and (frame-root-window-p (selected-window))
2806 ;; Don't iconify if it's the only frame.
2807 (not (eq (next-frame nil 0) (selected-frame))))
2806 (iconify-frame (window-frame (selected-window)))) 2808 (iconify-frame (window-frame (selected-window))))
2807 ((window-deletable-p) 2809 ((window-deletable-p)
2808 (delete-window))) 2810 (delete-window)))
@@ -5944,20 +5946,18 @@ functions should call `pop-to-buffer-same-window' instead."
5944 (interactive 5946 (interactive
5945 (list (read-buffer-to-switch "Switch to buffer: "))) 5947 (list (read-buffer-to-switch "Switch to buffer: ")))
5946 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) 5948 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
5947 (if (and (or (window-minibuffer-p) (eq (window-dedicated-p) t)) 5949 (cond
5948 (not (eq buffer (window-buffer)))) 5950 ;; Don't call set-window-buffer if it's not needed since it
5949 ;; Cannot switch to another buffer in a minibuffer or strongly 5951 ;; might signal an error (e.g. if the window is dedicated).
5950 ;; dedicated window that does not show the buffer already. Call 5952 ((eq buffer (window-buffer)) nil)
5951 ;; `pop-to-buffer' instead. 5953 ((window-minibuffer-p)
5952 (pop-to-buffer buffer 'same-window norecord) 5954 (error "Cannot switch buffers in minibuffer window"))
5953 (unless (eq buffer (window-buffer)) 5955 ((eq (window-dedicated-p) t)
5954 ;; I'm not sure why we should NOT call `set-window-buffer' here, 5956 (error "Cannot switch buffers in a dedicated window"))
5955 ;; but let's keep things as they are (otherwise we could always 5957 (t (set-window-buffer nil buffer)))
5956 ;; call `pop-to-buffer-same-window' here). 5958 (unless norecord
5957 (set-window-buffer nil buffer)) 5959 (select-window (selected-window)))
5958 (unless norecord 5960 (set-buffer buffer)))
5959 (select-window (selected-window)))
5960 (set-buffer buffer))))
5961 5961
5962(defun switch-to-buffer-same-frame (buffer-or-name &optional norecord) 5962(defun switch-to-buffer-same-frame (buffer-or-name &optional norecord)
5963 "Switch to buffer BUFFER-OR-NAME in a window on the selected frame. 5963 "Switch to buffer BUFFER-OR-NAME in a window on the selected frame.
diff --git a/src/ChangeLog b/src/ChangeLog
index dc51a2633ac..85cf1d2a255 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12011-07-01 Paul Eggert <eggert@cs.ucla.edu>
2
3 * eval.c (struct backtrace): Simplify and port the data structure.
4 Do not assume that "int nargs : BITS_PER_INT - 2;" produces a
5 signed bit field, as this assumption is not portable and it makes
6 Emacs crash when compiled with Sun C 5.8 on sparc. Do not use
7 "char debug_on_exit : 1" as this is not portable either; instead,
8 use the portable "unsigned int debug_on_exit : 1". Remove unused
9 member evalargs. Remove obsolete comments about cc bombing out.
10
12011-06-30 Jan Djärv <jan.h.d@swipnet.se> 112011-06-30 Jan Djärv <jan.h.d@swipnet.se>
2 12
3 * xsettings.c: Include glib-object.h, gio/gio.h if HAVE_GSETTINGS. 13 * xsettings.c: Include glib-object.h, gio/gio.h if HAVE_GSETTINGS.
diff --git a/src/eval.c b/src/eval.c
index 6ca8eacb100..cb8b4f3ea07 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -32,25 +32,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include "xterm.h" 32#include "xterm.h"
33#endif 33#endif
34 34
35/* This definition is duplicated in alloc.c and keyboard.c. */
36/* Putting it in lisp.h makes cc bomb out! */
37
38struct backtrace 35struct backtrace
39{ 36{
40 struct backtrace *next; 37 struct backtrace *next;
41 Lisp_Object *function; 38 Lisp_Object *function;
42 Lisp_Object *args; /* Points to vector of args. */ 39 Lisp_Object *args; /* Points to vector of args. */
43#define NARGS_BITS (BITS_PER_INT - 2) 40 ptrdiff_t nargs; /* Length of vector. */
44 /* Let's not use size_t because we want to allow negative values (for
45 UNEVALLED). Also let's steal 2 bits so we save a word (or more for
46 alignment). In any case I doubt Emacs would survive a function call with
47 more than 500M arguments. */
48 int nargs : NARGS_BITS; /* Length of vector.
49 If nargs is UNEVALLED, args points
50 to slot holding list of unevalled args. */
51 char evalargs : 1;
52 /* Nonzero means call value of debugger when done with this operation. */ 41 /* Nonzero means call value of debugger when done with this operation. */
53 char debug_on_exit : 1; 42 unsigned int debug_on_exit : 1;
54}; 43};
55 44
56static struct backtrace *backtrace_list; 45static struct backtrace *backtrace_list;
@@ -2291,7 +2280,6 @@ eval_sub (Lisp_Object form)
2291 backtrace.function = &original_fun; /* This also protects them from gc. */ 2280 backtrace.function = &original_fun; /* This also protects them from gc. */
2292 backtrace.args = &original_args; 2281 backtrace.args = &original_args;
2293 backtrace.nargs = UNEVALLED; 2282 backtrace.nargs = UNEVALLED;
2294 backtrace.evalargs = 1;
2295 backtrace.debug_on_exit = 0; 2283 backtrace.debug_on_exit = 0;
2296 2284
2297 if (debug_on_next_call) 2285 if (debug_on_next_call)
@@ -2325,10 +2313,7 @@ eval_sub (Lisp_Object form)
2325 xsignal2 (Qwrong_number_of_arguments, original_fun, numargs); 2313 xsignal2 (Qwrong_number_of_arguments, original_fun, numargs);
2326 2314
2327 else if (XSUBR (fun)->max_args == UNEVALLED) 2315 else if (XSUBR (fun)->max_args == UNEVALLED)
2328 { 2316 val = (XSUBR (fun)->function.aUNEVALLED) (args_left);
2329 backtrace.evalargs = 0;
2330 val = (XSUBR (fun)->function.aUNEVALLED) (args_left);
2331 }
2332 else if (XSUBR (fun)->max_args == MANY) 2317 else if (XSUBR (fun)->max_args == MANY)
2333 { 2318 {
2334 /* Pass a vector of evaluated arguments. */ 2319 /* Pass a vector of evaluated arguments. */
@@ -2984,7 +2969,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2984 backtrace.function = &args[0]; 2969 backtrace.function = &args[0];
2985 backtrace.args = &args[1]; 2970 backtrace.args = &args[1];
2986 backtrace.nargs = nargs - 1; 2971 backtrace.nargs = nargs - 1;
2987 backtrace.evalargs = 0;
2988 backtrace.debug_on_exit = 0; 2972 backtrace.debug_on_exit = 0;
2989 2973
2990 if (debug_on_next_call) 2974 if (debug_on_next_call)
@@ -3141,7 +3125,6 @@ apply_lambda (Lisp_Object fun, Lisp_Object args)
3141 3125
3142 backtrace_list->args = arg_vector; 3126 backtrace_list->args = arg_vector;
3143 backtrace_list->nargs = i; 3127 backtrace_list->nargs = i;
3144 backtrace_list->evalargs = 0;
3145 tem = funcall_lambda (fun, numargs, arg_vector); 3128 tem = funcall_lambda (fun, numargs, arg_vector);
3146 3129
3147 /* Do the debug-on-exit now, while arg_vector still exists. */ 3130 /* Do the debug-on-exit now, while arg_vector still exists. */