# HG changeset patch # User Katsumi Yamaoka # Date 1280702909 0 # Node ID 768a90ad492c2d985dc0b6f087316fab492f9a38 # Parent 9a965dbf641e8c7f339644ffa8edbc44bad6f3b4# Parent fa191ba5051136c4b74e5048d256485a2ae06fd4 Merge from mainline. diff -r 9a965dbf641e -r 768a90ad492c doc/emacs/ChangeLog --- a/doc/emacs/ChangeLog Fri Jul 30 02:11:29 2010 +0000 +++ b/doc/emacs/ChangeLog Sun Aug 01 22:48:29 2010 +0000 @@ -1,3 +1,8 @@ +2010-07-31 Eli Zaretskii + + * files.texi (Visiting): Add more index entries for + large-file-warning-threshold. + 2010-07-29 Jan Djärv * frames.texi (Tool Bars): Add doc for tool-bar-position. diff -r 9a965dbf641e -r 768a90ad492c doc/emacs/files.texi --- a/doc/emacs/files.texi Fri Jul 30 02:11:29 2010 +0000 +++ b/doc/emacs/files.texi Sun Aug 01 22:48:29 2010 +0000 @@ -202,6 +202,8 @@ to reread it. @vindex large-file-warning-threshold +@cindex file, warning when size is large +@cindex size of file, warning when visiting @cindex maximum buffer size exceeded, error message If you try to visit a file larger than @code{large-file-warning-threshold} (the default is 10000000, which is diff -r 9a965dbf641e -r 768a90ad492c doc/misc/ChangeLog --- a/doc/misc/ChangeLog Fri Jul 30 02:11:29 2010 +0000 +++ b/doc/misc/ChangeLog Sun Aug 01 22:48:29 2010 +0000 @@ -1,3 +1,12 @@ +2010-08-01 Alan Mackenzie + + Enhance the manual for the latest Java Mode. + + * cc-mode.texi (Syntactic Symbols): New symbols annotation-top-cont and + annotation-var-cont. + (Java Symbols): Page renamed from Anonymous Class Symbol. Document the + two new symbols. + 2010-07-28 Michael Albinus * tramp.texi (Traces and Profiles): Describe verbose level 9. diff -r 9a965dbf641e -r 768a90ad492c doc/misc/cc-mode.texi --- a/doc/misc/cc-mode.texi Fri Jul 30 02:11:29 2010 +0000 +++ b/doc/misc/cc-mode.texi Sun Aug 01 22:48:29 2010 +0000 @@ -312,19 +312,19 @@ Syntactic Symbols -* Function Symbols:: -* Class Symbols:: -* Conditional Construct Symbols:: -* Switch Statement Symbols:: -* Brace List Symbols:: -* External Scope Symbols:: -* Paren List Symbols:: -* Literal Symbols:: -* Multiline Macro Symbols:: -* Objective-C Method Symbols:: -* Anonymous Class Symbol:: -* Statement Block Symbols:: -* K&R Symbols:: +* Function Symbols:: +* Class Symbols:: +* Conditional Construct Symbols:: +* Switch Statement Symbols:: +* Brace List Symbols:: +* External Scope Symbols:: +* Paren List Symbols:: +* Literal Symbols:: +* Multiline Macro Symbols:: +* Objective-C Method Symbols:: +* Java Symbols:: +* Statement Block Symbols:: +* K&R Symbols:: Customizing Indentation @@ -3971,6 +3971,9 @@ Topmost definition continuation lines. This is only used in the parts that aren't covered by other symbols such as @code{func-decl-cont} and @code{knr-argdecl}. @ref{Function Symbols}. +@item annotation-top-cont +Topmost definition continuation lines where all previous items are +annotations. @ref{Java Symbols}. @item member-init-intro First line in a member initialization list. @ref{Class Symbols}. @item member-init-cont @@ -3999,6 +4002,9 @@ A statement. @ref{Function Symbols}. @item statement-cont A continuation of a statement. @ref{Function Symbols}. +@item annotation-var-cont +A continuation of a statement where all previous items are +annotations. @ref{Java Symbols}. @item statement-block-intro The first line in a new statement block. @ref{Conditional Construct Symbols}. @@ -4112,23 +4118,23 @@ @item inexpr-class A class definition inside an expression. This is used for anonymous classes in Java. It's also used for anonymous array initializers in -Java. @ref{Anonymous Class Symbol}. +Java. @ref{Java Symbols}. @end table @menu -* Function Symbols:: -* Class Symbols:: -* Conditional Construct Symbols:: -* Switch Statement Symbols:: -* Brace List Symbols:: -* External Scope Symbols:: -* Paren List Symbols:: -* Literal Symbols:: -* Multiline Macro Symbols:: -* Objective-C Method Symbols:: -* Anonymous Class Symbol:: -* Statement Block Symbols:: -* K&R Symbols:: +* Function Symbols:: +* Class Symbols:: +* Conditional Construct Symbols:: +* Switch Statement Symbols:: +* Brace List Symbols:: +* External Scope Symbols:: +* Paren List Symbols:: +* Literal Symbols:: +* Multiline Macro Symbols:: +* Objective-C Method Symbols:: +* Java Symbols:: +* Statement Block Symbols:: +* K&R Symbols:: @end menu @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -4233,7 +4239,7 @@ @noindent The primary syntactic symbol for this line is @code{access-label} as -this a label keyword that specifies access protection in C++. However, +this is a label keyword that specifies access protection in C++. However, because this line is also a top-level construct inside a class definition, the analysis actually shows two syntactic symbols. The other syntactic symbol assigned to this line is @code{inclass}. @@ -4740,7 +4746,7 @@ @xref{Custom Macros}, for more info about the treatment of macros. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Objective-C Method Symbols, Anonymous Class Symbol, Multiline Macro Symbols, Syntactic Symbols +@node Objective-C Method Symbols, Java Symbols, Multiline Macro Symbols, Syntactic Symbols @comment node-name, next, previous, up @subsection Objective-C Method Symbols @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -4767,34 +4773,45 @@ assigned @code{objc-method-call-cont} syntax. @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Anonymous Class Symbol, Statement Block Symbols, Objective-C Method Symbols, Syntactic Symbols +@node Java Symbols, Statement Block Symbols, Objective-C Method Symbols, Syntactic Symbols @comment node-name, next, previous, up -@subsection Anonymous Class Symbol (Java) +@subsection Java Symbols @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Java has a concept of anonymous classes which can look something like this: @example - 1: public void watch(Observable o) @{ - 2: o.addObserver(new Observer() @{ - 3: public void update(Observable o, Object arg) @{ - 4: history.addElement(arg); - 5: @} - 6: @}); - 7: @} + 1: @@Test + 2: public void watch(Observable o) @{ + 3: @@NonNull + 4: Observer obs = new Observer() @{ + 5: public void update(Observable o, Object arg) @{ + 6: history.addElement(arg); + 7: @} + 8: @}; + 9: o.addObserver(obs); + 10: @} @end example @ssindex inexpr-class The brace following the @code{new} operator opens the anonymous class. -Lines 3 and 6 are assigned the @code{inexpr-class} syntax, besides the +Lines 5 and 8 are assigned the @code{inexpr-class} syntax, besides the @code{inclass} symbol used in normal classes. Thus, the class will be indented just like a normal class, with the added indentation given to @code{inexpr-class}. An @code{inexpr-class} syntactic element doesn't have an anchor position. +@ssindex annotation-top-cont +@ssindex annotation-var-cont +Line 2 is assigned the @code{annotation-top-cont} syntax, due to it being a +continuation of a topmost introduction with an annotation symbol preceding +the current line. Similarly, line 4 is assigned the @code{annotation-var-cont} +syntax due to it being a continuation of a variable declaration where preceding +the declaration is an annotation. + @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@node Statement Block Symbols, K&R Symbols, Anonymous Class Symbol, Syntactic Symbols +@node Statement Block Symbols, K&R Symbols, Java Symbols, Syntactic Symbols @comment node-name, next, previous, up @subsection Statement Block Symbols @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff -r 9a965dbf641e -r 768a90ad492c etc/ChangeLog --- a/etc/ChangeLog Fri Jul 30 02:11:29 2010 +0000 +++ b/etc/ChangeLog Sun Aug 01 22:48:29 2010 +0000 @@ -1,3 +1,9 @@ +2010-07-31 Eli Zaretskii + + * tutorials/TUTORIAL.he: New file. + + * tutorials/TUTORIAL.translators: Add TUTORIAL.he. + 2010-07-24 Christoph Scholtes * NEWS: Document new --distfiles configure.bat option and diff -r 9a965dbf641e -r 768a90ad492c etc/NEWS --- a/etc/NEWS Fri Jul 30 02:11:29 2010 +0000 +++ b/etc/NEWS Sun Aug 01 22:48:29 2010 +0000 @@ -104,6 +104,9 @@ top, left, tight or bottom. The Options => Show/Hide menu has entries for this. +** Emacs uses GTK tooltips by default if built with GTK. You can turn that +off by customizing x-gtk-use-system-tooltips. + ** Lucid menus and dialogs can display antialiased fonts if Emacs is built with Xft. diff -r 9a965dbf641e -r 768a90ad492c etc/tutorials/TUTORIAL.he --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/tutorials/TUTORIAL.he Sun Aug 01 22:48:29 2010 +0000 @@ -0,0 +1,1037 @@ +שיעור ראשון בשימוש ב-Emacs. זכויות שימוש ראה בסוף המסמך. + +פקודות רבות של Emacs משתמשות במקש CONTROL (לפעמים הוא מסומן ב-CTRL או CTL) +או במקש META (לפעמים מסומן EDIT או ALT). במקום לציין את כל השמות האפשריים +בכל פעם, נשתמש בקיצורים הבאים: + +‏<תו>-C משמעותו לחץ והחזק מקש CONTROL ואז הקש על מקש <תו>. + לדוגמא, C-f משמעותו: לחץ והחזק CONTROL והקש על f. +‏<תו>-M משמעותו לחץ והחזק מקש META או EDIT או ALT ואז הקש על מקש <תו>. + אם במקלדת אין אף אחד ממקשי META או EDIT או ALT, אפשר להקיש + ולשחרר מקש ESC ואז להקיש <תו>. אנו נכתוב עבור מקש ESC. + +הערה חשובה: כדי לצאת מ-Emacs יש להקיש C-x C-c (שני תוים, משמאל לימין). +כדי להפסיק פקודה באמצע ההקשה, יש להקיש C-g. +המחרוזת ">>" בקצה הימני מסמנת הוראות עבורכם כדי לנסות להשתמש בפקודה כלשהי. +לדוגמה: +<<שורות ריקות תתווספנה סביב השורה הבאה ע"י help-with-tutorial>> +[אמצע העמוד הושאר ריק למטרות לימודיות. הטקסט ממשיך להלן] +>> הקישו עתה C-v (הצג העמוד הבא) ע"מ להתקדם לעמוד הבא. (קדימה, נסו זאת + ע"י לחיצה והחזקה של מקש CONTROL והקשה על v.) + מעתה והלאה, עליכם לעשות זאת בכל פעם שתסיימו לקרוא את המוצג על המסך. + +שימו לב לחפיפה של שתי שורות כאשר אתם עוברים ממסך למשך, מה שמבטיח רציפות +מסוימת בעת קריאת הטקסט. + +דבר ראשון שעליכם ללמוד הוא כיצד לנוע ממקום אחד למשנהו בתוך הטקסט. אתם +כבר יודעים כיצד להתקדם לעמוד הבא, עם C-v. לחזרה לעמוד הקודם הקישו M-v +(החזיקו מקש META והקישו v או הקישו ‭v‬ אם אין במקלדת מקש META +או EDIT או ALT). + +>> נסו עתה כמה פעמים להקיש M-v ואח"כ C-v. + + +* סיכום עד כאן +-------------- + +לשם תנועה בעמודים שלמים וצפייה בהם, השתמשו בפקודות הבאות: + + ‏C-v התקדם לעמוד הבא + ‏M-v חזור לעמוד הקודם + ‏C-l נקה תצוגה והצג מחדש את הטקסט, + כך שהטקסט ליד הסמן יימצא במרכז התצוגה + (שימו לב: CONTROL-L ולא CONTROL-1.) + +>> מצאו את הסמן ע"ג התצוגה וזכרו את הטקסט לידו. לאחר מכן הקישו C-l. + מצאו את הסמן שנית ושימו לב שהוא עדיין ליד אותו הטקסט, אבל עכשיו + הוא במרכז התצוגה. + אם תקישו C-l שוב, קטע הטקסט הזה יזוז לקצה העליון של התצוגה. הקישו + C-l שוב והוא יזוז לתחתית התצוגה. + +גם מקשי PageUp ו-PageDn, אם הם קיימים במקלדת שלכם, יכולים לשמש לתנועה +בעמודים שלמים, אולם השימוש ב-C-v ו-M-v יעיל יותר. + +* תנועת סמן בסיסית +------------------ + +תנועה בעמודים שלמים הינה שימושית, אבל כיצד ניתן להגיע למקום ספציפי +בתוך הטקסט ש-ע"ג התצוגה? + +ניתן לעשות זאת בכמה דרכים. אפשר למשל להשתמש במקשי החצים, אולם יהיה +זה יעיל יותר אם תחזיקו את הידיים מעל החלק הסטנדרטי של המקלדת ותשתמשו +בפקודות C-p, C-b, C-f ו-C-n. פקודות אלו שוות ערך לארבעת מקשי החצים, +כדלקמן: + + שורה קודמת, C-p + : + : + קדימה, C-f ... מיקום סמן נוכחי ... אחורה, C-b + : + : + השורה הבאה, C-n + +>> השתמשו במקשי C-n ו-C-p ע"מ להגיע לשורה האמצעית של הדיאגרמה. + הקישו C-l כדי למרכז את הדיאגרמה ע"ג התצוגה. + +קל יותר לזכור את המקשים הללו באמצעות המלים שהם מייצגים: +P מ-previous (קודם), N מ-Next (הבא), B מ-Backward (אחורה) +ו-F מ-Forward (קדימה). מקשי התנועה הבסיסיים הללו ישמשו אתכם כל הזמן. + +>> הקישו C-n כמה פעמים כדי למקם את הסמן בשורה זו. + +>> הניעו את הסמן בתוך השורה עם C-f ואחר-כך למעלה עם C-p. + שימו לב מה עושה C-p כאשר הסמן נמצא באמצע השורה. + +כל שורה של טקטס מסתיימת בתו מיוחד הנקרא Newline. תו זה מפריד בין +השורה לזו שאחריה. (ב-ד"כ, השורה האחרונה בקובץ תסתיים אף היא ב-Newline, +אך Emacs אינו זקוק לכך.) + +>> נסו C-b בתחילת שורה. הוא יגרום לסמן לנוע לסוף השורה הקודמת. זאת, + משום שהוא נע אחורה וחולף על-פני תו ה-Newline. + +גם C-f יכול לחלוף על-פני Newline, בדיוק כמו C-b. + +>> הקישו C-b עוד כמה פעמים כדי לקבל הרגשה היכן נמצא הסמן. + עתה הקישו C-f מספר פעמים הדרוש לשוב לסוף השורה. ואז הקישו + C-f עוד פעם אחת כדי לנוע לתחילת השורה הבאה. + +כשהסמן יוצא מגבולות הטקסט המוצג, חלקי הטקסט מעבר לחלק המוצג נכנסים +לתצוגה. לזה קוראים "גלילה". גלילה מאפשרת ל-Emacs להניע את הסמן למקום +כלשהו בטקסט מבלי שהסמן ייעלם מהתצוגה. + +>> נסו להניע את הסמן אל מחוץ לתצוגה ע"י הקשת C-n ושימו לב למה שקורה. + +אם תנועה תו-תו איטית מדי, תוכלו לנוע מילים שלמות. M-f ‏(META-f) מזיז +את הסמן מילה אחת קדימה ואילו M-b זז מילה אחורה. + +>> הקישו M-f ו-M-b מספר פעמים. + +אם הסמן נמצא באמצע מילה, M-f זז לסוף המילה. אם הסמן נמצא בין שתי מלים, +M-f עובר את המילה הבאה ונעצר בסופה. M-b פועל באופן דומה בכיוון הפוך. + +>> הקישו עתה M-f ו-M-b פעמים אחדות, וגם C-f ו-C-b פה ושם כדי שתוכלו + להתרשם מהתוצאה של M-f ו-M-b במקומות שונים בתוך ובין המלים. + +שימו לב להקבלה שבין C-f ו-C-b מצד אחד ו-M-f ו-M-b מהצד השני. לעתים +קרובות מאד מקשים עם META משמשים לפעולות הקשורות ליחידות של שפה (מלים, +משפטים, פסקאות) ואילו מקשים עם CONTROL פועלים על יחידות בסיסיות שאינן +תלויות בסוג הטקסט שהינכך עורכים (תוים, שורות, וכד'). + +ההקבלה הזאת קיימת גם לגבי שורות ומשפטים: C-a ו-C-e נעים לתחילת השורה +וסופה, בהתאמה, ואילו M-a ו-M-e נעים לתחילת המשפט וסופו. + +>> נסו עתה שתי הקשות על C-a ואחר-כך שתי הקשות על C-e. + נסו שני M-a ואחר-כך שני M-e. + +שימו לב שחזרה על C-a אינה עושה דבר, ואילו כל הקשה חוזרת על M-a מניעה +את הסמן במשפט נוסף. אמנם אין כאן אנלוגיה מושלמת, אבל התוצאה נראית +טבעית בשני המקרים. + +מקום הסמן בתוך הטקסט נקרא "point" ("נקודה"). במלים אחרות, הסמן מראה +את מיקומו של "point" בתוך הטקסט. + +הנה סיכום של פקודות פשוטות להנעת הסמן, כולל פקודות שנעות במלים +ומשפטים שלמים: + + ‏C-f נוע תו אחד קדימה + ‏C-b נוע תו אחד אחורה + + ‏M-f נוע מילה קדימה + ‏M-b נוע מילה אחורה + + ‏C-n נוע לשורה הבאה + ‏C-p נוע לשורה הקודמת + + ‏C-a נוע לתחילת השורה + ‏C-e נוע לסוף השורה + + ‏M-a נוע קדימה לסוף המשפט + ‏M-e נוע אחורה לתחילת המשפט + +>> נסו את כל הפקודות הללו מספר פעמים, לשם תרגול. + אלו הן הפקודות הנפוצות ביותר. + +שתי פקודות תנועה חשובות אחרת הן ‭M-<‬ ‏(META פחות), אשר נעה לתחילת +הטקסט, ו-‭M->‬ ‏(META יותר), אשר נעה לסוף הטקסט. + +ברוב המקלדות המקש ">" נמצא מעל הפסיק, לכן כדי להקישו יש צורך ללחוץ +ולהחזיק מקש Shift. באופן דומה יש ללחוץ על Shift כדי להקיש ‭M-<‬כי +אחרת היה יוצא M-פסיק. + +>> נסו עתה ‭M-<‬ כדי להגיע לתחילת השיעור. + אחר-כך הקישו C-v מספר פעמים, עד שתגיעו לכאן. + +>> עכשיו נסו ‭M->‬ כדי להגיע לסוף השיעור. + לאחר מכן הקישו M-v כמה פעמים כדי לחזור לכאן. + +ניתן להזיז את הסמן גם בעזרת מקשי החצים, אם הם קיימים במקלדת שלכם. +אבל אנחנו ממליצים ללמוד להשתמש ב-C-b, C-f, C-n ו-C-p משלוש סיבות. +קודם כל, הם יעבדו עם כל מקלדת. שנית, כשתתרגלו לעבוד עם Emacs, תראו +כי השימוש במקשים אלו מהיר יותר מהשימוש בחצים (מכיון שאין צורך להזיז +את היד מהחלק העיקרי של המקלדת). ושלישית, כשהמקשים הללו יהפכו להרגל, +יהיה לכם קל יותר ללמוד פקודות מתקדמות יותר של תנועת הסמן. + +רוב הפקודות של Emacs מקבלות ארגומנט נומרי; עבור רוב הפקודות הארגומנט +משמש כמונה של מספר החזרות על הפקודה. כדי לספק ארגומנט לפקודה, יש להקיש +C-u ואחר-כך ספרות, וזאת לפני שמקישים את הפקודה עצמה. עם במקלדת קיים +מקש META (או EDIT או ALT), יש גם אפשרות אחרת לציין ארגומנט נומרי: +הקישו את הספרות תוך כדי החזקת מקש META. אנו ממליצים על C-u משום שהוא +יעבוד עם כל מקלדת. הארגומנט הנומרי נקרא גם "ארגומנט קידומת" (prefix +argument) משום מקישים אותו לפני הפקודה אליה הוא מתייחס. + +למשל, C-u 8 C-f מניע את הסמן 8 תוים קדימה. + +>> נסו להקיש C-n או C-p עם ארגומנט נומרי, כדי להזיז את הסמן אל שורה + מסוימת בפקודה אחת בלבד. + +רוב הפקודות מפרשות את הארגומנט הנומרי כמונה חזרות, אבל פקודות מסוימות +משתמשות בו בצורות אחרות. כמה פקודות (אבל אף אחת מבין אלו שלמדנו עד כה) +משתמשות בו כדגלון -- נוכחותו של הארגומנט, ללא קשר לערכו המספרי, גורמת +לפקודה להתנהג קצת אחרת. + +‏C-v ו-M-v יוצאים מהכלל הזה באופן אחר. כשפקודות אלו מקבלות ארגומנט, +הן גוללים את התצוגה כמספר הזה של שורות, ולא בדפים. למשל, C-u 8 C-v +יגלול את התצוגה ב-8 שורות. + +>> נסו עתה להקיש C-u 8 C-v. + +כתוצאה, התצוגה היתה צריכה לזוז ב-8 שורות. אם ברצונכם לגלול בחזרה, +אפשר להשיג זאת ע"י מתן ארגומנט ל-M-v. + +אם הפעלתם את Emacs על-גבי מערכת חלונאית כגון X או MS-Windows, אתם +צריכים לראות פס צר וגבוה, ששמו פס גלילה (scroll bar) בצידו של החלון +של Emacs. (שימו לב שבשני צידי החלון קיימים פסים נוספים. אלה נקראים +"השוליים" -- "fringes" -- ומשמשים להצגת סימני המשך שורה וסימונים +אחרים. פס הגלילה, לעומתם, מופיע רק בצד אחד והוא הכי קרוב לקצה החלון +בצד ההוא.) + +>> נסו עתה להקליק בכפתור האמצעי של העכבר בחלק העליון של האזור המודגש + של פס הגלילה. פעולה זו אמורה לגלול את הטקסט בשיעור שתלוי במקום בו + הקלקתם. + +>> נסו לגרור את העכבר מעלה ומטה, תוך כדי לחיצה על הכפתור האמצעי. + כתוצאה, Emacs יגלול את הטקסט מעלה ומטה בהתאם לתנועת העכבר. + +אם העכבר שלכם מצויד בגלגל, תוכלו להשתמש גם בו לגלילת הטקסט. + +* אם Emacs מפסיק להגיב +---------------------- + +אם Emacs מפסיק להגיב לפקודות, תוכלו להפסיק אותו בבטחה ע"י הקשת C-g. +פקודות שביצוען מתארך אף הן ניתנות להפסקה בעזרת C-g. + +בנוסף, תגרום הקשת C-g לביטול הארגומנט הנומרי או תחילת הפקודה שטרם +השלמתם להקיש והתחרטתם. + +>> הקישו C-u 100 כדי לציין ארגומנט של 100, ולאחר מכן C-g. עתה הקישו + C-f. הוא צריך לנוע תו אחד בלבד, שכן ביטלתם את הארגומנט בעזרת C-g. + +אם הקשתם בטעות, ניתן לבטלו בעזרת C-g. + +* פקודות מנוטרלות +----------------- + +מספר פקודות ב-Emacs מנוטרלות בכוונה כדי שמשתמשים מתחילים לא יפעילו +אותן בדרך מקרה. + +אם תקישו את אחת הפקודות הללו, Emacs יציג הודעה המתארת את הפקודה וישאל +אם לבצע את הפקודה או לבטלה. + +אם אכן בכוונתכם לנסות את הפקודה, הקישו (מקש הרווח) בתשובה לשאלה. +בדרך כלל, אם אינכם מעוניינים לבצע את הפקודה המנוטרלת, הקישו "n" בתשובה +לשאלה הזו. + +* חלונות +-------- + +תצוגת Emacs יכולה לכלול יותר מחלון אחד, כשכל אחד מהם מציג טקסט משלו. +מאוחר יותר נסביר כיצד להשתמש בחלונות מרובים. כעת ברצוננו להסביר כיצד +להפטר מחלונות מנותרים ולחזור לעריכה בחלון יחיד. אין דבר פשוט מזה: + + ‏C-x 1 חלון אחד בלבד (כלומר, סגור את כל החלונות האחרים). + +כדי להפעיל פקודה זו, הקישו CONTROL-x ולאחריו את הספרה 1. הפקודה C-x 1 +מרחיבה את החלון המציג את הסמן כך שהוא תופס את כל שטח התצוגה. הפקודה +מבטלת את שאר החלונות. + +>> הניעו את הסמן לתוך שורה זו והקישו C-u 0 C-l. +>> עתה הקישו CONTROL-h k CONTROL-f. + שימו לב כיצד החלון הנוכחי מצטמצם ומופיע חלון חדש שבו מוצג + התיעוד של הפקודה CONTROL-f. + +>> הקישו C-x 1 ושימו לב שהחלון עם ההסבר על C-f נעלם. + +פקודה זו שונה מכל שאר הפקודות שלמדנו עד כה בכך שהיא מכילה שני תוים. +היא מתחילה עם התו CONTROL-x. פקודות רבות מאד מתחילות ב-CONTROL-x; חלק +גדול מהן עוסקות בחלונות, קבצים, חוצצים ונושאים דומים אחרים. פקודות אלו +מכילות שנים, שלושה ואפילו ארבעה תוים. + + +* הכנסה ומחיקה +------------- + +אם ברצונכם להכניס טקסט, פשוט הקישו על המקשים המתאימים. תוים רגילים, +כגון A, א, 7, * וכד' מתפרשים ע"י Emacs כטקסט ומיד מתווספים לטקסט +הקיים. הקישו (מקש חזרת גרר) כדי להכניס את תו השורה החדשה +(Newline). + +למחיקת התו האחרון שהקשתם הקישו . המקש שאנו קוראים לו +יכול להתקרא בשמות שונים -- "Delete", "DEL" או "Backspace". בדרך כלל +זהו מקש גדול ובולט שנמצא לא הרחק ממקש , והוא משמש אתכם למחיקת +התו אחרון גם בתוכניות אחרות, לא רק ב-Emacs. + +אם קיים במקלדת שלכם מקש גדול שעליו רשום , אז זהון המקש אשר +ישמש כ-. גם אם יהיה מקש אחר המסומן ב-"Delete" במקום אחרת זה +אינו ה- שלכם. + +באופן כללי יותר, מוחק את התו שקודם למיקום הסמן. + +>> הקישו עתה מספר תוים, ואחר-כך מחקו אותם ע"י הקשות אחדות + על . אל תחששו לשנות את הקובץ הזה -- העותק המקורי + של השיעור יישאר ללא שינוי. אתם עובדים על העותק האישי שלכם. + +כאשר שורה של טקסט נעשית ארוכה משורה אחת של תצוגה, חלק מהטקסט ממשיך +בשורת תצוגה נוספת, היא "שורת ההמשך". תו לוכסן ("/") בסוף השורה (או +חץ עקלקל קטן באזור השוליים -- "fringe") מסמל שלשורה יש שורת המשך. + +>> הקישו טקסט עד שתגיעו לקצה השורה, ואז תמשיכו להקיש עוד טקסט. + כתוצאה, תראו שמופיעה שורת המשך. + +>> עתה הקישו ע"מ למחוק טקסט עד שהשורה תיעשה קצרה מספיק + ותתאים לשורה בודדת ע"ג התצוגה. שורת ההמשך תיעלם. + +ניתן למחוק את תו ה-Newline כמו כל תו אחר. מחיקת ה-Newline בין שתי +שורות תמזג את השורות לשורה אחת. אם השורה המשולבת תהיה ארוכה מרוחב +התצוגה, היא תוצג עם שורת המשך. + +>> הניעו את הסמן לתחילת השורה והקישו . כתוצאה, השורה תתמזג + אם קודמתה. + +>> עתה הקישו כדי להחזיר את ה-Newline שמחקתם. + +זכרו כי לרוב הפקודות ב-Emacs אפשר לציין מספר חזרות. גם תוי טקסט +שייכים לקבוצת פקודות זו. חזרה על תו טקסט מכניסה אותו מספר פעמים. + +>> נסו זאת עכשיו -- הקישו ‪C-u 8 *‬ ע"מ להכניס ********. + +ובכן, למדתם את האופן הבסיסי ביותר להדפיס משהו ב-Emacs ולתקן שגיאות. +אפשר למחוק גם מלים ואף שורות שלמות. להלן סיכום פקודות המחיקה: + + ‏ מחק תו שלפני הסמן + ‏C-d מחק תו מתחת או אחרי הסמן + + ‏‭M-‬ גזור מילה שלפני הסמן + ‏M-d גזור מילה שאחרי הסמן + + ‏C-k גזור טקסט מהסמן ועד סוף השורה + ‏M-k גזור טקסט עד סוף המשפט הנוכחי. + +שימו לב שהיחס בין ו-C-d לעומת M-‎ ו-M-d ממשיכים את +ההקבלה שבין C-f ו-M-f (אמנם איננו תו בקרה, בוא נזניח את +הנקודה הזו לעת-עתה). C-k ו-M-k דומים ל-C-e ו-M-e, אם נקביל שורות +למשפטים. + +בנוסף, קיימת שיטה אחידה שמאפשרת לגזור קטע כלשהו של טקסט. לשם כך, תגיעו +לקצה האחד של חלק הטקסט והקישו C-@‎ או C-‎ (אחד מבין שני אלו). +( הוא מקש הרווח.) עתה הניעו את הסמן לקצה השני של חלק הטקסט והקישו +C-w. כתוצאה, כל הטקסט בין שני המקומות הללו ייגזר. + +>> הניעו את הסמן אל האות ב בתחילת הפיסקה הקודמת. +>> הקישו C-‎. ‏Emacs צריך להציג הודעה האומרת "Mark set" בתחתית + התצוגה. +>> הניעו את הסמן אל האות צ בשורה השניה של הפיסקה. +>> הקישו C-w. בכך תגזרו את חלק הטקסט שמתחיל ב-ב ומסתיים לפני ה-צ. + +ההבדל בין "מחיקה" ("deletion") ו-"גזירה" ("killing") הוא שהטקסט +"הגזור" ניתן לאחזור ולהכנסה (במקום כלשהוא בטקסט), ואילו טקסט "מחוק" לא +ניתן להכניס מחדש בשיטה זו. (אבל ניתן לבטל את מחיקה -- ראה להלן.) אחזור +הטקסט הגזור נקרא "הדבקה" ("yanking"). באופן כללי, פקודות אשר עלולות +להעלים כמויות גדולות של טקסט תמיד גוזרות את הטקסט (כך שניתן יהיה בקלות +לשחזרו) בעוד הפקודות שמורידות תו בודד או שורות ריקות ותוי רווח -- +מוחקות (כך שלא ניתן להדביק את הטקסט שנמחק). כך, ו-C-d מוחקים +כאשר מפעילים אותם ללא ארגומנט, אבל גוזרים כאשר מפעילים אותם עם ארגומנט. + +>> הניעו את הסמן לתחילת שורה שאינה ריקה. אחר-כך הקישו C-k כדי לגזור + את כל הטקסט של אותה שורה. +>> הקישו C-k פעם נוספת. שימו לב שהוא גוזר את ה-Newline שבסוף השורה. + +שימו לב ש-C-k בודד גוזר את תכולת השורה, ו-C-k נוסף גוזר גם את השורה +עצמה וגורם לשאר השורות לנוע כלפי מעלה. C-k מפרש את הארגומנט הנומרי +באופן מיוחד: הוא גוזר כמספר הזה שורות, כולל ה-Newlines שלהן. זה שונה +מסתם הפעלה חוזרת: C-u 2 C-k גוזר שתי שורות כולל ה-Newlines שלהן, +ואילו הקשה על C-k פעמיים לא עושה כן. + +אחזור הטקסט שגזרנו נקרא "הדבקה" ("yanking"). (תחשבו על זה כעל שליפה +של טקסט מתהום הנשייה אליה הוא נלקח.) ניתן להדביק את הטקסט שגזרתם +באותו מקום ממנו נגזר או במקום אחר כלשהו בתוך הטקסט שאתם עורכים, או +אפילו בקובץ אחר. ניתן להדביק את אותו הטקסט מספר פעמים ובכך ליצור +עותקים מרובים ממנו. תוכניות עריכה אחרות משתמשות במונחים "cutting" +ו-"pasting" במקום "killing" ו-"yanking" (ראה את מילון המונחים בפרק +ה-"Glossary" של מדריך למשתמשי Emacs). + +הפקודה להדבקה היא C-y. היא מכניסה את הטקסט הגזור במקום הנוכחי של הסמן. + +>> נסו זאת: הקישו C-y כדי לאחזר טקסט שגזרתם קודם לכן. + +אם תקישו C-k מספר פעמים ברצף, כל הטקסט שגזרתם בדרך זו נשמר ביחד, כך +ש-C-y בודד ידביק את כולו בבת אחת. + +>> עשו זאת עתה: הקישו C-k כמה פעמים. + +עכשיו לאחזור הטקסט שגזרתם: + +>> הקישו C-y. אחר-כך הניעו את הסמן כמה שורות כלפי מטה והקישו C-y שוב. + כפי שראיתם, כך תוכלו להעתיק חלק מהטקסט ממקום למקום. + +מה לעשות אם יש לכם טקסט להדבקה, אבל בינתיים גזרתם טקסט אחר? C-y ידביק +רק את הגזירה האחרונה. אולם הטקסט שגזרתם קודם לכן אינו הלך לאיבוד. ניתן +לאחזרו בעזרת הפקודה M-y. אחרי שהקשתם C-y שמדביק את הטקסט שגזרתם +לאחרונה, הקשה על M-y מחליפה את הטקסט המודבק בטקסט שגזרתם בפעם לפני +האחרונה. הקשה חוזרת ונשנית על M-y מביאה טקסט שגזרתם בפעמים קודמות יותר +ויותר. כשתראו שהטקסט המודבק הוא מה שרציתם להדביק, תפסיקו להקיש M-y +ותמשיכו בעריכה כרגיל. אין צורך בשום פקודה מיוחדת לשם כך. + +אם תקישו M-y מספיק פעמים בזו אחר זו, תגיעו חזרה לנקודת ההתחלה (טקסט +שגזרתם לאחרונה). + +>> גזרו שורה, אחר-כך תניעו את הסמן אנה ואנה, ולבסוף גזרו שורה נוספת. + הקישו C-y כדי לאחזר את השורה השניה שגזרתם. + עתה הקישו M-y והשורה שאחזרתם תוחלף בשורה הראשונה שגזרתם. + הקישו M-y מספר פעמים נוספות ושימו לב לתוצאות. המשיכו להקיש M-y + עד שהשורה השניה שגזרתם תופיע שוב, ואז תמשיכו עוד מספר פעמים. + אם תרצו, תוכלו לנסות M-y עם ארגומנט חיובי או שלילי. + + +* ביטול פעולות +-------------- + +אם שיניתם את הטקסט ואז החלטתם שהשינוי היה טעות, תוכלו לבטל את השינוי +בעזרת פקודת הביטול, C-x u. + +בדרך כלל, C-x u מבטל את השינויים שבוצעו ע"י פקודה אחת. הפעלה חוזרת של +C-x u ברצף מבטלת שינויים של פקודות קודמות, אחת אחרי השניה. + +שני יוצאים מהכלל הזה: פקודות שאינן משנות טקסט (למשל פקודות הנעת הסמן +ופקודות גלילה) אינן נספרות ותוים שמכניסים את עצמם מקובצים בקבוצות של +עד 20, כדי להקטין את מספר הפעמים שיש להקיש C-x u כדי לבטל הכנסת טקסט. + +>> גזרו שורה זו עם C-k, אחר-כך הקישו C-x u והיא תופיע שוב. + +‏C-_‎ הינה דרך חלופית להפעיל את פקודת הביטול. היא פועלת בדיוק כמו C-x u, +אבל קלה יותר להקשה מספר פעמים בזו אחר זו. החסרון של C-_‎ הוא שבכמה +מקלדות לא ברור מאליו כיצד להקיש זאת. זו הסיבה לקיומו של C-x u. במקלדות +אחדות ניתן להקיש C-_‎ ע"י החזקת CONTROL והקשת לוכסן /. + +ארגומנט נומרי ל-C-_‎ או ל-C-x u משמש כמספר החזרות על הפקודה. + +ניתן לבטל מחיקה של טקסט בדיוק כמו שניתן לבטל גזירה. ההבדלים בין מחיקה +וגזירה משפיעים על יכולתכם להדביק את הטקסט הגזור עם C-y; הם אינם חשובים +לעניין הביטול. + + +* קבצים +------- + +ע"מ שהטקסט שערכתם יישמר, יש לשים אותו בקובץ. אחרת, הוא ייעלם ברגע +שתצאו מ-Emacs. כדי לשים את הטקס בקובץ, יש "לפתוח" ("find") את הקובץ +לפני שמתחילים להקיש טקסט. (שם אחר לכך הוא "לפקוד" את הקובץ - "visit".) + +פתיחת הקובץ משמעותה שתוכן הקובץ מוצג בתוך Emacs. מבחינות רבות הדבר +דומה לעריכת הקובץ עצמו. אולם, השוניים שלכם בתוך Emacs אינם הופכים חלק +מהקובץ עד שאתם "שומרים" את הקובץ. זאת, כדי להימנע מיצירת קובץ שאינו +שלם במערכת שלא כרצונכם. אפילו אם אתם שומרים את הקובץ, Emacs משאיר את +התוכן המקורי בשם שונה למקרה שמאוחר יותר תחליטו שהשינויים נעשו בטעות. + +אם תביטו בחלק התחתון של התצוגה, תראו שם שורה בולטת שמתחילה ומסתיימת +במקפים וליד הקצה השמאלי שלה כתוב "TUTORIAL.he". חלק זה של התצוגה בדרך +כלל מציג את שם הקובץ אותו אתם פוקדים. כרגע אתם פוקדים קובץ בשם +"TUTORIAL.he" שהוא עותק הטיוטה האישי שלכם של שיעור השימוש ב-Emacs. +פתיחת קובץ כלשהו ב-Emacs תציג את שמו של הקובץ במקום זה. + +היבט אחד מיוחד של פתיחת קובץ הוא שיש לציין את שם הקובץ אשר ברצונכם +לפתוח. אנו אומרים שהפקודה "קוראת ארגומנט מהמסוף" (במקרה זה הארגומנט +הוא שם הקובץ). אחרי שתקישו את הפקודה + + ‏C-x C-f פתח קובץ + +‏Emacs מבקש שתקישו את שם הקובץ. שם הקובץ שתקישו מופיע בשורה התחתונה של +התצוגה. שורה זו נקראת "מיני-חוצץ" ("minibuffer") כשהיא משמשת לסוג זה +של קלט. ניתן להשתמש בכל פקודות העריכה הרגילות של Emacs כשמקישים את +שם הקובץ בחוצץ זה. + +אם טרם סיימתם להקיש את שם הקובץ (או כל סוג אחר של קלט במיני-חוצץ), +ניתן לבטל את הפקודה בעזרת C-g. + +>> הקישו C-x C-f ואחר-כך הקישו C-g. זה מבטל את המיני-חוצץ וגם מבטל + את הפקודה C-x C-f שהשתמשה במיני-חוצץ. התוצאה היא שאף קובץ לא נפתח. + +משסיימתם להקיש את שם הקובץ, הקישו לסיים את הקלט. או-אז תיגש +C-x C-f לעבודה ותמצא ותפתח את הקובץ שבחרתם. המיני-חוצץ נעלם כאשר +פקודת ה-C-x C-f תסיים את עבודתה. + +זמן קצר אחר-כך תוכן הקובץ יופיע ע"ג התצוגה ותוכלו לבצע בו שינויים. +כשתחליטו לשמור את השינויים, הקישו את הפקודה הבאה: + + ‏C-x C-s שמור את הקובץ + +פקודה זו שומרת בקובץ את הטקסט המוחזק בתוך Emacs. בפעם הראשונה שתפעילו +פקודה זו, Emacs משנה את שם הקובץ המקורי לשם חדש כך שהמקור לא ילך +לאיבוד. השם החדש נוצר ע"י הוספת "~" בסוף השם המקורי של הקובץ. + +כשהשמירה מסתיימת, Emacs מציג בשורה התחתונה את שם הקובץ שנשמר. נסו +לשמור לעתים מזומנות ע"מ להימנע מלאבד יותר מדי מהעבודה שלכם אם המחשב +ייפול (ראה להלן פיסקה על שמירה אוטומטית). + +>> הקישו C-x C-s כדי לשמור את העותק שלכם של השיעור. + כתוצאה, תופיע ההודעה "Wrote ... TUTORIAL.he" בתחתית התצוגה. + +ניתן לפתוח קובץ קיים ע"מ לצפות בו או לערוך אותו. ניתן גם לפתוח קובץ +שאינו קיים. זו הדרך ליצור קבצים חדשים בעזרת Emacs: פתחו את הקובץ +שיהיה תחילה ריק ואז התחילו להקיש טקסט לתוכו. כשתפעילו את פקודת השמירה, +Emacs ייצור את הקובץ עם הטקסט שהקשתם. מאותו רגע ואילך, תוכלו לחשוב +שהינכם עורכים קובץ קיים. + + +* חוצצים +-------- + +אם תפתחו קובץ נוסף עם C-x C-f, הקובץ הראשון עדיין נשאר פתוח ב-Emacs. +תוכלו לחזור אליו ע"י C-x C-f. כך תוכלו לפתוח מספר רב של קבצים. + +>> ניצור עתה קובץ בשם "foo" ע"י הקשת C-x C-f foo ‎. + אחר-כך הכניסו קצת טקסט, ערכו אותו ולבסוף שמרו בקובץ "foo" + ע"י C-x C-s. עתה חזרו לשיעור בעזרת C-x C-f TUTORIAL.he ‎. + +‏Emacs מחזיק כל קובץ בתוך יישות בשם "חוצץ" ("buffer"). פתיחת קובץ יוצרת +חוצץ חדש בתוך Emacs. כדי לראות את רשימת החוצצים הקיימים בתוך Emacs, +הקישו + + ‏C-x C-b הצג רשימת כל החוצצים + +>> נסו את C-x C-b בנקודה זו. + +שימו לב שלכל חוצץ יש שם וכל חוצץ עשוי גם לציין את שם הקובץ שאת תוכנו +הוא מחזיק. כל טקסט שאתם מקישים בחלון Emacs תמיד יהיה חלק של חוצץ +כלשהו. + +>> הקישו C-x 1 כדי להפטר מרשימת החוצצים. + +כשקיימים מספר חוצצים, רק אחד מהם יכול להיות החוצץ "הנוכחי" בכל רגע +נתון. זהו החוצץ בו אתם מבצעים עריכה באותו רגע. אם ברצונכם לערוך חוצץ +אחר, עליכם "לעבור" חוצץ. עבור חוצצים שמתאימים לקבצים, ניתן לעשות זאת +ע"י C-x C-f שיפקוד את הקובץ בשנית. אבל קיימת דרך פשוטה יותר: שימוש +בפקודה C-x b. פקודה זו תחייב אותכם להקיש את שם החוצץ. + +>> הקישו C-x b foo ‎ כדי לחזור לחוצץ "foo" אשר מחזיק טקסט של + הקובץ "foo". אחר-כך הקישו C-x b TUTORIAL.he ‎ כדי לשוב + לשיעור זה. + +ברוב המקרים שם החוצץ זהה לשם הקובץ (ללא שם התיקיה שלו). אבל אין זה +תמיד כך. רשימת החוצצים שנוצרת ע"י C-x C-b תמיד תציג את שמות כל החוצצים +הקיימים ב-Emacs. + +כל טקסט שמוצג בחלון של Emacs הינו תמיד חלק של חוצץ כלשהו. קיימים +חוצצים שאינם קשורים לשום קובץ. לדוגמא, החוצץ בשם "*Buffer List*" אינו +מציג שום קובץ. זהו חוצץ המחזיק את רשימת החוצצים שנוצר ע"י C-x C-b. +חוצץ בשם "*Messages*" אף הוא אינו קשור לשום קובץ; הוא מחזיק את ההודעות +שהופיעו בשורה התחתונה במהלך עבודתכם בתוך Emacs. + +>> הקישו C-x b *Messages* ‎ כדי לצפות בחוצץ של הודעות. + אחר-כך הקישו C-x b TUTORIAL.he ‎ ע"מ לחזור לשיעור זה. + +אם עשיתם שינויים בטקסט של קובץ ואחר-כך פתחתם קובץ אחר, אין הדבר שומר +את השינויים שעשיתם לקובץ הראשון. השינויים הללו נשארים בתוך Emacs, בתוך +החוצץ של אותו קובץ. יצירתו ועריכתו של הקובץ הנוסף אינם משפיעים על +החוצץ של הקובץ הראשון. דבר זה הוא שימושי, אך משמעותו היא שיש צורך +בשיטה נוחה לשמור את החוצץ של הקובץ הראשון. היה זה מאד לא נוח אילו +לשם כך הייתם צריכים לעבור לחוצץ ההוא בעזרת C-x C-f ואז לשמור עם +C-x C-s. לכן קיימת פקודה + + ‏C-x s שמור חוצצים אחדים + +‏C-x s עובר על כל החוצצים אשר מכילים שינויים שטרם נשמרו. לגבי כל חוצץ +כזה הוא שואל אתכם האם לשמור אותו או לא. + +>> הכניסו שורה של טקסט ואחר-כך הקישו C-x s. + הוא צריך לשאול האם לשמור חוצץ בשם TUTORIAL.he. + השיבו בחיוב ע"י הקשה על "y". + + +* הרחבת אוסף הפקודות +-------------------- + +מספר הפקודות ב-Emacs גדול בהרבה ממה שניתן להפעיל ע"י כל תוי ה-control +וה-meta. כדי להתגבר על בעיה זו, Emacs משתמש בפקודות X המרחיבות (eXtend) +את אוסף הפקודות הרגיל. פקודות הרחבה אלו הן שתים: + + ‏C-x הרחבת תו. תו בודד שבא אחריו משלים את הפקודה. + ‏M-x הרחבה ע"י שם הפקודה. אחריו בא שם ארוך של פקודה. + +בעזרת שתי אלו ניתן להפעיל פקודות שימושיות שבהן משתמשים לעתים רחוקות +יותר מאשר פקודות שלמדתם עד עכשיו. כמה מהן כבר ראיתם: C-x C-f לפתיחת +קובץ, ו-C-x C-s לשמירת קובץ, לדוגמא. דוגמא נוספת היא פקודה לצאת +מ-Emacs -- ‏C-x C-c. (כשאתם מפעילים C-x C-c, אל תדאגו לשינויים שטרם +נשמרו; C-x C-c מציע לשמור כל קובץ ששיניתם לפני שהוא מסיים את Emacs.) + +אם אתם משתמשים בצג גרפי אשר תומך במספר תוכניות במקביל, אינכם זקוקים +לפקודה מיוחדת כדי לעבור מ-Emacs לתוכנית אחרת. אפשר לעשות זאת בעזרת +העכבר או פקודות של מנהל החלונות. אולם, כאשר אתם משתמשים בתצוגה +טקסטואלית שמסוגלת להציג רק תוכנית אחת בו-זמנית, תצטרכו "להשעות" +("suspend") את Emacs ע"מ לעבור לתוכנית אחרת. + +הפקודה C-z יוצאת מ-Emacs *באופן זמני* -- כך שתוכלו לשוב אליו מאוחר +יותר ולהמשיך מאותה נקודה. כאשר Emacs רץ על תצוגת טקסט, C-z "משעה" את +Emacs: הוא מחזיר אתכם לשורת הפקודות הבסיסית של מערכת ההפעלה ("shell"), +אבל אינו מסיים את Emacs. ברוב המערכות, כדי להמשיך בעבודתכם ב-Emacs, +תצטרכו להקיש את הפקודה "fg" או ‭"%emacs"‬. + +הרגע הנכון להשתמש ב-C-x C-c הוא כאשר אתם עומדים להתנתק (log out). +כמו-כן, תצטרכו להשתמש בו כדי לצאת מ-Emacs שהופעל ע"י תוכניות אחרות +כגון קריאת דוא"ל -- תוכניות אלו לא תמיד יודעות להסתדר עם השעיית Emacs. + +קיימות פקודות C-x רבות מאד. להלן רשימת אלו שכבר למדתם: + + ‏C-x C-f פתח קובץ + ‏C-x C-s שמור קובץ + ‏C-x s שמור חוצצים אחדים + ‏C-x C-b הצג רשימת חוצצים + ‏C-x b החלף חוצץ + ‏C-x C-c צא מ-Emacs + ‏C-x 1 השאר רק חלון אחד ומחק כל השאר + ‏C-x u בטל פקודה אחרונה + +הרחבה ע"י שם הפקודה שימושית עם פקודות עוד יותר נדירות או פקודות +ספציפיות רק לאופני פעולה (modes) מיוחדים. דוגמא לכך היא פקודה +replace-string (החלף מחרוזת) אשר מחליפה מחרוזת אחת במשנה בכל החוצץ. +אחרי שתקישו M-x, ‏Emacs מציג M-x בתחתית התצוגה ומחכה שתקישו את שם +הפקודה, במקרה זה "replace-string". מספיק שתקישו "repl s‎" ו-Emacs +ישלים את השם המלא. ( הוא מקש Tab, בדרך כלל תמצאו אותו מעל מקש +ה-CapsLock או Shift, ליד הקצה השמאלי של המקלדת.) סיימו את שם הפקודה +ע"י הקשת . + +הפקודה להחלפת מחרוזת זקוקה לשני ארגומנטים -- המחרוזת שתוחלף וזו שתחליף +אותה. סיימו הקשה של כל אחת מהן ע"י . + +>> הביאו את הסמן שתי שורות מתחת לשורה זו. + עתה הקישו M-x repl schangedaltered‎. + + שימו לב שהמילה "changed" בשורה זו שתנתה: זה עתה החלפתם את + המילה c-h-a-n-g-e-d במילה "altered" בכל מקום בו היא נמצאת אחרי + הסמן. + + +* שמירה אוטומטית +---------------- + +שינויים שערכתם בקובץ אבל טרם שמרתם עלולים ללכת לאיבוד אם המחשב שלכם +נתקע. ע"מ להגן עליכם מפני סכנה זו, Emacs שומר לעתים מזומנות כל קובץ +שנמצא בעריכה. השמירה האוטומטית הזאת נעשית לקובץ נפרד ששמו מתחיל +ומסתיים בתו #. לדוגמא, אם הינכם עורכים קובץ בשם "hello.c", קובץ השמירה +האוטומטית שיווצר עבורו ייקרא "#hello.c#". שמירה רגילה של הקובץ על ידכם +מוחקת את קובץ השמירה האוטומטית. + +אם המחשב אכן נתקע, תוכלו לנציל את השינויים שלא הספקתם לשמור. לשם כך, +יש לפתוח את הקובץ כרגיל (את הקובץ בשמו המקורי, לא את קובץ השמירה +האוטומטית), ואחר-כך להקיש M-x recover-file ‎. כש-Emacs יבקש +אישור, הקישו yes‎ כדי ש-Emacs ישחזר את הקובץ כפי שנשמר +אוטומטית. + + +* תצוגת הד +---------- + +אם Emacs מגלה שאתם מקישים פקודה לאט, הוא מציג את שהקשתם בתחתית התצוגה, +באזור שנקרא "אזור תצוגת הד". אזור זה משתמש בשורה התחתונה של התצוגה. + + +* שורת סטטוס +------------ + +השורה שמעל אזור תצוגת הד נקראת "שורת הסטטוס" (mode line). שורה זו +מציגה משהו כמו: + + -U:**- TUTORIAL.he 63% L651 (Fundamental)----------------------- + +שורה זו מציגה מידע חשוב לגבי מצבו של Emacs ולגבי הטקסט שנמצא בעריכה. + +אתם כבר יודעים מהי משמעותו של שם הקובץ -- זהו הקובץ שפתחתם. NN%‎ מציין +את מיקומכם הנוכחי בתוך הטקסט, לאמור כי NN אחוזים מהטקסט קודמים לטקסט +המוצג כרגע בחלון. אם המוצג בחלון כולל את תחילת הטקסט, תראו שם "Top" +במקום "0% ". אם המוצג בחלון כולל את סוף הטקסט, תראו שם "Bot" ‏(bottom). +אם הטקסט כל-כך קצר שכולו מוצג בחלון, שורת הסטטוס תציג "All". + +האות L והמספר שאחריה מציינים את המיקום הנוכחי בדרך אחרת: הם מראים את +מספר השורה שבה נמצא הסמן. + +הכוכביות ליד הקצה השמאלי משמעותן כי שיניתם את הטקסט. מיד אחרי פתיחת +הקובץ או אחרי שמירתו החלק הזה של שורת הסטטוס אינו מציג כוכביות, אלא רק +מקפים. + +החלק שבתוך הסוגריים אומר לכם מהo אופני העריכה (editing modes) הפעילים +כעת. ברירת המחדל היא Fundamental, האופן הבסיס, שבו אתם משתמשים כעת. +זוהי דוגמא של "אופן עריכה ראשי" (major mode). + +ל-Emacs אופני עריכה ראשיים רבים ומגוונים. חלק מהם נועדו לעריכה של שפת +תכנות מסוימת ו/או סוג מסוים של טקסט, כגון Lisp mode, Text mode וכד'. +בכל רגע נתון רק אופן עיקרי אחד יכול להיות פעיל ושמו תמיד מצויין בשורת +הסטטוס באותו מקום בו כרגע אתם רואים "Fundamental". + +כל אופן עיקרי גורם לכמה פקודות לפעול בצורה מיוחדת. למשל, ישנן פקודות +ליצירת הערות בתוך תוכנית, והיות וכל שפת תכנות מגדירה את הפורמט של +הערות בצורה אחרת, כל אופן עיקרי חייב להכניס הערות בצורה שמתאימה לשפה. +כל אופן עיקרי הינו למעשה שם הפקודה שבעזרתה אפשר להפעיל את אותו האופן. +למשל הפקודה להפעיל את האופן Fundamental הינה M-x fundamental-mode. + +אם בכוונתכם לערוך טקסט בשפה אנושית כלשהי, כמו הקובץ הזה, כדאי לכם +להשתמש ב-Text mode. + +>> הקישו M-x text-mode ‎. + +אל דאגה: אף אחת מפקודות Emacs שלמדתם עד כה משנה את התנהגותה באופן +מהותי. עם זאת, שימו לב ש-M-f ו-M-b מתייחסים עכשיו ל-'גרש' כחלק מהמילה. +לפני-כן, ב-Fundamental mode, ‏M-f ו-M-b התנהגו עם הגרש כמפריד בין +מילים. + +אופנים ראשיים בדרך-כלל משנים קלות את התנהגות הפקודות: רוב הפקודות +עדיין "עושות אותה עבודה" בכל האופנים הראשיים, אבל עושות אותה קצת אחרת. + +לצפיה בתיעוד של האופן הראשי הנוכחי יש להקיש C-h m. + +>> השתמשו ב-C-u C-v פעם אחת או יותר כדי להביא שורה זו לראשית התצוגה. +>> עתה הקישו C-h m כדי לראות במה Text mode שונה מה-Fundamental mode. +>> לבסוף, הקישו C-x 1 כדי לסלק את התיעוד מהתצוגה. + +אופנים ראשיים נקראים כך משום שקיימים גם אופני-משנה (minor modes). +אופני משנה אינם מהווים חלופה לאופנים הראשיים, הם רק משנים אותם במקצת. +כל אופן-משנה ניתן להפעלה או ביטול ללא תלות בכל שאר אופני המשנה וללא +תלות באופן הראשי הנוכחי. לכן תוכלו להפעיל אופן-משנה אחד או יותר, או אף +אופן-משנה. + +אחד מאופני-המשנה השימושיים ביותר, במיוחד לשם עריכת טקס בשפת-אנוש, הוא +Auto Fill mode. כאשר אופן זה מופעל, Emacs אוטומטית פותח שורה חדשה +בסיום מילה אם הטקסט שהקשתם ארוך מדי בשביל שורה אחת. + +להפעלת Auto Fill mode יש להקיש M-x auto-fill-mode ‎. כאשר אופן +זה מופעל, ניתן לבטלו ע"י M-x auto-fill-mode ‎. זאת אומרת, פקודה +זו מפעילה את האופן כשאינו פעיל ומבטלת אותו כשהוא פעיל. לפעולה זו +קוראים "מיתוג" -- הפקודה "ממתגת" את האופן. + +>> הקישו עתה M-x auto-fill-mode ‎. אחר-כך הקישו "שדגכ " (עם + הרווח בסוף) שוב ושוב עד שתיפתח שורה חדשה. הרווחים חשובים משום + ש-Auto Fill mode שובר שורות אך ורק ברווח שבין המלים. + +השוליים (margin) ש-Emacs שומר בדרך-כלל מתחילים אחרי 70 תווים, אבל ניתן +לשנות הגדרה זו בעזרת הפקודה C-x f. פקודה זו מקבלת את ההגדרה החדשה של +השוליים כארגומנט נומרי. + +>> הקישו C-x f עם ארגומנט של 20. (C-u 2 0 C-x f). אחר-כך הקישו טקסט + כלשהו ושימו לב ש-Emacs פותח שורות חדשות אחרי 20 תווים לכל היותר. + לבסוף, החזירו את הגדרת השוליים ל-70 ע"י שימוש חוזר ב-C-x f. + +אם ערכתם שינויים באמצע פסקה, Auto Fill mode לא ימלא שורות מחדש באופן +אוטומטי. +כדי למלא מחדש את כל הפסקה הקישו M-q ‏(META-q) כשהסמן נמצא בתוך +הפסקה. + +>> הניעו את הסמן לתוך הפסקה הקודמת והקישו M-q. + + +* חיפוש +------- + +‏Emacs יכול לחפש מחרוזות (רצף של תווים או מילים) קדימה או אחורה בתוך +הטקסט. חיפוש של מחרוזת הוא סוג של פקודה להנעת הסמן: הוא ממקם את הסמן +היכן שנמצאה המחרוזת הבאה. + +החיפוש של Emacs הינו "מצטבר" ("incremental"). פירוש הדבר הוא שהחיפוש +מתבצע במקביל להקשתכם את המחרוזת אותה ברצונכם למצוא. + +הפקודה להתחיל בחיפוש היא C-s לחיפוש קדימה ו-C-r לחיפוש אחורה. חכו! אל +תפעילו אותן עדיין. + +כשתקישו C-s, תראו שבאזור תצוגת ההד יופיע הטקסט "I-search". זה אומר +ש-Emacs נמצא במצב "חיפוש מצטבר" ("incremental search") והוא ממתין +להקשתכם את המחרוזת אותה ברצונכם למצוא. הקשה על מסיימת את +החיפוש. + +>> הקישו עתה C-s כדי להתחיל בחיפוש. לאט-לאט, אות-אות, הקישו את המילה + "סמן", עם הפסקה אחרי כל אות, ושימו לב להתנהגות הסמן. + זה עתה מצאתם את המילה "סמן" פעם אחת. +>> הקישו C-s שוב, כדי למצוא את "סמן" במקומות נוספים בטקסט. +>> הקישו שלוש פעמים ושימו לב לתנועת הסמן בכל הקשה. +>> הקישו לסיום החיפוש. + +האם שמתם לב למה שקרה? במהלך "חיפוש מצטבר" Emacs מנסה למצוא את המקום +הבא בו מופיעה המחרוזת שהקשתם. כדי למצוא את המחרוזת במקום הבא, פשוט +הקישו C-s פעם נוספת. אם המחרוזת אינה נמצאת בהמשך הטקסט, Emacs מצפצף +ומודיע שהחיפוש נכנס למצב של "כשלון" ("failing"). הקשה על C-g גם היא +מסיימת את החיפוש. + +(הערה: במערכות אחדות הקשה על C-s מקפיעה את תצוגת המסך, כך שלא תראו +יותר שום פלט של Emacs. משמעות הדבר שתכונת מערכת ההפעלה ששמה "flow +control" מופעלת ע"י C-s ואינה מעבירה את C-s ל-Emacs. לביטול הקפאת +התצוגה במערכות אלו יש להקיש C-q.) + +אם במהלך החיפוש תקישו על , תראו שהתו האחרון של המחרוזת +המבוקשת נמחק והחיפוש חוזר למקום הקודם בו נמצאה המחרוזת ללא התו האחרון. +למשל, נניח שהקשתם "ס" ע"מ למצוא את המקום הבא בו מופיעה האות "ס". אם +עכשיו תקישו "מ", הסמן יזוז למקום בו נמצא "סמ". עתה הקישו . +ה-"מ" נמחק מהמחרוזת והסמן חוזר למקום בו הוא מצא את "ס" לראשונה. + +אם במהלך החיפוש תפעילו פקודה כלשהי ע"י הקשה על מקש תוך לחיצה על +CONTROL או META, החיפוש יסתיים. (כמה תווים יוצאים מכלל זה -- אלו תווים +מיוחדים בעת חיפוש, כדוגמת C-s ו-C-r.) + +הקשה על C-s מתחילה חיפוש שמנסה למצוא את המחרוזת _אחרי_ הסמן. אם +ברצונכם למצוא משהו בטקסט הקודם למקום הנוכחי, הקישו C-r במקום C-s. כל +מה שאמרנו לגבי C-s תקף גם לגבי C-r, אלא שכיוון החיפוש מתהפך. + + +* חלונות מרובים +--------------- + +אחת התכונות הנוחות של Emacs היא כי ניתן להציג יותר מחלון אחד על המסך +בו-זמנית. (הערה: Emacs משתמש במונח "frame" -- "תבנית" -- בשביל מה +שתוכניות אחרות מכנות "חלון". תבניות מתוארות בפסקה הבאה. תוכלו למצוא את +רשימת המונחים של Emacs בפרק "Glossary" של מדריך משתמש.) + +>> הביאו סמן לשורה זו והקישו C-u 0 C-l ‏(CONTROL-L ולא CONTROL-1). + +>> עתה הקישו C-x 2 וכתוצאה מכך החלון יתחלק לשניים. כל אחד משני החלונות + מציג את השיעור הזה. הסמן נשאר בחלון העליוןץ + +>> הקישו C-M-v כדי לגלול את החלון התחתון. + (אם במקלדת שלכם אין מקש META אמיתי, הקישו ‎ C-v כתחליף.) + +>> הקישו C-x o ‏("o" הוא רמז ל-"other", "אחר") ע"מ להעביר את הסמן לחלון + התחתון. +>> הקישו C-v ו-M-v בחלון התחתון כדי לגלול אותו. + המשיכו לקרוא הוראות אלו בחלון העליון. + +>> הקישו C-x o שוב לחזור לחלון העליון. + הסמן בחלון העליון יישאר במקום בו הוא היה לפני-כן. + +תוכלו להמשיך להשתמש ב-C-x o כדי לדלג בין שני החלונות. לכל חלון מיקום +סמן משלו, אבל רק חלון אחד מציג את הסמן בכל רגע. כל פקודות העריכה +הרגילות פועלות על החלון שבו מוצג הסמן. אנו קוראים לחלון זה "החלון +הנבחר". + +הפקודה C-M-v נוחה מאד כאשר הינכם עורכים טקסט בחלון אחד ומשתמשים בחלון +אחר לייחוס. תוכלו בכל עת לשמור על הסמן בחלון בו אתם עורכים טקסט +ולהתקדם בחלון השני בעזרת C-M-v. + +‏C-M-v היא דוגמא אחת של פקודת CONTROL-META. אם במקלדת שלכם קיים מקש +META אמיתי, תוכלו להקיש את הפקודה ע"י לחיצה והחזקה של מקשי CONTROL +ו-META גם יחד ואז להקיש v. הסדר שבו תלחצו על CONTROL ו-META אינו משנה +כי שני המקשים הללו פועלים ע"י שינוי התו המוקש יחד איתם. + +אם אין במקלדת מקש META אמיתי ואתם משתמשים ב- כתחליף, הסדר כן +משנה: חייבים להקיש ורק לאחר מכן CONTROL-v, וזאת משום +ש-CONTROL- v לא יעבוד. הוא תו בזכות עצמו, שלא כמו CONTROL +או META. + +>> הקישו C-x 1 (בחלון העליון) כדי לסלק את החלון התחתון. + +(אילו הקשתם C-x 1 בחלון התחתון, הייתם מסלקים את החלון העליון. תוכלו +לחשוב על פקודה זו כ-"השאר רק חלון אחד -- החלון בו אני נמצא עתה".) + +אין חובה להציג את אותו החוצץ בשני החלונות. תוכלו להשתמש ב-C-x C-f +לפתיחת קובץ באחד החלונות -- דבר זה אינו משפיע על החלון השני. אפשר גם +לפתוח קבצים שונים בכל אחד משני החלונות באופן בלתי-תלוי. + +הנה עוד שיטה להשתמש בשני חלונות להצגה של שני דברים שונים: + +>> הקישו C-x 4 C-f ואחר-כך הקישו שם של אחד הקבצים שלכם. + סיימו עם . שימו לב שהקובץ המבוקש מוצג בחלון התחתון. הסמן + מדלג לשם אף הוא. + +>> הקישו C-x o לעבור לחלון העליון ואחר-כך הקישו C-x 1 כדי לסלק את + החלון התחתון. + + +* תבניות מרובות +--------------- + +‏Emacs מסוגל לפתוח מספר "תבניות" ("frames") בתנאי שאינכם משתמשים בצג +שמסוגל להציג רק טקסט. תבנית כוללת קבוצת חלונות, תפריט, פסי גלילה, אזור +תצוגת הד וכו'. (תוכניות אחרות נוהגות לקרוא לזה "חלון".) + +>> הקישו M-x make-frame ‎. + כתוצאה, תבנית חדשה תופיע על המסך. + +כל מה שעשיתם בתבנית המקורית ניתן לעשות גם בתבנית החדשה. התבנית הראשונה +אין בה שום דבר מיוחד. + +>> הקישו M-x delete-frame ‎. + התבנית שבה הקשתם את הפקודה תיסגר ותיעלם מהמסך. + +כמו-כן, ניתן לסגור תבנית בדרך הרגילה הנתמכת ע"י מנהל החלונות של המערכת +שלכם (בדרך-כלל, ע"י הקלקה על הכפתור המסומן ב-"X" בפינה עליונה של +התבנית.) שום מידע אינו הולך לעיבוד כאשר סוגרים תבנית (או חלון). המידע +הזה פשוט יורד מהתצוגה, אבל ניתן לאחזרו מאוחר יותר. + + +* רמות עריכה רקורסיביות +----------------------- + +יתכן ותיקלעו למצב שקרוי "רמת עריכה רקורסיבית". Emacs מציין זאת ע"י +סוגריים מרובעים בשורת הסטטוס מסביב לשם האופן הראשי. למשל, יוצג שם +[(Fundamental)] במקום (Fundamental). + +כדי להחלץ מרמת עריכה רקורסיבית יש להקיש . זוהי פקודה +כללית של "הימלטות". ניתן להשתמש בה גם כדי לסלק חלונות מיותרים וליציאה +מתוך מיני-חוצץ. + +>> הקישו M-x כדי להיכנס למיני-חוצץ; אחר-כך הקישו כדי + להיחלץ משם. + +הקשה על C-g לא תחלץ אתכם מרמות עריכה רקורסיביות. זאת, משום ש-C-g מבטל +פקודות וארגומנטים _במסגרת_ הרמה הרקורסיבית, מבלי לצאת ממנה. + + +* לקבלת עזרה נוספת +------------------ + +בשיעור הראשון הזה השתדלנו לתת בידיכם מידע שאך יספיק להתחלת השימוש שלכם +ב-Emacs. ‏Emacs מכיל כל-כך הרבה שאין שום אפשרות לתאר ולהסביר כאן את +הכל. אולם, סביר שתרצו ללמוד יותר על Emacs שכן יש בו עוד הרבה תכונות +שימושיות. Emacs כולל פקודות לשם קריאת תיעוד על הפקודות של Emacs. +הפעלת פקודות "עזרה" אלו תמיד מתחילה במקש CONTROL-h שעל-כן נקרא "מקש +עזרה" ("help"). + +להפעלת פקודות עזרה יש להקיש את C-h ואחר-כך עוד תו שמבקש עזרה מסוג +מסויים. אם אתם _באמת_ אבודים, הקישו C-h ?‎ ו-Emacs יציג את סוגי העזרה +שהוא מעמיד לרשותכם. אם הקשתם C-h ובסופו של דבר החלטתם שאין צורך בשום +עזרה, פשוט הקישו C-g לבטל את הפקודה. + +(אם הקשת C-h אינה מציגה בתחתית התצוגה הודעה בדבר עזרה, נסו להקיש F1 או +M-x help ‎ כתחליף.) + +סוג העזרה הבסיס ביותר הוא C-h c. הקישו C-h, אחריו את האות c ואז הקישו +סדרת מקשים שמפעילה פקודה כלשהי. Emacs יציג תיאור מאד קצר של הפקודה +ההיא. + +>> הקישו C-h c C-p. + +התוצאה שתוצג צריכה להיות משהו כמו זה: + + C-p runs the command previous-line + +ההודעה הזו מראה את "שם הפונקציה". היות ושמות הפונקציות נבחרים כדי +לציין מה הן עושות, השמות עשויים לשמש כתיעוד מקוצר -- מספיק כדי להזכיר +לכם את הפקודות שלמדתם בעבר. + +ניתן לציין אחרי C-h c גם פקודות שמופעלות ע"י סדרת מקשים באורך גדול +מאחד, כגון C-x C-s או (אם אין מקש META או EDIT או ALT) ‏‎ v. + +לקבלת מידע מפורט יותר על פקודה, השתמשו בפקודה C-h k במקום C-h c. + +>> הקישו C-h k C-p. + +כתוצאה, יוצגו השם והתיעוד של הפונקציה בחלון Emacs נפרד. כשתסיימו לקרוא +את התיעוד, הקישו C-x 1 כדי לסלק את חלון העזרה. לא חייבים לעשות זאת +מיד. אפשר לבצע קצת עריכה תוך שימוש בתיעוד המוצג ורק אח"כ להקיש C-x 1. + +הנה עוד כמה פקודות עזרה שימושיות: + + ‏C-h f תן הסבר על פונקציה. יש להקיש את שם הפונקציה. + +>> נסו להקיש C-h f previous-line ‎. + כתוצאה, יוצג תיעוד מלא של הפונקציה המממשת את הפקודה C-p כפי שהוא + ידוע ל-Emacs. + +פקודה דומה C-h v מציגה תיעוד של משתנה, כולל אלו שאת הערכים שלהם ניתן +לשנות כדי לקסטם את Emacs. יש להקיש את שם המשתנה כאשר Emacs יבקש זאת. + + ‏C-h a פקודות בנוגע לנושא מסויים. הקישו מילת מפתח ו-Emacs + יציג את רשימת הפקודות ששמותיהן מכילות את מילת המפתח. + כל הפקודות הללו ניתנות להפעלה ע"י META-x. עבור חלק + מהפקודות תוצג גם סדרת מקשים שמפעילה את הפקודה. + +>> הקישו C-h a file ‎. + +כתוצאה מזה, יוצג חלון עם רשימה של כל הפקודות ששמותיהן מכילות את המילה +"file". ביניהן תראו גם מקשי קיצור כגון C-x C-f לצד שמות הפקודות כגון +find-file. + +>> הקישו C-M-v כדי לגלול את חלון העזרה. עשו זאת פעמים אחדות. + +>> עתה הקישו C-x 1 כדי לסגור את חלון העזרה. + + ‏C-h i הצג מדריכים למשתמש הכלולים בחבילת Emacs. (פקודה זו + ידועה גם בשם "Info".) פקודה זאת פותחת חוצץ מיוחד הקרוי + "*info*" שבו תוכלו לקרוא מדריכים המותקנים במערכת שלכם. + הקישו m emacs ‎ כדי לקרוא במדריך למשתמשי Emacs. + אם אינכם מכירים את Info, הקישו ? ו-Emacs יקח אתכם + לשיעור על התכונות של Info mode. כשתסיימו עם השיעור + הזה, אנו בהחלט ממליצים להשתמש במדריך Emacs בתור התיעוד + העיקרי שלכם. + + +* עוד תכונות +------------ + +תוכלו ללמוד עוד על-אודות Emacs ע"י קריאה במדריך למשתמש שלו, אם כספר +מודפס או בגירסה מקוונת בתוך Emacs עצמו. (תוכלו להגיע אל המדריך דרך +תפריט Help או ע"י הקשה על C-h r.) אולם שתי תכונות שבוודאי ימצאו חן +בעיניכם הן השלמה אשר חוסכת הקשות, ו-dired שמאפשרת טיפול נוח בקבצים. + +השלמה היא דרך להימנע מהקשות מיותרות. למשל, אם ברצונכם לעבור לחוצץ +*Messages*, תוכלו להקיש C-x b *M‎ ו-Emacs ישלים את שאר האותיות של +שם החוצץ ככל שניתן להסיק ממה שהקשתם. השלמה פועלת גם על שמות הפקודות +ושמות קבצים. תכונת ההשלמה מתוארת במלואה במדריך למשתמש Emacs בצומת +(node) בשם "Completion". + +‏Dired מאפשר להציג רשימת קבצים בתיקיה (וכאפציה גם בתת-תיקיות שלה), לנוע +בתוך הרשימה הזו, לפתוח קבצים, לשנות את שמותיהם, למחוק אותם ולבצע עליהם +עוד פעולות רבות. Dired מתואר במלואו במדריך למשתמש בצומת בשם "Dired". + +בנוסף, מדריך למשתמש מתאר עוד הרבה מאד תכונות של Emacs. + + +* לסיום +------- + +כדי לצאת מ-Emacs יש להקיש C-x C-c. + +שיעור זה נכתב כדי להיות מובן לכל המשתמשים החדשים, לכן אם מצאתם שמשהו +כאן אינו ברור, אל תשבו ותאשימו את עצמכם -- תתלוננו! + + +* זכויות שימוש +-------------- + +שיעור זה הינו צאצא של שורה ארוכה של שיעורים בשימוש ב-Emacs, החל מהגרסה +הראשונה שנכתבה ע"י Stuart Cracraft עבור גירסת ה-Emacs המקורית. + +גירסה זו של השיעור הינה חלק מחבילת GNU Emacs. היא מוגנת בזכויות יוצרים +וניתנת להעתקה והפצת עותקים בתנאים מסויימים כדלקמן: + + Copyright (C) 2010 Free Software Foundation, Inc. + +‏GNU Emacs הינו תכנה חפשית; זכותכם להפיצו ו\או לשנותו בכפוף לתנאי +הרשיון GNU General Public License, כפי שהוא יוצא לאור ע"י Free +Software Foundation, אם בגרסא 3 של הרשיון, ואם (כאופציה השמורה לכם) +בכל גרסא מאוחרת יותר. + +‏GNU Emacs מופץ מתוך תקווה שהוא יביא תועלת, אולם ללא כל כתב אחריות; +אפילו לא אחריות-במשתמע של סחירות או התאמה לאיזו תכלית מסוימת. לפרטים, +אנא עיינו ב-GNU General Public License. + +‏GNU Emacs אמור להיות מלווה בעותק של GNU General Public License; אם לא +קיבלתם אותו, תוכלו למצוא אותו ב-‭‬. + +הנכם מוזמנים לקרוא את הקובץ COPYING ואז אכן לחלק עותקים של GNU Emacs +לחבריכם. עזרו לנו לחסל את "הבעלות" על תוכנה שאינה אלא חבלה בתוכנה, +וזאת ע"י שימוש, כתיבה ושיתוף של תוכנה חופשית! + + + +--- end of TUTORIAL.he --- + +;;; Local Variables: +;;; coding: utf-8 +;;; bidi-display-reordering: t +;;; sentence-end-double-space: nil +;;; bidi-paragraph-direction: nil +;;; End: diff -r 9a965dbf641e -r 768a90ad492c etc/tutorials/TUTORIAL.translators --- a/etc/tutorials/TUTORIAL.translators Fri Jul 30 02:11:29 2010 +0000 +++ b/etc/tutorials/TUTORIAL.translators Sun Aug 01 22:48:29 2010 +0000 @@ -31,6 +31,10 @@ Author: Éric Jacoboni Maintainer: Éric Jacoboni +* TUTORIAL.he +Author: Eli Zaretskii +Maintainer: Eli Zaretskii + * TUTORIAL.it: Author: Alfredo Finelli Italian GNU Translation Group diff -r 9a965dbf641e -r 768a90ad492c lisp/ChangeLog --- a/lisp/ChangeLog Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/ChangeLog Sun Aug 01 22:48:29 2010 +0000 @@ -1,3 +1,71 @@ +2010-08-01 YAMAMOTO Mitsuharu + + * mouse.el (mouse-fixup-help-message): Match "mouse-2" only at the + beginning of the string. Use `string-match-p'. (Bug#6765) + +2010-08-01 Jan Djärv + + * cus-start.el (x-gtk-use-system-tooltips): New variable. + +2010-08-01 Chong Yidong + + * emacs-lisp/package.el (package--list-packages): Fix column + alignment. + (package--builtins): Tweak descriptions. + (package-print-package): Upcase descriptions if necessary. Show + all built-in packages in font-lock-builtin-face. + (package-list-packages-internal): Omit "emacs" package. Show + status of built-in packages as "built-in". + +2010-07-31 Chong Yidong + + * mouse.el (mouse-save-then-kill): Doc fix. Deactivate mark + before killing to preserve the primary selection (Bug#6701). + + * term/x-win.el (x-select-text): Doc fix. + +2010-07-31 Alan Mackenzie + Enhanced Java Mode to handle Java 5.0 (Tiger) and Java 6 + (Mustang). Contributed by Nathaniel Flath. The following + functions were modified or created: + + * progmodes/cc-vars.el (c-offsets-alist, c-inside-block-syms) + (objc-font-lock-extra-types): + + * progmodes/cc-mode.el (c-basic-common-init): + + * progmodes/cc-langs.el (c-make-mode-syntax-table) + (c++-make-template-syntax-table) + (c-identifier-syntax-modifications, c-symbol-start, c-operators) + (c-<-op-cont-regexp, c->-op-cont-regexp, c-class-decl-kwds) + (c-brace-list-decl-kwds, c-modifier-kwds, c-prefix-spec-kwds-re) + (c-type-list-kwds, c-decl-prefix-re, c-opt-type-suffix-key): + + + * progmodes/cc-fonts.el (c-make-inverse-face) + (c-basic-matchers-after): + + * progmodes/cc-engine.el (c-forward-keyword-clause) + (c-forward-<>-arglist, c-forward-<>-arglist-recur) + (c-forward-name, c-forward-type, c-forward-decl-or-cast-1) + (c-guess-continued-construct, c-guess-basic-syntax): + +2010-07-31 Jan Djärv + + * faces.el (face-all-attributes): Improved documentation (Bug#6767). + +2010-07-31 Eli Zaretskii + + * files.el (bidi-paragraph-direction): Define safe local values. + + * language/hebrew.el ("Hebrew"): Add TUTORIAL.he to + language-info-alist. Remove outdated FIXME in a comment. + +2010-07-31 Alan Mackenzie + + * progmodes/cc-cmds.el (c-mask-paragraph): Fix bug #6688: + Auto-fill broken in C/C++ modes. + 2010-07-29 Jan Djärv * menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left) diff -r 9a965dbf641e -r 768a90ad492c lisp/ChangeLog.7 --- a/lisp/ChangeLog.7 Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/ChangeLog.7 Sun Aug 01 22:48:29 2010 +0000 @@ -7738,7 +7738,7 @@ 1997-12-09 Kenichi HANDA * language/korea-util.el (setup-korean-environment): - Bind C-f9 (intead of C-f10) to quail-hangul-switch-symbol-ksc. + Bind C-f9 (instead of C-f10) to quail-hangul-switch-symbol-ksc. * language/korean.el: Documentation for "Korean" language environment adjusted for the above change. diff -r 9a965dbf641e -r 768a90ad492c lisp/ChangeLog.8 --- a/lisp/ChangeLog.8 Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/ChangeLog.8 Sun Aug 01 22:48:29 2010 +0000 @@ -8808,14 +8808,14 @@ enable-kinsoku. * simple.el (do-auto-fill): Don't check kinsoku-enable here. - Don't call kinsoku directly, intead call fill-find-break-point. + Don't call kinsoku directly, instead call fill-find-break-point. * textmodes/fill.el: Setup `fill-find-break-point-function' property to character sets which require `kinsoku' processing for filling. (fill-find-break-point): New function. (fill-region-as-paragraph): Don't check kinsoku-enable here. - Don't call kinsoku directly, intead call fill-find-break-point. + Don't call kinsoku directly, instead call fill-find-break-point. 1998-10-18 Richard Stallman diff -r 9a965dbf641e -r 768a90ad492c lisp/cus-start.el --- a/lisp/cus-start.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/cus-start.el Sun Aug 01 22:48:29 2010 +0000 @@ -358,6 +358,7 @@ (x-gtk-show-hidden-files menu boolean "22.1") (x-gtk-file-dialog-help-text menu boolean "22.1") (x-gtk-whole-detached-tool-bar x boolean "22.1") + (x-gtk-use-system-tooltips tooltip boolean "23.3") ;; xterm.c (x-use-underline-position-properties display boolean "22.1") (x-underline-at-descent-line display boolean "22.1") diff -r 9a965dbf641e -r 768a90ad492c lisp/emacs-lisp/package.el --- a/lisp/emacs-lisp/package.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/emacs-lisp/package.el Sun Aug 01 22:48:29 2010 +0000 @@ -292,15 +292,15 @@ (if (>= emacs-major-version 22) ;; FIXME: emacs 22 includes tramp, rcirc, maybe ;; other things... - '((erc . [(5 2) nil "An Emacs Internet Relay Chat client"]) + '((erc . [(5 2) nil "Internet Relay Chat client"]) ;; The external URL is version 1.15, so make sure the ;; built-in one looks newer. (url . [(1 16) nil "URL handling libary"]))) (if (>= emacs-major-version 23) '(;; Strangely, nxml-version is missing in Emacs 23. ;; We pick the merge date as the version. - (nxml . [(20071123) nil "Major mode for editing XML documents."]) - (bubbles . [(0 5) nil "Puzzle game for Emacs."]))))) + (nxml . [(20071123) nil "Major mode for XML documents"]) + (bubbles . [(0 5) nil "A puzzle game"]))))) "Alist of all built-in packages. Maps the package name to a vector [VERSION REQS DOCSTRING].") (put 'package--builtins 'risky-local-variable t) @@ -358,16 +358,6 @@ ;; Both null. (funcall fun 0 0)))) -(defun package--test-version-compare () - "Test suite for `package-version-compare'." - (unless (and (package-version-compare '(0) '(0) '=) - (not (package-version-compare '(1) '(0) '=)) - (package-version-compare '(1 0 1) '(1) '>=) - (package-version-compare '(1 0 1) '(1) '>) - (not (package-version-compare '(0 9 1) '(1 0 2) '>=))) - (error "Failed")) - t) - (defun package-strip-version (dirname) "Strip the version from a combined package name and version. E.g., if given \"quux-23.0\", will return \"quux\"" @@ -1422,7 +1412,7 @@ (defun package-print-package (package version key desc) (let ((face - (cond ((eq package 'emacs) 'font-lock-builtin-face) + (cond ((string= key "built-in") 'font-lock-builtin-face) ((string= key "available") 'default) ((string= key "held") 'font-lock-constant-face) ((string= key "disabled") 'font-lock-warning-face) @@ -1444,7 +1434,9 @@ ;; FIXME: this 'when' is bogus... (when desc (indent-to 43 1) - (insert (propertize desc 'font-lock-face face))) + (let ((opoint (point))) + (insert (propertize desc 'font-lock-face face)) + (upcase-region opoint (min (point) (1+ opoint))))) (insert "\n"))) (defun package-list-maybe-add (package version status description result) @@ -1462,22 +1454,31 @@ (setq buffer-read-only nil) (erase-buffer) (let ((info-list) - name desc hold) + name desc hold + builtin) ;; List installed packages (dolist (elt package-alist) + ;; Ignore the Emacs package. (setq name (car elt) desc (cdr elt) hold (assq name package-load-list)) - (setq info-list - (package-list-maybe-add name (package-desc-vers desc) - ;; FIXME: it turns out to be - ;; tricky to see if this package - ;; is presently activated. - (if (stringp (cadr hold)) - "held" - "installed") - (package-desc-doc desc) - info-list))) + (unless (eq name 'emacs) + (setq info-list + (package-list-maybe-add + name (package-desc-vers desc) + ;; FIXME: it turns out to be tricky to see if this + ;; package is presently activated. + (cond ((stringp (cadr hold)) + "held") + ((and (setq builtin (assq name package--builtins)) + (package-version-compare + (package-desc-vers (cdr builtin)) + (package-desc-vers desc) + '=)) + "built-in") + (t "installed")) + (package-desc-doc desc) + info-list)))) ;; List available packages (dolist (elt package-archive-contents) (setq name (car elt) @@ -1574,8 +1575,8 @@ '((0 . "") (2 . "Package") (20 . "Version") - (30 . "Status") - (41 . "Description")) + (32 . "Status") + (43 . "Description")) "")) ;; It's okay to use pop-to-buffer here. The package menu buffer diff -r 9a965dbf641e -r 768a90ad492c lisp/faces.el --- a/lisp/faces.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/faces.el Sun Aug 01 22:48:29 2010 +0000 @@ -376,7 +376,7 @@ (defun face-all-attributes (face &optional frame) "Return an alist stating the attributes of FACE. Each element of the result has the form (ATTR-NAME . ATTR-VALUE). -Normally the value describes the default attributes, +If FRAME is omitted or nil the value describes the default attributes, but if you specify FRAME, the value describes the attributes of FACE on FRAME." (mapcar (lambda (pair) diff -r 9a965dbf641e -r 768a90ad492c lisp/files.el --- a/lisp/files.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/files.el Sun Aug 01 22:48:29 2010 +0000 @@ -2784,6 +2784,9 @@ (truncate-lines . booleanp) ;; C source code (bidi-display-reordering . booleanp))) ;; C source code +(put 'bidi-paragraph-direction 'safe-local-variable + (lambda (v) (memq v '(nil right-to-left left-to-right)))) + (put 'c-set-style 'safe-local-eval-function t) (defvar file-local-variables-alist nil diff -r 9a965dbf641e -r 768a90ad492c lisp/language/hebrew.el --- a/lisp/language/hebrew.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/language/hebrew.el Sun Aug 01 22:48:29 2010 +0000 @@ -46,14 +46,13 @@ (define-coding-system-alias 'iso-8859-8 'hebrew-iso-8bit) ;; These are for Explicit and Implicit directionality information, as -;; defined in RFC 1556. We don't yet support directional information -;; in bidi languages, so these aliases are a lie, especially as far as -;; iso-8859-8-e is concerned. FIXME. +;; defined in RFC 1556. (define-coding-system-alias 'iso-8859-8-e 'hebrew-iso-8bit) (define-coding-system-alias 'iso-8859-8-i 'hebrew-iso-8bit) (set-language-info-alist - "Hebrew" '((charset iso-8859-8) + "Hebrew" '((tutorial . "TUTORIAL.he") + (charset iso-8859-8) (coding-priority hebrew-iso-8bit) (coding-system hebrew-iso-8bit windows-1255 cp862) (nonascii-translation . iso-8859-8) diff -r 9a965dbf641e -r 768a90ad492c lisp/mouse.el --- a/lisp/mouse.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/mouse.el Sun Aug 01 22:48:29 2010 +0000 @@ -879,8 +879,7 @@ (let (mp pos) (if (and mouse-1-click-follows-link (stringp msg) - (save-match-data - (string-match "^mouse-2" msg)) + (string-match-p "\\`mouse-2" msg) (setq mp (mouse-pixel-position)) (consp (setq pos (cdr mp))) (car pos) (>= (car pos) 0) @@ -1336,16 +1335,23 @@ (undo-boundary)) (defun mouse-save-then-kill (click) - "Save text to point in kill ring; the second time, kill the text. -If the text between point and the mouse is the same as what's -at the front of the kill ring, this deletes the text. -Otherwise, it adds the text to the kill ring, like \\[kill-ring-save], -which prepares for a second click to delete the text. + "Set the region according to CLICK; the second time, kill the region. +Assuming this command is bound to a mouse button, CLICK is the +corresponding input event. -If you have selected words or lines, this command extends the -selection through the word or line clicked on. If you do this -again in a different position, it extends the selection again. -If you do this twice in the same position, the selection is killed." +If the region is already active, adjust it. Normally, this +happens by moving either point or mark, whichever is closer, to +the position of CLICK. But if you have selected words or lines, +the region is adjusted by moving point or mark to the word or +line boundary closest to CLICK. + +If the region is inactive, activate it temporarily; set mark at +the original point, and move click to the position of CLICK. + +However, if this command is being called a second time (i.e. the +value of `last-command' is `mouse-save-then-kill'), kill the +region instead. If the text in the region is the same as the +text in the front of the kill ring, just delete it." (interactive "e") (let ((before-scroll (with-current-buffer (window-buffer (posn-window (event-start click))) @@ -1357,44 +1363,50 @@ (this-command this-command)) (if (and (with-current-buffer (window-buffer (posn-window (event-start click))) - (and (mark t) (> (mod mouse-selection-click-count 3) 0) + (and (mark t) + (> (mod mouse-selection-click-count 3) 0) ;; Don't be fooled by a recent click in some other buffer. (eq mouse-selection-click-count-buffer (current-buffer))))) - (if (not (and (eq last-command 'mouse-save-then-kill) - (equal click-posn - (car (cdr-safe (cdr-safe mouse-save-then-kill-posn)))))) - ;; Find both ends of the object selected by this click. - (let* ((range - (mouse-start-end click-posn click-posn - mouse-selection-click-count))) - ;; Move whichever end is closer to the click. - ;; That's what xterm does, and it seems reasonable. - (if (< (abs (- click-posn (mark t))) - (abs (- click-posn (point)))) - (set-mark (car range)) - (goto-char (nth 1 range))) - ;; We have already put the old region in the kill ring. - ;; Replace it with the extended region. - ;; (It would be annoying to make a separate entry.) - (kill-new (buffer-substring (point) (mark t)) t) - (mouse-set-region-1) - ;; Arrange for a repeated mouse-3 to kill this region. - (setq mouse-save-then-kill-posn - (list (car kill-ring) (point) click-posn))) - ;; If we click this button again without moving it, - ;; that time kill. - (mouse-save-then-kill-delete-region (mark) (point)) - (setq mouse-selection-click-count 0) - (setq mouse-save-then-kill-posn nil)) + (if (and (eq last-command 'mouse-save-then-kill) + (equal click-posn (nth 2 mouse-save-then-kill-posn))) + ;; If we click this button again without moving it, kill. + (progn + ;; Call `deactivate-mark' to save the primary selection. + (deactivate-mark) + (mouse-save-then-kill-delete-region (mark) (point)) + (setq mouse-selection-click-count 0) + (setq mouse-save-then-kill-posn nil)) + ;; Find both ends of the object selected by this click. + (let* ((range + (mouse-start-end click-posn click-posn + mouse-selection-click-count))) + ;; Move whichever end is closer to the click. + ;; That's what xterm does, and it seems reasonable. + (if (< (abs (- click-posn (mark t))) + (abs (- click-posn (point)))) + (set-mark (car range)) + (goto-char (nth 1 range))) + ;; We have already put the old region in the kill ring. + ;; Replace it with the extended region. + ;; (It would be annoying to make a separate entry.) + (kill-new (buffer-substring (point) (mark t)) t) + (mouse-set-region-1) + ;; Arrange for a repeated mouse-3 to kill this region. + (setq mouse-save-then-kill-posn + (list (car kill-ring) (point) click-posn)))) + (if (and (eq last-command 'mouse-save-then-kill) mouse-save-then-kill-posn (eq (car mouse-save-then-kill-posn) (car kill-ring)) - (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn))) + (equal (cdr mouse-save-then-kill-posn) + (list (point) click-posn))) ;; If this is the second time we've called ;; mouse-save-then-kill, delete the text from the buffer. (progn - (mouse-save-then-kill-delete-region (point) (mark)) + ;; Call `deactivate-mark' to save the primary selection. + (deactivate-mark) + (mouse-save-then-kill-delete-region (point) (mark t)) ;; After we kill, another click counts as "the first time". (setq mouse-save-then-kill-posn nil)) ;; This is not a repetition. diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-cmds.el --- a/lisp/progmodes/cc-cmds.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-cmds.el Sun Aug 01 22:48:29 2010 +0000 @@ -3974,16 +3974,17 @@ ;; "Invalid search bound (wrong side of point)" ;; error in the subsequent re-search. Maybe ;; another fix would be needed (2007-12-08). - (and (> (- (cdr c-lit-limits) 2) (point)) + (or (<= (- (cdr c-lit-limits) 2) (point)) + (and (search-forward-regexp (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)") (- (cdr c-lit-limits) 2) t) (not (search-forward-regexp "\\(\\s \\|\\sw\\)" (- (cdr c-lit-limits) 2) 'limit)) - ;; The comment ender IS on its own line. Exclude - ;; this line from the filling. - (set-marker end (c-point 'bol)))) + ;; The comment ender IS on its own line. Exclude + ;; this line from the filling. + (set-marker end (c-point 'bol))))) ;; The comment ender is hanging. Replace all space between it ;; and the last word either by one or two 'x's (when diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-engine.el --- a/lisp/progmodes/cc-engine.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-engine.el Sun Aug 01 22:48:29 2010 +0000 @@ -5401,6 +5401,7 @@ ;; `nconc' doesn't mind that the tail of ;; `c-record-found-types' is t. (nconc c-record-found-types c-record-type-identifiers))) + (if (c-major-mode-is 'java-mode) (c-fontify-recorded-types-and-refs)) t) (goto-char start) @@ -5420,7 +5421,6 @@ ;; List that collects the positions after the argument ;; separating ',' in the arglist. arg-start-pos) - ;; If the '<' has paren open syntax then we've marked it as an angle ;; bracket arglist before, so skip to the end. (if (and (not c-parse-and-markup-<>-arglists) @@ -5431,7 +5431,6 @@ (if (and (c-go-up-list-forward) (eq (char-before) ?>)) t - ;; Got unmatched paren angle brackets. We don't clear the paren ;; syntax properties and retry, on the basis that it's very ;; unlikely that paren angle brackets become operators by code @@ -5441,70 +5440,51 @@ nil)) (forward-char) + (unless (looking-at c-<-op-cont-regexp) - (while (and + (while (and (progn - - (when c-record-type-identifiers - (if all-types - - ;; All encountered identifiers are types, so set the - ;; promote flag and parse the type. - (progn - (c-forward-syntactic-ws) - (when (looking-at c-identifier-start) - (let ((c-promote-possible-types t)) - (c-forward-type)))) - - ;; Check if this arglist argument is a sole type. If - ;; it's known then it's recorded in - ;; `c-record-type-identifiers'. If it only is found - ;; then it's recorded in `c-record-found-types' which we - ;; might roll back if it turns out that this isn't an - ;; angle bracket arglist afterall. - (when (memq (char-before) '(?, ?<)) - (let ((orig-record-found-types c-record-found-types)) - (c-forward-syntactic-ws) - (and (memq (c-forward-type) '(known found)) - (not (looking-at "[,>]")) - ;; A found type was recorded but it's not the - ;; only thing in the arglist argument, so reset - ;; `c-record-found-types'. - (setq c-record-found-types - orig-record-found-types)))))) - - (setq pos (point)) - (or (when (eq (char-after) ?>) - ;; Must check for '>' at the very start separately, - ;; since the regexp below has to avoid ">>" without - ;; using \\=. - (forward-char) - t) - - ;; Note: These regexps exploit the match order in \| so - ;; that "<>" is matched by "<" rather than "[^>:-]>". - (c-syntactic-re-search-forward - (if c-restricted-<>-arglists - ;; Stop on ',', '|', '&', '+' and '-' to catch - ;; common binary operators that could be between - ;; two comparison expressions "ad". - "[<;{},|&+-]\\|\\([^>:-]>\\)" - ;; Otherwise we still stop on ',' to find the - ;; argument start positions. - "[<;{},]\\|\\([^>:-]>\\)") - nil 'move t t 1) - - ;; If the arglist starter has lost its open paren - ;; syntax but not the closer, we won't find the - ;; closer above since we only search in the - ;; balanced sexp. In that case we stop just short - ;; of it so check if the following char is the closer. - (when (eq (char-after) ?>) - (forward-char) - t))) - - (cond - ((eq (char-before) ?>) + (c-forward-syntactic-ws) + (let ((orig-record-found-types c-record-found-types)) + (when (or (and c-record-type-identifiers all-types) + (c-major-mode-is 'java-mode)) + ;; All encountered identifiers are types, so set the + ;; promote flag and parse the type. + (progn + (c-forward-syntactic-ws) + (if (looking-at "\\?") + (forward-char) + (when (looking-at c-identifier-start) + (let ((c-promote-possible-types t) + (c-record-found-types t)) + (c-forward-type)))) + + (c-forward-syntactic-ws) + + (when (or (looking-at "extends") + (looking-at "super")) + (forward-word) + (c-forward-syntactic-ws) + (let ((c-promote-possible-types t) + (c-record-found-types t)) + (c-forward-type) + (c-forward-syntactic-ws)))))) + + (setq pos (point)) + + (or + ;; Note: These regexps exploit the match order in \| so + ;; that "<>" is matched by "<" rather than "[^>:-]>". + (c-syntactic-re-search-forward + ;; Stop on ',', '|', '&', '+' and '-' to catch + ;; common binary operators that could be between + ;; two comparison expressions "ad". + "[<;{},|+&-]\\|[>)]" + nil t t) + t)) + + (cond + ((eq (char-before) ?>) ;; Either an operator starting with '>' or the end of ;; the angle bracket arglist. @@ -5526,7 +5506,6 @@ ((eq (char-before) ?<) ;; Either an operator starting with '<' or a nested arglist. - (setq pos (point)) (let (id-start id-end subres keyword-match) (if (if (looking-at c-<-op-cont-regexp) @@ -5546,14 +5525,14 @@ (when (or (setq keyword-match (looking-at c-opt-<>-sexp-key)) (not (looking-at c-keywords-regexp))) - (setq id-start (point)))) - - (setq subres - (let ((c-record-type-identifiers nil) - (c-record-found-types nil)) - (c-forward-<>-arglist-recur - (and keyword-match - (c-keyword-member + (setq id-start (point)))) + + (setq subres + (let ((c-promote-possible-types t) + (c-record-found-types t)) + (c-forward-<>-arglist-recur + (and keyword-match + (c-keyword-member (c-keyword-sym (match-string 1)) 'c-<>-type-kwds))))) ))) @@ -5574,14 +5553,16 @@ (c-forward-syntactic-ws) (looking-at c-opt-identifier-concat-key))) (c-record-ref-id (cons id-start id-end)) - (c-record-type-id (cons id-start id-end)))))) - t) - - ((and (eq (char-before) ?,) - (not c-restricted-<>-arglists)) - ;; Just another argument. Record the position. The - ;; type check stuff that made us stop at it is at - ;; the top of the loop. + (c-record-type-id (cons id-start id-end)))))) + t) + + ((and (not c-restricted-<>-arglists) + (or (and (eq (char-before) ?&) + (not (eq (char-after) ?&))) + (eq (char-before) ?,))) + ;; Just another argument. Record the position. The + ;; type check stuff that made us stop at it is at + ;; the top of the loop. (setq arg-start-pos (cons (point) arg-start-pos))) (t @@ -5590,7 +5571,6 @@ ;; it's useless to try to find a surrounding arglist ;; if we're nested. (throw 'angle-bracket-arglist-escape nil)))))) - (if res (or c-record-found-types t))))) @@ -5793,9 +5773,8 @@ ((and c-recognize-<>-arglists (eq (char-after) ?<)) ;; Maybe an angle bracket arglist. - - (when (let (c-record-type-identifiers - c-record-found-types) + (when (let ((c-record-type-identifiers t) + (c-record-found-types t)) (c-forward-<>-arglist nil)) (c-add-type start (1+ pos)) @@ -5844,6 +5823,9 @@ ;; `c-record-type-identifiers' is non-nil. ;; ;; This function might do hidden buffer changes. + (when (looking-at "<") + (c-forward-<>-arglist t) + (c-forward-syntactic-ws)) (let ((start (point)) pos res name-res id-start id-end id-range) @@ -6043,6 +6025,18 @@ res)) +(defun c-forward-annotation () + ;; Used for Java code only at the moment. Assumes point is on the + ;; @, moves forward an annotation. returns nil if there is no + ;; annotation at point. + (and (looking-at "@") + (progn (forward-char) t) + (c-forward-type) + (progn (c-forward-syntactic-ws) t) + (if (looking-at "(") + (c-go-list-forward) + t))) + ;; Handling of large scale constructs like statements and declarations. @@ -6212,6 +6206,9 @@ (save-rec-type-ids c-record-type-identifiers) (save-rec-ref-ids c-record-ref-identifiers)) + (while (c-forward-annotation) + (c-forward-syntactic-ws)) + ;; Check for a type. Unknown symbols are treated as possible ;; types, but they could also be specifiers disguised through ;; macros like __INLINE__, so we recognize both types and known @@ -6545,13 +6542,14 @@ ;; CASE 3 (when (= (point) start) ;; Got a plain list of identifiers. If a colon follows it's - ;; a valid label. Otherwise the last one probably is the - ;; declared identifier and we should back up to the previous - ;; type, providing it isn't a cast. - (if (eq (char-after) ?:) - ;; If we've found a specifier keyword then it's a - ;; declaration regardless. - (throw 'at-decl-or-cast (eq at-decl-or-cast t)) + ;; a valid label. Otherwise the last one probably is the + ;; declared identifier and we should back up to the previous + ;; type, providing it isn't a cast. + (if (and (eq (char-after) ?:) + (not (c-major-mode-is 'java-mode))) + ;; If we've found a specifier keyword then it's a + ;; declaration regardless. + (throw 'at-decl-or-cast (eq at-decl-or-cast t)) (setq backup-if-not-cast t) (throw 'at-decl-or-cast t))) @@ -8512,7 +8510,7 @@ ;; ;; This function might do hidden buffer changes. - (let (special-brace-list) + (let (special-brace-list placeholder) (goto-char indent-point) (skip-chars-forward " \t") @@ -8619,6 +8617,22 @@ (c-add-stmt-syntax 'func-decl-cont nil t containing-sexp paren-state)) + ;;CASE F: continued statement and the only preceding items are + ;;annotations. + ((and (c-major-mode-is 'java-mode) + (setq placeholder (point)) + (c-beginning-of-statement-1) + (progn + (while (and (c-forward-annotation) + (< (point) placeholder)) + (c-forward-syntactic-ws)) + t) + (prog1 + (>= (point) placeholder) + (goto-char placeholder))) + (c-beginning-of-statement-1 containing-sexp) + (c-add-syntax 'annotation-var-cont (point))) + ;; CASE D: continued statement. (t (c-beginning-of-statement-1 containing-sexp) @@ -8718,7 +8732,6 @@ (when (and containing-sexp (eq (char-after containing-sexp) ?\()) (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) - ;; cache char before and after indent point, and move point to ;; the most likely position to perform the majority of tests (goto-char indent-point) @@ -9468,23 +9481,36 @@ (c-add-syntax 'objc-method-args-cont placeholder)) ;; CASE 5L: we are at the first argument of a template - ;; arglist that begins on the previous line. - ((and c-recognize-<>-arglists - (eq (char-before) ?<) - (setq placeholder (1- (point))) - (not (and c-overloadable-operators-regexp - (c-after-special-operator-id lim)))) - (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) - (c-add-syntax 'template-args-cont (c-point 'boi) placeholder)) - - ;; CASE 5Q: we are at a statement within a macro. - (macro-start - (c-beginning-of-statement-1 containing-sexp) - (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) - - ;; CASE 5M: we are at a topmost continuation line - (t - (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) + ;; arglist that begins on the previous line. + ((and c-recognize-<>-arglists + (eq (char-before) ?<) + (not (and c-overloadable-operators-regexp + (c-after-special-operator-id lim)))) + (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) + (c-add-syntax 'template-args-cont (c-point 'boi))) + + ;; CASE 5Q: we are at a statement within a macro. + (macro-start + (c-beginning-of-statement-1 containing-sexp) + (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) + + ;;CASE 5N: We are at a tompmost continuation line and the only + ;;preceding items are annotations. + ((and (c-major-mode-is 'java-mode) + (setq placeholder (point)) + (c-beginning-of-statement-1) + (progn + (while (and (c-forward-annotation)) + (c-forward-syntactic-ws)) + t) + (prog1 + (>= (point) placeholder) + (goto-char placeholder))) + (c-add-syntax 'annotation-top-cont (c-point 'boi))) + + ;; CASE 5M: we are at a topmost continuation line + (t + (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) (when (c-major-mode-is 'objc-mode) (setq placeholder (point)) (while (and (c-forward-objc-directive) @@ -9495,43 +9521,20 @@ (c-add-syntax 'topmost-intro-cont (c-point 'boi))) )) - ;; (CASE 6 has been removed.) - - ;; CASE 19: line is an expression, not a statement, and is directly - ;; contained by a template delimiter. Most likely, we are in a - ;; template arglist within a statement. This case is based on CASE - ;; 7. At some point in the future, we may wish to create more - ;; syntactic symbols such as `template-intro', - ;; `template-cont-nonempty', etc., and distinguish between them as we - ;; do for `arglist-intro' etc. (2009-12-07). - ((and c-recognize-<>-arglists - (setq containing-< (c-up-list-backward indent-point containing-sexp)) - (eq (char-after containing-<) ?\<)) - (setq placeholder (c-point 'boi containing-<)) - (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not - ; '<') before indent-point. - (if (>= (point) placeholder) - (progn - (forward-char) - (skip-chars-forward " \t")) - (goto-char placeholder)) - (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) - paren-state)) - - - ;; CASE 7: line is an expression, not a statement. Most - ;; likely we are either in a function prototype or a function - ;; call argument list, or a template argument list. - ((not (or (and c-special-brace-lists - (save-excursion - (goto-char containing-sexp) - (c-looking-at-special-brace-list))) - (eq (char-after containing-sexp) ?{) - (eq (char-after containing-sexp) ?<))) - (cond - - ;; CASE 7A: we are looking at the arglist closing paren. + + ;; (CASE 6 has been removed.) + + ;; CASE 7: line is an expression, not a statement. Most + ;; likely we are either in a function prototype or a function + ;; call argument list + ((not (or (and c-special-brace-lists + (save-excursion + (goto-char containing-sexp) + (c-looking-at-special-brace-list))) + (eq (char-after containing-sexp) ?{))) + (cond + + ;; CASE 7A: we are looking at the arglist closing paren. ;; C.f. case 7F. ((memq char-after-ip '(?\) ?\])) (goto-char containing-sexp) @@ -9543,12 +9546,34 @@ (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'arglist-close (list containing-sexp) t - (c-most-enclosing-brace paren-state (point)) - paren-state)) - - ;; CASE 7B: Looking at the opening brace of an - ;; in-expression block or brace list. C.f. cases 4, 16A - ;; and 17E. + (c-most-enclosing-brace paren-state (point)) + paren-state)) + + ;; CASE 19: line is an expression, not a statement, and is directly + ;; contained by a template delimiter. Most likely, we are in a + ;; template arglist within a statement. This case is based on CASE + ;; 7. At some point in the future, we may wish to create more + ;; syntactic symbols such as `template-intro', + ;; `template-cont-nonempty', etc., and distinguish between them as we + ;; do for `arglist-intro' etc. (2009-12-07). + ((and c-recognize-<>-arglists + (setq containing-< (c-up-list-backward indent-point containing-sexp)) + (eq (char-after containing-<) ?\<)) + (setq placeholder (c-point 'boi containing-<)) + (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not + ; '<') before indent-point. + (if (>= (point) placeholder) + (progn + (forward-char) + (skip-chars-forward " \t")) + (goto-char placeholder)) + (c-add-stmt-syntax 'template-args-cont (list containing-<) t + (c-most-enclosing-brace c-state-cache (point)) + paren-state)) + + ;; CASE 7B: Looking at the opening brace of an + ;; in-expression block or brace list. C.f. cases 4, 16A + ;; and 17E. ((and (eq char-after-ip ?{) (progn (setq placeholder (c-inside-bracelist-p (point) diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-fonts.el --- a/lisp/progmodes/cc-fonts.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-fonts.el Sun Aug 01 22:48:29 2010 +0000 @@ -194,6 +194,10 @@ (unless (face-property-instance oldface 'reverse) (invert-face newface))))) +(defvar c-annotation-face (make-face 'c-annotation-face) + "Face used to highlight annotations in java-mode and other modes that may wish to use it.") +(set-face-foreground 'c-annotation-face "blue") + (eval-and-compile ;; We need the following functions during compilation since they're ;; called when the `c-lang-defconst' initializers are evaluated. @@ -1538,6 +1542,9 @@ '((c-fontify-types-and-refs ((c-promote-possible-types t)) (c-forward-keyword-clause 1) (if (> (point) limit) (goto-char limit)))))))) + + ,@(when (c-major-mode-is 'java-mode) + `((eval . (list "\\<\\(@[a-zA-Z0-9]+\\)\\>" 1 c-annotation-face)))) )) (c-lang-defconst c-matchers-1 diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-langs.el --- a/lisp/progmodes/cc-langs.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-langs.el Sun Aug 01 22:48:29 2010 +0000 @@ -359,7 +359,7 @@ (let ((table (make-syntax-table))) (c-populate-syntax-table table) ;; Mode specific syntaxes. - ,(cond ((c-major-mode-is 'objc-mode) + ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode)) ;; Let '@' be part of symbols in ObjC to cope with ;; its compiler directives as single keyword tokens. ;; This is then necessary since it's assumed that @@ -382,7 +382,7 @@ ;; '<' and '>' characters. Therefore this syntax table might go ;; away when CC Mode handles templates correctly everywhere. t nil - c++ `(lambda () + (java c++) `(lambda () (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) (modify-syntax-entry ?< "(>" table) (modify-syntax-entry ?> ")<" table) @@ -425,7 +425,7 @@ ;; it as an indentifier character since it's often used in various ;; machine generated identifiers. t '((?_ . "w") (?$ . "w")) - objc (append '((?@ . "w")) + (objc java) (append '((?@ . "w")) (c-lang-const c-identifier-syntax-modifications)) awk '((?_ . "w"))) (c-lang-defvar c-identifier-syntax-modifications @@ -502,9 +502,10 @@ (c-lang-defconst c-symbol-start "Regexp that matches the start of a symbol, i.e. any identifier or -keyword. It's unspecified how far it matches. Does not contain a \\| +keyword. It's unspecified how far it matches. Does not contain a \\| operator at the top level." t (concat "[" c-alpha "_]") + java (concat "[" c-alpha "_@]") objc (concat "[" c-alpha "@]") pike (concat "[" c-alpha "_`]")) (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start)) @@ -859,7 +860,7 @@ ;; Primary. ,@(c-lang-const c-identifier-ops) - ,@(cond ((c-major-mode-is 'c++-mode) + ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode)) `((postfix-if-paren "<" ">"))) ; Templates. ((c-major-mode-is 'pike-mode) `((prefix "global" "predef"))) @@ -1118,6 +1119,7 @@ t "\\`<." (lambda (op) (substring op 1))))) + (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) (c-lang-defconst c->-op-cont-regexp @@ -1127,7 +1129,13 @@ (c-filter-ops (c-lang-const c-all-op-syntax-tokens) t "\\`>." - (lambda (op) (substring op 1))))) + (lambda (op) (substring op 1)))) + java (c-make-keywords-re nil + (c-filter-ops (c-lang-const c-all-op-syntax-tokens) + t + "\\`>[^>]\\|\\`>>[^>]" + (lambda (op) (substring op 1))))) + (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp)) (c-lang-defconst c-stmt-delim-chars @@ -1628,7 +1636,7 @@ c++ '("class" "struct" "union") objc '("struct" "union" "@interface" "@implementation" "@protocol") - java '("class" "interface") + java '("class" "@interface" "interface") idl '("component" "eventtype" "exception" "home" "interface" "struct" "union" "valuetype" ;; In CORBA PSDL: @@ -1651,7 +1659,7 @@ `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses will be handled." t '("enum") - (java awk) nil) + (awk) nil) (c-lang-defconst c-brace-list-key ;; Regexp matching the start of declarations where the following @@ -1772,7 +1780,7 @@ "bindsTo" "delegatesTo" "implements" "proxy" "storedOn") ;; Note: "const" is not used in Java, but it's still a reserved keyword. java '("abstract" "const" "final" "native" "private" "protected" "public" - "static" "strictfp" "synchronized" "transient" "volatile") + "static" "strictfp" "synchronized" "transient" "volatile" "@[A-Za-z0-9]+") pike '("final" "inline" "local" "nomask" "optional" "private" "protected" "public" "static" "variant")) @@ -1858,7 +1866,11 @@ (c-lang-defconst c-prefix-spec-kwds-re ;; Adorned regexp of `c-prefix-spec-kwds'. - t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))) + t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)) + java (replace-regexp-in-string + "\\\\\\[" "[" + (replace-regexp-in-string "\\\\\\+" "+" (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))))) + (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re)) (c-lang-defconst c-specifier-key @@ -1950,7 +1962,7 @@ t nil c++ '("operator") objc '("@class") - java '("import" "new" "extends" "implements" "throws") + java '("import" "new" "extends" "super" "implements" "throws") idl '("manages" "native" "primarykey" "supports" ;; In CORBA PSDL: "as" "implements" "of" "scope") @@ -2499,7 +2511,7 @@ ;; in all languages except Java for when a cpp macro definition ;; begins with a declaration. t "\\([\{\}\(\);,]+\\)" - java "\\([\{\}\(;,]+\\)" + java "\\([\{\}\(;,<]+\\)" ;; Match "<" in C++ to get the first argument in a template arglist. ;; In that case there's an additional check in `c-find-decl-spots' ;; that it got open paren syntax. @@ -2759,7 +2771,7 @@ is in effect or not." t nil (c c++ objc pike) "\\(\\.\\.\\.\\)" - java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)")) + java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)")) (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key)) (c-lang-defvar c-known-type-key diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-mode.el --- a/lisp/progmodes/cc-mode.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-mode.el Sun Aug 01 22:48:29 2010 +0000 @@ -522,7 +522,7 @@ (when (or c-recognize-<>-arglists (c-major-mode-is 'awk-mode) - (c-major-mode-is '(c-mode c++-mode objc-mode))) + (c-major-mode-is '(java-mode c-mode c++-mode objc-mode))) ;; We'll use the syntax-table text property to change the syntax ;; of some chars for this language, so do the necessary setup for ;; that. diff -r 9a965dbf641e -r 768a90ad492c lisp/progmodes/cc-vars.el --- a/lisp/progmodes/cc-vars.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/progmodes/cc-vars.el Sun Aug 01 22:48:29 2010 +0000 @@ -1056,9 +1056,13 @@ ;; Anchor pos: Boi at the topmost intro line. (knr-argdecl . 0) ;; Anchor pos: At the beginning of the first K&R argdecl. - (topmost-intro . 0) + (topmost-intro . 0) ;; Anchor pos: Bol at the last line of previous construct. (topmost-intro-cont . c-lineup-topmost-intro-cont) + ;;Anchor pos: Bol at the topmost annotation line + (annotation-top-cont . 0) + ;;Anchor pos: Bol at the topmost annotation line + (annotation-var-cont . +) ;; Anchor pos: Boi at the topmost intro line. (member-init-intro . +) ;; Anchor pos: Boi at the func decl arglist open. @@ -1285,12 +1289,16 @@ between them; in C++ and Java, throws declarations and other things can appear in this context. knr-argdecl-intro -- First line of a K&R C argument declaration. - knr-argdecl -- Subsequent lines in a K&R C argument declaration. - topmost-intro -- The first line in a topmost construct definition. - topmost-intro-cont -- Topmost definition continuation lines. - member-init-intro -- First line in a member initialization list. - member-init-cont -- Subsequent member initialization list lines. - inher-intro -- First line of a multiple inheritance list. + knr-argdecl -- Subsequent lines in a K&R C argument declaration. + topmost-intro -- The first line in a topmost construct definition. + topmost-intro-cont -- Topmost definition continuation lines. + annotation-top-cont -- Topmost definition continuation line where only + annotations are on previous lines. + annotation-var-cont -- A continuation of a C (or like) statement where + only annotations are on previous lines. + member-init-intro -- First line in a member initialization list. + member-init-cont -- Subsequent member initialization list lines. + inher-intro -- First line of a multiple inheritance list. inher-cont -- Subsequent multiple inheritance lines. block-open -- Statement block open brace. block-close -- Statement block close brace. @@ -1376,7 +1384,7 @@ '(defun-block-intro block-open block-close statement statement-cont statement-block-intro statement-case-intro statement-case-open substatement substatement-open substatement-label case-label label - do-while-closure else-clause catch-clause inlambda)) + do-while-closure else-clause catch-clause inlambda annotation-var-cont)) (defcustom c-style-variables-are-local-p t "*Whether style variables should be buffer local by default. @@ -1577,7 +1585,7 @@ :group 'c) (defcustom java-font-lock-extra-types - (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) + (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw")) (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means capitalized words are treated as type names (the requirement for a diff -r 9a965dbf641e -r 768a90ad492c lisp/term/x-win.el --- a/lisp/term/x-win.el Fri Jul 30 02:11:29 2010 +0000 +++ b/lisp/term/x-win.el Sun Aug 01 22:48:29 2010 +0000 @@ -1234,18 +1234,12 @@ (defun x-select-text (text &optional push) "Select TEXT, a string, according to the window system. - -On X, put TEXT in the primary X selection. For backward -compatibility with older X applications, set the value of X cut -buffer 0 as well, and if the optional argument PUSH is non-nil, -rotate the cut buffers. If `x-select-enable-clipboard' is -non-nil, copy the text to the X clipboard as well. - -On Windows, make TEXT the current selection. If -`x-select-enable-clipboard' is non-nil, copy the text to the -clipboard as well. The argument PUSH is ignored. - -On Nextstep, put TEXT in the pasteboard; PUSH is ignored." +If `x-select-enable-clipboard' is non-nil, copy TEXT to the +clipboard. If `x-select-enable-primary' is non-nil, put TEXT in +the primary selection. For backward compatibility with older X +applications, this function also sets the value of X cut buffer +0, and, if the optional argument PUSH is non-nil, rotates the cut +buffers." ;; With multi-tty, this function may be called from a tty frame. (when (eq (framep (selected-frame)) 'x) ;; Don't send the cut buffer too much text. diff -r 9a965dbf641e -r 768a90ad492c src/ChangeLog --- a/src/ChangeLog Fri Jul 30 02:11:29 2010 +0000 +++ b/src/ChangeLog Sun Aug 01 22:48:29 2010 +0000 @@ -1,3 +1,41 @@ +2010-08-01 Jan Djärv + + * xterm.h (struct x_output): Add ttip_widget, ttip_window and + ttip_lbl. + + * xterm.c (x_clear_frame): Check FRAME_GTK_WIDGET (f) before + calling gtk_widget_queue_draw. + (x_free_frame_resources): Call xg_free_frame_widgets. + + * xfns.c (x_gtk_use_system_tooltips): New variable. + (Fx_show_tip): If USE_GTK and x_gtk_use_system_tooltips, call + new gtkutil tooltip functions to show the tooltip. + (Fx_hide_tip): Call xg_hide_tooltip. + (syms_of_xfns): Defvar x-gtk-use-system-tooltips. + + * gtkutil.h (xg_free_frame_widgets, xg_prepare_tooltip) + (xg_show_tooltip, xg_hide_tooltip): Declare. + + * gtkutil.c (hierarchy_ch_cb, qttip_cb, xg_prepare_tooltip) + (xg_show_tooltip, xg_hide_tooltip, xg_free_frame_widgets): New + functions. + (xg_create_frame_widgets): Set ttip_* to 0. Set a dummy tooltip + text so qttip_cb is called. Connect query-tooltip to qttip_cb. + Remove code that is commented out. + +2010-08-01 Stefan Monnier + + * keymap.c (Fdefine_key, Flookup_key): Say what event is invalid. + +2010-07-31 Chong Yidong + + * xselect.c (x_own_selection): Use list4. + +2010-07-30 Dan Nicolaescu + + * buffer.c (Qwindow): Do not define, already defined in data.c. + (syms_of_buffer): Do not intern and staticpro Qwindow. (Bug#6760) + 2010-07-29 Chad Brown Replace tests for SYSV_SYSTEM_DIR with HAVE_DIRENT_H, set via autoconf. @@ -21303,7 +21341,7 @@ * charset.c (charset_ordered_list_tick): New variable. (Fdefine_charset_internal): Increment charset_ordered_list_tick. (Funify_charset): New optional arg DEUNIFY. If it is non-nil, - deunify intead of unify a charset. + deunify instead of unify a charset. (string_xstring_p): Add `const' to local variables. (find_charsets_in_text): Add `const' to arguments and local variables. (encode_char): Adjust for the change of Funify_charset. Fix diff -r 9a965dbf641e -r 768a90ad492c src/buffer.c --- a/src/buffer.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/buffer.c Sun Aug 01 22:48:29 2010 +0000 @@ -162,7 +162,7 @@ Lisp_Object Qoverlayp; -Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string; +Lisp_Object Qpriority, Qevaporate, Qbefore_string, Qafter_string; Lisp_Object Qmodification_hooks; Lisp_Object Qinsert_in_front_hooks; @@ -5345,8 +5345,6 @@ staticpro (&Qget_file_buffer); Qpriority = intern_c_string ("priority"); staticpro (&Qpriority); - Qwindow = intern_c_string ("window"); - staticpro (&Qwindow); Qbefore_string = intern_c_string ("before-string"); staticpro (&Qbefore_string); Qafter_string = intern_c_string ("after-string"); diff -r 9a965dbf641e -r 768a90ad492c src/gtkutil.c --- a/src/gtkutil.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/gtkutil.c Sun Aug 01 22:48:29 2010 +0000 @@ -508,6 +508,161 @@ /*********************************************************************** + Tooltips + ***********************************************************************/ +/* Gtk+ calls this callback when the parent of our tooltip dummy changes. + We use that to pop down the tooltip. This happens if Gtk+ for some + reason wants to change or hide the tooltip. */ + +static void +hierarchy_ch_cb (GtkWidget *widget, + GtkWidget *previous_toplevel, + gpointer user_data) +{ + FRAME_PTR f = (FRAME_PTR) user_data; + struct x_output *x = f->output_data.x; + GtkWidget *top = gtk_widget_get_toplevel (x->ttip_lbl); + + if (! top || ! GTK_IS_WINDOW (top)) + gtk_widget_hide (previous_toplevel); +} + +/* Callback called when Gtk+ thinks a tooltip should be displayed. + We use it to get the tooltip window and the tooltip widget so + we can manipulate the ourselves. + + Return FALSE ensures that the tooltip is not shown. */ + +static gboolean +qttip_cb (GtkWidget *widget, + gint xpos, + gint ypos, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) +{ + FRAME_PTR f = (FRAME_PTR) user_data; + struct x_output *x = f->output_data.x; + if (x->ttip_widget == NULL) + { + g_object_set (G_OBJECT (widget), "has-tooltip", FALSE, NULL); + x->ttip_widget = tooltip; + g_object_ref (G_OBJECT (tooltip)); + x->ttip_lbl = gtk_label_new (""); + g_object_ref (G_OBJECT (x->ttip_lbl)); + gtk_tooltip_set_custom (tooltip, x->ttip_lbl); + x->ttip_window = GTK_WINDOW (gtk_widget_get_toplevel (x->ttip_lbl)); + /* Realize so we can safely get screen later on. */ + gtk_widget_realize (GTK_WIDGET (x->ttip_window)); + gtk_widget_realize (x->ttip_lbl); + + g_signal_connect (x->ttip_lbl, "hierarchy-changed", + G_CALLBACK (hierarchy_ch_cb), f); + } + return FALSE; +} + +/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT. + Return zero if no system tooltip available, non-zero otherwise. */ + +int +xg_prepare_tooltip (FRAME_PTR f, + Lisp_Object string, + int *width, + int *height) +{ + struct x_output *x = f->output_data.x; + GtkWidget *widget; + GdkWindow *gwin; + GdkScreen *screen; + GtkSettings *settings; + gboolean tt_enabled = TRUE; + GtkRequisition req; + Lisp_Object encoded_string; + + if (!x->ttip_lbl) return 0; + + BLOCK_INPUT; + encoded_string = ENCODE_UTF_8 (string); + widget = GTK_WIDGET (x->ttip_lbl); + gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window)); + screen = gdk_drawable_get_screen (gwin); + settings = gtk_settings_get_for_screen (screen); + g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL); + if (tt_enabled) + { + g_object_set (settings, "gtk-enable-tooltips", FALSE, NULL); + /* Record that we disabled it so it can be enabled again. */ + g_object_set_data (G_OBJECT (x->ttip_window), "restore-tt", + (gpointer)f); + } + + /* Prevent Gtk+ from hiding tooltip on mouse move and such. */ + g_object_set_data (G_OBJECT + (gtk_widget_get_display (GTK_WIDGET (x->ttip_window))), + "gdk-display-current-tooltip", NULL); + + /* Put out dummy widget in so we can get callbacks for unrealize and + hierarchy-changed. */ + gtk_tooltip_set_custom (x->ttip_widget, widget); + + gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string)); + gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req); + if (width) *width = req.width; + if (height) *height = req.height; + + UNBLOCK_INPUT; + + return 1; +} + +/* Show the tooltip at ROOT_X and ROOT_Y. + xg_prepare_tooltip must have been called before this function. */ + +void +xg_show_tooltip (FRAME_PTR f, int root_x, int root_y) +{ + struct x_output *x = f->output_data.x; + if (x->ttip_window) + { + BLOCK_INPUT; + gtk_window_move (x->ttip_window, root_x, root_y); + gtk_widget_show_all (GTK_WIDGET (x->ttip_window)); + UNBLOCK_INPUT; + } +} + +/* Hide tooltip if shown. Do nothing if not shown. + Return non-zero if tip was hidden, non-ero if not (i.e. not using + system tooltips). */ + +int +xg_hide_tooltip (FRAME_PTR f) +{ + int ret = 0; + if (f->output_data.x->ttip_window) + { + GtkWindow *win = f->output_data.x->ttip_window; + BLOCK_INPUT; + gtk_widget_hide (GTK_WIDGET (win)); + + if (g_object_get_data (G_OBJECT (win), "restore-tt")) + { + GdkWindow *gwin = gtk_widget_get_window (GTK_WIDGET (win)); + GdkScreen *screen = gdk_drawable_get_screen (gwin); + GtkSettings *settings = gtk_settings_get_for_screen (screen); + g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL); + } + UNBLOCK_INPUT; + + ret = 1; + } + + return ret; +} + + +/*********************************************************************** General functions for creating widgets, resizing, events, e.t.c. ***********************************************************************/ @@ -847,17 +1002,34 @@ style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup (""); gtk_widget_modify_style (wfixed, style); - /* GTK does not set any border, and they look bad with GTK. */ - /* That they look bad is no excuse for imposing this here. --Stef - It should be done by providing the proper default in Fx_create_Frame. - f->border_width = 0; - f->internal_border_width = 0; */ + /* Steal a tool tip window we can move ourselves. */ + f->output_data.x->ttip_widget = 0; + f->output_data.x->ttip_lbl = 0; + f->output_data.x->ttip_window = 0; + gtk_widget_set_tooltip_text (wtop, "Dummy text"); + g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f); UNBLOCK_INPUT; return 1; } +void +xg_free_frame_widgets (FRAME_PTR f) +{ + if (FRAME_GTK_OUTER_WIDGET (f)) + { + struct x_output *x = f->output_data.x; + gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); + FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */ + FRAME_GTK_OUTER_WIDGET (f) = 0; + if (x->ttip_lbl) + gtk_widget_destroy (x->ttip_lbl); + if (x->ttip_widget) + g_object_unref (G_OBJECT (x->ttip_widget)); + } +} + /* Set the normal size hints for the window manager, for frame F. FLAGS is the flags word to use--or 0 meaning preserve the flags that the window now has. diff -r 9a965dbf641e -r 768a90ad492c src/gtkutil.h --- a/src/gtkutil.h Fri Jul 30 02:11:29 2010 +0000 +++ b/src/gtkutil.h Sun Aug 01 22:48:29 2010 +0000 @@ -194,6 +194,7 @@ extern GdkCursor * xg_create_default_cursor (Display *dpy); extern int xg_create_frame_widgets (FRAME_PTR f); +extern void xg_free_frame_widgets (FRAME_PTR f); extern void x_wm_set_size_hint (FRAME_PTR f, long flags, int user_position); @@ -203,6 +204,14 @@ Pixmap icon_pixmap, Pixmap icon_mask); +extern int xg_prepare_tooltip (FRAME_PTR f, + Lisp_Object string, + int *width, + int *height); +extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y); +extern int xg_hide_tooltip (FRAME_PTR f); + + /* Mark all callback data that are Lisp_object:s during GC. */ extern void xg_mark_data (void); diff -r 9a965dbf641e -r 768a90ad492c src/keymap.c --- a/src/keymap.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/keymap.c Sun Aug 01 22:48:29 2010 +0000 @@ -1226,7 +1226,7 @@ && (!CONSP (c) /* If C is a range, it must be a leaf. */ || (INTEGERP (XCAR (c)) && idx != length))) - error ("Key sequence contains invalid event"); + message_with_string ("Key sequence contains invalid event %s", c, 1); if (idx == length) RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); @@ -1340,7 +1340,7 @@ /* Allow string since binding for `menu-bar-select-buffer' includes the buffer name in the key sequence. */ if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c) && !STRINGP (c)) - error ("Key sequence contains invalid event"); + message_with_string ("Key sequence contains invalid event %s", c, 1); cmd = access_keymap (keymap, c, t_ok, 0, 1); if (idx == length) diff -r 9a965dbf641e -r 768a90ad492c src/xfns.c --- a/src/xfns.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/xfns.c Sun Aug 01 22:48:29 2010 +0000 @@ -161,6 +161,10 @@ int x_gtk_whole_detached_tool_bar; +/* If non-zero, use Gtk+ tooltips. */ + +static int x_gtk_use_system_tooltips; + /* The background and shape of the mouse pointer, and shape when not over text or in the modeline. */ @@ -4610,7 +4614,9 @@ when this happens. */ static Lisp_Object -x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms, Lisp_Object text) +x_create_tip_frame (struct x_display_info *dpyinfo, + Lisp_Object parms, + Lisp_Object text) { struct frame *f; Lisp_Object frame, tem; @@ -5037,6 +5043,27 @@ else CHECK_NUMBER (dy); +#ifdef USE_GTK + if (x_gtk_use_system_tooltips) + { + int ok; + + /* Hide a previous tip, if any. */ + Fx_hide_tip (); + + BLOCK_INPUT; + if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0) + { + compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); + xg_show_tooltip (f, root_x, root_y); + /* This is used in Fx_hide_tip. */ + XSETFRAME (tip_frame, f); + } + UNBLOCK_INPUT; + if (ok) goto start_timer; + } +#endif /* USE_GTK */ + if (NILP (last_show_tip_args)) last_show_tip_args = Fmake_vector (make_number (3), Qnil); @@ -5197,6 +5224,7 @@ int count; Lisp_Object deleted, frame, timer; struct gcpro gcpro1, gcpro2; + struct frame *f; /* Return quickly if nothing to do. */ if (NILP (tip_timer) && NILP (tip_frame)) @@ -5214,6 +5242,14 @@ if (!NILP (timer)) call1 (Qcancel_timer, timer); +#ifdef USE_GTK + /* When using system tooltip, tip_frame is the Emacs frame on which + the tip is shown. */ + f = XFRAME (frame); + if (xg_hide_tooltip (f)) + frame = Qnil; +#endif + if (FRAMEP (frame)) { delete_frame (frame, Qnil); @@ -5224,8 +5260,9 @@ redisplay procedure is not called when a tip frame over menu items is unmapped. Redisplay the menu manually... */ { - struct frame *f = SELECTED_FRAME (); - Widget w = f->output_data.x->menubar_widget; + Widget w; + f = SELECTED_FRAME (); + w = f->output_data.x->menubar_widget; if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) && w != NULL) @@ -5894,6 +5931,12 @@ the tool bar buttons. */); x_gtk_whole_detached_tool_bar = 0; + DEFVAR_BOOL ("x-gtk-use-system-tooltips", &x_gtk_use_system_tooltips, + doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used. +Otherwise use Emacs own tooltip implementation. +When using Gtk+ tooltips, the tooltip face is not used. */); + x_gtk_use_system_tooltips = 1; + Fprovide (intern_c_string ("x"), Qnil); #ifdef USE_X_TOOLKIT diff -r 9a965dbf641e -r 768a90ad492c src/xselect.c --- a/src/xselect.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/xselect.c Sun Aug 01 22:48:29 2010 +0000 @@ -392,7 +392,7 @@ selecting_window = FRAME_X_WINDOW (sf); display = FRAME_X_DISPLAY (sf); dpyinfo = FRAME_X_DISPLAY_INFO (sf); - + CHECK_SYMBOL (selection_name); selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name); @@ -410,10 +410,8 @@ Lisp_Object prev_value; selection_time = long_to_cons ((unsigned long) time); - selection_data = Fcons (selection_name, - Fcons (selection_value, - Fcons (selection_time, - Fcons (selected_frame, Qnil)))); + selection_data = list4 (selection_name, selection_value, + selection_time, selected_frame); prev_value = assq_no_quit (selection_name, Vselection_alist); Vselection_alist = Fcons (selection_data, Vselection_alist); @@ -1015,7 +1013,7 @@ } } UNBLOCK_INPUT; - + selection_symbol = x_atom_to_symbol (display, selection); local_selection_data = assq_no_quit (selection_symbol, Vselection_alist); @@ -2416,7 +2414,7 @@ Atom props[8]; Display *display; struct frame *sf = SELECTED_FRAME (); - + check_x (); if (! FRAME_X_P (sf)) diff -r 9a965dbf641e -r 768a90ad492c src/xterm.c --- a/src/xterm.c Fri Jul 30 02:11:29 2010 +0000 +++ b/src/xterm.c Sun Aug 01 22:48:29 2010 +0000 @@ -2842,7 +2842,8 @@ #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) /* Make sure scroll bars are redrawn. As they aren't redrawn by redisplay, do it here. */ - gtk_widget_queue_draw (FRAME_GTK_WIDGET (f)); + if (FRAME_GTK_WIDGET (f)) + gtk_widget_queue_draw (FRAME_GTK_WIDGET (f)); #endif XFlush (FRAME_X_DISPLAY (f)); @@ -9278,14 +9279,7 @@ #else /* !USE_X_TOOLKIT */ #ifdef USE_GTK - /* In the GTK version, tooltips are normal X - frames. We must check and free both types. */ - if (FRAME_GTK_OUTER_WIDGET (f)) - { - gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); - FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow below */ - FRAME_GTK_OUTER_WIDGET (f) = 0; - } + xg_free_frame_widgets (f); #endif /* USE_GTK */ if (FRAME_X_WINDOW (f)) diff -r 9a965dbf641e -r 768a90ad492c src/xterm.h --- a/src/xterm.h Fri Jul 30 02:11:29 2010 +0000 +++ b/src/xterm.h Sun Aug 01 22:48:29 2010 +0000 @@ -502,6 +502,10 @@ /* The last size hints set. */ GdkGeometry size_hints; long hint_flags; + + GtkTooltip *ttip_widget; + GtkWidget *ttip_lbl; + GtkWindow *ttip_window; #endif /* If >=0, a bitmap index. The indicated bitmap is used for the