-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsynonyms.el
1416 lines (1313 loc) · 64.9 KB
/
synonyms.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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; synonyms.el --- Look up synonyms for a word or phrase in a thesaurus.
;;
;; Filename: synonyms.el
;; Description: Look up synonyms for a word or phrase in a thesaurus.
;; Author: Drew Adams
;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
;; Copyright (C) 2005-2018, Drew Adams, all rights reserved.
;; Created: Tue Dec 20 14:39:26 2005
;; Version: 0
;; Package-Requires: ()
;; Last-Updated: Mon Jan 1 16:00:01 2018 (-0800)
;; By: dradams
;; Update #: 2560
;; URL: https://www.emacswiki.org/emacs/download/synonyms.el
;; Doc URL: https://www.emacswiki.org/emacs/ThesauriAndSynonyms
;; Keywords: text, dictionary, thesaurus, spelling, apropos, help
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
;;
;; Features that might be required by this library:
;;
;; `thingatpt', `thingatpt+'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Look up synonyms for a word or phrase in a thesaurus.
;;
;;
;; Getting Started
;; ---------------
;;
;; To use library Synonyms, you will need the Moby Thesaurus II file,
;; `mthesaur.txt', available here:
;;
;; https://archive.org/details/mobythesauruslis03202gut
;;
;; Put this in your initialization file (~/.emacs):
;;
;; ;; The file names are absolute, not relative, locations
;; ;; - e.g. /foobar/mthesaur.txt.cache, not mthesaur.txt.cache
;; (setq synonyms-file <name & location of mthesaur.txt>)
;; (setq synonyms-cache-file <name & location of your cache file>)
;; (require 'synonyms)
;;
;; As an alternative to the first two lines, you can use Customize to
;; set `synonyms-file' and `synonyms-cache-file' persistently. The
;; second of these files is created by this library, to serve as a
;; synonym cache for completion.
;;
;; The main command is `synonyms'. It prompts you for a word or
;; phrase to look up in the thesaurus. The synonyms found are then
;; displayed in buffer *Synonyms*. For example, `M-x synonyms RET
;; democracy' displays synonyms for `democracy'.
;;
;; If you do not define `synonyms-file' and `synonyms-cache-file'
;; prior to using command `synonyms', that command will prompt you to
;; define them. If you want to use the same values during subsequent
;; Emacs sessions, then you should use `M-x customize-option' to save
;; those newly defined values.
;;
;;
;; Some Definitions
;; ----------------
;;
;; The thesaurus is divided into "entries", which are like glossary
;; entries: each entry is followed by associated words and phrases,
;; which, for lack of a better word, I refer to as "synonyms". For
;; example, `democracy' is an entry, and it is followed by its
;; synonyms. Some synonyms are not also entries. For example,
;; `patriarchy' is in the thesaurus as a synonym but not as an entry.
;;
;; Note: What I call "synonyms" here are not necessarily synonyms, in
;; the sense of having the same or even similar meanings. They are
;; simply terms collected together with the same thesaurus entry
;; because they are related in some way - the grouping is what
;; defines their relation.
;;
;; In Moby Thesaurus II, the meanings of synonyms in the same group
;; do have something in common, but this might be simply the fact
;; that they are terms of a similar kind. For example, the
;; "synonyms" following the `democracy' thesaurus entry are words
;; such as `dictatorship' and `autocracy'. These are different forms
;; of the same general thing: government - they are certainly not
;; synonymous with each other or with the entry `democracy'.
;;
;;
;; Searching the Thesaurus
;; -----------------------
;;
;; The default input value for command `synonyms' is the word under
;; the cursor. Alternatively, if a region is active and you are in
;; Transient Mark mode (recommended), then it is the text in the
;; region (selection).
;;
;; Your input is actually treated as a regular expression (regexp),
;; so you can also input patterns like `for.*ion', which will match
;; thesaurus entries `formation', `formulation', `fornication',
;; `fortification', and `forward motion'. Note that the last of
;; these is a phrase rather than a single word.
;;
;; Using a regexp as input is a powerful way to search, but be aware
;; that it can be costly in CPU time and computer memory if the
;; regexp is not appropriate. The regexp `.*' will, for example,
;; likely use up available memory before being able to return the
;; entire thesaurus (it's very large). You can always use `C-g' to
;; interrupt a thesaurus search if you mistakenly use an inefficient
;; regexp.
;;
;;
;; Using a Prefix Argument To Do More
;; ----------------------------------
;;
;; You can use a prefix argument to modify searching and the
;; presentation of search results, as follows:
;;
;; `C-u' - Search for additional synonyms, in two senses:
;;
;; 1) Return also synonyms that are matched partially
;; by the input.
;;
;; 2) Search the entire thesaurus for input matches,
;; even if the input matches a thesaurus entry.
;;
;; `M--' - Append the search results to any previous search
;; results, in buffer *Synonyms*. (Normally, the new
;; results replace any previous results.)
;;
;; `C-u C-u' - `C-u' plus `M--': Search more and append results.
;;
;; If you find yourself often using a particular prefix argument (for
;; example, to append results), then you might want to instead change
;; the default behavior to reflect this preference. Options
;; `synonyms-match-more-flag' and `synonyms-append-result-flag'
;; correspond to using `C-u' and `M--', respectively. In fact, a
;; prefix argument simply toggles the value of the corresponding
;; option for the duration of the command. So, for example, if
;; `synonyms-append-result-flag' is t and you use `M--', then results
;; will not be appended.
;;
;; When partially matching input (`C-u', sense #1), complete synonyms
;; are matched against your input. This means that you generally
;; need not add a preceding or trailing `.*' to try to match a
;; complete synonym. For example, input `format' will match the
;; complete synonyms `conformation', `efformation', `format',
;; `formation', `formative', `formational', `information',
;; `informative', `informational', `malformation', `deformation',
;; `reformation', `transformation', `reformatory', and so on - there
;; is no need to input `.*format.*' to match the same synonyms.
;;
;; To better understand the meaning of #2 above for `C-u' (to
;; continue the search even if your input matches an entry), try, for
;; example, `C-u M-x synonyms RET widespread'. You'll see not only
;; the main synonyms listed for `widespread' as an entry, but also
;; lots of different meanings of `widespread', judging by the entries
;; for which it is listed as a synonym:
;;
;; `accepted', `ample', `broad', `broadcast', `capacious',
;; `catholic', `commodious', `commonness', `conventional',
;; `currency', `current', `customary', `deep', `deltoid',
;; `diffuse', `discrete', `dispersed', `disseminated',
;; `dissipated', `distributed', `epidemic', `established',
;; `everyday', `expansive', `extended', `extensive', `familiar',
;; `fan shaped', `far flung', `far reaching', `flaring', `full',
;; `general', `indiscriminate', `infinite', `large scale',
;; `liberal', `normal', `normality', `open', `ordinary',
;; `outstretched', `pervasive', `popular', `prescribed',
;; `prescriptive', `prevailing', `prevalence', `prevalent',
;; `public', `rampant', `received', `regnant', `regular',
;; `regulation', `reign', `rife', `roomy', `ruling', `run',
;; `scattered', `set', spacious`', `sparse', `splay', `sporadic',
;; `sprawling', `spread', `standard', `stock', `straggling',
;; `stretched out', `sweeping', `time-honored', `traditional',
;; `universal', `usual', `vast', `voluminous', `wholesale', `wide
;; open', `wide', and `wonted'.
;;
;; These are just the entries! Each of these is of course followed by
;; its own synonyms - perhaps 100 or 300, including `widespread'.
;;
;; This list of entries is not the same list as the synonyms for
;; entry `widespread'. There are words and phrases here that are not
;; in the latter list, and vice versa. For example, the former (but
;; not the latter) list includes `full'; the latter (but not the
;; former) list includes `wide-reaching'.
;;
;; The latter are the words most closely related to `widespread'.
;; The list above are the other thesaurus entries (corresponding to
;; main categories) to which `widespread' is most closely related.
;; Looking at all of the synonym groups in which `widespread' appears
;; can tell you additional information about its meanings - and it
;; can provide additional synonyms for `widespread'.
;;
;;
;; Using Completion with Synonyms
;; ------------------------------
;;
;; You can complete words and phrases in the minibuffer, as input to
;; command `synonyms'. You can use library Synonyms together with
;; library `Icicles to complete a partial word in a text buffer into a
;; word or phrase in the thesaurus. If you use both libraries then
;; load Icicles after Synonyms. For more information on Icicles, see
;; `https://www.emacswiki.org/emacs/Icicles'.
;;
;; ** Minibuffer Input Completion **
;;
;; You can enter any text to match against thesaurus synonyms. When
;; you are prompted by command `synonyms' to enter this text, you can
;; also use input completion to complete to a thesaurus synonym.
;; That is, even though you can enter any text (including a regexp),
;; completion will only complete to synonyms in the thesaurus.
;;
;; If you load library Icicles, then a more powerful version of
;; command `synonyms' is used. In particular, it lets you:
;;
;; - Use `S-TAB' during completion to see the list of all synonyms
;; (thesaurus terms) that match your minibuffer input so far.
;;
;; - Use `next' (or repeated `S-TAB'), and `prior' (usually keys
;; `Page Down' and `Page Up') during completion to cycle through
;; the completion candidates (synonyms) that match your input.
;;
;; - Use `C-next' and `C-prior' during completion to display the
;; synonyms of the current completion candidate.
;;
;; ** Completing Buffer Text Using the Thesaurus **
;;
;; Icicles also provides two commands for using completion to insert
;; thesaurus entries in a buffer:
;;
;; - `icicle-complete-thesaurus-entry' completes a word in a text
;; buffer to any word or phrase in the thesaurus. I bind it to
;; `C-c /'.
;;
;; - `icicle-insert-thesaurus-entry' inserts thesaurus words and
;; phrases in a text buffer. It is a multi-command, which means
;; that, within a single call to it, you can insert any number of
;; thesaurus entries, in succession. If you want to, you can
;; write an entire book using a single call to
;; `icicle-insert-thesaurus-entry'!
;;
;;
;; Browsing the Thesaurus
;; ----------------------
;;
;; Besides using command `synonyms' to search for synonyms, you can
;; use Synonyms to browse the thesaurus. This is really just the
;; same thing, but key and mouse bindings are provided in buffer
;; *Synonyms*, so you need not input anything - just point and click
;; the hyperlinks. Buffer *Synonyms* is in Synonyms major mode,
;; which provides a few additional features.
;;
;; You can still choose to search for additional synonyms or append
;; search results, without bothering with a prefix argument, by using
;; modifier keys (Control, Meta) with a mouse click.
;;
;; Another way of browsing is to revisit previous search-result
;; pages. You can do this using commands `synonyms-history-backward'
;; and `synonyms-history-forward'. In buffer *Synonyms*, these are
;; bound to the following key sequences, for convenience:
;;
;; `l', `p', `mouse-4' - `synonyms-history-backward'
;; `r', `n', `mouse-5' - `synonyms-history-forward'
;;
;; The `l' and `r' bindings correspond to the history bindings in
;; Info. The `p' and `n' bindings stand for "previous" and "next".
;; The bindings to additional mouse buttons correspond to typical
;; bindings for Back and Forward in Web browsers.
;;
;; In addition to these bindings, the same history commands can be
;; accessed by clicking links [Back] and [Forward] with `mouse-2'.
;;
;; If you have previously used the append option (via, for example,
;; `M-mouse2'), so that there are multiple search results in buffer
;; *Synonyms*, then using a history command simply takes you to the
;; preceding (for [Back]) or following (for [Forward]) result in the
;; buffer, measured from the current cursor position. Depending on
;; the cursor position, this might be different from the previous or
;; next search made previously.
;;
;; This is for convenience, but it is also more efficient in the case
;; of a regexp search that takes a long time. Except for this
;; special treatment of appended results, whenever you navigate the
;; search-results history you are actually searching again for a
;; synonym you sought previously. The case of appended results is
;; analogous to accessing a Web browser cache when navigating the
;; history.
;;
;; You can of course use modifier keys (Control, Meta) while you
;; click links [Back] and [Forward], to impose their usual behavior:
;; search for additional synonyms or append search results, or both.
;;
;; Finally, some people prefer menus, so there is a Synonyms menu-bar
;; menu when you are in Synonyms mode, complete with all of the
;; functionalities described above.
;;
;; For more information on the browsing possibilities in buffer
;; *Synonyms*, use `?' in Synonyms mode.
;;
;;
;; Dictionary Definitions, Antonyms, etc.
;; --------------------------------------
;;
;; Synonyms works with a large but simple database of groups of words
;; and phrases that are synonyms of each other. This database does
;; not provide definitions of words or phrases; it simply groups
;; them. Command `synonym-definition' (aka `dictionary-definition')
;; lets you look up a word or phrase (or a regexp) using one or more
;; dictionaries on the Web. That is usually the best source for this
;; kind of information, but you obviously need an Internet connection
;; to use this command.
;;
;; Options (variables) `synonyms-dictionary-url' and
;; `synonyms-dictionary-alternate-url' are URLs you can set to point
;; to the dictionaries of your choice. The default value of
;; `synonyms-dictionary-alternate-url' looks up the search term in
;; multiple dictionaries, and it lets you use wildcards. Use `C-h v
;; synonyms-dictionary-alternate-url' for more information. The
;; default value of `synonyms-dictionary-url' usually provides a
;; quicker answer. Both of these URLs also give you access to
;; additional information about the search term (antonyms, etymology,
;; even pronunciation).
;;
;; In buffer *Synonyms*, you can simply hit `d' followed by `RET' or
;; `mouse-2' to look up a term that is in the buffer. Just as for
;; looking up a synonym by clicking `mouse-2', if you select text
;; (region), then that text is looked up.
;;
;;
;; A Cache File of Synonyms
;; ------------------------
;;
;; The very first time you use Synonyms, a large list of synonyms
;; will be compiled and written to a cache file. This is slow - it
;; takes 2-3 minutes - but it is only a one-time cost. From then on,
;; whenever you first use Synonyms during an Emacs session, the cache
;; file will be read (quickly), to create the list of synonyms that
;; are used for minibuffer completion.
;;
;;
;; Using Other Thesauri, Dictionaries, and so on - CSV data
;; --------------------------------------------------------
;;
;; There is nothing in library Synonyms that ties it to the Moby
;; Thesaurus II thesaurus. All of its functionality will work with
;; any file of comma-separated values. Each line of such a file is
;; interpreted as a synonym group, as understood here, and the first
;; word or phrase on each line is interpreted as a thesaurus entry,
;; as understood here. This means only that search results are
;; organized into sections with entry headers.
;;
;; If, for example, you had a CSV file of personal contacts, where
;; the first term in each line was a last name or a company name,
;; then you could use library Synonyms to query it, producing the
;; same kind of output as for the thesaurus.
;;
;; One thing to keep in mind if you try to use library Synonyms with
;; a different CSV file is that there are several different CSV-file
;; syntaxes. The one that Synonyms is built to use is a simple one,
;; with no quote marks around entries and no embedded quote marks
;; within entries.
;;
;; Similarly, there is nothing here that limits the functionality to
;; English. If you had a thesaurus in another language, it should
;; work as well.
;;
;; Currently, Synonyms works with a single raw synonyms file
;; (thesaurus) and a corresponding single cache file (for
;; completion). However, it would be easy to extend the
;; functionality to use multiple thesauri or, in general, multiple
;; CSV files. Suggestions of requirements (e.g. ways to select a
;; thesaurus for particular passages of text) are welcome.
;;
;;
;; Things Defined Here
;; -------------------
;;
;; Faces defined here -
;;
;; `synonyms-heading', `synonyms-search-text',
;; `synonyms-mouse-face'.
;;
;;
;; User options (variables) defined here -
;;
;; `synonyms-append-result-flag', `synonyms-cache-file',
;; `synonyms-file', `synonyms-fill-column',
;; `synonyms-match-more-flag', `synonyms-mode-hook',
;; `synonyms-use-cygwin-flag'.
;;
;; Commands defined here -
;;
;; `dictionary-definition', `synonyms', `synonyms-append-result',
;; `synonyms-append-result-no-read', `synonyms-definition',
;; `synonyms-definition-mouse', `synonyms-definition-no-read',
;; `synonyms-ensure-synonyms-read-from-cache',
;; `synonyms-history-backward', `synonyms-history-forward',
;; `synonyms-make-obarray', `synonyms-match-more',
;; `synonyms-match-more-no-read',
;; `synonyms-match-more+append-result',
;; `synonyms-match-more+append-result-no-read', `synonyms-mode',
;; `synonyms-mouse', `synonyms-mouse-append-result',
;; `synonyms-mouse-match-more',
;; `synonyms-mouse-match-more+append-result', `synonyms-no-read',
;; `synonyms-write-synonyms-to-cache'.
;;
;; Non-interactive functions defined here -
;;
;; `synonyms-action', `synonyms-add-history-links',
;; `synonyms-default-regexp', `synonyms-define-cache-file',
;; `synonyms-define-synonyms-file', `synonyms-format-entries',
;; `synonyms-format-entry', `synonyms-format-finish',
;; `synonyms-format-synonyms',
;; `synonyms-hack-backslashes-if-cygwin', `synonyms-lookup',
;; `synonyms-nearest-word', `synonyms-file-readable-p',
;; `synonyms-search-entries', `synonyms-search-synonyms',
;; `synonyms-show-synonyms', `synonyms-file-writable-p'.
;;
;; Internal variables defined here -
;;
;; `synonyms-history', `synonyms-history-forward',
;; `synonyms-list-for-obarray', `synonyms-mode-map',
;; `synonyms-obarray', `synonyms-search-text'.
;;
;; Key bindings made here - see `synonyms-mode'. All key bindings
;; are local to Synonyms mode; no global bindings are made here.
;;
;;
;; Acknowledgements
;; ----------------
;;
;; The basic functionality provided here was derived from library
;; `mthesaur.el', by Tad Ashlock <[email protected]>. That
;; library, in turn, was inspired by library `thesaurus.el', by Ray
;; Nickson. Thanks also to those who sent helpful bug reports.
;;
;;
;; Note on MS Windows Emacs 20 and Cygwin `grep'
;; ---------------------------------------------
;;
;; There is apparently a bug in the Emacs (at least versions 20-22) C
;; code that implements function `call-process' on MS Windows. When
;; using native Windows Emacs with Cygwin commands, such as `grep',
;; the C code removes a level of backslashes in some cases, so string
;; arguments supplied to `call-process' need to have twice as many
;; backslashes as they should need in those cases. It is for this
;; reason that option `synonyms-use-cygwin-flag' is supplied here.
;; When that option is non-nil, backslashes in regexps are hacked to
;; do the right thing. (In Emacs 20, this means doubling the
;; backslashes; in Emacs 21-22, this means doubling them unless there
;; are spaces in the search string.)
;;
;;
;; Maybe To Do?
;; ------------
;;
;; 1. It would be ideal to have not only synonym information but also
;; definitions, antonyms, more general and more specific terms,
;; filtering by part of speech (verb vs adjective etc.), and so
;; on. A good example of what I'd really like to have is provided
;; by the free Windows program WordWeb (available here:
;; https://wordweb.info/). Combining that functionality with
;; Icicles completion features would provide a great tool, IMO.
;;
;; `synonyms-definition*' goes a long way toward providing this,
;; and perhaps it is the best way to go, since there is so much
;; more definitional info on the Web.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change Log:
;;
;; 2015/09/19 dadams
;; synonyms-action: Added args APPENDP and MOREP.
;; synonyms, synonyms-history-(backward|forward): Pass APPENDP and MOREP to synonyms-action.
;; synonyms-no-read: Use synonyms-action (same code, factored out).
;; 2012/08/21 dadams
;; Call tap-put-thing-at-point-props after load thingatpt+.el.
;; 2012/08/18 dadams
;; Invoke tap-define-aliases-wo-prefix if thingatpt+.el is loaded.
;; 2012/03/02 dadams
;; Require cl.el at compile time only for Emacs 20.
;; 2011/07/30 dadams
;; Moved Icicles code to icicles-cmd2.el. Removed soft-require of icicles.el.
;; 2011/02/11 dadams
;; Better defaults for faces, for dark backgrounds.
;; 2011/01/04 dadams
;; Added autoload cookies (for defgroup, defface, defcustom, and commands).
;; 2010/08/20 dadams
;; synonyms - non-Icicles version: Made ARG optional too.
;; synonyms(-no-read|-history-(backward|forward)):
;; Use ARG, not current-prefix-arg.
;; 2010/01/12 dadams
;; synonyms-history-(backward|forward): save-excursion + set-buffer -> with-current-buffer.
;; 2007/12/05 dadams
;; synonyms-obarray: Removed * doc-string prefix.
;; 2007/02/10 dadams
;; icicle-sort-case-insensitively -> icicle-case-insensitive-string-less-p.
;; 2006/12/22 dadams
;; Renamed group synonyms to Synonyms. :group 'icicles -> :group 'Icicles.
;; 2006/03/31 dadams
;; synonyms-write-synonyms-to-cache: Use prin1 instead of pp.
;; 2006/03/17 dadams
;; synonyms-file-(read|writ)able-p: Put non-empty string condition first.
;; 2006/03/14 dadams
;; synonyms-file-(read|writ)able-p: Make sure also not a directory.
;; 2006/03/12 dadams
;; synonyms-ensure-synonyms-read-from-cache, synonyms-define-synonyms-file:
;; Set synonyms(-cache)-file to expanded version.
;; 2006/03/01 dadams
;; Updated Commentary to mention Icicles completion of synonyms.
;; 2006/02/02 dadams
;; synonyms-define-cache-file: Fixed typo.
;; 2006/01/28 dadams
;; synonyms-define-cache-file: wrap file-name-directory in expand-file-name.
;; 2006/01/19 dadams
;; synonyms-format-finish: Minor tweak to regexp: space and tab, but not newline or formfeed.
;; 2006/01/18 dadams
;; Added dictionary definition lookup:
;; Added: synonyms-dictionary(-alternate)-url, synonyms-definition*.
;; Bound synonyms-definition-*.
;; 2006/01/14 dadams
;; Bug fixes -
;; Make sure file name is expanded (thanks to Nikos Apostolakis):
;; synonyms-search-(entries|synonyms): Expand file name.
;; synonyms-define-*-file: Set variable after expanding file name.
;; synonyms-format-entry, synonyms-history-*, synonyms-add-history-links:
;; Raise error if search finds nothing.
;; synonyms-hack-backslashes-if-cygwin: Don't double if spaces and not Emacs 20.
;; Renamed synonyms-double-backslashes-if-cygwin to synonyms-hack-backslashes-if-cygwin.
;; synonyms-mode-map: swapped bindings for C-mouse-2 and C-down-mouse-2, for Emacs 22.
;; 2006/01/11 dadams
;; Fixed typo: require 'synonyms. (Thanks to Nikos Apostolakis.)
;; 2006/01/07 dadams
;; Added :link.
;; 2006/01/04 dadams
;; synonyms-format-finish: Don't skip numbered header, so highlight multiple synonyms in entry.
;; 2006/01/02 dadams
;; Added: synonyms-define-cache-file, synonyms-define-synonyms-file,
;; synonyms-file-readable-p, synonyms-file-writable-p.
;; synonyms-make-obarray: Use synonyms-define-synonyms-file.
;; Use synonyms-mode, to get modified syntax (bug fix).
;; synonyms-write-synonyms-to-cache: Use synonyms-define-cache-file.
;; synonyms-ensure-synonyms-read-from-cache: Use synonyms-file-readable-p.
;; synonyms(-cache)-file: Use empty string as initial value.
;; Thanks to Alex Schroeder [[email protected]] for suggestion to prompt for file names.
;; 2005/12/31 dadams
;; Added menu-bar Synonyms menu.
;; Renamed synonyms-read-synonyms-from-cache to synonyms-ensure-synonyms-read-from-cache.
;; Call it from synonyms, not from synonyms-mode.
;; Defined synonyms-mode-map per convention.
;; synonyms-match-more, synonyms-append-result, synonyms-match-more+append-result:
;; Use synonyms, not synonyms-no-read.
;; Added: synonyms-*-no-read. Bound those, not the new read versions.
;; 2005/12/29 dadams
;; Treat modifiers with clicks on [Back] and [Forward] links.
;; synonyms-history-(backward|forward): Add prefix arg. Bind options.
;; synonyms-mode, synonyms-lookup: Disable undo.
;; 2005/12/28 dadams
;; Added: synonyms-history-(backward|forward), synonyms-add-history-links, synonyms-link.
;; Added: [Back] and [Forward] links.
;; synonyms-show-synonyms: Put cursor on first synonym.
;; synonyms-mouse, synonyms-lookup: Removed save-excursion.
;; synonyms-mouse: Treat clicks on [Back] and [Forward] links too.
;; synonyms-format-finish: Added save-excursion for last part: filling and adding mouse-face.
;; synonyms-nearest-word: Remove text properties.
;; synonyms: Use synonym-action.
;; synonyms-lookup: When no synonyms found, remove search-text from history.
;; Require cl.el when compile.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; ;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(eval-when-compile (when (< emacs-major-version 21) (require 'cl))) ;; push, pop
(require 'thingatpt nil t) ;; (no error if not found): word-at-point
(when (and (require 'thingatpt+ nil t);; (no error if not found): word-nearest-point
(fboundp 'tap-put-thing-at-point-props)) ; >= 2012-08-21
(tap-define-aliases-wo-prefix)
(tap-put-thing-at-point-props))
;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Faces (alphabetical) -----------------------------------
;;;###autoload
(defgroup Synonyms nil
"Commands to look up synonyms in a thesaurus."
:prefix "synonyms-"
:group 'convenience :group 'help :group 'apropos :group 'matching
:link `(url-link :tag "Send Bug Report"
,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
synonyms.el bug: \
&body=Describe bug here, starting with `emacs -q'. \
Don't forget to mention your Emacs and library versions."))
:link '(url-link :tag "Other Libraries by Drew"
"https://www.emacswiki.org/emacs/DrewsElispLibraries")
:link '(url-link :tag "Download" "https://www.emacswiki.org/emacs/download/synonyms.el")
:link '(url-link :tag "Description" "https://www.emacswiki.org/emacs/Synonyms")
:link '(emacs-commentary-link :tag "Commentary" "synonyms"))
;;;###autoload
(defface synonyms-heading '((((background dark)) (:foreground "Yellow"))
(t (:foreground "Blue")))
"*Face for different synonym types."
:group 'Synonyms :group 'faces)
;;;###autoload
(defface synonyms-search-text '((t (:foreground "Red")))
"*Face for the term whose synonyms were sought."
:group 'Synonyms :group 'faces)
;;;###autoload
(defface synonyms-link '((((background dark)) (:foreground "Yellow" :underline t))
(t (:foreground "Blue" :underline t)))
"*Face for history links."
:group 'Synonyms :group 'faces)
;;;###autoload
(defface synonyms-mouse-face '((((background dark)) (:background "DarkCyan"))
(t (:background "Cyan")))
"*Mouse face for the term whose synonyms were sought."
:group 'Synonyms :group 'faces)
;;; User Options (alphabetical) ----------------------------
;;;###autoload
(defcustom synonyms-append-result-flag nil
"*t means that `synonyms' appends search result to previous results.
No other value, besides t, has this effect.
This can be overridden by using a negative prefix argument,
for example, `M--'. If you use `C-u C-u', then both this and
`synonyms-match-more-flag' are overridden."
:type 'boolean :group 'Synonyms)
;;;###autoload
(defcustom synonyms-cache-file ""
"*Location to write cache file containing synonyms.
Written to save the list of synonyms used for completion.
This is an absolute (complete-path) location, including the file name."
:type '(file :must-match t) :group 'Synonyms)
;;;###autoload
(defcustom synonyms-file ""
"*Location of thesaurus file `mthesaur.txt'.
This is an absolute (complete-path) location, including the file name."
:type '(file :must-match t) :group 'Synonyms)
;;;###autoload
(defcustom synonyms-fill-column 80
"*Synonyms* buffer text is wrapped (filled) to this many columns."
:type 'integer :group 'Synonyms)
;;;###autoload
(defcustom synonyms-match-more-flag nil
"*t means additional thesaurus entries can be matched by `synonyms'.
No other value, besides t, has this effect.
A value of t means two things:
1) Input can match parts of synonyms, in addition to whole synonyms.
2) All synonyms are shown, even if input matches a thesaurus entry.
This can be overridden by using a positive prefix argument,
for example, `C-u'. If you use `C-u C-u', then both this and
`synonyms-append-result-flag' are overridden."
:type 'boolean :group 'Synonyms)
;;;###autoload
(defcustom synonyms-mode-hook nil
"*Normal hook run when entering Thesaurus mode."
:type 'hook :group 'Synonyms)
;;;###autoload
(defcustom synonyms-use-cygwin-flag nil
"*Non-nil means to double backslashes in arguments to `call-process'.
There is apparently a bug in the Emacs (at least versions 20-22) C
code that implements function `call-process' on MS Windows. When
using native Windows Emacs with Cygwin commands, such as `grep', the C
code removes a level of backslashes, so string arguments supplied to
`call-process' need to have twice as many backslashes as they should
need. If you are using Emacs on Windows and Cygwin `grep', then you
probably will want to use a non-nil value for
`synonyms-use-cygwin-flag'."
:type 'boolean :group 'Synonyms)
;;;###autoload
(defcustom synonyms-dictionary-url "http://dictionary.reference.com/search?q="
"*URL of a Web dictionary lookup. Text to look up is appended to this.
See also `synonyms-dictionaries-url'."
:type 'string :group 'Synonyms)
;;;###autoload
(defcustom synonyms-dictionary-alternate-url "https://www.onelook.com/?ls=b&w="
"*URL of a Web dictionary lookup. Text to look up is appended to this.
The default value, \"http://www.onelook.com/?ls=b&w=\" lets you use `?'
and `*' as wildcards in the terms you look up. These are not used as
regexp wildcards, however. `?' stands for any single character, and
`*' stands for any sequence of characters. In terms of regexp syntax,
`?' here is equivalent to the regexp `.', and `*' is equivalent to the
regexp `.*'. See https://www.onelook.com/?c=faq#patterns for more
information on the allowed wildcard patterns.
See also `synonyms-dictionary-url'."
:type 'string :group 'Synonyms)
;;; Internal variables (alphabetical) ----------------------
(defvar synonyms-history nil "Minibuffer history list for thesaurus lookup.")
(defvar synonyms-history-forward nil
"Minibuffer history list for thesaurus lookup using `synonyms-history-backward'.")
(defvar synonyms-list-for-obarray nil "List of synonyms to be used for completion")
(defvar synonyms-mode-map nil "Keymap for `synonyms-mode'.")
(unless synonyms-mode-map
(let ((map (make-sparse-keymap "Synonyms")))
(define-key map [(?d) (mouse-2)] 'synonyms-definition-mouse)
(define-key map "d\r" 'synonyms-definition-no-read)
(define-key map "s" 'synonyms)
(define-key map [S-return] 'synonyms)
(define-key map "\r" 'synonyms-no-read)
(define-key map [C-return] 'synonyms-match-more-no-read)
(define-key map [M-return] 'synonyms-append-result-no-read)
(define-key map [C-M-return] 'synonyms-match-more+append-result-no-read)
(define-key map [mouse-2] 'synonyms-mouse)
(define-key map [C-mouse-2] 'undefined)
(define-key map [C-down-mouse-2] 'synonyms-mouse-match-more) ; Get rid of `facemenu-mouse-menu'
(define-key map [M-mouse-2] 'synonyms-mouse-append-result)
(define-key map [C-M-mouse-2] 'synonyms-mouse-match-more+append-result)
(define-key map "l" 'synonyms-history-backward) ; As in Info
(define-key map "p" 'synonyms-history-backward) ; As in previous
(define-key map "r" 'synonyms-history-forward) ; As in Info
(define-key map "n" 'synonyms-history-forward) ; As in next
(define-key map [mouse-4] 'synonyms-history-backward)
(define-key map [mouse-5] 'synonyms-history-forward)
(define-key map " " 'scroll-up) ; SPC
(define-key map "\^?" 'scroll-down) ; DEL
(define-key map "?" 'describe-mode)
(define-key map "q" 'quit-window)
(define-key map [menu-bar] (make-sparse-keymap))
(define-key map [menu-bar synonyms] (cons "Synonyms" map))
(define-key map [synonyms-help] '("Help" . describe-mode))
(define-key map [synonyms-separator-2] '("--"))
(define-key map [synonyms-next] '("Show Next" . synonyms-history-forward))
(put 'synonyms-history-forward 'menu-enable 'synonyms-history-forward)
(define-key map [synonyms-previous] '("Show Previous" . synonyms-history-backward))
(put 'synonyms-history-backward 'menu-enable '(and synonyms-history (cdr synonyms-history)))
(define-key map [synonyms-separator] '("--"))
(define-key map [synonyms-more-append]
'("Find (Max), Append Results" . synonyms-match-more+append-result))
(define-key map [synonyms-append]
'("Find, Append Results" . synonyms-append-result))
(define-key map [synonyms-more] '("Find (Max)" . synonyms-match-more))
(define-key map [synonyms-synonyms] '("Find" . synonyms))
(setq synonyms-mode-map map)))
;; 103307 is the smallest prime > 103304, which is the number of synonyms.
(defvar synonyms-obarray (make-vector 103307 0)
"Obarray of synonyms. Used for completion.")
(defvar synonyms-search-text nil "Current text being looked up (matched).")
;;; Functions ----------------------------------------------
;;;###autoload
(define-derived-mode synonyms-mode text-mode "Synonyms"
"Major mode for browsing thesaurus entries (synonyms).
Like Text mode but with these additional key bindings:
\\<synonyms-mode-map>\\[synonyms-mouse], \\[synonyms-no-read], \\[synonyms] - \
Look up synonyms for a word or phrase
\\[synonyms-mouse-match-more], \\[synonyms-match-more] - Like \\[synonyms-no-read], but \
try to match more terms
\\[synonyms-mouse-append-result], \\[synonyms-append-result] - Like \\[synonyms-no-read], but \
add result to previous result
\\[synonyms-mouse-match-more+append-result], \\[synonyms-match-more+append-result] - Like \
\\[synonyms-match-more] and \\[synonyms-append-result] combined
\\[scroll-up] - Scroll down through the buffer of synonyms
\\[scroll-down] - Scroll up through the buffer of synonyms
\\[describe-mode] - Display this help
\\[quit-window] - Quit Synonyms mode
Of the various key bindings that look up synonyms, the most flexible
is \\[synonyms] - it prompts you for the search string to match. This
can be a regular expression (regexp). The other lookup bindings are
for convenience - just click.
In Synonyms mode, Transient Mark mode is enabled.
Options `synonyms-match-more-flag' and `synonyms-append-result-flag'
affect synonym matching and the results. For convenience, \\[synonyms-mouse-match-more],
\\[synonyms-mouse-append-result], and \\[synonyms-mouse-match-more+append-result] \
toggle the effect of those options for the
duration of the command.
Note that even though Synonyms mode is similar to Text mode, buffer
`*Synonyms*' is read-only, by default - use `C-x C-q' to toggle.
Turning on Synonyms mode runs the normal hooks `text-mode-hook' and
`synonyms-mode-hook' (in that order)."
;; Synonyms to account for:
;; `$', `1', `0': $100-a-plate dinner; `2': catch-22, V-2; `3': 3-D; `9': strontium 90.
;; To match `$', you will of course need to escape it: `\$'.
(modify-syntax-entry ?- "w" synonyms-mode-syntax-table) ; Make hyphen (-) a word character.
(modify-syntax-entry ?1 "w" synonyms-mode-syntax-table) ; Make numerals 1,2,3,9,0 word characters.
(modify-syntax-entry ?2 "w" synonyms-mode-syntax-table)
(modify-syntax-entry ?3 "w" synonyms-mode-syntax-table)
(modify-syntax-entry ?9 "w" synonyms-mode-syntax-table)
(modify-syntax-entry ?0 "w" synonyms-mode-syntax-table)
(modify-syntax-entry ?$ "w" synonyms-mode-syntax-table) ; Make dollar ($) a word character.
(buffer-disable-undo)
(setq fill-column synonyms-fill-column)
(set (make-local-variable 'transient-mark-mode) t))
;;;###autoload
(defun synonyms-ensure-synonyms-read-from-cache ()
"Ensure synonyms are in `synonyms-obarray', from `synonyms-cache-file'.
If this file does not yet exist, then it and the obarray are created.
Creating the obarray for the first time takes 2-3 minutes.
This does nothing if the obarray is already complete."
(interactive)
(unless (intern-soft "synonym" synonyms-obarray) ; Do nothing if already complete.
(setq synonyms-list-for-obarray () ; Just to make sure.
synonyms-cache-file (expand-file-name synonyms-cache-file))
(if (synonyms-file-readable-p synonyms-cache-file)
(let ((list-buf (find-file-noselect synonyms-cache-file 'nowarn 'raw))
(obarray synonyms-obarray))
(unwind-protect
(setq synonyms-list-for-obarray (read list-buf))
(kill-buffer list-buf)))
(synonyms-make-obarray) ; Create obarray from scratch
(synonyms-write-synonyms-to-cache)))) ; and write it out, for next time.
;;;###autoload
(defun synonyms-make-obarray ()
"Fill `synonyms-obarray' with the available synonyms."
(interactive)
(unless (intern-soft "synonym" synonyms-obarray) ; Do nothing if already complete.
(synonyms-define-synonyms-file)
(with-temp-message "Building synonyms list for completion. This will take a few minutes..."
(let ((thesaurus-buf (find-file-noselect synonyms-file 'nowarn 'raw))
synonym)
(unwind-protect
(save-current-buffer
(set-buffer thesaurus-buf)
(goto-char (point-min))
(synonyms-mode) ; To use the modified syntax table.
(while (re-search-forward "\\(\\(\\w\\|[ ]\\)+\\)\\(,\\|$\\)" nil t)
(setq synonym (buffer-substring (match-beginning 1) (match-end 1)))
(intern synonym synonyms-obarray)))
(kill-buffer thesaurus-buf))))))
(defun synonyms-define-synonyms-file ()
"Prompt user to define `synonyms-file', unless it is readable."
(setq synonyms-file (expand-file-name synonyms-file))
(unless (synonyms-file-readable-p synonyms-file)
(while (not (synonyms-file-readable-p synonyms-file))
(setq synonyms-file (read-file-name "Thesaurus file: " nil nil 'confirm "mthesaur.txt")))
(custom-set-variables (list 'synonyms-file
(setq synonyms-file (expand-file-name synonyms-file))
'now))))
;;;###autoload
(defun synonyms-write-synonyms-to-cache ()
"Write synonyms in `synonyms-obarray' to file `synonyms-cache-file'."
(interactive)
(synonyms-define-cache-file)
(with-temp-message "Writing synonyms cache file..."
(with-temp-file synonyms-cache-file
(mapatoms (lambda (symb) (push symb synonyms-list-for-obarray)) synonyms-obarray)
(prin1 synonyms-list-for-obarray (current-buffer)))))
(defun synonyms-define-cache-file ()
"Prompt user to define `synonyms-cache-file', unless it is writable."
(unless (synonyms-file-writable-p synonyms-cache-file)
(while (not (synonyms-file-writable-p synonyms-cache-file))
(setq synonyms-cache-file
(read-file-name "Cache file: "
(expand-file-name (file-name-directory synonyms-file)) nil nil
(concat (file-name-nondirectory synonyms-file) ".cache"))))
(custom-set-variables (list 'synonyms-cache-file
(setq synonyms-cache-file (expand-file-name synonyms-cache-file))
'now))))
(defun synonyms-file-readable-p (file)
"Return non-nil if FILE (a string) names a readable file."
(and (not (string= "" file)) (file-readable-p file) (not (file-directory-p file))))
(defun synonyms-file-writable-p (file)
"Return non-nil if FILE (a string) names a writable file."
(and (not (string= "" file)) (file-writable-p file) (not (file-directory-p file))))
(defun synonyms (&optional arg regexp)
"Show synonyms that match a regular expression (e.g. a word or phrase).
You are prompted for the regexp. By default, it is the text
of the region, if it is active and `transient-mark-mode' is enabled,
or the nearest word to the cursor, if not.
Option `synonyms-match-more-flag' non-nil means additional thesaurus
entries can be matched. This can be more time-consuming. It means
two things:
1) Input can match parts of synonyms, in addition to whole synonyms.
2) All synonyms are shown, even if input matches a thesaurus entry.
Option `synonyms-append-result-flag' non-nil means to append search
result to previous results.
A prefix argument toggles the meaning of each of those options for the
duration of the command:
If `C-u' or `C-u C-u', then toggle `synonyms-match-more-flag'.
If negative or `C-u C-u', then toggle `synonyms-append-result-flag'.
\(`C-u C-u' thus means toggle both options.)
When called from Lisp, optional second argument REGEXP is the regexp
to match (no prompting)."
(interactive "P")
(synonyms-ensure-synonyms-read-from-cache) ; Fill `synonyms-obarray', for use in completion.
(let* ((num-arg (prefix-numeric-value arg))
(morep (eq synonyms-match-more-flag (atom arg)))
(appendp (eq synonyms-append-result-flag (and (wholenump num-arg)
(/= 16 num-arg))))
(default-search-text (or regexp (synonyms-default-regexp)))
(search-text (or regexp (let ((case-fold-search t)) ; Case-insensitive completion.
(completing-read
"Show synonyms for word or phrase (regexp): "
synonyms-obarray nil nil nil 'synonyms-history
default-search-text)))))
(synonyms-action search-text appendp morep)))
(defun synonyms-action (search-text appendp morep)
"Helper function for `synonyms*' commands."
(setq synonyms-search-text search-text) ; Save it.
(when (string= "" search-text) (error "No text to look up"))
(unless (member search-text synonyms-history) (push search-text synonyms-history))
;; Change `.' to `[^,]' in `search-text', so we don't mix terms.
(setq search-text (replace-regexp-in-string "\\." "[^,]" search-text nil t))
(synonyms-lookup search-text appendp morep))
;;;###autoload
(defun synonyms-no-read (arg)
"Same as command `synonyms', but uses the default input text (regexp)."
(interactive "P")
(let* ((num-arg (prefix-numeric-value arg))
(morep (eq synonyms-match-more-flag (atom arg)))
(appendp (eq synonyms-append-result-flag (and (wholenump num-arg) (/= 16 num-arg))))
(search-text (synonyms-default-regexp)))
(synonyms-action search-text appendp morep)))
;;;###autoload
(defun synonyms-match-more ()
"Same as using `synonyms' with `synonyms-match-more-flag' = t."
(interactive)
(let ((synonyms-match-more-flag t))
(synonyms)))
;;;###autoload
(defun synonyms-match-more-no-read (arg)
"Same as using `synonyms' with `synonyms-match-more-flag' = t."
(interactive "P")
(let ((synonyms-match-more-flag t))
(synonyms-no-read arg)))
;;;###autoload
(defun synonyms-append-result ()
"Same as using `synonyms' with `synonyms-append-result-flag' = t."
(interactive)
(let ((synonyms-append-result-flag t))
(synonyms)))