Now on revision 106929. ------------------------------------------------------------ revno: 106929 author: Mats Lidell committer: Chong Yidong branch nick: trunk timestamp: Wed 2012-01-25 14:12:10 +0800 message: Update TUTORIAL.sv. diff: === modified file 'admin/FOR-RELEASE' --- admin/FOR-RELEASE 2012-01-25 05:48:11 +0000 +++ admin/FOR-RELEASE 2012-01-25 06:12:10 +0000 @@ -118,7 +118,7 @@ TUTORIAL.ru TUTORIAL.sk TUTORIAL.sl Primoz PETERLIN -TUTORIAL.sv +TUTORIAL.sv Mats Lidell TUTORIAL.th TUTORIAL.zh === modified file 'etc/ChangeLog' --- etc/ChangeLog 2012-01-21 14:58:38 +0000 +++ etc/ChangeLog 2012-01-25 06:12:10 +0000 @@ -1,3 +1,7 @@ +2012-01-25 Mats Lidell + + * tutorials/TUTORIAL.sv: Updated; synchronize with TUTORIAL. + 2012-01-21 Ognyan Kulev * tutorials/TUTORIAL.bg: Updated; synchronize with TUTORIAL. === modified file 'etc/tutorials/TUTORIAL.sv' --- etc/tutorials/TUTORIAL.sv 2012-01-19 07:21:25 +0000 +++ etc/tutorials/TUTORIAL.sv 2012-01-25 06:12:10 +0000 @@ -11,6 +11,7 @@ den och trycker sedan . Viktigt: För att avsluta Emacs trycker du C-x C-c (två tecken). +För att avsluta kommandon som inte skrivits in fullt, tryck C-g. Tecknen ">>" i vänstermarginalen anger att du kan prova ett kommando. Till exempel: <> @@ -45,7 +46,9 @@ >> Leta reda på markören och se vad som står där. Tryck sedan C-l. Hitta markören igen och notera att det är samma text som står kring - markören nu. + markören nu, men nu mitt på skärmen. Om du trycker C-l igen så + flyttas texten högst upp på skärmen. Tryck C-l igen och den flyttas + ner till botten. Du kan också använda PageUp och PageDn tangenterna, om din terminal har dem, för att flytta en hel skärmbild åt gången, men du redigerar @@ -77,8 +80,8 @@ Detta är enklare att komma ihåg om du tänker på dessa förkortningar: P för föregående (previous), N för nästa (next), B för bakåt (backward) -och F för framåt (forward). Dessa är de grundläggande kommandona för -att flytta markören och du kommer att använda dem hela tiden. +och F för framåt (forward). Du kommer att använda dessa grundläggande +kommandona hela tiden. >> Gör några C-n så att du kommer ned till den här raden. @@ -223,22 +226,16 @@ Detta borde ha flyttat skärmbilden 8 rader uppåt. Om du önskar flytta tillbaka igen är det bara att ge samma argument till M-v. -Om du använder Emacs under ett fönstersystem, som X11 eller -MS-Windows, finns det troligen ett rektangulärt område på sidan -av Emacs-fönstret, en så kallad rullningslist. Genom att klicka i den -med musen kan du rulla texten. - ->> Prova att trycka med den mellersta musknappen i det utvalda området - på rullningslisten. Detta bör flytta skärmbilden till en plats i - texten beroende på var i rullningslisten du trycker. - ->> Prova att flytta musen upp och ner medan du håller ner den - mellersta musknappen. Du ser att texten rullar upp och ner beroende - på hur du för musen. - - -* OM EMACS HÄNGER ------------------ +Om du använder ett fönstersystem, som X eller MS-Windows, finns det +troligen ett rektangulärt område på sidan av Emacs-fönstret, en så +kallad rullningslist. Genom att klicka i den med musen kan du rulla +texten. + +Om din mus har ett rullningshjul kan även den användas för att rulla +texten. + +* OM EMACS SLUTAR SVARA +----------------------- Om Emacs slutar att reagera på kommandon kan du lugnt stoppa dem genom att trycka C-g. Du kan också använda C-g för att stoppa ett kommando @@ -264,9 +261,9 @@ meddelande som berättar vilket kommando det är och kommer att fråga om du verkligen vill fortsätta och utföra detta kommando. -Om du verkligen önskar att utföra kommandot trycker du mellanslag som -svar på frågan. Normalt, om du inte önskar att utföra detta kommando, -svarar du "n" på frågan. +Om du verkligen önskar att utföra kommandot skriver du , +(mellanslagstangenten) som svar på frågan. Normalt, om du inte önskar +att utföra detta kommando, svarar du "n" på frågan. >> Skriv C-x C-l (som är ett spärrat kommando). Skriv n som svar på frågan. @@ -275,8 +272,8 @@ * FÖNSTER --------- -Emacs kan ha flera fönster och varje fönster kan visa sin egen text. -Vi kommer förklara senare hur man använder flera fönster. Här skall vi +Emacs kan ha flera "fönster" där varje kan visa sin egen text. Vi +kommer förklara senare hur man använder flera fönster. Här skall vi förklara hur man blir av med extra fönster för att komma tillbaka till det grundläggande läget med endast ett fönster. Det är enkelt: @@ -289,7 +286,7 @@ >> Flytta markören till den här raden och tryck C-u 0 C-l. >> Tryck C-h k C-f. Se hur det här fönstret krymper samtidigt som ett nytt uppträder - för att visa dokumentationen för C-f-kommandot. + för att visa dokumentationen av C-f-kommandot. >> Slå C-x 1 och se hur dokumentationsfönstret nu försvinner. @@ -303,39 +300,36 @@ * SKRIVA OCH TA BORT TEXT ------------------------- -Om du önskar att sätta in text är det bara att skriva in -texten. Tecken som du kan se, så som A, 7, *, etc. tolkas som text och -sätts in direkt. Skriv (retur-tangenten) för att sätta in en -radbrytning. - -Du kan radera det sista tecknet du skrev genom att trycka . - är en tangent på tangentbordet -- samma som du normalt -använder utanför Emacs för att ta bort det senaste tecknet du skrivit. -Det är vanligen en stor tangent några rader ovanför retur-tangenten, -och den är vanligtvis märkt "Delete, "Del" eller "Backspace". - -Om den stora tangenten är märkt med "Backspace" så är det den du -använder för . Det kan finnas en annan tangent som är märkt -med "Delete" men det är inte . - -Generellt raderar tecknet precis före den aktuella -markörspositionen. +Om du önskar att sätta in text är det bara att skriva in texten. +Vanliga tecken, som A, 7, *, etc., sätts in direkt när du skriver dem. +Tryck på för att sätta in en radbrytning. (Det är den tangent +på tangentbordet som ibland är märkt med "Enter") + +För att radera tecknet omedelbart före aktuell markörposition, +skriv . Det är tangenten på tangentbordet som vanligtvis är +markerad med "Backspace" -- det är samma tangent som du normal +använder för att radera det sist inmatade tecknet utanför Emacs. + +Det kan finnas en annan tangent på ditt tangentbordet som är märkt med +"Delete", men det är inte den vi menar med . >> Gör detta nu: Skriv in några tecken och ta bort dem genom att - använda . Var inte rädd för att skriva i den här filen, - du kommer inte att kunna förändra originalet till vägledningen. - Detta är bara en lokal kopia. + använda . Var inte rädd för att skriva i den här filen, du + kommer inte att kunna förändra originalet till vägledningen. Detta + är bara en lokal kopia. När en rad blir för lång för att rymmas på en skärmbredd så fortsätter -den på raden under. Ett bakstreck ("\") (eller om du kör under ett -fönstersystem, en liten böjd pil) i slutet av högermarginalen -indikerar att raden fortsätter. +den på raden under. Om du använder ett fönstersystem, visas små böjda +pilar i det lilla utrymmet på bägge sidor om textmassan (i vänster och +höger marginal) för att ange var en rad fortsätter, Om du använder +en textterminal anges med ett bakstreck ("\") i kolumnen längst till +höger att raden fortsätter. >> Skriv in lite text så att du kommer till slutet av raden och fortsätt att skriva lite till. Du kommer då att se hur fortsättningstecknet ser ut. ->> Använd för att radera texten tills raden ryms på en +>> Använd för att radera texten tills raden ryms på en skärmbredd igen. Fortsättningstecknet kommer då att försvinna. Du kan radera radbrytning precis som andra tecken. Genom att radera @@ -343,7 +337,7 @@ resultatet av denna sammanslagning blir för stor för att passa inom en skärmbredd, så kommer den att visas med ett fortsättningstecken. ->> Flytta markören till början av en rad och tryck . +>> Flytta markören till början av en rad och tryck . Detta kommer att klistra ihop raden med raden över. >> Tryck för att sätta in radbrytningen du tog bort. @@ -358,28 +352,30 @@ Emacs och att rätta fel. Du kan radera ord och rader också. Här är en översikt över kommandon för radering: - Raderar tecknet som står precis före markören + Raderar tecknet som står precis före markören C-d Raderar tecknet som står precis under markören - M- Raderar ordet precis före markören + M- Raderar ordet precis före markören M-d Raderar ordet precis efter markören C-k Raderar från markören till slutet av raden M-k Raderar till slutet av stycket -Lägg märke till att och C-d kontra M- och M-d -följer mönstret som började med C-f och M-f. ( är inte precis -ett kontrolltecken men låt oss inte bry oss om det.) C-k och M-k -fungerar på samma sätt som C-e och M-e (nästan). +Lägg märke till att och C-d kontra M- och M-d följer +mönstret som började med C-f och M-f. ( är inte precis ett +kontrolltecken men låt oss inte bry oss om det.) C-k och M-k fungerar +på liknande sätt som C-e och M-e när det gäller rader respektive +meningar. -Du kan också ta bort vilken del som helst av texten med hjälp av -följande allmänna metod. Flytta till ena änden av det område du vill -ta bort och tryck C-@ eller C-mellanslag. Flytta till andra änden av -området och tryck C-w. Detta tar bort all text mellan de två -positionerna. +Du kan också ta bort en del av en texten med hjälp av följande +allmänna metod. Flytta till ena änden av det område du vill ta bort +och tryck C-. ( är mellanslagstangenten.) Flytta sedan till +andra änden av området du vill ta bort. När du gör det markerar Emacs +texten mellan markören och den plats där du tryckte C-. Slutligen, +tryck C-w. Detta tar bort texten mellan de två positionerna. >> Flytta markören till bokstaven D i föregående stycke. ->> Tryck C-mellanslag. Emacs skall nu visa meddelandet "Mark set" +>> Tryck C-. Emacs skall nu visa meddelandet "Mark set" längst ner på skärmen. >> Flytta markören till bokstaven o i ordet metod på andra raden i stycket. @@ -387,12 +383,15 @@ o. Skillnaden mellan att "ta bort" (killing) och "radera" (deleting) text -är att "borttagen" text kan hämtas tillbaka, medan raderad text inte -kan det. Återinsättning av borttagen text kallas "återhämtning" -(yanking). Generellt kan man säga att kommandon som tar bort fler än -ett tecken sparar undan texten (så att den kan återhämtas) medan -kommandon som bara raderar ett tecken eller tomma rader och mellanrum -inte sparar någonting (och den texten kan alltså inte återhämtas). +är att "borttagen" text kan sättas tillbaka (var som helst), medan +raderad text inte kan det på det sättet. (Du kan dock ångra en +radering--se nedan.) Återinsättning av borttagen text kallas +"återhämtning" (yanking). Generellt kan man säga att kommandon som +tar bort fler än ett tecken sparar undan texten (så att den kan +återhämtas) medan kommandon som bara raderar ett tecken, eller bara +raderar tomma rader och mellanrum inte sparar någonting (och den +texten kan alltså inte återhämtas). och C-d raderar i det enkla +fallet utan argument. Med argument så tar de bort i stället. >> Flytta markören till början av en rad som inte är tom. Tryck C-k för att ta bort texten på raden. @@ -412,7 +411,9 @@ plats som där den blev borttagen, eller så kan du sätta in den på en annan plats i texten du redigerar eller till och med i en helt annan fil. Du kan också hämta tillbaka samma text flera gånger så att du får -flera lika förekomster av den. +flera kopior av den. Några andra textredigerare kallar "ta bort" och +"återhämta" att "klippa ut" respektive "klistra in" (Se ordlistan i +Emacs-manualen) Kommandot för att hämta tillbaka text är C-y. Kommandot hämtar tillbaka den sist borttagna texten och placerar den där markören är. @@ -455,28 +456,26 @@ ------- Om du gör en förändring i texten och sedan ångrar dig, så kan du -upphäva ändringen med kommandot C-x u (undo). +upphäva ändringen med ångra-kommandot C-/. -Normalt kommer C-x u upphäva förändringen som gjordes av det sist -utförda kommandot. Om du repeterar C-x u flera gånger kommer varje +Normalt kommer C-/ upphäva förändringen som gjordes av det sist +utförda kommandot. Om du repeterar C-/ flera gånger kommer varje repetition upphäva ett kommando till. Det finns två undantag. Kommandon som inte förändrar texten räknas inte (detta inkluderar markörförflyttningar och bläddringskommandon), och inskrivna enkelbokstäver blir vanligtvis grupperade i grupper om -upp till 20 tecken. Detta är för att reducera antalet C-x u som behövs +upp till 20 tecken. Detta är för att reducera antalet C-/ som behövs för att ångra inskriven text. ->> Ta bort den här raden med C-k. C-x u kommer att hämta tillbaka den - igen. - -C-_ är ett alternativ till ångra-kommandot. Den fungerar på samma sätt -som C-x u men är enklare att trycka flera gånger i följd. Det -olämpliga med C-_ är att den är svår att hitta på en del tangentbord. -Det är därför vi också har C-x u. På en del terminaler kan du få fram -C-_ genom att trycka / samtidigt som Ctrl hålls nere. - -Ett numeriskt argument till C-_ eller C-x u medför repetering. +>> Ta bort den här raden med C-k, hämta sedan tillbaka den med C-/. + +C-_ är ett alternativt ångra-kommandot. Den fungerar exakt på samma +sätt som C-/. På vissa textterminaler skickar C-/ faktiskt C-_ till +Emacs. Även C-x u fungerar precis som C-/, men är inte lika enkelt att +skriva. + +Ett numeriskt argument till C-/, C-_ eller C-x u medför upprepning. Du kan ångra radering av text precis på samma sätt som du kan ångra att du tagit bort text. Skillnaden mellan att ta bort och att radera @@ -500,16 +499,16 @@ nytt namn, som backup, ifall du senare ångrar alltihop. Om du tittar nästan längst ner på skärmbilden så kommer du se en rad -som börjar och slutar med minustecken, och som innehåller texten -"--:-- TUTORIAL.sv". Denna del av skärmbilden visar alltid namnet på -filen du besöker. Just nu är du inne i en fil som heter "TUTORIAL.sv" -och som är en personlig kopia av vägledningen till Emacs. Vilken fil -du än är inne i så kommer filnamnet stå där. +som börjar med minustecken, och som startar med "--:-- TUTORIAL.sv" +eller något snarlikt. Denna del av skärmbilden visar normalt namnet på +filen du besöker. Just nu besöker du din personlig kopia av +vägledningen till Emacs, vilken heter "TUTORIAL.sv". Vilken fil du än +är inne i så kommer filnamnet stå där. En annan sak med kommandot för att finna filer är att du måste ange -vilket filnamn du önskar. Vi säger att kommandot "läser ett argument -från terminalen". I detta fall är argumentet namnet på filen. Efter -att du gett kommandot +vilket filnamn du önskar. Vi säger att kommandot "läser ett +argument". I detta fall är argumentet namnet på filen. Efter att du +gett kommandot C-x C-f Finn en fil @@ -526,12 +525,11 @@ du inte finner någon fil. När du är färdig med att skriva filnamnet trycker du för att -utföra kommandot. Då kommer C-x C-f kommandot att börja leta fram -filen. Minibufferten försvinner när C-x C-f kommandot är färdigt. +utföra kommandot. Minibufferten försvinner och C-x C-f kommandot börja +leta efter filen. -Efter en liten stund kommer filen upp på skärmen och du kan börja -redigera innehållet. När du vill spara filen kan du använda detta -kommando +Filinnehållet visas nu upp på skärmen och du kan börja redigera +innehållet. När du vill spara filen kan du använda detta kommando C-x C-s Spara fil @@ -542,11 +540,11 @@ När lagringen är utförd kommer Emacs skriva ut namnet på filen som blev sparad. Du bör spara ofta så att du inte förlorar så mycket om -systemet kraschar. +systemet kraschar. (Se kapitlet om sparautomatik nedan.) ->> Skriv C-x C-s för att spara en kopia av denna vägledning. - Detta skall leda till att "Wrote ...TUTORIAL.sv" skrivs ut nederst - på skärmbilden. +>> Skriv C-x C-s TUTORIAL.sv . + Detta sparar den här handledningen i en fil med namnet TUTORIAL + och "Wrote ...TUTORIAL.sv" skrivs ut nederst på skärmbilden. Du kan finna en existerande fil, antingen för att förändra den eller för att titta på den. Du kan också finna en fil som inte existerar. @@ -565,11 +563,6 @@ den på nytt med C-x C-f. På så sätt kan du ha ett stort antal filer öppna i Emacs. ->> Skapa en fil med namnet "foo" genom att trycka C-x C-f foo . - Skriv in lite text, redigera den och spara "foo" genom att använda - C-x C-s. Skriv till slut C-x C-f TUTORIAL.sv för att komma - tillbaka till den här vägledningen. - Emacs sparar texten för varje fil i ett objekt kallat "buffert". När du finner en ny fil skapas en ny buffert i Emacs. För att se en lista över existerande buffertar i Emacs kan du skriva @@ -591,9 +584,9 @@ C-f. Det finns dock ett enklare sätt: använd C-x b kommandot. I det kommandot anger du buffertens namn. ->> Skriv C-x b foo för att gå tillbaka till bufferten "foo" - som innehåller texten i filen "foo". Skriv sedan C-x b TUTORIAL.sv - för att komma tillbaka till den här handledningen. +>> Skapa en fil med namnet "foo" genom att trycka C-x C-f foo . + Skriv sedan C-x b TUTORIAL.sv för att komma tillbaka till + den här handledningen. Mestadels är buffertens namn densamma som filens namn (utan katalogdel.) Det är dock inte alltid så. Bufferlistan du skapar med @@ -646,24 +639,21 @@ förändringar du har gjort. C-x C-c erbjuder dig att spara förändringar innan Emacs avslutas. +Om du använder ett fönstersystem behöver du inte något speciellt +kommando för att byta till ett annat program. Du kan göra det med +musen eller med ett kommando till fönsterhanteraren. Men om du +använder en textterminal, som bara kan visa ett program åt gången, så +måste du avbryta Emacs för att flytta till ett annat program. + C-z är kommandot för att avsluta Emacs *tillfälligt* så att du kan -återvända till samma Emacs senare. - -På system som tillåter det kommer C-z suspendera Emacs, dvs. returnera -till kommandoraden utan att avsluta Emacs. I de flesta system kan du få -tillbaka Emacs med kommandot 'fg' eller '%emacs'. - -På system som saknar suspendering startar C-z ett skal som kör under -Emacs och som ger dig chansen till att köra andra program och sedan -återgå till Emacs efteråt. Den ger ingen riktig avslutning av Emacs. I -detta fall återvänder man vanligtvis till Emacs med kommandot 'exit'. +återvända till samma Emacs senare. När Emacs körs från en textterminal +så avbryts Emacs med C-z, dvs du återgår till kommandoskalet utan att +Emacsprocessen förstörs. I de flesta vanliga kommandoskalen så kan man +återgå till Emacs med kommandot 'fg' eller med '%emacs'. C-x C-c används när du skall avsluta Emacs. Det är klokt att avsluta Emacs om den har startats av ett mail-program eller andra -applikationer eftersom det inte är säkert att de kan hantera -suspendering av Emacs. Under normala omständigheter, om du inte har -tänkt att logga ut, är det bättre att suspendera Emacs med C-z -istället för att avsluta. +applikationer. Det finns många C-x kommandon. Här är en lista över de du har lärt dig hittills: @@ -685,7 +675,7 @@ fallet "replace-string". Det är bara att skriva "repl s" och Emacs kommer då att fylla i kommandonamnet. ( är tabulatortangenten, som vanligtvis finns över CapsLock- eller -skifttangenten nära den vänstra kanten på tangentbordet.) Avsluta +skifttangenten nära den vänstra kanten på tangentbordet.) Kör kommandot med . Kommandot replace-string kräver två argument, teckensträngen som skall @@ -770,7 +760,7 @@ Om du skall redigera text, såsom den här filen, bör du troligen använda Text-läge. ->> Skriv M-x text mode. +>> Skriv M-x text-mode . Inget av kommandona du har lärt dig hittills förändrar Emacs i någon högre grad. Men lägg märke till att M-f och M-b nu behandlar @@ -784,8 +774,7 @@ För att få fram dokumentationen för det läge du är i nu kan du skriva C-h m. ->> Använd C-u C-v så att denna rad kommer nära toppen av - skärmbilden. +>> Använd C-l C-l för att få denna rad överst på skärmbilden. >> Skriv C-h m och se hur Text-läget skiljer sig från Fundamental-läget. >> Tryck C-x 1 för att ta bort dokumentationen från skärmbilden. @@ -801,13 +790,13 @@ rader mellan ord automatisk när du skriver in text så att en rad blir för lång. -Du kan slå på radbrytningsläget genom att skriva M-x auto fill -mode. När läget är påslaget kan du slå av det igen genom att -upprepa M-x auto fill mode. Om läget är avslaget slår +Du kan slå på radbrytningsläget genom att skriva M-x auto-fill-mode +. När läget är påslaget kan du slå av det igen genom att +upprepa M-x auto-fill-mode . Om läget är avslaget slår kommandot på det och vice versa. Vi säger att kommandot "växlar läget". ->> Skriv M-x auto fill mode nu. Skriv så in en rad med +>> Skriv M-x auto-fill-mode nu. Skriv så in en rad med "asdf " tills raden delar sig. Du måste sätta in blanktecken, för Auto Fill bryter bara raden mellan ord. @@ -831,15 +820,13 @@ * SÖKNING --------- -Emacs kan söka efter textsträngar (grupper med sammanhängande -bokstäver eller ord) antingen framåt eller bakåt i texten. När du +Emacs kan söka efter textsträngar (en "sträng" är en grupp med +sammanhängande bokstäver) antingen framåt eller bakåt i texten. När du söker efter text kommer markören att flytta sig till nästa plats där teckensträngen uppträder. -Sökmetoden i Emacs skiljer sig lite från sökmetoder i andra -redigeringsprogram genom att den är inkrementell. Detta betyder att -sökandet fortgår medan du skriver in teckensträngen du skall söka -efter. +Sökmetoden i Emacs är inkrementell. Detta betyder att sökandet fortgår +medan du skriver in teckensträngen du skall söka efter. Kommandot för att inleda en sökning är C-s för att söka framåt och C-r för att söka bakåt. MEN VÄNTA! Prova dem inte än. @@ -855,7 +842,7 @@ har du sökt efter ordet "markör" en gång. >> Skriv C-s en gång till för att söka efter nästa förekomst av ordet "markör". ->> Tryck nu på fyra gånger och se hur markören flyttar sig +>> Tryck nu på fyra gånger och se hur markören flyttar sig >> Tryck för att avsluta sökandet. Såg du vad som hände? Under inkrementell sökning försöker Emacs att gå @@ -865,22 +852,18 @@ Om det inte finns flera förekomster kommer Emacs att pipa och meddela att sökandet har misslyckats. C-g avbryter också sökandet. -Observera: På vissa system gör C-s att skärmen låser sig. Detta tyder -på att systemets flödeskontroll har fångat upp C-s och inte skickat -den vidare till Emacs. För att fortsätta måste du trycka C-q. Se i så -fall avsnittet "Spontaneous Entry to Incremental Search" i -Emacs-manualen för råd om hur detta kan undvikas. - -Om du är inne i en inkrementell sökning och trycker kommer -du lägga märke till att den sista bokstaven i söksträngen blir raderad -och sökandet hoppar tillbaka till en tidigare förekomst. Om du till -exempel skriver "m" för att söka efter den första förekomsten av "m", -och sedan trycker "a" så kommer markören flytta sig till första -förekomsten av "ma". Tryck nu . Detta avlägsnar "a" från -söksträngen, och markören flyttar sig tillbaka till den första -förekomsten av "m". - -Om du är mitt i en sökning och trycker ett KONTROLL- eller META-tecken +Om du är inne i en inkrementell sökning och trycker kommer den +sökningen att återgå till en tidigare plats. Om du skriver +precis efter att du skrivit C-s för att gå till nästa förekomst av +söksträngen, kommer att flytta markören tillbaka till en +tidigare förekomst. Om det inte finns några tidigare förekomster så +raderar sista tecknet i söksträngen. Om du till exempel skriver +"m" för att söka efter den första förekomsten av "m", och sedan +trycker "a" så kommer markören flytta sig till första förekomsten av +"ma". Tryck nu . Detta avlägsnar "a" från söksträngen, och +markören flyttar sig tillbaka till den första förekomsten av "m". + +Om du är mitt i en sökning och trycker ett kontroll- eller meta-tecken så avbryts sökandet. Undantag är tecken som används under sökningen, så som C-s och C-r. @@ -894,21 +877,22 @@ --------------- En av egenskaperna hos Emacs är att den kan visa mera än en buffert på -skärmen samtidig. +skärmen samtidig. (Notera att Emacs använder termen "ramar" +(frames), som beskrivs i nästa kapitel, för det som en del andra +program kallar för "fönster" (windows). Emacs-manualen innehåller en +ordlista över Emacs-termer. ->> Flytta markören till den här raden och tryck C-u 0 C-l (alltså - KONTROLL-L, inte KONTROLL-1). +>> Flytta markören till den här raden och tryck C-l C-l. >> Skriv nu C-x 2, som leder till att skärmen delas i två - fönster. Bägge fönstren visar den här vägledningen. Markören står i - det övre fönstret. + fönster. Bägge fönstren visar den här vägledningen. + Redigeringsmarkören stannar i det övre fönstret. >> Skriv C-M-v för att rulla det nedre fönstret. (Om du inte har META-tangenten trycker du C-v.) ->> Skriv C-x o (o för other) för att flytta markören till det +>> Skriv C-x o ("o" för "other") för att flytta markören till det nedre fönstret. - >> Använd C-v och M-v i det nedre fönstret för att flytta upp och ned i texten. Fortsätt att läsa den här texten i det övre fönstret. @@ -918,21 +902,20 @@ gjorde när du lämnade det. Du kan fortsätta att använda C-x o för att byta mellan de två -fönstren. Vart och ett av fönstren har sin egen markörposition men det -är bara ett av fönstren som visar den. Alla redigeringskommandon -fungerar i det fönster där markören är synlig. Vi kallar detta fönster -för det valda fönstret (selected window). +fönstren. Det valda fönstret, där de flesta redigeringarna äger rum, är +det med den tydligaste markören, som blinkar när du inte skriver. De +andra fönstren har sin egen markörposition. Om du kör Emacs under ett +fönstersystem, ritas dessa markörer som en tom ruta som inte blinkar.. Kommandot C-M-v är bra när du redigerar text i ett fönster och -använder det andra fönstret för referenser. Då kan du kan ha markören -i samma fönster hela tiden och du kan använda C-M-v för att flytta dig -i det andra fönstret. +använder det andra fönstret för referenser. Utan att lämna det valda +fönstret du kan använda C-M-v för att rulla det andra fönstret. -C-M-v är ett exempel på en KONTROLL-META-kombination. Om du har -META-tangenten håller du både KONTROLL och META nedtryckt samtidigt -som du trycker v. Det har ingen betydelse vilken av tangenterna -KONTROLL och META som trycks först, för bägge fungerar så att de -"modifierar" de andra tangenterna du trycker. +C-M-v är ett exempel på en KONTROLL-META-kombination. Om du har META- +eller Alt-tangenten håller du både KONTROLL och META nedtryckt +samtidigt som du trycker v. Det har ingen betydelse vilken av +tangenterna KONTROLL och META som trycks först, för bägge fungerar så +att de "modifierar" de andra tangenterna du trycker. Om du inte har META-tangenten och använder istället är ordningsföljden viktig. Du måste trycka följt av KONTROLL-v, @@ -961,6 +944,28 @@ >> Skriv C-x o för att gå tillbaka till det övre fönstret och C-x 1 för att bli kvitt det nedre igen. +* MULTIPLA RAMAR +---------------- + +Emacs kan också skapa flera "ramar". En ram är vad vi kallar en +samling av fönster tillsammans med menyer, rullningslister, ekoområde +etc. Det som Emacs kallar för ram kallar de flesta andra program för +fönster. Flera grafiska ramar kan visas på skärmen samtidigt. På en +textterminal kan bara en ram visas åt gången. + +>> Skriv M-x make-frame . + En ny ram visas på din skärm. + +Du kan göra allt du gjorde i den första ramen i den här nya ramen. Det +finns inget speciellt med den första ramen. + +>> Skriv M-x delete-frame . + Ta bort den valda ramen. + +Du kan också ta bort ramen genom den vanliga metod som tillhandahålls +av fönstersystemet (ofta klickar man på knappen med symbolen "X" i +något av de övre hörnen.) Om den sista ramen tas bort på det här +sättet så avlutas Emacs. * REKURSIVA REDIGERINGSNIVÅER ----------------------------- @@ -999,11 +1004,8 @@ har skrivit C-h och bestämmer dig för att du inte behöver ha någon hjälp kan du trycka C-g för att avbryta. -(På vissa platser är C-h omkonfigurerad. Det är normalt ingen bra ide´, -så du kan på goda grunder klaga hos systemadministratören. Under -tiden, om C-h inte visar ett hjälpmeddelande längst ner på skärmen, -kan du i stället försöka med funktionstangenten F1 eller M-x -help.) +(Om C-h inte visar ett hjälpmeddelande längst ner på skärmen, kan du i +stället försöka med funktionstangenten F1 eller M-x help .) Den mest grundläggande hjälp-funktionen är C-h c. Skriv C-h, ett "c" och en knappsekvens. Emacs ger då en beskrivning av kommandot. @@ -1014,8 +1016,7 @@ C-p runs the command previous-line -Detta ger ett funktionsnamn. Funktionsnamnen används huvudsakligen för -att specialanpassa och utvidga Emacs. Men eftersom funktionerna har +Detta ger dig namnet på funktionen. Eftersom funktionerna har beskrivande namn kan de också fungera som en enkel dokumentation, tillräckligt för att påminna dig om kommandon du redan lärt dig. @@ -1062,9 +1063,9 @@ >> Type C-x 1 för att ta bort hjälpfönstret. - C-h i Läs direktmanualen (alias Info). Detta kommando + C-h i Läs den bifogade manualen (alias Info). Detta kommando placerar dig i en speciell buffer vid namn "*info*" - där du kan läsa direkthjälpen för de paket som är + där du kan läsa hjälpen för de paket som är installerade i ditt system. Slå m emacs för att läsa Emacs-manualen. Om du aldrig tidigare har använt dig av Info, skriv ? och Emacs tar dig på en @@ -1074,18 +1075,6 @@ din huvudsakliga källa till dokumentation. -* TILL SIST ------------ - -Tänk på att använda C-x C-c för att avsluta Emacs permanent. För att -tillfälligt gå till ett skal, så att du senare kan komma tillbaka -igen, använd C-z. (Under X kommer detta att minimera Emacs.) - -Denna vägledningen är avsedd för nya användare, om det är något som är -oklart duger det inte att sitta och tycka synd om sig själv -- Skicka -ett mail och klaga! - - * MER FUNKTIONER ---------------- @@ -1108,6 +1097,15 @@ Manualen beskriver även många andra Emacs funktioner. +* SLUTORD +--------- + +För att avsluta Emacs använd C-x C-c. + +Den här handledningen är tänkt att vara förståelig för alla nya +Emacs-användare. Så om det är något som är oklart, klandra inte dig +själv, klaga! + * KOPIERING ----------- @@ -1121,24 +1119,26 @@ Copyright (C) 1985, 1996, 1998, 2001-2012 Free Software Foundation, Inc. - Permission is granted to anyone to make or distribute verbatim copies - of this document as received, in any medium, provided that the - copyright notice and permission notice are preserved, - and that the distributor grants the recipient permission - for further redistribution as permitted by this notice. - - Permission is granted to distribute modified versions - of this document, or of portions of it, - under the above conditions, provided also that they - carry prominent notices stating who last altered them. - -The conditions for copying Emacs itself are more complex, but in the -same spirit. Please read the file COPYING and then do give copies of -GNU Emacs to your friends. Help stamp out software obstructionism -("ownership") by using, writing, and sharing free software! +This file is part of GNU Emacs. + + GNU Emacs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GNU Emacs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Emacs. If not, see . + +Please read the file COPYING and then do give copies of GNU Emacs to +your friends. Help stamp out software obstructionism ("ownership") by +using, writing, and sharing free software! ;;; Local Variables: ;;; coding: latin-1 ;;; sentence-end-double-space: nil ;;; End: - ------------------------------------------------------------ revno: 106928 [merge] committer: Chong Yidong branch nick: trunk timestamp: Wed 2012-01-25 13:55:39 +0800 message: HIROSHI OOTA diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-25 05:48:11 +0000 +++ src/ChangeLog 2012-01-25 05:55:01 +0000 @@ -1,3 +1,8 @@ +2012-01-25 HIROSHI OOTA (tiny change) + + * coding.c (encode_designation_at_bol): Change return value to + EMACS_INT. + 2012-01-25 Chong Yidong * eval.c (Fuser_variable_p): Doc fix; mention custom-variable-p. === modified file 'src/coding.c' --- src/coding.c 2012-01-19 07:21:25 +0000 +++ src/coding.c 2012-01-25 05:55:01 +0000 @@ -855,7 +855,7 @@ static unsigned char *alloc_destination (struct coding_system *, EMACS_INT, unsigned char *); static void setup_iso_safe_charsets (Lisp_Object); -static int encode_designation_at_bol (struct coding_system *, +static EMACS_INT encode_designation_at_bol (struct coding_system *, int *, int *, unsigned char *); static int detect_eol (const unsigned char *, EMACS_INT, enum coding_category); @@ -4351,7 +4351,7 @@ If the current block ends before any end-of-line, we may fail to find all the necessary designations. */ -static int +static EMACS_INT encode_designation_at_bol (struct coding_system *coding, int *charbuf, int *charbuf_end, unsigned char *dst) ------------------------------------------------------------ revno: 106927 committer: Chong Yidong branch nick: trunk timestamp: Wed 2012-01-25 13:48:11 +0800 message: Tweak custom-variable-p and user-variable-p docs. * lisp/custom.el (custom-variable-p): Doc fix. * src/eval.c (Fuser_variable_p): Doc fix; mention custom-variable-p. diff: === modified file 'admin/FOR-RELEASE' --- admin/FOR-RELEASE 2012-01-23 04:23:50 +0000 +++ admin/FOR-RELEASE 2012-01-25 05:48:11 +0000 @@ -126,7 +126,7 @@ abbrevs.texi cyd ack.texi -anti.texi +anti.texi cyd arevert-xtra.texi cyd basic.texi cyd buffers.texi cyd === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-25 02:01:22 +0000 +++ lisp/ChangeLog 2012-01-25 05:48:11 +0000 @@ -1,3 +1,7 @@ +2012-01-25 Chong Yidong + + * custom.el (custom-variable-p): Doc fix. + 2012-01-25 Glenn Morris * progmodes/compile.el (compilation-next-error-function): === modified file 'lisp/custom.el' --- lisp/custom.el 2012-01-19 07:21:25 +0000 +++ lisp/custom.el 2012-01-25 05:48:11 +0000 @@ -591,8 +591,10 @@ ;; This test is also in the C code of `user-variable-p'. (defun custom-variable-p (variable) - "Return non-nil if VARIABLE is a custom variable. -This recursively follows aliases." + "Return non-nil if VARIABLE is a customizable variable. +A customizable variable is either (i) a variable whose property +list contains a non-nil `standard-value' or `custom-autoload' +property, or (ii) an alias for another customizable variable." (setq variable (indirect-variable variable)) (or (get variable 'standard-value) (get variable 'custom-autoload))) === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-21 15:52:46 +0000 +++ src/ChangeLog 2012-01-25 05:48:11 +0000 @@ -1,3 +1,7 @@ +2012-01-25 Chong Yidong + + * eval.c (Fuser_variable_p): Doc fix; mention custom-variable-p. + 2012-01-21 Chong Yidong * floatfns.c (Fcopysign): Make the second argument non-optional, === modified file 'src/eval.c' --- src/eval.c 2012-01-19 07:21:25 +0000 +++ src/eval.c 2012-01-25 05:48:11 +0000 @@ -926,13 +926,14 @@ DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0, doc: /* Return t if VARIABLE is intended to be set and modified by users. \(The alternative is a variable used internally in a Lisp program.) -A variable is a user variable if -\(1) the first character of its documentation is `*', or -\(2) it is customizable (its property list contains a non-nil value - of `standard-value' or `custom-autoload'), or -\(3) it is an alias for another user variable. -Return nil if VARIABLE is an alias and there is a loop in the -chain of symbols. */) + +This function returns t if (i) the first character of its +documentation is `*', or (ii) it is customizable (its property list +contains a non-nil value of `standard-value' or `custom-autoload'), or +\(iii) it is an alias for a user variable. + +But condition (i) is considered obsolete, so for most purposes this is +equivalent to `custom-variable-p'. */) (Lisp_Object variable) { Lisp_Object documentation; ------------------------------------------------------------ revno: 106926 committer: Glenn Morris branch nick: trunk timestamp: Tue 2012-01-24 21:01:22 -0500 message: compile/grep fix for bug#10594 * lisp/progmodes/compile.el (compilation-next-error-function): Respect compilation-first-column in the "*compilation*" buffer. * lisp/progmodes/grep.el (grep-first-column): New variable. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-25 00:07:04 +0000 +++ lisp/ChangeLog 2012-01-25 02:01:22 +0000 @@ -1,5 +1,9 @@ 2012-01-25 Glenn Morris + * progmodes/compile.el (compilation-next-error-function): + Respect compilation-first-column in the "*compilation*" buffer. + * progmodes/grep.el (grep-first-column): New variable. (Bug#10594) + * vc/vc.el (vc-modify-change-comment): Scoping fix. (Bug#10513) 2012-01-24 Glenn Morris === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2012-01-19 07:21:25 +0000 +++ lisp/progmodes/compile.el 2012-01-25 02:01:22 +0000 @@ -2271,6 +2271,7 @@ (when reset (setq compilation-current-error nil)) (let* ((screen-columns compilation-error-screen-columns) + (first-column compilation-first-column) (last 1) (msg (compilation-next-error (or n 1) nil (or compilation-current-error @@ -2309,7 +2310,10 @@ ;; Obey the compilation-error-screen-columns of the target ;; buffer if its major mode set it buffer-locally. (if (local-variable-p 'compilation-error-screen-columns) - compilation-error-screen-columns screen-columns))) + compilation-error-screen-columns screen-columns)) + (compilation-first-column + (if (local-variable-p 'compilation-first-column) + compilation-first-column first-column))) (save-restriction (widen) (goto-char (point-min)) === modified file 'lisp/progmodes/grep.el' --- lisp/progmodes/grep.el 2012-01-19 07:21:25 +0000 +++ lisp/progmodes/grep.el 2012-01-25 02:01:22 +0000 @@ -374,6 +374,9 @@ ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") +(defvar grep-first-column 0 ; bug#10594 + "Value to use for `compilation-first-column' in grep buffers.") + (defvar grep-error "grep hit" "Message to print when no matches are found.") ------------------------------------------------------------ revno: 106925 committer: Glenn Morris branch nick: trunk timestamp: Tue 2012-01-24 19:07:04 -0500 message: * lisp/vc/vc.el (vc-modify-change-comment): Scoping fix. (Bug#10513) diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-24 18:10:39 +0000 +++ lisp/ChangeLog 2012-01-25 00:07:04 +0000 @@ -1,3 +1,7 @@ +2012-01-25 Glenn Morris + + * vc/vc.el (vc-modify-change-comment): Scoping fix. (Bug#10513) + 2012-01-24 Glenn Morris * pcmpl-gnu.el (pcomplete/tar): Handle " - ". (Bug#10457) === modified file 'lisp/vc/vc.el' --- lisp/vc/vc.el 2012-01-19 07:21:25 +0000 +++ lisp/vc/vc.el 2012-01-25 00:07:04 +0000 @@ -1880,7 +1880,8 @@ "Enter a replacement change comment." "*vc-log*" (lambda () (vc-call-backend backend 'log-edit-mode)) - (lexical-let ((rev rev)) + (lexical-let ((rev rev) + (backend backend)) (lambda (files comment) (vc-call-backend backend 'modify-change-comment files rev comment)))))) ------------------------------------------------------------ revno: 106924 committer: Glenn Morris branch nick: trunk timestamp: Tue 2012-01-24 13:10:39 -0500 message: * lisp/pcmpl-gnu.el (pcomplete/tar): Handle " - ". (Bug#10457) diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-24 12:06:51 +0000 +++ lisp/ChangeLog 2012-01-24 18:10:39 +0000 @@ -1,3 +1,7 @@ +2012-01-24 Glenn Morris + + * pcmpl-gnu.el (pcomplete/tar): Handle " - ". (Bug#10457) + 2012-01-24 Julien Danjou * color.el (color-rgb-to-hsl): Fix value computing. === modified file 'lisp/pcmpl-gnu.el' --- lisp/pcmpl-gnu.el 2012-01-19 07:21:25 +0000 +++ lisp/pcmpl-gnu.el 2012-01-24 18:10:39 +0000 @@ -243,6 +243,8 @@ "--volno-file="))) (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")) (cond + ((pcomplete-match "\\`-\\'" 0) + (pcomplete-here*)) ((pcomplete-match "\\`--after-date=" 0) (pcomplete-here*)) ((pcomplete-match "\\`--backup=" 0) ------------------------------------------------------------ revno: 106923 committer: Chong Yidong branch nick: trunk timestamp: Wed 2012-01-25 00:08:00 +0800 message: Update Variables chapter of Lisp manual to handle lexical binding. * doc/lispref/variables.texi (Variables, Local Variables, Void Variables): Edit to make the descriptions less specific to dynamic binding. (Local Variables): Default max-specpdl-size is now 1300. (Defining Variables): Edits for lexical scoping. Delete information about starting docstrings with *. De-document user-variable-p. (Tips for Defining): Remove an unimportant discussion of quitting in the middle of a load. (Accessing Variables, Setting Variables): Discuss lexical binding. (Variable Scoping): Rewrite. (Scope, Extent, Impl of Scope): Nodes deleted. (Dynamic Binding): New node, with material from Scope, Extent, and Impl of Scope nodes. (Dynamic Binding Tips): Rename from Using Scoping. (Lexical Binding): Rewrite. (Using Lexical Binding): Rename from Converting to Lexical Binding. Convert to subsection. * doc/lispref/customize.texi (Variable Definitions): Add custom-variable-p. Move user-variable-p documentation here. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2012-01-23 04:23:50 +0000 +++ doc/lispref/ChangeLog 2012-01-24 16:08:00 +0000 @@ -1,3 +1,26 @@ +2012-01-24 Chong Yidong + + * variables.texi (Variables, Local Variables, Void Variables): + Edit to make the descriptions less specific to dynamic binding. + (Local Variables): Default max-specpdl-size is now 1300. + (Defining Variables): Edits for lexical scoping. Delete + information about starting docstrings with *. De-document + user-variable-p. + (Tips for Defining): Remove an unimportant discussion of quitting + in the middle of a load. + (Accessing Variables, Setting Variables): Discuss lexical binding. + (Variable Scoping): Rewrite. + (Scope, Extent, Impl of Scope): Nodes deleted. + (Dynamic Binding): New node, with material from Scope, Extent, and + Impl of Scope nodes. + (Dynamic Binding Tips): Rename from Using Scoping. + (Lexical Binding): Rewrite. + (Using Lexical Binding): Rename from Converting to Lexical + Binding. Convert to subsection. + + * customize.texi (Variable Definitions): Add custom-variable-p. + Move user-variable-p documentation here. + 2012-01-23 Chong Yidong * strings.texi (Text Comparison): Minor qualification. === modified file 'doc/lispref/customize.texi' --- doc/lispref/customize.texi 2012-01-19 07:21:25 +0000 +++ doc/lispref/customize.texi 2012-01-24 16:08:00 +0000 @@ -262,12 +262,6 @@ This macro declares @var{option} as a customizable @dfn{user option}. You should not quote @var{option}. -This causes the function @code{user-variable-p} to return @code{t} -when given @var{option} as an argument. @xref{Defining Variables}. -The argument @var{doc} specifies the documentation string for the -variable. (Note that there is no need to start @var{doc} with a -@samp{*}.) - The argument @var{standard} is an expression that specifies the standard value for @var{option}. Evaluating the @code{defcustom} form evaluates @var{standard}, but does not necessarily install the @@ -285,6 +279,9 @@ @var{standard}, because they are not expanded when editing the value, so list values will appear to have the wrong structure. +The argument @var{doc} specifies the documentation string for the +variable. + Every @code{defcustom} should specify @code{:group} at least once. If you specify the @code{:set} keyword, to make the variable take other @@ -474,6 +471,22 @@ or in the various hooks it calls. @end defun +@defun custom-variable-p arg +This function returns non-@code{nil} if @var{arg} is a customizable +variable. A customizable variable is either a variable that has a +@code{standard-value} or @code{custom-autoload} property (usually +meaning it was declared with @code{defcustom}), or an alias for +another customizable variable. +@end defun + +@defun user-variable-p arg +This function is like @code{custom-variable-p}, except it also returns +@code{t} if the first character of the variable's documentation string +is the character @samp{*}. That is an obsolete way of indicating a +user option, so for most purposes you may consider +@code{user-variable-p} as equivalent to @code{custom-variable-p}. +@end defun + @node Customization Types @section Customization Types === modified file 'doc/lispref/elisp.texi' --- doc/lispref/elisp.texi 2012-01-23 04:23:50 +0000 +++ doc/lispref/elisp.texi 2012-01-24 16:08:00 +0000 @@ -436,12 +436,10 @@ Scoping Rules for Variable Bindings -* Scope:: Scope means where in the program a value - is visible. Comparison with other languages. -* Extent:: Extent means how long in time a value exists. -* Impl of Scope:: Two ways to implement dynamic scoping. -* Using Scoping:: How to use dynamic scoping carefully and - avoid problems. +* Dynamic Binding:: The default for binding local variables in Emacs. +* Dynamic Binding Tips:: Avoiding problems with dynamic binding. +* Lexical Binding:: A different type of local variable binding. +* Using Lexical Binding:: How to enable lexical binding. Buffer-Local Variables === modified file 'doc/lispref/objects.texi' --- doc/lispref/objects.texi 2012-01-21 16:04:55 +0000 +++ doc/lispref/objects.texi 2012-01-24 16:08:00 +0000 @@ -1795,6 +1795,9 @@ @item consp @xref{List-related Predicates, consp}. +@item custom-variable-p +@xref{Variable Definitions, custom-variable-p}. + @item display-table-p @xref{Display Tables, display-table-p}. @@ -1870,9 +1873,6 @@ @item syntax-table-p @xref{Syntax Tables, syntax-table-p}. -@item user-variable-p -@xref{Defining Variables, user-variable-p}. - @item vectorp @xref{Vectors, vectorp}. === modified file 'doc/lispref/variables.texi' --- doc/lispref/variables.texi 2012-01-21 03:15:07 +0000 +++ doc/lispref/variables.texi 2012-01-24 16:08:00 +0000 @@ -8,20 +8,23 @@ @cindex variable A @dfn{variable} is a name used in a program to stand for a value. -Nearly all programming languages have variables of some sort. In the -text of a Lisp program, variables are written using the syntax for -symbols. - - In Lisp, unlike most programming languages, programs are represented -primarily as Lisp objects and only secondarily as text. The Lisp -objects used for variables are symbols: the symbol name is the -variable name, and the variable's value is stored in the value cell of -the symbol. The use of a symbol as a variable is independent of its -use as a function name. @xref{Symbol Components}. - - The textual form of a Lisp program is given by the read syntax of -the Lisp objects that constitute the program. Hence, a variable in a -textual Lisp program is written using the read syntax for the symbol +In Lisp, each variable is represented by a Lisp symbol +(@pxref{Symbols}). The symbol's name serves as the variable name, and +the symbol's value cell holds the variable's value@footnote{Strictly +speaking, the symbol's value cell always holds the variable's current +value under the default @dfn{dynamic binding} rules. Under +@dfn{lexical binding} rules, the value cell holds the variable's +@dfn{global value}. @xref{Variable Scoping}, for details.}. +@xref{Symbol Components}. + + In Emacs Lisp, the use of a symbol as a variable is independent of +its use as a function name. + + As previously noted in this manual, a Lisp program is represented +primarily by Lisp objects, and only secondarily as text. The textual +form of a Lisp program is given by the read syntax of the Lisp objects +that constitute the program. Hence, the textual form of a variable in +a Lisp program is written using the read syntax for the symbol representing the variable. @menu @@ -145,63 +148,63 @@ @cindex global binding Global variables have values that last until explicitly superseded -with new values. Sometimes it is useful to create variable values that -exist temporarily---only until a certain part of the program finishes. -These values are called @dfn{local}, and the variables so used are -called @dfn{local variables}. - - For example, when a function is called, its argument variables receive -new local values that last until the function exits. The @code{let} -special form explicitly establishes new local values for specified -variables; these last until exit from the @code{let} form. - -@cindex shadowing of variables - Establishing a local value saves away the variable's previous value -(or lack of one). We say that the previous value is @dfn{shadowed} -and @dfn{not visible}. Both global and local values may be shadowed -(@pxref{Scope}). After the life span of the local value is over, the -previous value (or lack of one) is restored. - - If you set a variable (such as with @code{setq}) while it is local, -this replaces the local value; it does not alter the global value, or -previous local values, that are shadowed. To model this behavior, we -speak of a @dfn{local binding} of the variable as well as a local value. - - The local binding is a conceptual place that holds a local value. -Entering a function, or a special form such as @code{let}, creates the -local binding; exiting the function or the @code{let} removes the -local binding. While the local binding lasts, the variable's value is -stored within it. Using @code{setq} or @code{set} while there is a -local binding stores a different value into the local binding; it does -not create a new binding. +with new values. Sometimes it is useful to give a variable a +@dfn{local value}---a value that takes effect only within a certain +part of a Lisp program. When a variable has a local value, we say +that it has a @dfn{local binding}, or that it is a @dfn{local +variable}. + + For example, when a function is called, its argument variables +receive local values, which are the actual arguments supplied to the +function call; these local bindings take effect within the body of the +function. To take another example, the @code{let} special form +explicitly establishes local bindings for specific variables, which +take effect within the body of the @code{let} form. We also speak of the @dfn{global binding}, which is where (conceptually) the global value is kept. +@cindex shadowing of variables + Establishing a local binding saves away the variable's previous +value (or lack of one). We say that the previous value is +@dfn{shadowed}. Both global and local values may be shadowed. If a +local binding is in effect, using @code{setq} on the local variable +stores the specified value in the local binding. When that local +binding is no longer in effect, the previously shadowed value (or lack +of one) comes back. + @cindex current binding - A variable can have more than one local binding at a time (for -example, if there are nested @code{let} forms that bind it). In such a -case, the most recently created local binding that still exists is the -@dfn{current binding} of the variable. (This rule is called -@dfn{dynamic scoping}; see @ref{Variable Scoping}.) If there are no -local bindings, the variable's global binding is its current binding. -We sometimes call the current binding the @dfn{most-local existing -binding}, for emphasis. Ordinary evaluation of a symbol always returns -the value of its current binding. - - The special forms @code{let} and @code{let*} exist to create -local bindings. + A variable can have more than one local binding at a time (e.g.@: if +there are nested @code{let} forms that bind the variable). The +@dfn{current binding} is the local binding that is actually in effect. +It determines the value returned by evaluating the variable symbol, +and it is the binding acted on by @code{setq}. + + For most purposes, you can think of the current binding as the +``innermost'' local binding, or the global binding if there is no +local binding. To be more precise, a rule called the @dfn{scoping +rule} determines where in a program a local binding takes effect. The +default scoping rule in Emacs Lisp is called @dfn{dynamic scoping}, +which simply states that the current binding at any given point in the +execution of a program is the most recently-created local binding for +that variable that still exists. For details about dynamic scoping, +and an alternative scoping rule called @dfn{lexical scoping}, +@xref{Variable Scoping}. + + The special forms @code{let} and @code{let*} exist to create local +bindings: @defspec let (bindings@dots{}) forms@dots{} -This special form binds variables according to @var{bindings} and then -evaluates all of the @var{forms} in textual order. The @code{let}-form -returns the value of the last form in @var{forms}. +This special form sets up local bindings for a certain set of +variables, as specified by @var{bindings}, and then evaluates all of +the @var{forms} in textual order. Its return value is the value of +the last form in @var{forms}. Each of the @var{bindings} is either @w{(i) a} symbol, in which case -that symbol is bound to @code{nil}; or @w{(ii) a} list of the form -@code{(@var{symbol} @var{value-form})}, in which case @var{symbol} is -bound to the result of evaluating @var{value-form}. If @var{value-form} -is omitted, @code{nil} is used. +that symbol is locally bound to @code{nil}; or @w{(ii) a} list of the +form @code{(@var{symbol} @var{value-form})}, in which case +@var{symbol} is locally bound to the result of evaluating +@var{value-form}. If @var{value-form} is omitted, @code{nil} is used. All of the @var{value-form}s in @var{bindings} are evaluated in the order they appear and @emph{before} binding any of the symbols to them. @@ -213,6 +216,7 @@ (setq y 2) @result{} 2 @end group + @group (let ((y 1) (z y)) @@ -226,15 +230,15 @@ This special form is like @code{let}, but it binds each variable right after computing its local value, before computing the local value for the next variable. Therefore, an expression in @var{bindings} can -reasonably refer to the preceding symbols bound in this @code{let*} -form. Compare the following example with the example above for -@code{let}. +refer to the preceding symbols bound in this @code{let*} form. +Compare the following example with the example above for @code{let}. @example @group (setq y 2) @result{} 2 @end group + @group (let* ((y 1) (z y)) ; @r{Use the just-established value of @code{y}.} @@ -262,7 +266,7 @@ Variables}); a few variables have terminal-local bindings (@pxref{Multiple Terminals}). These kinds of bindings work somewhat like ordinary local bindings, but they are localized depending on -``where'' you are in Emacs, rather than localized in time. +``where'' you are in Emacs. @defopt max-specpdl-size @anchor{Definition of max-specpdl-size} @@ -280,7 +284,7 @@ @code{max-lisp-eval-depth} provides another limit on depth of nesting. @xref{Definition of max-lisp-eval-depth,, Eval}. -The default value is 1000. Entry to the Lisp debugger increases the +The default value is 1300. Entry to the Lisp debugger increases the value, if there is little room left, to make sure the debugger itself has room to execute. @end defopt @@ -291,45 +295,32 @@ @cindex void variable If you have never given a symbol any value as a global variable, we -say that that symbol's global value is @dfn{void}. In other words, the -symbol's value cell does not have any Lisp object in it. If you try to -evaluate the symbol, you get a @code{void-variable} error rather than -a value. - - Note that a value of @code{nil} is not the same as void. The symbol -@code{nil} is a Lisp object and can be the value of a variable just as any -other object can be; but it is @emph{a value}. A void variable does not -have any value. - - After you have given a variable a value, you can make it void once more -using @code{makunbound}. +say that that symbol's global value is @dfn{void}. Note that this +does @emph{not} mean the value is @code{nil}. The symbol @code{nil} +is a Lisp object and can be the value of a variable, just as any other +object can be; but it is still a value. + + More precisely, a variable is void if its symbol has an unassigned +value cell (@pxref{Symbol Components}). Under Emacs Lisp's default +dynamic binding rules, the value cell stores the variable's current +(local or global) value; if a variable is void, trying to evaluate the +variable signals a @code{void-variable} error rather than a value. +But when a variable is lexically bound, it can have a local value +which is determined by the lexical environment, even if the value cell +is empty and the variable is technically void. @xref{Variable +Scoping}. @defun makunbound symbol -This function makes the current variable binding of @var{symbol} void. -Subsequent attempts to use this symbol's value as a variable will signal -the error @code{void-variable}, unless and until you set it again. - -@code{makunbound} returns @var{symbol}. - -@example -@group -(makunbound 'x) ; @r{Make the global value of @code{x} void.} - @result{} x -@end group -@group -x -@error{} Symbol's value as variable is void: x -@end group -@end example - -If @var{symbol} is locally bound, @code{makunbound} affects the most -local existing binding. This is the only way a symbol can have a void -local binding, since all the constructs that create local bindings -create them with values. In this case, the voidness lasts at most as -long as the binding does; when the binding is removed due to exit from -the construct that made it, the previous local or global binding is -reexposed as usual, and the variable is no longer void unless the newly -reexposed binding was void all along. +This function empties out the value cell of @var{symbol}, making the +variable void. It returns @var{symbol}. + +If @var{symbol} has a (dynamic) local binding, @code{makunbound} voids +the current binding, and this voidness lasts only as long as the local +binding is in effect. Afterwards, the previously shadowed local or +global binding is reexposed; then the variable will no longer be void, +unless the reexposed binding is void too. + +Here are some examples (assuming dynamic binding is in effect): @smallexample @group @@ -361,17 +352,11 @@ @end smallexample @end defun - A variable that has been made void with @code{makunbound} is -indistinguishable from one that has never received a value and has -always been void. - - You can use the function @code{boundp} to test whether a variable is -currently void. - @defun boundp variable -@code{boundp} returns @code{t} if @var{variable} (a symbol) is not void; -more precisely, if its current binding is not void. It returns -@code{nil} otherwise. +This function returns @code{t} if @var{variable} (a symbol) is not +void, and @code{nil} if it is void. + +Here are some examples (assuming dynamic binding is in effect): @smallexample @group @@ -402,52 +387,41 @@ @section Defining Global Variables @cindex variable definition - You may announce your intention to use a symbol as a global variable -with a @dfn{variable definition}: a special form, either @code{defconst} -or @code{defvar}. - - In Emacs Lisp, definitions serve three purposes. First, they inform -people who read the code that certain symbols are @emph{intended} to be -used a certain way (as variables). Second, they inform the Lisp system -of these things, supplying a value and documentation. Third, they -provide information to utilities such as @code{etags} and -@code{make-docfile}, which create data bases of the functions and -variables in a program. - - The difference between @code{defconst} and @code{defvar} is primarily -a matter of intent, serving to inform human readers of whether the value -should ever change. Emacs Lisp does not restrict the ways in which a -variable can be used based on @code{defconst} or @code{defvar} -declarations. However, it does make a difference for initialization: -@code{defconst} unconditionally initializes the variable, while -@code{defvar} initializes it only if it is void. - -@ignore - One would expect user option variables to be defined with -@code{defconst}, since programs do not change them. Unfortunately, this -has bad results if the definition is in a library that is not preloaded: -@code{defconst} would override any prior value when the library is -loaded. Users would like to be able to set user options in their init -files, and override the default values given in the definitions. For -this reason, user options must be defined with @code{defvar}. -@end ignore + A @dfn{variable definition} is a construct that announces your +intention to use a symbol as a global variable. It uses the special +forms @code{defvar} or @code{defconst}, which are documented below. + + A variable definition serves three purposes. First, it informs +people who read the code that the symbol is @emph{intended} to be used +a certain way (as a variable). Second, it informs the Lisp system of +this, optionally supplying an initial value and a documentation +string. Third, it provides information to programming tools such as +@command{etags}, allowing them to find where the variable was defined. + + The difference between @code{defconst} and @code{defvar} is mainly a +matter of intent, serving to inform human readers of whether the value +should ever change. Emacs Lisp does not actually prevent you from +changing the value of a variable defined with @code{defconst}. One +notable difference between the two forms is that @code{defconst} +unconditionally initializes the variable, whereas @code{defvar} +initializes it only if it is originally void. + + To define a customizable variable, you should use @code{defcustom} +(which calls @code{defvar} as a subroutine). @xref{Customization}. @defspec defvar symbol [value [doc-string]] -This special form defines @var{symbol} as a variable and can also -initialize and document it. The definition informs a person reading -your code that @var{symbol} is used as a variable that might be set or -changed. It also declares this variable as @dfn{special}, meaning that it -should always use dynamic scoping rules. Note that @var{symbol} is not -evaluated; the symbol to be defined must appear explicitly in the -@code{defvar}. +This special form defines @var{symbol} as a variable. Note that +@var{symbol} is not evaluated; the symbol to be defined should appear +explicitly in the @code{defvar} form. The variable is marked as +@dfn{special}, meaning that it should always be dynamically bound +(@pxref{Variable Scoping}). If @var{symbol} is void and @var{value} is specified, @code{defvar} -evaluates it and sets @var{symbol} to the result. But if @var{symbol} -already has a value (i.e., it is not void), @var{value} is not even -evaluated, and @var{symbol}'s value remains unchanged. -If @var{value} is omitted, the value of @var{symbol} is not changed in any -case; instead, the only effect of @code{defvar} is to declare locally that this -variable exists elsewhere and should hence always use dynamic scoping rules. +evaluates @var{value} and sets @var{symbol} to the result. But if +@var{symbol} already has a value (i.e.@: it is not void), @var{value} +is not even evaluated, and @var{symbol}'s value remains unchanged. If +@var{value} is omitted, the value of @var{symbol} is not changed in +any case. If @var{symbol} has a buffer-local binding in the current buffer, @code{defvar} operates on the default value, which is buffer-independent, @@ -459,19 +433,9 @@ @code{eval-defun} arranges to set the variable unconditionally, without testing whether its value is void. -If the @var{doc-string} argument appears, it specifies the documentation -for the variable. (This opportunity to specify documentation is one of -the main benefits of defining the variable.) The documentation is -stored in the symbol's @code{variable-documentation} property. The -Emacs help functions (@pxref{Documentation}) look for this property. - -If the documentation string begins with the character @samp{*}, Emacs -allows users to set it interactively using the @code{set-variable} -command. However, you should nearly always use @code{defcustom} -instead of @code{defvar} to define such variables, so that users can -use @kbd{M-x customize} and related commands to set them. In that -case, it is not necessary to begin the documentation string with -@samp{*}. @xref{Customization}. +If the @var{doc-string} argument is supplied, it specifies the +documentation string for the variable (stored in the symbol's +@code{variable-documentation} property). @xref{Documentation}. Here are some examples. This form defines @code{foo} but does not initialize it: @@ -494,38 +458,6 @@ @end group @end example -The following form changes the documentation string for @code{bar}, -making it a user option, but does not change the value, since @code{bar} -already has a value. (The addition @code{(1+ nil)} would get an error -if it were evaluated, but since it is not evaluated, there is no error.) - -@example -@group -(defvar bar (1+ nil) - "*The normal weight of a bar.") - @result{} bar -@end group -@group -bar - @result{} 23 -@end group -@end example - -Here is an equivalent expression for the @code{defvar} special form: - -@example -@group -(defvar @var{symbol} @var{value} @var{doc-string}) -@equiv{} -(progn - (if (not (boundp '@var{symbol})) - (setq @var{symbol} @var{value})) - (if '@var{doc-string} - (put '@var{symbol} 'variable-documentation '@var{doc-string})) - '@var{symbol}) -@end group -@end example - The @code{defvar} form returns @var{symbol}, but it is normally used at top level in a file where its value does not matter. @end defspec @@ -538,6 +470,11 @@ or by other programs. Note that @var{symbol} is not evaluated; the symbol to be defined must appear explicitly in the @code{defconst}. +The @code{defconst} form, like @code{defvar}, marks the variable as +@dfn{special}, meaning that it should always be dynamically bound +(@pxref{Variable Scoping}). In addition, it marks the variable as +risky (@pxref{File Local Variables}). + @code{defconst} always evaluates @var{value}, and sets the value of @var{symbol} to the result. If @var{symbol} does have a buffer-local binding in the current buffer, @code{defconst} sets the default value, @@ -567,37 +504,13 @@ @end example @end defspec -@defun user-variable-p variable -@cindex user option -This function returns @code{t} if @var{variable} is a user option---a -variable intended to be set by the user for customization---and -@code{nil} otherwise. (Variables other than user options exist for the -internal purposes of Lisp programs, and users need not know about them.) - -User option variables are distinguished from other variables either -though being declared using @code{defcustom}@footnote{They may also be -declared equivalently in @file{cus-start.el}.} or by the first character -of their @code{variable-documentation} property. If the property exists -and is a string, and its first character is @samp{*}, then the variable -is a user option. Aliases of user options are also user options. -@end defun - -@cindex @code{variable-interactive} property -@findex set-variable - If a user option variable has a @code{variable-interactive} property, -the @code{set-variable} command uses that value to control reading the -new value for the variable. The property's value is used as if it were -specified in @code{interactive} (@pxref{Using Interactive}). However, -this feature is largely obsoleted by @code{defcustom} -(@pxref{Customization}). - - @strong{Warning:} If the @code{defconst} and @code{defvar} special -forms are used while the variable has a local binding (made with -@code{let}, or a function argument), they set the local-binding's -value; the top-level binding is not changed. This is not what you -usually want. To prevent it, use these special forms at top level in -a file, where normally no local binding is in effect, and make sure to -load the file before making a local binding for the variable. + @strong{Warning:} If you use a @code{defconst} or @code{defvar} +special form while the variable has a local binding (made with +@code{let}, or a function argument), it sets the local binding rather +than the global binding. This is not what you usually want. To +prevent this, use these special forms at top level in a file, where +normally no local binding is in effect, and make sure to load the file +before making a local binding for the variable. @node Tips for Defining @section Tips for Defining Variables Robustly @@ -667,9 +580,9 @@ initialized properly, never in-between. If it is still uninitialized, reloading the file will initialize it properly. Second, reloading the file once the variable is initialized will not alter it; that is -important if the user has run hooks to alter part of the contents (such -as, to rebind keys). Third, evaluating the @code{defvar} form with -@kbd{C-M-x} @emph{will} reinitialize the map completely. +important if the user has run hooks to alter part of the contents +(such as, to rebind keys). Third, evaluating the @code{defvar} form +with @kbd{C-M-x} will reinitialize the map completely. Putting so much code in the @code{defvar} form has one disadvantage: it puts the documentation string far away from the line which names the @@ -690,37 +603,27 @@ the @code{defvar}, except that you must type @kbd{C-M-x} twice, once on each form, if you do want to reinitialize the variable. - But be careful not to write the code like this: - -@example -(defvar my-mode-map nil - @var{docstring}) -(unless my-mode-map - (setq my-mode-map (make-sparse-keymap)) - (define-key my-mode-map "\C-c\C-a" 'my-command) - @dots{}) -@end example - -@noindent -This code sets the variable, then alters it, but it does so in more than -one step. If the user quits just after the @code{setq}, that leaves the -variable neither correctly initialized nor void nor @code{nil}. Once -that happens, reloading the file will not initialize the variable; it -will remain incomplete. - @node Accessing Variables @section Accessing Variable Values The usual way to reference a variable is to write the symbol which -names it (@pxref{Symbol Forms}). This requires you to specify the -variable name when you write the program. Usually that is exactly what -you want to do. Occasionally you need to choose at run time which -variable to reference; then you can use @code{symbol-value}. +names it. @xref{Symbol Forms}. + + Occasionally, you may want to reference a variable which is only +determined at run time. In that case, you cannot specify the variable +name in the text of the program. You can use the @code{symbol-value} +function to extract the value. @defun symbol-value symbol This function returns the value of @var{symbol}. This is the value in -the innermost local binding of the symbol, or its global value if it -has no local bindings. +the symbol's value cell, which is where the variable's current +(dynamic) value is stored. If the variable has no local binding, this +is simply its global value. + +If the variable is lexically bound, the value reported by +@code{symbol-value} is the dynamic value, and not the local lexical +value (which is determined by the lexical environment rather than the +symbol's value cell). @xref{Variable Scoping}. @example @group @@ -755,12 +658,12 @@ @end group @end example -A @code{void-variable} error is signaled if the current binding of -@var{symbol} is void. +A @code{void-variable} error is signaled if @var{symbol} is void as a +variable. @end defun @node Setting Variables -@section How to Alter a Variable Value +@section Setting Variable Values The usual way to change the value of a variable is with the special form @code{setq}. When you need to compute the choice of variable at @@ -769,8 +672,8 @@ @defspec setq [symbol form]@dots{} This special form is the most common method of changing a variable's value. Each @var{symbol} is given a new value, which is the result of -evaluating the corresponding @var{form}. The most-local existing -binding of the symbol is changed. +evaluating the corresponding @var{form}. The current binding of the +symbol is changed. @code{setq} does not evaluate @var{symbol}; it sets the symbol that you write. We say that this argument is @dfn{automatically quoted}. The @@ -809,12 +712,17 @@ @end defspec @defun set symbol value -This function sets @var{symbol}'s value to @var{value}, then returns -@var{value}. Since @code{set} is a function, the expression written for -@var{symbol} is evaluated to obtain the symbol to set. +This function puts @var{value} in the value cell of @var{symbol}. +Since it is a function rather than a special form, the expression +written for @var{symbol} is evaluated to obtain the symbol to set. +The return value is @var{value}. -The most-local existing binding of the variable is the binding that is -set; shadowed bindings are not affected. +When dynamic variable binding is in effect (the default), @code{set} +has the same effect as @code{setq}, apart from the fact that +@code{set} evaluates its @var{symbol} argument whereas @code{setq} +does not. But when a variable is lexically bound, @code{set} affects +its @emph{dynamic} value, whereas @code{setq} affects its current +(lexical) value. @xref{Variable Scoping}. @example @group @@ -854,327 +762,337 @@ (set '(x y) 'z) @error{} Wrong type argument: symbolp, (x y) @end example - -Logically speaking, @code{set} is a more fundamental primitive than -@code{setq}. Any use of @code{setq} can be trivially rewritten to use -@code{set}; @code{setq} could even be defined as a macro, given the -availability of @code{set}. However, @code{set} itself is rarely used; -beginners hardly need to know about it. It is useful only for choosing -at run time which variable to set. For example, the command -@code{set-variable}, which reads a variable name from the user and then -sets the variable, needs to use @code{set}. - -@cindex CL note---@code{set} local -@quotation -@b{Common Lisp note:} In Common Lisp, @code{set} always changes the -symbol's ``special'' or dynamic value, ignoring any lexical bindings. -In Emacs Lisp, all variables and all bindings are dynamic, so @code{set} -always affects the most local existing binding. -@end quotation @end defun @node Variable Scoping @section Scoping Rules for Variable Bindings - A given symbol @code{foo} can have several local variable bindings, -established at different places in the Lisp program, as well as a global -binding. The most recently established binding takes precedence over -the others. + When you create a local binding for a variable, that binding takes +effect only within a limited portion of the program (@pxref{Local +Variables}). This section describes exactly what this means. @cindex scope @cindex extent -@cindex dynamic scoping -@cindex lexical scoping - By default, local bindings in Emacs Lisp have @dfn{indefinite scope} and -@dfn{dynamic extent}. @dfn{Scope} refers to @emph{where} textually in -the source code the binding can be accessed. ``Indefinite scope'' means -that any part of the program can potentially access the variable -binding. @dfn{Extent} refers to @emph{when}, as the program is -executing, the binding exists. ``Dynamic extent'' means that the binding -lasts as long as the activation of the construct that established it. - - The combination of dynamic extent and indefinite scope is called -@dfn{dynamic scoping}. By contrast, most programming languages use -@dfn{lexical scoping}, in which references to a local variable must be -located textually within the function or block that binds the variable. -Emacs can also support lexical scoping, upon request (@pxref{Lexical -Binding}). - -@cindex CL note---special variables -@quotation -@b{Common Lisp note:} Variables declared ``special'' in Common Lisp are -dynamically scoped, like all variables in Emacs Lisp. -@end quotation + Each local binding has a certain @dfn{scope} and @dfn{extent}. +@dfn{Scope} refers to @emph{where} in the textual source code the +binding can be accessed. @dfn{Extent} refers to @emph{when}, as the +program is executing, the binding exists. + +@cindex dynamic binding +@cindex indefinite scope +@cindex dynamic extent + By default, the local bindings that Emacs creates are @dfn{dynamic +bindings}. Such a binding has @dfn{indefinite scope}, meaning that +any part of the program can potentially access the variable binding. +It also has @dfn{dynamic extent}, meaning that the binding lasts only +while the binding construct (such as the body of a @code{let} form) is +being executed. + +@cindex lexical binding +@cindex lexical scope +@cindex indefinite extent + Emacs can optionally create @dfn{lexical bindings}. A lexical +binding has @dfn{lexical scope}, meaning that any reference to the +variable must be located textually within the binding construct. It +also has @dfn{indefinite extent}, meaning that under some +circumstances the binding can live on even after the binding construct +has finished executing, by means of special objects called +@dfn{closures}. + + The following subsections describe dynamic binding and lexical +binding in greater detail, and how to enable lexical binding in Emacs +Lisp programs. @menu -* Scope:: Scope means where in the program a value is visible. - Comparison with other languages. -* Extent:: Extent means how long in time a value exists. -* Impl of Scope:: Two ways to implement dynamic scoping. -* Using Scoping:: How to use dynamic scoping carefully and avoid problems. -* Lexical Binding:: Use of lexical scoping. +* Dynamic Binding:: The default for binding local variables in Emacs. +* Dynamic Binding Tips:: Avoiding problems with dynamic binding. +* Lexical Binding:: A different type of local variable binding. +* Using Lexical Binding:: How to enable lexical binding. @end menu -@node Scope -@subsection Scope - - Emacs Lisp uses @dfn{indefinite scope} for local variable bindings. -This means that any function anywhere in the program text might access a -given binding of a variable. Consider the following function -definitions: - -@example -@group -(defun binder (x) ; @r{@code{x} is bound in @code{binder}.} - (foo 5)) ; @r{@code{foo} is some other function.} -@end group - -@group -(defun user () ; @r{@code{x} is used ``free'' in @code{user}.} - (list x)) -@end group -@end example - - In a lexically scoped language, the binding of @code{x} in -@code{binder} would never be accessible in @code{user}, because -@code{user} is not textually contained within the function -@code{binder}. However, in dynamically-scoped Emacs Lisp, @code{user} -may or may not refer to the binding of @code{x} established in -@code{binder}, depending on the circumstances: +@node Dynamic Binding +@subsection Dynamic Binding + + By default, the local variable bindings made by Emacs are dynamic +bindings. When a variable is dynamically bound, its current binding +at any point in the execution of the Lisp program is simply the most +recently-created dynamic local binding for that symbol, or the global +binding if there is no such local binding. + + Dynamic bindings have indefinite scope and dynamic extent, as shown +by the following example: + +@example +@group +(defvar x -99) ; @r{@code{x} receives an initial value of -99.} + +(defun getx () + x) ; @r{@code{x} is used ``free'' in this function.} + +(let ((x 1)) ; @r{@code{x} is dynamically bound.} + (getx)) + @result{} 1 + +;; @r{After the @code{let} form finishes, @code{x} reverts to its} +;; @r{previous value, which is -99.} + +(getx) + @result{} -99 +@end group +@end example + +@noindent +The function @code{getx} refers to @code{x}. This is a ``free'' +reference, in the sense that there is no binding for @code{x} within +that @code{defun} construct itself. When we call @code{getx} from +within a @code{let} form in which @code{x} is (dynamically) bound, it +retrieves the local value of @code{x} (i.e.@: 1). But when we call +@code{getx} outside the @code{let} form, it retrieves the global value +of @code{x} (i.e.@: -99). + + Here is another example, which illustrates setting a dynamically +bound variable using @code{setq}: + +@example +@group +(defvar x -99) ; @r{@code{x} receives an initial value of -99.} + +(defun addx () + (setq x (1+ x))) ; @r{Add 1 to @code{x} and return its new value.} + +(let ((x 1)) + (addx) + (addx)) + @result{} 3 ; @r{The two @code{addx} calls add to @code{x} twice.} + +;; @r{After the @code{let} form finishes, @code{x} reverts to its} +;; @r{previous value, which is -99.} + +(addx) + @result{} -98 +@end group +@end example + + Dynamic binding is implemented in Emacs Lisp in a simple way. Each +symbol has a value cell, which specifies its current dynamic value (or +absence of value). @xref{Symbol Components}. When a symbol is given +a dynamic local binding, Emacs records the contents of the value cell +(or absence thereof) in a stack, and stores the new local value in the +value cell. When the binding construct finishes executing, Emacs pops +the old value off the stack, and puts it in the value cell. + +@node Dynamic Binding Tips +@subsection Proper Use of Dynamic Binding + + Dynamic binding is a powerful feature, as it allows programs to +refer to variables that are not defined within their local textual +scope. However, if used without restraint, this can also make +programs hard to understand. There are two clean ways to use this +technique: @itemize @bullet @item -If we call @code{user} directly without calling @code{binder} at all, -then whatever binding of @code{x} is found, it cannot come from -@code{binder}. +If a variable has no global definition, use it as a local variable +only within a binding construct, e.g.@: the body of the @code{let} +form where the variable was bound, or the body of the function for an +argument variable. If this convention is followed consistently +throughout a program, the value of the variable will not affect, nor +be affected by, any uses of the same variable symbol elsewhere in the +program. @item -If we define @code{foo} as follows and then call @code{binder}, then the -binding made in @code{binder} will be seen in @code{user}: +Otherwise, define the variable with @code{defvar}, @code{defconst}, or +@code{defcustom}. @xref{Defining Variables}. Usually, the definition +should be at top-level in an Emacs Lisp file. As far as possible, it +should include a documentation string which explains the meaning and +purpose of the variable. You should also choose the variable's name +to avoid name conflicts (@pxref{Coding Conventions}). + +Then you can bind the variable anywhere in a program, knowing reliably +what the effect will be. Wherever you encounter the variable, it will +be easy to refer back to the definition, e.g.@: via the @kbd{C-h v} +command (provided the variable definition has been loaded into Emacs). +@xref{Name Help,,, emacs, The GNU Emacs Manual}. + +For example, it is common to use local bindings for customizable +variables like @code{case-fold-search}: @example @group -(defun foo (lose) - (user)) +(defun search-for-abc () + "Search for the string \"abc\", ignoring case differences." + (let ((case-fold-search nil)) + (re-search-forward "abc"))) @end group @end example - -@item -However, if we define @code{foo} as follows and then call @code{binder}, -then the binding made in @code{binder} @emph{will not} be seen in -@code{user}: - -@example -(defun foo (x) - (user)) -@end example - -@noindent -Here, when @code{foo} is called by @code{binder}, it binds @code{x}. -(The binding in @code{foo} is said to @dfn{shadow} the one made in -@code{binder}.) Therefore, @code{user} will access the @code{x} bound -by @code{foo} instead of the one bound by @code{binder}. @end itemize -Emacs Lisp used dynamic scoping by default because simple implementations of -lexical scoping are slow. In addition, every Lisp system needs to offer -dynamic scoping at least as an option; if lexical scoping is the norm, there -must be a way to specify dynamic scoping instead for a particular variable. -Nowadays, Emacs offers both, but the default is still to use exclusively -dynamic scoping. - -@node Extent -@subsection Extent - - @dfn{Extent} refers to the time during program execution that a -variable name is valid. In Emacs Lisp, a variable is valid only while -the form that bound it is executing. This is called @dfn{dynamic -extent}. ``Local'' or ``automatic'' variables in most languages, -including C and Pascal, have dynamic extent. - - One alternative to dynamic extent is @dfn{indefinite extent}. This -means that a variable binding can live on past the exit from the form -that made the binding. Common Lisp and Scheme, for example, support -this, but Emacs Lisp does not. - - To illustrate this, the function below, @code{make-add}, returns a -function that purports to add @var{n} to its own argument @var{m}. This -would work in Common Lisp, but it does not do the job in Emacs Lisp, -because after the call to @code{make-add} exits, the variable @code{n} -is no longer bound to the actual argument 2. - -@example -(defun make-add (n) - (function (lambda (m) (+ n m)))) ; @r{Return a function.} - @result{} make-add -(fset 'add2 (make-add 2)) ; @r{Define function @code{add2}} - ; @r{with @code{(make-add 2)}.} - @result{} (lambda (m) (+ n m)) -(add2 4) ; @r{Try to add 2 to 4.} -@error{} Symbol's value as variable is void: n -@end example - -@cindex closures not available - Some Lisp dialects have ``closures,'' objects that are like functions -but record additional variable bindings. Emacs Lisp does not have -closures. - -@node Impl of Scope -@subsection Implementation of Dynamic Scoping -@cindex deep binding - - A simple sample implementation (which is not how Emacs Lisp actually -works) may help you understand dynamic binding. This technique is -called @dfn{deep binding} and was used in early Lisp systems. - - Suppose there is a stack of bindings, which are variable-value pairs. -At entry to a function or to a @code{let} form, we can push bindings -onto the stack for the arguments or local variables created there. We -can pop those bindings from the stack at exit from the binding +@node Lexical Binding +@subsection Lexical Binding + +Optionally, you can create lexical bindings in Emacs Lisp. A +lexically bound variable has @dfn{lexical scope}, meaning that any +reference to the variable must be located textually within the binding construct. - We can find the value of a variable by searching the stack from top to -bottom for a binding for that variable; the value from that binding is -the value of the variable. To set the variable, we search for the -current binding, then store the new value into that binding. - - As you can see, a function's bindings remain in effect as long as it -continues execution, even during its calls to other functions. That is -why we say the extent of the binding is dynamic. And any other function -can refer to the bindings, if it uses the same variables while the -bindings are in effect. That is why we say the scope is indefinite. - -@cindex shallow binding - The actual implementation of variable scoping in GNU Emacs Lisp uses a -technique called @dfn{shallow binding}. Each variable has a standard -place in which its current value is always found---the value cell of the -symbol. - - In shallow binding, setting the variable works by storing a value in -the value cell. Creating a new binding works by pushing the old value -(belonging to a previous binding) onto a stack, and storing the new -local value in the value cell. Eliminating a binding works by popping -the old value off the stack, into the value cell. - - We use shallow binding because it has the same results as deep -binding, but runs faster, since there is never a need to search for a -binding. - -@node Using Scoping -@subsection Proper Use of Dynamic Scoping - - Binding a variable in one function and using it in another is a -powerful technique, but if used without restraint, it can make programs -hard to understand. There are two clean ways to use this technique: - -@itemize @bullet -@item -Use or bind the variable only in a few related functions, written close -together in one file. Such a variable is used for communication within -one program. - -You should write comments to inform other programmers that they can see -all uses of the variable before them, and to advise them not to add uses -elsewhere. - -@item -Give the variable a well-defined, documented meaning, and make all -appropriate functions refer to it (but not bind it or set it) wherever -that meaning is relevant. For example, the variable -@code{case-fold-search} is defined as ``non-@code{nil} means ignore case -when searching''; various search and replace functions refer to it -directly or through their subroutines, but do not bind or set it. - -Then you can bind the variable in other programs, knowing reliably what -the effect will be. -@end itemize - - In either case, you should define the variable with @code{defvar}. -This helps other people understand your program by telling them to look -for inter-function usage. It also avoids a warning from the byte -compiler. Choose the variable's name to avoid name conflicts---don't -use short names like @code{x}. - - -@node Lexical Binding -@subsection Use of Lexical Scoping - -Emacs Lisp can be evaluated in two different modes: in dynamic binding -mode or lexical binding mode. In dynamic binding mode, all local -variables use dynamic scoping, whereas in lexical binding mode -variables that have been declared @dfn{special} (i.e., declared with -@code{defvar}, @code{defcustom} or @code{defconst}) use dynamic -scoping and all others use lexical scoping. + Here is an example +@iftex +(see the next subsection, for how to actually enable lexical binding): +@end iftex +@ifnottex +(@pxref{Using Lexical Binding}, for how to actually enable lexical binding): +@end ifnottex + +@example +@group +(defun getx () + x) ; @r{@code{x} is used ``free'' in this function.} + +(let ((x 1)) ; @r{@code{x} is lexically bound.} + (+ x 3)) + @result{} 4 + +(let ((x 1)) ; @r{@code{x} is lexically bound.} + (getx)) +@error{} Symbol's value as variable is void: x +@end group +@end example + +@noindent +Here, the variable @code{x} has no global value. When it is lexically +bound within a @code{let} form, it can be used in the textual confines +of that @code{let} form. But it can @emph{not} be used from within a +@code{getx} function called from the @code{let} form, since the +function definition of @code{getx} occurs outside the @code{let} form +itself. + +@cindex lexical environment + Here is how lexical binding works. Each binding construct defines a +@dfn{lexical environment}, specifying the symbols that are bound +within the construct and their local values. When the Lisp evaluator +wants the current value of a variable, it looks first in the lexical +environment; if the variable is not specified in there, it looks in +the symbol's value cell, where the dynamical value is stored. + +@cindex closures + Lexical bindings have indefinite extent. Even after a binding +construct has finished executing, its lexical environment can be +``kept around'' in Lisp objects called @dfn{closures}. A closure is +created whenever you evaluate a lambda expression (@pxref{Lambda +Expressions}) with lexical binding enabled. It is represented by a +list whose @sc{car} is the symbol @code{closure}. It is a function, +in the sense that it can be passed as an argument to @code{funcall}; +when called as a function, any lexical variable references within its +definition will use the retained lexical environment. + + Here is an example which illustrates the use of a closure: + +@example +(defvar my-ticker nil) ; @r{We will use this dynamically bound} + ; @r{variable to store a closure.} + +(let ((x 0)) ; @r{@code{x} is lexically bound.} + (setq my-ticker (lambda () + (setq x (1+ x))))) + @result{} (closure ((x . 0) t) () + (1+ x)) + +(funcall my-ticker) + @result{} 1 + +(funcall my-ticker) + @result{} 2 + +(funcall my-ticker) + @result{} 3 + +x ; @r{Note that @code{x} has no global value.} +@error{} Symbol's value as variable is void: x +@end example + +@noindent +The @code{let} binding defines a lexical environment in which the +variable @code{x} is locally bound to 0. Within this binding +construct, we define a lambda expression which increments @code{x} by +one and returns the incremented value. This lambda expression is +automatically turned into a closure, in which the lexical environment +lives on even after the @code{let} binding construct has exited. Each +time we evaluate the closure, it increments @code{x}, using the +binding of @code{x} in that lexical environment. + + Note that functions like @code{symbol-value}, @code{boundp}, and +@code{set} only retrieve or modify a variable's dynamic binding +(i.e.@: the contents of its symbol's value cell). Also, the code in +the body of a @code{defun} or @code{defmacro} cannot refer to +surrounding lexical variables. + + Currently, lexical binding is not much used within the Emacs +sources. However, we expect its importance to increase in the future. +Lexical binding opens up a lot more opportunities for optimization, so +Emacs Lisp code that makes use of lexical binding is likely to run +faster in future Emacs versions. Such code is also much more friendly +to concurrency, which we want to add to Emacs in the near future. + +@node Using Lexical Binding +@subsection Using Lexical Binding + + When loading an Emacs Lisp file or evaluating a Lisp buffer, lexical +binding is enabled if the buffer-local variable @code{lexical-binding} +is non-@code{nil}: @defvar lexical-binding -When non-nil, evaluation of Lisp code uses lexical scoping for non-special -local variables instead of dynamic scoping. If nil, dynamic scoping is used -for all local variables. This variable is typically set for a whole Elisp file -via file local variables (@pxref{File Local Variables}). +If this buffer-local variable is non-@code{nil}, Emacs Lisp files and +buffers are evaluated using lexical binding instead of dynamic +binding. (However, special variables are still dynamically bound; see +below.) If @code{nil}, dynamic binding is used for all local +variables. This variable is typically set for a whole Emacs Lisp +file, as a file local variable (@pxref{File Local Variables}). @end defvar +@noindent +When evaluating Emacs Lisp code directly using an @code{eval} call, +lexical binding is enabled if the @var{lexical} argument to +@code{eval} is non-@code{nil}. @xref{Eval}. + +@cindex special variables + Even when lexical binding is enabled, certain variables will +continue to be dynamically bound. These are called @dfn{special +variables}. Every variable that has been defined with @code{defvar}, +@code{defcustom} or @code{defconst} is a special variable +(@pxref{Defining Variables}). All other variables are subject to +lexical binding. + @defun special-variable-p SYMBOL -Return whether SYMBOL has been declared as a special variable, via -@code{defvar} or @code{defconst}. +This function returns non-@code{nil} if @var{symbol} is a special +variable (i.e.@: it has a @code{defvar}, @code{defcustom}, or +@code{defconst} variable definition). Otherwise, the return value is +@code{nil}. @end defun -The use of a special variable as a formal argument in a function is generally -discouraged and its behavior in lexical binding mode is unspecified (it may use -lexical scoping sometimes and dynamic scoping other times). - -Functions like @code{symbol-value}, @code{boundp}, or @code{set} only know -about dynamically scoped variables, so you cannot get the value of a lexical -variable via @code{symbol-value} and neither can you change it via @code{set}. -Another particularity is that code in the body of a @code{defun} or -@code{defmacro} cannot refer to surrounding lexical variables. - -Evaluation of a @code{lambda} expression in lexical binding mode will not just -return that lambda expression unchanged, as in the dynamic binding case, but -will instead construct a new object that remembers the current lexical -environment in which that lambda expression was defined, so that the function -body can later be evaluated in the proper context. Those objects are called -@dfn{closures}. They are also functions, in the sense that they are accepted -by @code{funcall}, and they are represented by a cons cell whose @code{car} is -the symbol @code{closure}. - -@menu -* Converting to Lexical Binding:: How to start using lexical scoping -@end menu - -@node Converting to Lexical Binding -@subsubsection Converting a package to use lexical scoping - -Lexical scoping, as currently implemented, does not bring many significant -benefits, unless you are a seasoned functional programmer addicted to -higher-order functions. But its importance will increase in the future: -lexical scoping opens up a lot more opportunities for optimization, so -lexically scoped code is likely to run faster in future Emacs versions, and it -is much more friendly to concurrency, which we want to add in the near future. - -Converting a package to lexical binding is usually pretty easy and should not -break backward compatibility: just add a file-local variable setting -@code{lexical-binding} to @code{t} and add declarations of the form -@code{(defvar @var{VAR})} for every variable which still needs to use -dynamic scoping. - -To find which variables need this declaration, the simplest solution is to -check the byte-compiler's warnings. The byte-compiler will usually find those -variables either because they are used outside of a let-binding (leading to -warnings about reference or assignment to ``free variable @var{VAR}'') or -because they are let-bound but not used within the let-binding (leading to -warnings about ``unused lexical variable @var{VAR}''). - -In cases where a dynamically scoped variable was bound as a function argument, -you will also need to move this binding to a @code{let}. These cases are also -flagged by the byte-compiler. - -To silence byte-compiler warnings about unused variables, just use a variable -name that start with an underscore, which the byte-compiler interpret as an -indication that this is a variable known not to be used. - -In most cases, the resulting code will then work with either setting of -@code{lexical-binding}, so it can still be used with older Emacsen (which will -simply ignore the @code{lexical-binding} variable setting). + The use of a special variable as a formal argument in a function is +discouraged. Doing so gives rise to unspecified behavior when lexical +binding mode is enabled (it may use lexical binding sometimes, and +dynamic binding other times). + + Converting an Emacs Lisp program to lexical binding is pretty easy. +First, add a file-local variable setting of @code{lexical-binding} to +@code{t} in the Emacs Lisp source file. Second, check that every +variable in the program which needs to be dynamically bound has a +variable definition, so that it is not inadvertently bound lexically. + + A simple way to find out which variables need a variable definition +is to byte-compile the source file. @xref{Byte Compilation}. If a +non-special variable is used outside of a @code{let} form, the +byte-compiler will warn about reference or assignment to a ``free +variable''. If a non-special variable is bound but not used within a +@code{let} form, the byte-compiler will warn about an ``unused lexical +variable''. The byte-compiler will also issue a warning if you use a +special variable as a function argument. + + (To silence byte-compiler warnings about unused variables, just use +a variable name that start with an underscore. The byte-compiler +interprets this as an indication that this is a variable known not to +be used.) @node Buffer-Local Variables @section Buffer-Local Variables ------------------------------------------------------------ revno: 106922 author: Julien Danjou committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2012-01-24 12:06:51 +0000 message: color.el: Add saturate, lighten functions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-24 08:22:50 +0000 +++ lisp/ChangeLog 2012-01-24 12:06:51 +0000 @@ -1,3 +1,12 @@ +2012-01-24 Julien Danjou + + * color.el (color-rgb-to-hsl): Fix value computing. + (color-hue-to-rgb): New function. + (color-hsl-to-rgb): New function. + (color-clamp, color-saturate-hsl, color-saturate-name) + (color-desaturate-hsl, color-desaturate-name, color-lighten-hsl) + (color-lighten-name, color-darken-hsl, color-darken-name): New function. + 2012-01-24 Glenn Morris * vc/vc-rcs.el (vc-rcs-create-tag): === modified file 'lisp/color.el' --- lisp/color.el 2012-01-19 23:06:49 +0000 +++ lisp/color.el 2012-01-24 12:06:51 +0000 @@ -92,6 +92,34 @@ result)) (nreverse result))) +(defun color-hue-to-rgb (v1 v2 h) + "Compute hue from V1 and V2 H. Internally used by +`color-hsl-to-rgb'." + (cond + ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) + ((< h 0.5) v2) + ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) + (t v1))) + +(defun color-hsl-to-rgb (H S L) + "Convert H S L (HUE, SATURATION, LUMINANCE) , where HUE is in +radians and both SATURATION and LUMINANCE are between 0.0 and +1.0, inclusive to their RGB representation. + +Return a list (RED, GREEN, BLUE) which each be numbers between +0.0 and 1.0, inclusive." + + (if (= S 0.0) + (list L L L) + (let* ((m2 (if (<= L 0.5) + (* L (+ 1.0 S)) + (- (+ L S) (* L S)))) + (m1 (- (* 2.0 L) m2))) + (list + (color-hue-to-rgb m1 m2 (+ H (/ 1.0 3))) + (color-hue-to-rgb m1 m2 H) + (color-hue-to-rgb m1 m2 (- H (/ 1.0 3))))))) + (defun color-complement-hex (color) "Return the color that is the complement of COLOR, in hexadecimal format." (apply 'color-rgb-to-hex (color-complement color))) @@ -141,23 +169,21 @@ (min (min r g b)) (delta (- max min)) (l (/ (+ max min) 2.0))) - (list - (if (< (- max min) 1e-8) - 0 - (* 2 float-pi - (/ (cond ((= max r) - (+ (/ (- g b) delta) (if (< g b) 6 0))) - ((= max g) - (+ (/ (- b r) delta) 2)) - (t - (+ (/ (- r g) delta) 4))) - 6))) - (if (= max min) - 0 - (if (> l 0.5) - (/ delta (- 2 (+ max min))) - (/ delta (+ max min)))) - l))) + (if (= delta 0) + (list 0.0 0.0 l) + (let* ((s (if (<= l 0.5) (/ delta (+ max min)) + (/ delta (- 2.0 max min)))) + (rc (/ (- max r) delta)) + (gc (/ (- max g) delta)) + (bc (/ (- max b) delta)) + (h (mod + (/ + (cond + ((= r max) (- bc gc)) + ((= g max) (+ 2.0 rc (- bc))) + (t (+ 4.0 gc (- rc)))) + 6.0) 1.0))) + (list h s l))))) (defun color-srgb-to-xyz (red green blue) "Convert RED GREEN BLUE colors from the sRGB color space to CIE XYZ. @@ -313,6 +339,82 @@ (expt (/ ΔH′ (* Sh kH)) 2.0) (* Rt (/ ΔC′ (* Sc kC)) (/ ΔH′ (* Sh kH))))))))) +(defun color-clamp (value) + "Make sure VALUE is a number between 0.0 and 1.0 inclusive." + (min 1.0 (max 0.0 value))) + +(defun color-saturate-hsl (H S L percent) + "Return a color PERCENT more saturated than the one defined in +H S L color-space. + +Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians +and both SATURATION and LUMINANCE are between 0.0 and 1.0, +inclusive." + (list H (color-clamp (+ S (/ percent 100.0))) L)) + +(defun color-saturate-name (name percent) + "Short hand to saturate COLOR by PERCENT. + +See `color-saturate-hsl'." + (apply 'color-rgb-to-hex + (apply 'color-hsl-to-rgb + (apply 'color-saturate-hsl + (append + (apply 'color-rgb-to-hsl + (color-name-to-rgb name)) + (list percent)))))) + +(defun color-desaturate-hsl (H S L percent) + "Return a color PERCENT less saturated than the one defined in +H S L color-space. + +Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians +and both SATURATION and LUMINANCE are between 0.0 and 1.0, +inclusive." + (color-saturate-hsl H S L (- percent))) + +(defun color-desaturate-name (name percent) + "Short hand to desaturate COLOR by PERCENT. + +See `color-desaturate-hsl'." + (color-saturate-name name (- percent))) + +(defun color-lighten-hsl (H S L percent) + "Return a color PERCENT lighter than the one defined in +H S L color-space. + +Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians +and both SATURATION and LUMINANCE are between 0.0 and 1.0, +inclusive." + (list H S (color-clamp (+ L (/ percent 100.0))))) + +(defun color-lighten-name (name percent) + "Short hand to saturate COLOR by PERCENT. + +See `color-lighten-hsl'." + (apply 'color-rgb-to-hex + (apply 'color-hsl-to-rgb + (apply 'color-lighten--hsl + (append + (apply 'color-rgb-to-hsl + (color-name-to-rgb name)) + (list percent)))))) + +(defun color-darken-hsl (H S L percent) + "Return a color PERCENT darker than the one defined in +H S L color-space. + +Return a list (HUE, SATURATION, LUMINANCE), where HUE is in radians +and both SATURATION and LUMINANCE are between 0.0 and 1.0, +inclusive." + (color-lighten-hsl H S L (- percent))) + +(defun color-darken-name (name percent) + "Short hand to saturate COLOR by PERCENT. + +See `color-darken-hsl'." + (color-lighten-name name (- percent))) + (provide 'color) ;;; color.el ends here ------------------------------------------------------------ revno: 106921 fixes bug(s): http://debbugs.gnu.org/10515 committer: Glenn Morris branch nick: trunk timestamp: Tue 2012-01-24 00:22:50 -0800 message: Fix rcs and sccs create-tag commands. * lisp/vc/vc-rcs.el (vc-rcs-create-tag): * lisp/vc/vc-sccs.el (vc-sccs-create-tag): Fix argument spec to be what vc-create-tag expects. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-23 08:18:22 +0000 +++ lisp/ChangeLog 2012-01-24 08:22:50 +0000 @@ -1,3 +1,9 @@ +2012-01-24 Glenn Morris + + * vc/vc-rcs.el (vc-rcs-create-tag): + * vc/vc-sccs.el (vc-sccs-create-tag): + Fix argument spec to be what vc-create-tag expects. (Bug#10515) + 2012-01-23 Mike Lamb (tiny change) * eshell/esh-util.el (eshell-read-hosts-file): === modified file 'lisp/vc/vc-rcs.el' --- lisp/vc/vc-rcs.el 2012-01-19 07:21:25 +0000 +++ lisp/vc/vc-rcs.el 2012-01-24 08:22:50 +0000 @@ -809,9 +809,9 @@ ;;; Tag system ;;; -(defun vc-rcs-create-tag (backend dir name branchp) +(defun vc-rcs-create-tag (dir name branchp) (when branchp - (error "RCS backend %s does not support module branches" backend)) + (error "RCS backend does not support module branches")) (let ((result (vc-tag-precondition dir))) (if (stringp result) (error "File %s is not up-to-date" result) === modified file 'lisp/vc/vc-sccs.el' --- lisp/vc/vc-sccs.el 2012-01-19 07:21:25 +0000 +++ lisp/vc/vc-sccs.el 2012-01-24 08:22:50 +0000 @@ -359,9 +359,9 @@ ;;; our own set of name-to-revision mappings. ;;; -(defun vc-sccs-create-tag (backend dir name branchp) +(defun vc-sccs-create-tag (dir name branchp) (when branchp - (error "SCCS backend %s does not support module branches" backend)) + (error "SCCS backend does not support module branches")) (let ((result (vc-tag-precondition dir))) (if (stringp result) (error "File %s is not up-to-date" result) ------------------------------------------------------------ revno: 106920 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-01-23 11:44:28 -0800 message: Spelling fix. diff: === modified file 'lisp/files.el' --- lisp/files.el 2012-01-21 00:41:05 +0000 +++ lisp/files.el 2012-01-23 19:44:28 +0000 @@ -3779,7 +3779,7 @@ ;; Don't change the mode if the local variable list specifies it. ;; The file name can influence whether the local variables apply. (and old-try-locals - ;; h-l-v also checks it, but might as well be explcit. + ;; h-l-v also checks it, but might as well be explicit. (not (inhibit-local-variables-p)) (hack-local-variables t)) ;; TODO consider making normal-mode handle this case. ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.