-
Notifications
You must be signed in to change notification settings - Fork 0
/
orgstar-mode.el
780 lines (697 loc) · 24.8 KB
/
orgstar-mode.el
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
;;; orgstar-mode.el v0.02--- WordStar emulation mode for GNU Emacs Org mode
;;; Commentary:
;; This emulates WordStar, with a major mode.
;; Crudely hacked together from the original ws-mode.el by shawnh
;; 'which-key' package and capslock remapped to control highly recommended
;; 'ispell' used for spellcheck
;; 'powerthesaurus' for thesaurus functions
;;; Code:
(defvar orgstar-mode-map nil "")
(defvar orgstar-C-j-map nil "")
(defvar orgstar-C-k-map nil "")
(defvar orgstar-C-o-map nil "")
(defvar orgstar-C-q-map nil "")
(if orgstar-mode-map
()
(setq orgstar-mode-map (make-keymap))
(setq orgstar-C-k-map (make-keymap))
(setq orgstar-C-o-map (make-keymap))
(setq orgstar-C-q-map (make-keymap))
;; stop olivetti blocking C-c scroll
(eval-after-load "olivetti"
'(progn
(define-key olivetti-mode-map (kbd "\C-c") #'nil)))
(define-key orgstar-mode-map "\C-a" 'backward-word)
(define-key orgstar-mode-map "\C-b" 'fill-paragraph)
(define-key orgstar-mode-map "\C-c" 'scroll-up)
(define-key orgstar-mode-map "\C-d" 'forward-char)
(define-key orgstar-mode-map "\C-e" 'previous-line)
(define-key orgstar-mode-map "\C-f" 'forward-word)
(define-key orgstar-mode-map "\C-g" 'delete-char)
(define-key orgstar-mode-map "\C-h" 'backward-char)
(define-key orgstar-mode-map "\C-i" 'indent-for-tab-command)
(define-key orgstar-mode-map "\C-j" 'help-for-help)
(define-key orgstar-mode-map "\C-k" orgstar-C-k-map)
(define-key orgstar-mode-map "\C-l" 'os-repeat-search)
(define-key orgstar-mode-map "\C-n" 'open-line)
(define-key orgstar-mode-map "\C-o" orgstar-C-o-map)
(define-key orgstar-mode-map "\C-p" 'quoted-insert)
(define-key orgstar-mode-map "\C-q" orgstar-C-q-map)
(define-key orgstar-mode-map "\C-r" 'scroll-down)
(define-key orgstar-mode-map "\C-s" 'backward-char)
(define-key orgstar-mode-map "\C-t" 'kill-word)
(define-key orgstar-mode-map "\C-u" 'keyboard-quit)
(define-key orgstar-mode-map "\C-v" 'overwrite-mode)
(define-key orgstar-mode-map "\C-w" 'scroll-down-line)
(define-key orgstar-mode-map "\C-x" 'next-line)
(define-key orgstar-mode-map "\C-y" 'kill-complete-line)
(define-key orgstar-mode-map "\C-z" 'scroll-up-line)
(define-key orgstar-mode-map "\t" 'org-cycle)
;; orgstar-C-k-map
(define-key orgstar-C-k-map " " ())
(define-key orgstar-C-k-map "0" 'os-set-marker-0)
(define-key orgstar-C-k-map "1" 'os-set-marker-1)
(define-key orgstar-C-k-map "2" 'os-set-marker-2)
(define-key orgstar-C-k-map "3" 'os-set-marker-3)
(define-key orgstar-C-k-map "4" 'os-set-marker-4)
(define-key orgstar-C-k-map "5" 'os-set-marker-5)
(define-key orgstar-C-k-map "6" 'os-set-marker-6)
(define-key orgstar-C-k-map "7" 'os-set-marker-7)
(define-key orgstar-C-k-map "8" 'os-set-marker-8)
(define-key orgstar-C-k-map "9" 'os-set-marker-9)
(define-key orgstar-C-k-map "b" 'os-begin-block)
(define-key orgstar-C-k-map "\C-b" 'os-begin-block)
(define-key orgstar-C-k-map "c" 'os-copy-block)
(define-key orgstar-C-k-map "\C-c" 'os-copy-block)
(define-key orgstar-C-k-map "d" 'dired)
(define-key orgstar-C-k-map "\C-d" 'dired)
(define-key orgstar-C-k-map "f" 'find-file)
(define-key orgstar-C-k-map "\C-f" 'find-file)
(define-key orgstar-C-k-map "h" 'os-show-markers)
(define-key orgstar-C-k-map "\C-h" 'os-show-markers)
(define-key orgstar-C-k-map "i" 'os-indent-block)
(define-key orgstar-C-k-map "\C-i" 'os-indent-block)
(define-key orgstar-C-k-map "k" 'os-end-block)
(define-key orgstar-C-k-map "\C-k" 'os-end-block)
(define-key orgstar-C-k-map "p" 'os-print-block)
(define-key orgstar-C-k-map "\C-p" 'os-print-block)
(define-key orgstar-C-k-map "q" 'kill-emacs)
(define-key orgstar-C-k-map "\C-q" 'kill-emacs)
(define-key orgstar-C-k-map "r" 'insert-file)
(define-key orgstar-C-k-map "\C-r" 'insert-file)
(define-key orgstar-C-k-map "s" 'save-some-buffers)
(define-key orgstar-C-k-map "\C-s" 'save-some-buffers)
(define-key orgstar-C-k-map "t" 'os-mark-word)
(define-key orgstar-C-k-map "\C-t" 'os-mark-word)
(define-key orgstar-C-k-map "u" 'os-exdent-block)
(define-key orgstar-C-k-map "\C-u" 'keyboard-quit)
(define-key orgstar-C-k-map "v" 'os-move-block)
(define-key orgstar-C-k-map "\C-v" 'os-move-block)
(define-key orgstar-C-k-map "w" 'os-write-block)
(define-key orgstar-C-k-map "\C-w" 'os-write-block)
(define-key orgstar-C-k-map "x" 'save-buffers-kill-emacs)
(define-key orgstar-C-k-map "\C-x" 'save-buffers-kill-emacs)
(define-key orgstar-C-k-map "y" 'os-delete-block)
(define-key orgstar-C-k-map "\C-y" 'os-delete-block)
;; orgstar-C-o-map
(define-key orgstar-C-o-map " " ())
(define-key orgstar-C-o-map "c" 'orgstar-center-line)
(define-key orgstar-C-o-map "\C-c" 'orgstar-center-line)
(define-key orgstar-C-o-map "b" 'switch-to-buffer)
(define-key orgstar-C-o-map "\C-b" 'switch-to-buffer)
(define-key orgstar-C-o-map "i" 'ibuffer)
(define-key orgstar-C-o-map "j" 'justify-current-line)
(define-key orgstar-C-o-map "\C-j" 'justify-current-line)
(define-key orgstar-C-o-map "k" 'kill-buffer)
(define-key orgstar-C-o-map "\C-k" 'kill-buffer)
(define-key orgstar-C-o-map "l" 'list-buffers)
(define-key orgstar-C-o-map "\C-l" 'list-buffers)
(define-key orgstar-C-o-map "m" 'auto-fill-mode)
(define-key orgstar-C-o-map "\C-m" 'auto-fill-mode)
(define-key orgstar-C-o-map "r" 'set-fill-column)
(define-key orgstar-C-o-map "\C-r" 'set-fill-column)
(define-key orgstar-C-o-map "\C-u" 'keyboard-quit)
;;org headline manipulation
(define-key orgstar-C-o-map "e" 'org-move-subtree-up)
(define-key orgstar-C-o-map "\C-e" 'org-move-subtree-up)
(define-key orgstar-C-o-map "x" 'org-move-subtree-down)
(define-key orgstar-C-o-map "\C-x" 'org-move-subtree-down)
(define-key orgstar-C-o-map "s" 'org-do-promote)
(define-key orgstar-C-o-map "\C-s" 'org-do-promote)
(define-key orgstar-C-o-map "d" 'org-do-demote)
(define-key orgstar-C-o-map "\C-d" 'org-do-demote)
;; o prefix for org commands
(define-key orgstar-C-o-map "o" :which-key "ORG")
(define-key orgstar-C-o-map "oa" 'org-agenda)
(define-key orgstar-C-o-map "oc" 'org-toggle-checkbox)
(define-key orgstar-C-o-map "od" 'org-todo)
(define-key orgstar-C-o-map "on" 'org-next-visible-heading)
(define-key orgstar-C-o-map "op" 'org-previous-visible-heading)
(define-key orgstar-C-o-map "ot" 'org-table-create)
;; w prefix for window managgement
(define-key orgstar-C-o-map "wd" 'delete-other-windows)
(define-key orgstar-C-o-map "wh" 'split-window-horizontally)
(define-key orgstar-C-o-map "wo" 'other-window)
(define-key orgstar-C-o-map "wv" 'split-window-vertically)
;; orgstar-C-q-map
(define-key orgstar-C-q-map " " ())
(define-key orgstar-C-q-map "0" 'os-find-marker-0)
(define-key orgstar-C-q-map "1" 'os-find-marker-1)
(define-key orgstar-C-q-map "2" 'os-find-marker-2)
(define-key orgstar-C-q-map "3" 'os-find-marker-3)
(define-key orgstar-C-q-map "4" 'os-find-marker-4)
(define-key orgstar-C-q-map "5" 'os-find-marker-5)
(define-key orgstar-C-q-map "6" 'os-find-marker-6)
(define-key orgstar-C-q-map "7" 'os-find-marker-7)
(define-key orgstar-C-q-map "8" 'os-find-marker-8)
(define-key orgstar-C-q-map "9" 'os-find-marker-9)
(define-key orgstar-C-q-map "a" 'os-query-replace)
(define-key orgstar-C-q-map "\C-a" 'os-query-replace)
(define-key orgstar-C-q-map "b" 'os-goto-block-begin)
(define-key orgstar-C-q-map "\C-b" 'os-goto-block-begin)
(define-key orgstar-C-q-map "c" 'end-of-buffer)
(define-key orgstar-C-q-map "\C-c" 'end-of-buffer)
(define-key orgstar-C-q-map "d" 'org-end-of-line)
(define-key orgstar-C-q-map "\C-d" 'org-end-of-line)
(define-key orgstar-C-q-map "f" 'os-search)
(define-key orgstar-C-q-map "\C-f" 'os-search)
(define-key orgstar-C-q-map "j" 'powerthesaurus-lookup-dwim)
(define-key orgstar-C-q-map "\C-j" 'powerthesaurus-lookup-dwim)
(define-key orgstar-C-q-map "k" 'os-goto-block-end)
(define-key orgstar-C-q-map "\C-k" 'os-goto-block-end)
(define-key orgstar-C-q-map "l" 'ispell-buffer)
(define-key orgstar-C-q-map "\C-l" 'ispell-buffer)
(define-key orgstar-C-q-map "n" 'ispell-word)
(define-key orgstar-C-q-map "\C-n" 'ispell-word)
(define-key orgstar-C-q-map "p" 'os-last-cursorp)
(define-key orgstar-C-q-map "\C-p" 'os-last-cursorp)
(define-key orgstar-C-q-map "r" 'beginning-of-buffer)
(define-key orgstar-C-q-map "\C-r" 'beginning-of-buffer)
(define-key orgstar-C-q-map "s" 'org-beginning-of-line)
(define-key orgstar-C-q-map "\C-s" 'org-beginning-of-line)
(define-key orgstar-C-q-map "u" 'os-undo)
(define-key orgstar-C-q-map "\C-u" 'keyboard-quit)
(define-key orgstar-C-q-map "w" 'os-last-error)
(define-key orgstar-C-q-map "\C-w" 'os-last-error)
(define-key orgstar-C-q-map "y" 'os-kill-eol)
(define-key orgstar-C-q-map "\C-y" 'os-kill-eol)
(define-key orgstar-C-q-map "\177" 'os-kill-bol))
(put 'orgstar-mode 'mode-class 'special)
;;;###autoload
(defun orgstar-mode ()
"Major mode with WordStar-like key bindings.
BUGS:
- Help menus with WordStar commands (C-j just calls help-for-help)
are not implemented
- Options for search and replace
- Show markers (C-k h) is somewhat strange
- Search and replace (C-q a) is only available in forward direction
No key bindings beginning with ESC are installed, they will work
Emacs-like.
The key bindings are:
C-a backward-word
C-b fill-paragraph
C-c scroll-up-line
C-d forward-char
C-e previous-line
C-f forward-word
C-g delete-char
C-h backward-char
C-i indent-for-tab-command
C-j help-for-help
C-k ordstar-C-k-map
C-l os-repeat-search
C-n open-line
C-p quoted-insert
C-r scroll-down-line
C-s backward-char
C-t kill-word
C-u keyboard-quit
C-v overwrite-mode
C-w scroll-down
C-x next-line
C-y kill-complete-line
C-z scroll-up
C-k 0 os-set-marker-0
C-k 1 os-set-marker-1
C-k 2 os-set-marker-2
C-k 3 os-set-marker-3
C-k 4 os-set-marker-4
C-k 5 os-set-marker-5
C-k 6 os-set-marker-6
C-k 7 os-set-marker-7
C-k 8 os-set-marker-8
C-k 9 os-set-marker-9
C-k b os-begin-block
C-k c os-copy-block
C-k d dired
C-k f find-file
C-k h os-show-markers
C-k i os-indent-block
C-k k os-end-block
C-k p os-print-block
C-k q kill-emacs
C-k r insert-file
C-k s save-some-buffers
C-k t os-mark-word
C-k u os-exdent-block
C-k C-u keyboard-quit
C-k v os-move-block
C-k w os-write-block
C-k x save-buffers-kill-emacs
C-k y os-delete-block
C-o c orgstar-center-line
C-o b switch-to-buffer
C-o j justify-current-line
C-o k kill-buffer
C-o l list-buffers
C-o m auto-fill-mode
C-o r set-fill-column
C-o C-u keyboard-quit
C-o e org-move-subtree-up
C-o x org-move-subtree-down
C-o s org-do-promote
C-o d org-do-demote
C-o oa org-agenda
C-o oc org-toggle-checkbox
C-o od org-todo
C-o on org-next-visible-heading
C-o op org-previous-visible-heading
C-o ot org-table-create
C-o wd delete-other-windows
C-o wh split-window-horizontally
C-o wo other-window
C-o wv split-window-vertically
C-q 0 os-find-marker-0
C-q 1 os-find-marker-1
C-q 2 os-find-marker-2
C-q 3 os-find-marker-3
C-q 4 os-find-marker-4
C-q 5 os-find-marker-5
C-q 6 os-find-marker-6
C-q 7 os-find-marker-7
C-q 8 os-find-marker-8
C-q 9 os-find-marker-9
C-q a os-query-replace
C-q b os-to-block-begin
C-q c end-of-buffer
C-q d end-of-line
C-q f os-search
C-q j powerthesaurus-lookup-dwim
C-q k os-to-block-end
C-q l os-undo
C-q p os-last-cursorp
C-q r beginning-of-buffer
C-q u undo
C-q C-u keyboard-quit
C-q w os-last-error
C-q y os-kill-eol
C-q DEL os-kill-bol
"
(interactive)
;; (kill-all-local-variables)
(use-local-map orgstar-mode-map)
(setq mode-name "Orgstar")
(setq major-mode 'orgstar-mode)
(run-mode-hooks 'orgstar-mode-hook))
(defun orgstar-center-paragraph ()
"Center each line in the paragraph at or after point.
See `orgstar-center-line' for more info."
(interactive)
(save-excursion
(forward-paragraph)
(or (bolp) (newline 1))
(let ((end (point)))
(backward-paragraph)
(orgstar-center-region (point) end))))
(defun orgstar-center-region (from to)
"Center each line starting in the region.
See `orgstar-center-line' for more info."
(interactive "r")
(if (> from to)
(let ((tem to))
(setq to from from tem)))
(save-excursion
(save-restriction
(narrow-to-region from to)
(goto-char from)
(while (not (eobp))
(orgstar-center-line)
(forward-line 1)))))
(defun orgstar-center-line ()
"Center the line point is on, within the width specified by `fill-column'.
This means adjusting the indentation to match
the distance between the end of the text and `fill-column'."
(interactive)
(save-excursion
(let (line-length)
(beginning-of-line)
(delete-horizontal-space)
(end-of-line)
(delete-horizontal-space)
(setq line-length (current-column))
(beginning-of-line)
(indent-to
(+ left-margin
(/ (- fill-column left-margin line-length) 2))))))
(defun scroll-down-line ()
"Scroll one line down."
(interactive)
(scroll-down 1))
(defun scroll-up-line ()
"Scroll one line up."
(interactive)
(scroll-up 1))
;;;;;;;;;;;
;; orgstar special variables:
(defvar os-marker-0 nil "Position marker 0 in Orgstar mode.")
(defvar os-marker-1 nil "Position marker 1 in Orgstar mode.")
(defvar os-marker-2 nil "Position marker 2 in Orgstar mode.")
(defvar os-marker-3 nil "Position marker 3 in Orgstar mode.")
(defvar os-marker-4 nil "Position marker 4 in Orgstar mode.")
(defvar os-marker-5 nil "Position marker 5 in Orgstar mode.")
(defvar os-marker-6 nil "Position marker 6 in Orgstar mode.")
(defvar os-marker-7 nil "Position marker 7 in Orgstar mode.")
(defvar os-marker-8 nil "Position marker 8 in Orgstar mode.")
(defvar os-marker-9 nil "Position marker 9 in Orgstar mode.")
(defvar os-block-begin-marker nil "Beginning of \"Block\" in Orgstar mode.")
(defvar os-block-end-marker nil "End of \"Block\" in Orgstar mode.")
(defvar os-search-string nil "String of last search in Orgstar mode.")
(defvar os-search-direction t
"Direction of last search in Orgstar mode. t if forward, nil if backward.")
(defvar os-last-cursorposition nil
"Position before last search etc. in Orgstar mode.")
(defvar os-last-errormessage nil
"Last error message issued by a Orgstar mode function.")
;;;;;;;;;;;
;; orgstar special functions:
(defun os-error (string)
"Report error of a Orgstar special function. Error message is saved
in os-last-errormessage for recovery with C-q w."
(setq os-last-errormessage string)
(error string))
(defun os-set-marker-0 ()
"In Orgstar mode: Set marker 0 to current cursor position."
(interactive)
(setq os-marker-0 (point-marker))
(message "Marker 0 set"))
(defun os-set-marker-1 ()
"In Orgstar mode: Set marker 1 to current cursor position."
(interactive)
(setq os-marker-1 (point-marker))
(message "Marker 1 set"))
(defun os-set-marker-2 ()
"In Orgstar mode: Set marker 2 to current cursor position."
(interactive)
(setq os-marker-2 (point-marker))
(message "Marker 2 set"))
(defun os-set-marker-3 ()
"In Orgstar mode: Set marker 3 to current cursor position."
(interactive)
(setq os-marker-3 (point-marker))
(message "Marker 3 set"))
(defun os-set-marker-4 ()
"In Orgstar mode: Set marker 4 to current cursor position."
(interactive)
(setq os-marker-4 (point-marker))
(message "Marker 4 set"))
(defun os-set-marker-5 ()
"In Orgstar mode: Set marker 5 to current cursor position."
(interactive)
(setq os-marker-5 (point-marker))
(message "Marker 5 set"))
(defun os-set-marker-6 ()
"In Orgstar mode: Set marker 6 to current cursor position."
(interactive)
(setq os-marker-6 (point-marker))
(message "Marker 6 set"))
(defun os-set-marker-7 ()
"In Orgstar mode: Set marker 7 to current cursor position."
(interactive)
(setq os-marker-7 (point-marker))
(message "Marker 7 set"))
(defun os-set-marker-8 ()
"In Orgstar mode: Set marker 8 to current cursor position."
(interactive)
(setq os-marker-8 (point-marker))
(message "Marker 8 set"))
(defun os-set-marker-9 ()
"In Orgstar mode: Set marker 9 to current cursor position."
(interactive)
(setq os-marker-9 (point-marker))
(message "Marker 9 set"))
(defun os-begin-block ()
"In Orgstar mode: Set block begin marker to current cursor position."
(interactive)
(setq os-block-begin-marker (point-marker))
(message "Block begin marker set"))
(defun os-show-markers ()
"In Orgstar mode: Show block markers."
(interactive)
(if (or os-block-begin-marker os-block-end-marker)
(save-excursion
(if os-block-begin-marker
(progn
(goto-char os-block-begin-marker)
(message "Block begin marker")
(sit-for 2))
(message "Block begin marker not set")
(sit-for 2))
(if os-block-end-marker
(progn
(goto-char os-block-end-marker)
(message "Block end marker")
(sit-for 2))
(message "Block end marker not set"))
(message ""))
(message "Block markers not set")))
(defun os-indent-block ()
"In Orgstar mode: Indent block (not yet implemented)."
(interactive)
(os-error "Indent block not yet implemented"))
(defun os-end-block ()
"In Orgstar mode: Set block end marker to current cursor position."
(interactive)
(setq os-block-end-marker (point-marker))
(message "Block end marker set"))
(defun os-print-block ()
"In Orgstar mode: Print block."
(interactive)
(message "Don't do this. Write block to a file (C-k w) and print this file."))
(defun os-mark-word ()
"In Orgstar mode: Mark current word as block."
(interactive)
(save-excursion
(forward-word 1)
(sit-for 1)
(os-end-block)
(forward-word -1)
(sit-for 1)
(os-begin-block)))
(defun os-exdent-block ()
"I don't know what this (C-k u) should do."
(interactive)
(os-error "This won't be done -- not yet implemented."))
(defun os-move-block ()
"In Orgstar mode: Move block to current cursor position."
(interactive)
(if (and os-block-begin-marker os-block-end-marker)
(progn
(kill-region os-block-begin-marker os-block-end-marker)
(yank)
(save-excursion
(goto-char (region-beginning))
(setq os-block-begin-marker (point-marker))
(goto-char (region-end))
(setq os-block-end-marker (point-marker))))
(os-error (cond (os-block-begin-marker "Block end marker not set")
(os-block-end-marker "Block begin marker not set")
(t "Block markers not set")))))
(defun os-write-block ()
"In Orgstar mode: Write block to file."
(interactive)
(if (and os-block-begin-marker os-block-end-marker)
(let ((filename (read-file-name "Write block to file: ")))
(write-region os-block-begin-marker os-block-end-marker filename))
(os-error (cond (os-block-begin-marker "Block end marker not set")
(os-block-end-marker "Block begin marker not set")
(t "Block markers not set")))))
(defun os-delete-block ()
"In Orgstar mode: Delete block."
(interactive)
(if (and os-block-begin-marker os-block-end-marker)
(progn
(kill-region os-block-begin-marker os-block-end-marker)
(setq os-block-end-marker nil)
(setq os-block-begin-marker nil))
(os-error (cond (os-block-begin-marker "Block end marker not set")
(os-block-end-marker "Block begin marker not set")
(t "Block markers not set")))))
(defun os-find-marker-0 ()
"In Orgstar mode: Go to marker 0."
(interactive)
(if os-marker-0
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-0))
(os-error "Marker 0 not set")))
(defun os-find-marker-1 ()
"In Orgstar mode: Go to marker 1."
(interactive)
(if os-marker-1
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-1))
(os-error "Marker 1 not set")))
(defun os-find-marker-2 ()
"In Orgstar mode: Go to marker 2."
(interactive)
(if os-marker-2
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-2))
(os-error "Marker 2 not set")))
(defun os-find-marker-3 ()
"In Orgstar mode: Go to marker 3."
(interactive)
(if os-marker-3
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-3))
(os-error "Marker 3 not set")))
(defun os-find-marker-4 ()
"In Orgstar mode: Go to marker 4."
(interactive)
(if os-marker-4
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-4))
(os-error "Marker 4 not set")))
(defun os-find-marker-5 ()
"In Orgstar mode: Go to marker 5."
(interactive)
(if os-marker-5
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-5))
(os-error "Marker 5 not set")))
(defun os-find-marker-6 ()
"In Orgstar mode: Go to marker 6."
(interactive)
(if os-marker-6
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-6))
(os-error "Marker 6 not set")))
(defun os-find-marker-7 ()
"In Orgstar mode: Go to marker 7."
(interactive)
(if os-marker-7
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-7))
(os-error "Marker 7 not set")))
(defun os-find-marker-8 ()
"In Orgstar mode: Go to marker 8."
(interactive)
(if os-marker-8
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-8))
(os-error "Marker 8 not set")))
(defun os-find-marker-9 ()
"In Orgstar mode: Go to marker 9."
(interactive)
(if os-marker-9
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-marker-9))
(os-error "Marker 9 not set")))
(defun os-goto-block-begin ()
"In Orgstar mode: Go to block begin marker."
(interactive)
(if os-block-begin-marker
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-block-begin-marker))
(os-error "Block begin marker not set")))
(defun os-search (string)
"In Orgstar mode: Search string, remember string for repetition."
(interactive "sSearch for: ")
(message "Forward (f) or backward (b)")
(let ((direction
(read-char)))
(cond ((equal (upcase direction) ?F)
(setq os-search-string string)
(setq os-search-direction t)
(setq os-last-cursorposition (point-marker))
(search-forward string))
((equal (upcase direction) ?B)
(setq os-search-string string)
(setq os-search-direction nil)
(setq os-last-cursorposition (point-marker))
(search-backward string))
(t (keyboard-quit)))))
(defun os-goto-block-end ()
"In Orgstar mode: Go to block end marker."
(interactive)
(if os-block-end-marker
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-block-end-marker))
(os-error "Block end marker not set")))
(defun os-undo ()
"In Orgstar mode: Undo and give message about undoing more changes."
(interactive)
(undo)
(message "Repeat C-q u to undo more changes."))
(defun os-goto-last-cursorposition ()
"In Orgstar mode: "
(interactive)
(if os-last-cursorposition
(progn
(setq os-last-cursorposition (point-marker))
(goto-char os-last-cursorposition))
(os-error "No last cursor position available.")))
(defun os-last-error ()
"In Orgstar mode: repeat last error message.
This will only work for errors raised by Orgstar mode functions."
(interactive)
(if os-last-errormessage
(message "%s" os-last-errormessage)
(message "No Orgstar error yet.")))
(defun os-kill-eol ()
"In Orgstar mode: Kill to end of line (like Orgstar, not like Emacs)."
(interactive)
(let ((p (point)))
(end-of-line)
(kill-region p (point))))
(defun os-kill-bol ()
"In Orgstar mode: Kill to beginning of line
\(like Orgstar, not like Emacs)."
(interactive)
(let ((p (point)))
(beginning-of-line)
(kill-region (point) p)))
(defun kill-complete-line ()
"Kill the complete line."
(interactive)
(beginning-of-line)
(if (eobp) (error "End of buffer"))
(let ((beg (point)))
(forward-line 1)
(kill-region beg (point))))
(defun os-repeat-search ()
"In Orgstar mode: Repeat last search."
(interactive)
(setq os-last-cursorposition (point-marker))
(if os-search-string
(if os-search-direction
(search-forward os-search-string)
(search-backward os-search-string))
(os-error "No search to repeat")))
(defun os-query-replace (from to)
"In Orgstar mode: Search string, remember string for repetition."
(interactive "sReplace:
sWith: " )
(setq os-search-string from)
(setq os-search-direction t)
(setq os-last-cursorposition (point-marker))
(query-replace from to))
(defun os-copy-block ()
"In Orgstar mode: Copy block to current cursor position."
(interactive)
(if (and os-block-begin-marker os-block-end-marker)
(progn
(copy-region-as-kill os-block-begin-marker os-block-end-marker)
(yank)
(save-excursion
(goto-char (region-beginning))
(setq os-block-begin-marker (point-marker))
(goto-char (region-end))
(setq os-block-end-marker (point-marker))))
(os-error (cond (os-block-begin-marker "Block end marker not set")
(os-block-end-marker "Block begin marker not set")
(t "Block markers not set")))))
(provide 'orgstar-mode)
;;; orgstar-mode.el ends here