Uploads from Xah Lee

Watch and track your favorite playlist.

Curated by: Xah Lee (847 videos)


Currently Playing: Xah Ep755 emacs lisp write a find text command, condition if occur inside given text

Video Summary (Generated by AI, Edited by Human.) The video is an Emacs Lisp coding session by Xah Lee, where he demonstrates how to write a script that finds text within files based on specific conditions (0:30). Here's a breakdown of the key points: • Project Goal (1:40): The main goal is to create an Emacs Lisp script that can find a specific text string within files, but only if that string is located between two other defined text strings (e.g., within HTML tags). The example used is finding "console" within pre tags for JavaScript code. • Challenges with Traditional Tools (3:54): Xah Lee explains that standard Unix grep commands cannot handle this kind of conditional search, necessitating a custom script. • Traversing Directories (5:00): He begins by outlining the process of traversing directories to gather a list of files. This involves defining variables for the input directory and file name regular expressions (12:10) to filter for specific file types (e.g., HTML, JavaScript). • File Processing (22:21): The next step is to open and read each file. He details how to create a temporary buffer in Emacs to load file content and then navigate within that buffer (24:00). • Defining Search Parameters (25:57): Three key variables are defined: begin-tag-text (the text that must occur before the target text), end-tag-text (the text that must occur after), and find-text (the actual text to search for). • Implementing the Search Logic (27:50): The core of the script involves nested search operations. First, it searches for the begin-tag-text, then for the find-text within that found section, and finally for the end-tag-text to confirm the context. If all conditions are met, the file path and position are reported (40:22). • Testing and Debugging (42:00): Xah Lee demonstrates running the code, addressing issues like unquoted functions and errors related to ignored search errors (44:20). He successfully finds instances of "console log" within pre tags for JavaScript code (47:47). • Future Refinements (54:50): He discusses potential improvements, such as displaying the actual text occurrences rather than just positions, and adding a feature to find instances where the find-text does not occur within the specified tags. • Side Discussions (13:05): Throughout the video, Xah Lee engages with chat comments, including a significant digression on the "idiotic jargon" of "idempotency" in programming. Notes at http://xahlee.info/talk_show/xah_talk_show_ep755.html If browser says security error, that is because it auto changes URL from HTTP to HTTPS. It's a way to censor 22 million old websites. Remove the S in HTTPS. Or use brave browser or safari.


Tracks in this Playlist

✅ Progress Tracking

Automatically track which videos you have watched. Your completion status is updated at a glance, preventing you from re-watching episodes by mistake.

⏯️ Resume Playback

Never lose your spot. Our custom player remembers your exact video and timestamp, allowing you to dive right back in seamlessly.

📱 Cross-Device Sync

Sync your playlist states, watched progress, and premium preferences across your desktop, laptop, tablet, and mobile phone automatically.

Start Organizing Your YouTube Playlists

Simply paste any YouTube playlist URL or channel link in the application search bar to immediately generate a custom, sorted, and progress-tracked workspace. No registration required to start.

Explore Playlist Guides & How-Tos