source: trunk/source/cocoa-ide/hemlock/src/package.lisp @ 15536

Last change on this file since 15536 was 15536, checked in by gb, 7 years ago

Support using the "coding" option in a file's file options line (a
line at the start of a text file that contains name:value pairs
separated by semicolons bracketed by -*- sequences) to determine a
file's character encoding. Specifically:

  • OPEN now allows an external-format of :INFERRED; previously, this was shorthand for an external-format whose line-termination was inferred and whose character encoding was based on *DEFAULT-FILE-CHARACTER-ENCODING*. When an input file whose external-format is specified as :INFERRED is opened, its file options are parsed and the value of the "coding" option is used if such an option is found (and if the value is something that CCL supports.) If a supported "coding" option isn't found, *DEFAULT-FILE-CHARACTER-ENCODING* is used as before.
  • In the Cocoa IDE, the Hemlock command "Ensure File Options Line" (bound to Control-Meta-M by default) ensures that the first line in the current buffer is a file options line and fills in some plausible values for the "Mode", "Package", and "Coding" options. The "Process File Options" command (Control-Meta-m) can be used to process the file options line after it's been edited. (The file options line is always processed when the file is first opened; changes to the "coding" option affect how the file will be saved.)

When a Lisp source file is opened in the IDE editor, the following
character encodings are tried in this order until one of them
succeeds:

  • if the "Open ..." panel was used to open the file and an encoding other than "Automatic" - which is now the default - is selected, that encoding is tried.
  • if a "coding" option is found, that encoding is tried.
  • the value of *DEFAULT-FILE-CHARACTER-ENCODING* is tried.
  • iso-8859-1 is tried. All files can be decoded in iso-8859-1.

This is all supposed to be what Emacs does and I think that it's
pretty close in practice.

A file that caused problems for Paul Krueger a few days ago
because its encoding (ISO-8859-1) wasn't guessed correctly
now has an explicit "coding" option and serves as a test case.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.1 KB
Line 
1(in-package :cl-user)
2
3(defpackage :hemlock-interface
4  (:use)
5  (:export
6   ;; Symbols from the CIM, by chapter:
7
8   ;; Representation of Text
9   #:linep
10   #:line-string
11   #:line-previous
12   #:line-next
13   #:line-buffer
14   #:line-length
15   #:line-character
16   #:line-plist
17   #:line-signature
18   #:markp
19   #:mark-line
20   #:mark-charpos
21   #:mark-kind
22   #:mark-buffer
23   #:mark-absolute-position
24   #:previous-character
25   #:next-character
26   #:mark
27   #:copy-mark
28   #:delete-mark
29   #:with-mark
30   #:move-to-position
31   #:move-to-absolute-position
32   #:move-mark
33   #:line-start
34   #:line-end
35   #:buffer-start
36   #:buffer-end
37   #:mark-before
38   #:mark-after
39   #:character-offset
40   #:line-offset
41   #:region
42   #:regionp
43   #:make-empty-region
44   #:copy-region
45   #:region-to-string
46   #:string-to-region
47   #:line-to-region
48   #:region-start
49   #:region-end
50   #:region-bounds
51   #:set-region-bounds
52   #:count-lines
53   #:count-characters
54
55   ;; charprops
56   #:next-charprop-value
57   #:previous-charprop-value
58   #:set-charprop-value
59   #:find-charprop-value
60   #:next-charprops
61   #:previous-charprops
62   #:set-charprops
63   #:charprops-in-region
64   #:apply-charprops
65   #:find-charprops
66   #:find-charprops-change
67   #:charprop-equal
68   #:charprops-get
69   #:charprops-set
70   #:charprops-equal
71   #:charprops-as-plist
72   #:charprops-as-hash
73   #:charprops-names
74   #:set-buffer-charprops
75   #:buffer-charprops
76
77   ;; Buffers
78   #:current-buffer
79   #:current-point-for-insertion
80   #:current-point-for-deletion
81   #:current-point-unless-selection
82   #:current-point-collapsing-selection
83   #:current-point-extending-selection
84   #:current-point-for-selection-start
85   #:current-point-for-selection-end
86   #:current-point
87   #:current-mark
88   #:pop-buffer-mark
89   #:push-buffer-mark
90   #:push-new-buffer-mark
91   #:all-buffers
92   #:make-buffer
93   #:bufferp
94   #:buffer-name
95   #:buffer-region
96   #:buffer-pathname
97   #:buffer-write-date
98   #:buffer-point
99   #:buffer-mark
100   #:buffer-start-mark
101   #:buffer-end-mark
102   #:buffer-writable
103   #:buffer-modified
104   #:buffer-signature
105   #:buffer-variables
106   #:buffer-modes
107   #:buffer-delete-hook
108   #:buffer-package
109   #:buffer-plist
110   #:delete-buffer
111   #:with-writable-buffer
112   #:make-modeline-field
113   #:modeline-field-p
114   #:modeline-field-name
115   #:modeline-field
116   #:modeline-field-function
117   #:modeline-field-width
118   #:buffer-modeline-fields
119   #:buffer-modeline-field-p
120   #:update-modeline-fields
121
122   ;; Altering and Searching Text
123   #:insert-character
124   #:insert-string
125   #:insert-region
126   #:ninsert-region
127   #:delete-characters
128   #:delete-region
129   #:delete-and-save-region
130   #:filter-region
131   #:start-line-p
132   #:end-line-p
133   #:empty-line-p
134   #:blank-line-p
135   #:blank-before-p
136   #:blank-after-p
137   #:same-line-p
138   #:mark<
139   #:mark<=
140   #:mark=
141   #:mark/=
142   #:mark>=
143   #:mark>
144   #:line<
145   #:line<=
146   #:line>=
147   #:line>
148   #:lines-related
149   #:first-line-p
150   #:last-line-p
151   #:kill-region
152   #:kill-characters
153   #:*kill-ring-pushes-to-clipboard*
154   #:*ephemerally-active-command-types*
155   #:activate-region
156   #:deactivate-region
157   #:region-active-p
158   #:check-region-active
159   #:current-region
160   #:new-search-pattern
161   #:search-pattern-p
162   #:get-search-pattern
163   #:find-pattern
164   #:replace-pattern
165   #:*last-search-string*
166   #:collapse-if-selection
167
168   ;; Hemlock Variables
169   #:*global-variable-names*
170   #:current-variable-tables
171   #:defhvar
172   #:variable-value
173   #:variable-documentation
174   #:variable-hooks
175   #:variable-name
176   #:string-to-variable
177   #:value
178   #:setv
179   #:hlet
180   #:hemlock-bound-p
181   #:delete-variable
182   #:add-hook
183   #:remove-hook
184   #:invoke-hook
185
186   ;; Commands
187   #:*command-names*
188   #:defcommand
189   #:make-command
190   #:commandp
191   #:command-documentation
192   #:command-function
193   #:command-name
194   #:bind-key
195   #:command-bindings
196   #:delete-key-binding
197   #:get-command
198   #:map-bindings
199   #:key-translation
200   #:last-command-type
201   #:prefix-argument
202
203   ;; Modes
204   #:*mode-names*
205   #:defmode
206   #:mode-documentation
207   #:buffer-major-mode
208   #:buffer-minor-mode
209   #:mode-variables
210   #:mode-major-p
211
212   ;; Character attributes
213   #:*character-attribute-names*
214   #:defattribute
215   #:character-attribute-name
216   #:character-attribute-documentation
217   #:character-attribute
218   #:character-attribute-p
219   #:shadow-attribute
220   #:unshadow-attribute
221   #:find-attribute
222   #:find-not-attribute
223   #:reverse-find-attribute
224   #:reverse-find-not-attribute
225   #:character-attribute-hooks
226
227   ;; Controlling the Display
228   #:current-view
229   #:hemlock-view-p
230   #:hemlock-view-buffer
231   #:mark-column
232   #:move-to-column
233   #:set-scroll-position
234
235   ;; Logical Key Events
236   #:*logical-key-event-names*
237   #:define-logical-key-event
238   #:logical-key-event-key-events
239   #:logical-key-event-name
240   #:logical-key-event-documentation
241   #:logical-key-event-p
242
243   ;; The Echo Area
244   #:clear-echo-area
245   #:message
246   #:loud-message
247   #:beep
248   #:command-case
249   #:prompt-for-buffer
250   #:prompt-for-package
251   #:prompt-for-key-event
252   #:prompt-for-key
253   #:prompt-for-file
254   #:prompt-for-integer
255   #:prompt-for-keyword
256   #:prompt-for-expression
257   #:prompt-for-string
258   #:prompt-for-variable
259   #:prompt-for-y-or-n
260   #:prompt-for-yes-or-no
261   #:parse-for-something
262
263   ;; Files
264   #:define-file-option
265   #:define-file-type-hook
266   #:process-file-options
267   #:pathname-to-buffer-name
268   #:buffer-default-pathname
269   #:read-file
270   #:write-file
271   #:write-buffer-file
272   #:read-buffer-file
273  ;; #:find-file-buffer
274
275   ;;# Hemlock's Lisp Environment
276   ;;   #:ed
277   #:*key-event-history*
278   #:last-key-event-typed
279   #:last-char-typed
280   #:make-hemlock-output-stream
281   #:hemlock-output-stream-p
282   #:make-hemlock-region-stream
283   #:hemlock-region-stream-p
284   #:with-input-from-region
285   #:with-output-to-mark
286   #:with-pop-up-display
287   #:editor-error
288   #:handle-lisp-errors
289   #:in-lisp
290   #:do-alpha-chars
291
292   ;; Higher-Level Text Primitives
293   #:indent-region
294   #:indent-region-for-commands
295   #:delete-horizontal-space
296   #:pre-command-parse-check
297   #:form-offset
298   #:top-level-offset
299   #:mark-top-level-form
300   #:defun-region
301   #:inside-defun-p
302   #:start-defun-p
303   #:forward-up-list
304   #:backward-up-list
305   #:valid-spot
306   #:defindent
307   #:word-offset
308   #:sentence-offset
309   #:paragraph-offset
310   #:mark-paragraph
311   #:fill-region
312   #:fill-region-by-paragraphs
313
314   ;; Utilities
315   #:make-string-table
316   #:string-table-p
317   #:string-table-separator
318   #:delete-string
319   #:clrstring
320   #:getstring
321   #:complete-string
322   #:find-ambiguous
323   #:find-containing
324   #:do-strings
325   #:make-ring
326   #:ringp
327   #:ring-length
328   #:ring-ref
329   #:ring-push
330   #:ring-pop
331   #:rotate-ring
332   #:save-for-undo
333   #:make-region-undo
334
335   ;; Miscellaneous
336
337   #:define-keysym
338   #:define-keysym-code
339   #:define-mouse-keysym
340   #:name-keysym
341   #:keysym-names
342   #:keysym-preferred-name
343   #:define-key-event-modifier
344   #:*all-modifier-names*
345   #:make-key-event-bits
346   #:key-event-modifier-mask
347   #:key-event-bits-modifiers
348   #:make-key-event
349   #:key-event-p
350   #:key-event-bits
351   #:key-event-keysym
352   #:char-key-event
353   #:key-event-char
354   #:key-event-bit-p
355   #:do-alpha-key-events
356   #:pretty-key-string
357   ))
358
359;; Functions defined externally (i.e. used by but not defined in hemlock).  In theory,
360;; these (and codes for the symbolic keysyms in keysym-defs.lisp, q.v.) is all you need
361;; to implement to port the IDE to a different window system.
362(defpackage :hemlock-ext
363  (:use)
364  ;;
365  (:export
366   #:invoke-modifying-buffer-storage
367   #:invoke-allowing-buffer-display
368   #:note-selection-set-by-search
369   #:buffer-note-font-change
370   #:buffer-note-insertion
371   #:buffer-note-modification
372   #:buffer-note-deletion
373   #:buffer-encoding-name
374   #:scroll-view
375   #:ensure-selection-visible
376   #:report-hemlock-error
377   #:top-listener-output-stream
378   #:top-listener-input-stream
379   #:invalidate-modeline
380   #:set-buffer-external-format
381   #:note-buffer-saved
382   #:note-buffer-unsaved
383   #:read-only-listener-p
384   #:all-hemlock-views
385   #:open-hemlock-buffer
386   #:save-hemlock-buffer
387   #:revert-hemlock-buffer
388   #:open-sequence-dialog
389   #:execute-in-file-view
390   #:change-active-pane
391   #:send-string-to-listener
392   #:buffer-process-description
393   #:raise-buffer-view
394   #:string-to-clipboard
395   ))
396
397(defpackage :hi
398  (:use :common-lisp :hemlock-interface)
399  (:nicknames :hemlock-internals)
400  (:import-from
401   ;; gray streams
402   #+EXCL  :excl
403   #+CLISP :gray
404   #+CMU   :ext
405   #+sbcl  :sb-gray
406   #+scl   :ext
407   #+clozure :gray
408   ;;
409   ;; Note the patch i received from DTC mentions character-output and
410   ;; character-input-stream here, so we actually see us faced to
411   ;; provide for compatibility classes. --GB
412   #-scl   #:fundamental-character-output-stream
413   #-scl   #:fundamental-character-input-stream
414   ;; There is conditionalization in streams.lisp, see above --GB
415   #+scl   #:character-output-stream
416   #+scl   #:character-input-stream
417   
418   #:stream-write-char
419   #-scl   #:stream-write-string     ; wonder what that is called --GB
420   #:stream-read-char
421   #:stream-listen
422   #:stream-unread-char
423   #:stream-clear-input
424   #:stream-finish-output
425   #:stream-force-output
426   #:stream-line-column)
427  (:import-from :ccl
428                #:delq #:memq #:assq
429                #:getenv
430                #:fixnump)
431  (:import-from :gui
432                #:log-debug)
433  ;; ** TODO: get rid of this.  The code that uses it assumes it guarantees atomicity,
434  ;; and it doesn't.
435  (:import-from :ccl #:without-interrupts)
436  ;;
437  (:export
438   #:*FAST*                             ;hmm not sure about this one
439   
440   ;; Imported
441   #:delq #:memq #:assq #:getenv #:fixnump #:log-debug
442
443   ;; hemlock-ext.lisp
444   #:hemlock-char-code-limit
445   #:file-writable #:default-directory #:complete-file #:ambiguous-files
446
447   ;; rompsite.lisp
448   #:editor-describe-function
449   #:merge-relative-pathnames
450   ;;
451   ;; Export default-font to prevent a name conflict that occurs due to
452   ;; the Hemlock variable "Default Font" defined in SITE-INIT below.
453   ;;
454   #:default-font
455   #:*beep-function* #:beep
456
457   ;;
458   #:mark #:mark-line #:mark-charpos #:mark-column #:move-to-column
459   #:markp #:region #:region-start #:region-end
460   #:regionp #:buffer #:bufferp #:buffer-modes #:buffer-point #:buffer-writable
461   #:buffer-delete-hook #:buffer-variables #:buffer-write-date
462   #:region #:regionp #:region-start #:region-end
463   #:commandp #:command #:command-function
464   #:command-documentation #:modeline-field #:modeline-field-p
465
466   ;; from macros.lisp
467   #:invoke-hook #:value #:setv #:hlet #:string-to-variable #:add-hook #:remove-hook
468   #:defcommand #:with-mark #:use-buffer #:editor-error
469   #:editor-error-format-string #:editor-error-format-arguments #:do-strings
470   #:command-case #:reprompt #:with-output-to-mark #:with-input-from-region
471   #:handle-lisp-errors #:with-pop-up-display
472
473   ;; from views.lisp
474   #:hemlock-view #:current-view #:hemlock-view-buffer
475   #:current-prefix-argument-state #:last-key-event-typed #:last-char-typed
476   #:invoke-command
477   #:abort-to-toplevel #:abort-current-command
478   #:set-scroll-position
479   #:native-key-event-p
480
481   ;; from line.lisp
482   #:line #:linep #:line-previous #:line-next #:line-plist #:line-signature
483
484   ;; from ring.lisp
485   #:ring #:ringp #:make-ring #:ring-push #:ring-pop #:ring-length #:ring-ref
486   #:rotate-ring
487
488   ;; from table.lisp
489   #:string-table #:string-table-p #:make-string-table
490   #:string-table-separator #:getstring
491   #:find-ambiguous #:complete-string #:find-containing
492   #:delete-string #:clrstring #:do-strings
493
494   ;; buffer.lisp
495   #:buffer-modified #:buffer-region #:buffer-name #:buffer-pathname
496   #:buffer-major-mode #:buffer-minor-mode #:buffer-modeline-fields
497   #:buffer-modeline-field-p #:current-buffer #:current-point
498   #:defmode #:mode-major-p #:mode-variables #:mode-documentation
499   #:make-buffer #:delete-buffer #:with-writable-buffer #:buffer-start-mark
500   #:buffer-end-mark #:*buffer-list*
501
502   ;; charmacs.lisp
503   #:syntax-char-code-limit #:search-char-code-limit #:do-alpha-chars
504
505   ;; charprops.lisp
506   #:next-charprop-value #:previous-charprop-value
507   #:set-charprop-value #:find-charprop-value #:next-charprops
508   #:previous-charprops #:set-charprops #:charprops-in-region
509   #:apply-charprops #:find-charprops #:find-charprops-change
510   #:charprop-equal #:charprops-get #:charprops-set #:charprops-equal
511   #:charprops-as-plist #:charprops-as-hash #:charprops-names
512   #:set-buffer-charprops #:buffer-charprops
513
514   ;; key-event.lisp
515   #:define-keysym-code #:define-mouse-keysym #:define-modifier-bit
516   #:*all-modifier-names* #:*modifier-translations*
517   #:make-key-event #:char-key-event #:do-alpha-key-events
518   #:key-event-modifier-mask #:key-event-char #:key-event-bit-p
519   #:pretty-key-string
520
521   ;; echo.lisp
522   #:*echo-area-stream*
523   #:clear-echo-area #:message #:loud-message
524   #:current-echo-parse-state #:exit-echo-parse
525   #:eps-parse-type #:eps-parse-starting-mark #:eps-parse-input-region
526   #:eps-parse-verification-function #:eps-parse-string-tables
527   #:eps-parse-default #:eps-parse-help #:eps-parse-key-handler
528   #:prompt-for-buffer #:prompt-for-package #:prompt-for-file #:prompt-for-integer
529   #:prompt-for-keyword #:prompt-for-expression #:prompt-for-string
530   #:prompt-for-variable #:prompt-for-yes-or-no #:prompt-for-y-or-n
531   #:prompt-for-key-event #:prompt-for-key
532   #:*logical-key-event-names*
533   #:logical-key-event-p #:logical-key-event-documentation
534   #:logical-key-event-name #:logical-key-event-key-events
535   #:define-logical-key-event #:current-variable-tables
536
537
538   ;; commands
539   #:make-prefix-argument-state #:prefix-argument-resetting-state
540
541 
542   ;; files.lisp
543   #:read-file #:write-file
544
545
546   ;; font.lisp
547   #:font-mark #:delete-font-mark #:delete-line-font-marks #:move-font-mark
548   #:window-font
549
550   ;; htext1.lisp
551   #:line-length #:line-buffer #:line-string #:line-character #:mark #:mark-kind
552   #:copy-mark #:delete-mark #:move-to-position #:mark-absolute-position
553   #:move-to-absolute-position #:buffer-selection-range #:region #:make-empty-region
554   #:start-line-p #:end-line-p #:empty-line-p #:blank-line-p #:blank-before-p
555   #:blank-after-p #:same-line-p #:mark< #:mark<= #:mark> #:mark>= #:mark= #:mark/=
556   #:line< #:line<= #:line> #:line>= #:first-line-p #:last-line-p #:buffer-signature
557   #:lines-related
558
559
560   ;; htext2.lisp
561   #:region-to-string #:string-to-region #:line-to-region
562   #:previous-character #:next-character #:count-lines
563   #:count-characters #:line-start #:line-end #:buffer-start
564   #:buffer-end #:move-mark #:mark-before #:mark-after
565   #:character-offset #:line-offset #:region-bounds
566   #:set-region-bounds #:*print-region*
567
568
569   ;; htext3.lisp
570   #:insert-character #:insert-string #:insert-region #:ninsert-region
571   #:paste-characters
572
573   ;; htext4.lisp
574   #:delete-characters #:delete-region #:delete-and-save-region #:copy-region
575   #:filter-region
576
577
578   ;; interp.lisp
579   #:bind-key #:delete-key-binding #:get-command #:map-bindings
580   #:make-command #:command-name #:command-bindings #:last-command-type
581   #:prefix-argument #:key-translation
582
583
584   ;; main.lisp
585   #:*global-variable-names* #:*mode-names* #:*buffer-names*
586   #:*character-attribute-names* #:*command-names* #:*buffer-list*
587   #:after-editor-initializations
588
589   ;; search1.lisp
590   #:search-pattern #:search-pattern-p #:find-pattern #:replace-pattern
591   #:new-search-pattern
592
593   ;; modeline.lisp
594   #:modeline-field-width
595   #:modeline-field-function #:make-modeline-field
596   #:update-modeline-field #:modeline-field-name #:modeline-field
597
598   ;; streams.lisp
599   #:make-hemlock-output-stream
600   #:hemlock-region-stream #:hemlock-region-stream-p
601   #:hemlock-output-stream #:make-hemlock-region-stream
602   #:hemlock-output-stream-p #:make-kbdmac-stream
603   #:modify-kbdmac-stream
604
605   ;; syntax.lisp
606   #:character-attribute-name
607   #:defattribute #:character-attribute-documentation #:character-attribute
608   #:character-attribute-hooks #:character-attribute-p #:shadow-attribute
609   #:unshadow-attribute #:find-attribute #:reverse-find-attribute
610
611   ;; vars.lisp
612   #:variable-value #:variable-hooks #:variable-documentation #:variable-name
613   #:hemlock-bound-p #:defhvar #:delete-variable
614
615   #:input-stream-reading-line
616
617   ))
618
619
620(defpackage :hemlock
621  (:use :common-lisp :hemlock-interface :hemlock-internals :hemlock-ext)
622  )
623
624
625;; $Log$
626;; Revision 1.2  2005/08/01 10:54:17  gb
627;; Don't export CHECK-REGION-QUERY-SIZE.
628;;
629;; Revision 1.1.1.1  2003/10/19 08:57:16  gb
630;; recovered 0.14 sources
631;;
632;; Revision 1.1.2.1  2003/08/10 19:11:33  gb
633;; New files, imported from upstream CVS as of 03/08/09.
634;;
635;; Revision 1.9  2003/08/05 19:58:21  gilbert
636;; - we now have a HEMLOCK-INTERFACE package which exports symbols mentioned
637;;   in the Command Implementors Manual.
638;;
639;; Revision 1.8  2003/07/28 20:35:32  jdz
640;; BEEP function now works.
641;;
642;; Revision 1.7  2003/07/27 10:11:06  jdz
643;; HEMLOCK-EXT package is now used by HEMLOCK.  Conflicting symbols from
644;; EXTENSIONS package in CMUCL are shadowed.
645;;
646;; Revision 1.6  2003/05/12 11:01:48  gbyers
647;; Conditionalize (Gray streams package) for OpenMCL.
648;;
649;; Revision 1.5  2003/03/26 07:50:10  gilbert
650;; Port to SCL by Douglas Crosher
651;;
652;; Revision 1.4  2003/03/06 21:38:58  gilbert
653;; The symbol *FAST* is now exported from HI (no idea if that is the
654;; right thing to do) and imported into HEMLOCK. Fixes bug:
655;; auto-save.lisp was not compiling.
656;;
Note: See TracBrowser for help on using the repository browser.